From b6ae82b2cc35534b96c7a2a81300e6c9ac8e1b92 Mon Sep 17 00:00:00 2001 From: xy <271556543@qq.com> Date: Thu, 10 Oct 2024 15:35:52 +0800 Subject: [PATCH] init --- src/api/dashboard/notice.js | 20 ++++- src/components/LxHeader/index.vue | 4 +- src/components/ThemePicker/index.vue | 85 +++++++++++++++++++ src/components/XySelectors/index.vue | 8 +- src/layout/index.vue | 5 -- src/main.js | 2 +- src/permission.js | 1 - .../dashboard/components/carryStatic.vue | 10 +-- src/views/dashboard/index.vue | 31 ++++--- 9 files changed, 132 insertions(+), 34 deletions(-) diff --git a/src/api/dashboard/notice.js b/src/api/dashboard/notice.js index ab5350d..ca89170 100644 --- a/src/api/dashboard/notice.js +++ b/src/api/dashboard/notice.js @@ -26,10 +26,26 @@ export function readNotice(params){ }) } -export function statistic(params,noLoading = false){ +export function statisticProgress(params,noLoading = false){ return request({ method:'get', - url:'/api/ht/notice/statistic', + url:'/api/ht/notice/statistic-progress', + params, + noLoading + }) +} +export function statisticDepartment(params,noLoading = false){ + return request({ + method:'get', + url:'/api/ht/notice/statistic-department', + params, + noLoading + }) +} +export function statisticType(params,noLoading = false){ + return request({ + method:'get', + url:'/api/ht/notice/statistic-type', params, noLoading }) diff --git a/src/components/LxHeader/index.vue b/src/components/LxHeader/index.vue index e1c247c..60a702a 100644 --- a/src/components/LxHeader/index.vue +++ b/src/components/LxHeader/index.vue @@ -66,9 +66,9 @@ // padding-top: 10px; font-weight: bold; font-size: 15px; - color: #338de3; + color: var(--theme-color); white-space: nowrap; - border-bottom: 2px solid #338de3; + border-bottom: 2px solid var(--theme-color); >span { position: relative; diff --git a/src/components/ThemePicker/index.vue b/src/components/ThemePicker/index.vue index e6e83a8..19205fe 100644 --- a/src/components/ThemePicker/index.vue +++ b/src/components/ThemePicker/index.vue @@ -80,6 +80,7 @@ export default { this.$emit('change', val) Cookies.set('defaultTheme', val) document.body.style.setProperty('--theme-color', val) + this.handleIViewTheme() index++ $message?.close() } @@ -159,6 +160,87 @@ export default { } clusters.push(shadeColor(theme, 0.1)) return clusters + }, + + handleIViewTheme() { + const styleSheets = document.styleSheets; + const lightColor = this.colorUtils(this.theme, 0.2) + + for (let i = 0; i < styleSheets.length; i++) { + const styleSheet = styleSheets[i]; + try { + // 获取样式表中的所有规则 + const rules = styleSheet.cssRules || styleSheet.rules; + + // 遍历每个规则 + for (let j = 0; j < rules.length; j++) { + const rule = rules[j]; + + // 检查规则是否是 .ivu-btn-primary + if(rule.selectorText === '.ivu-btn-ghost.ivu-btn-primary') { + rule.style.color = this.theme; + } + else if (rule.selectorText === '.ivu-btn-ghost.ivu-btn-primary:hover') { + rule.style.color = lightColor; + } + else if(rule.selectorText === '.ivu-page-item-active') { + rule.style.borderColor = this.theme; + } + else if (/^.ivu-.*?-primary$|^.ivu-input-search$/.test(rule.selectorText)) { + // 修改 color 属性 + rule.style.borderColor = this.theme; // 替换为你想要的颜色 + rule.style.backgroundColor = this.theme; + } else if(/^.ivu-.*?-primary(:hover|:focus)$|^.ivu-input-search(:hover|:active)$/.test(rule.selectorText)) { + rule.style.borderColor = lightColor; // 替换为你想要的颜色 + rule.style.backgroundColor = lightColor; + } + } + } catch (e) { + // 某些样式表可能无法访问(例如跨域样式表),需要捕获异常 + console.error(e); + } + } + }, + + colorUtils(color, level) { + function hex2Rgb(str) { + var r = /^#?[0-9a-fA-F]{6}$/; + //test方法检查在字符串中是否存在一个模式,如果存在则返回true,否则返回false + if (!r.test(str)) { + console.log("输入错误的hex") + return + } + //replace替换查找的到的字符串 + str = str.replace("#", ""); + //match得到查询数组 + var hxs = str.match(/../g); + for (var i = 0; i < 3; i++) { + hxs[i] = parseInt(hxs[i], 16); + } + return hxs; + } + function rgb2Hex(a, b, c) { + var r = /^\d{1,3}$/; + if (!r.test(a) || !r.test(b) || !r.test(c)) { + console.log("输入错误的rgb颜色值") + return + } + var hexs = [a.toString(16), b.toString(16), c.toString(16)]; + for (var i = 0; i < 3; i++) { + if (hexs[i].length === 1) hexs[i] = "0" + hexs[i]; + } + return "#" + hexs.join(""); + } + var r = /^#?[0-9a-fA-F]{6}$/; + if (!r.test(color)) { + console.log("输入错误的hex颜色值") + return + } + var rgbc = hex2Rgb(color); + for (var i = 0; i < 3; i++){ + rgbc[i] = Math.floor((255 - rgbc[i]) * level + rgbc[i]); + } + return rgb2Hex(rgbc[0], rgbc[1], rgbc[2]); } } } @@ -179,4 +261,7 @@ export default { .theme-picker-dropdown .el-color-dropdown__link-btn { display: none; } +:root { + --theme-color: #409EFF; +} diff --git a/src/components/XySelectors/index.vue b/src/components/XySelectors/index.vue index c86f362..965fa0c 100644 --- a/src/components/XySelectors/index.vue +++ b/src/components/XySelectors/index.vue @@ -135,7 +135,7 @@ export default { border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom: none; - box-shadow: 0 2px 10px 1px $primaryColor; + box-shadow: 0 2px 10px 1px var(--theme-color); position: relative; &::after{ @@ -155,8 +155,8 @@ export default { //width: 100%; background: rgba(239,242,250,0.95); border-radius: 0 4px 4px 4px; - border: $primaryColor solid 1px; - box-shadow: 0 4px 10px 1px $primaryColor; + border: var(--theme-color) solid 1px; + box-shadow: 0 4px 10px 1px var(--theme-color); z-index: 4; position: absolute; @@ -174,7 +174,7 @@ export default { padding: 36px 0 44px 8px; &::-webkit-scrollbar-thumb{ - background: $primaryColor; + background: var(--theme-color); } } &-btn{ diff --git a/src/layout/index.vue b/src/layout/index.vue index baf0eb1..d368a01 100644 --- a/src/layout/index.vue +++ b/src/layout/index.vue @@ -2,11 +2,6 @@