فهرست منبع

成渝样式修改

duy 3 ماه پیش
والد
کامیت
71b3808aca

+ 78 - 12
src/layout/index.vue

@@ -120,11 +120,13 @@ const { isAppLoading } = useProject()
 // 在 setup 中添加
 
 //渲染完成
-onMounted(() => {
+onMounted(async () => {
     const layout = useRoutes?.query?.layout, layout2 = store.isLayout
     isLayout.value = layout ?? layout2
     annRefs.value = []
     initButtons()
+     // 确保初始化时加载样式
+    currentStyle = await loadStyles()
 })
 
 //监听layout
@@ -388,27 +390,91 @@ onUnmounted(() => {
     }
   }
 })
+
 // 动态加载样式
-const loadStyles = () => {
-  const styleElement = document.createElement('style')
-  styleElement.type = 'text/css'
-  const styleContent = isYunNanProject.value
-    ? import('./test-yn/index-yn.scss')
-    : import('./index.scss')
-  styleElement.textContent = styleContent
-  document.head.appendChild(styleElement)
-  return styleElement
+const loadStyles = async () => {
+  try {
+    // 确保先移除旧样式
+    if (currentStyle) {
+      document.head.removeChild(currentStyle)
+      currentStyle = null
+    }
+
+    const styleElement = document.createElement('style')
+    styleElement.type = 'text/css'
+
+    // 使用动态import加载样式模块
+    const module = isYunNanProject.value 
+      ? await import('./test-yn/index-yn.scss?inline') // 添加?inline确保直接获取样式内容
+      : await import('./index.scss?inline')
+    
+    styleElement.textContent = module.default
+    document.head.appendChild(styleElement)
+    currentStyle = styleElement
+
+    // 强制触发重绘
+    document.body.style.display = 'none'
+    document.body.offsetHeight // 触发重排
+    document.body.style.display = ''
+
+    return styleElement
+  } catch (error) {
+    console.error('加载样式失败:', error)
+    return null
+  }
 }
 let currentStyle = null
 
+
+
 // 监听项目类型变化,动态切换样式
-watch(() => isYunNanProject.value, () => {
+watch(() => isYunNanProject.value, async (newVal) => {
   if (currentStyle) {
     document.head.removeChild(currentStyle)
+    currentStyle = null
   }
-  currentStyle = loadStyles()
+  
+  currentStyle = await loadStyles()
+  console.log('样式已更新:', newVal ? 'yunnan' : 'default')
 }, { immediate: true })
+// 添加watch来更新isYunNanProject
+watch(() =>store.getProjectId, (newProjectId) => {
+    isYunNanProject.value = newProjectId === '1904814720589430785'
+    //重新加载菜单
+    let val = store.getMenus
+    if (!isYunNanProject.value) {
+       
+        return
+    }
+     const filterAndRenameMenus = (menus) => {
+            return menus.map(menu => {
+                // 创建新对象,而不是修改原对象
+                const newMenu = { ...menu }
+                
+                // 过滤掉个人中心和系统设置
+                if (newMenu.name === '个人中心' || newMenu.name === '系统设置') {
+                    return null
+                }
+                
+                // 重命名档案收集为文件管理
+                if (newMenu.name === '档案收集') {
+                    newMenu.name = '文件管理'
+                }
+                
+                // 递归处理子菜单
+                if (newMenu.children && newMenu.children.length > 0) {
+                    newMenu.children = filterAndRenameMenus(newMenu.children)
+                }
+                
+                return newMenu
+            }).filter(Boolean) // 过滤掉null值
+        }
+        
+        menuBarData.value = filterAndRenameMenus(getArrValue(val))
+         isAsideMenu.value = true
+       
 
+})
 // 组件卸载时清理样式
 </script>
 

+ 1 - 1
src/layout/modules/MenuItem.vue

@@ -69,7 +69,7 @@ const isYunNanProject = ref(projectId.value === '1904814720589430785')
 
 
 // 添加watch来更新isYunNanProject
-watch(() => projectId.value, (newProjectId) => {
+watch(() =>store.getProjectId, (newProjectId) => {
     isYunNanProject.value = newProjectId === '1904814720589430785'
 })
 //初始变量

+ 1 - 1
src/layout/modules/UserInfoBar.vue

@@ -42,7 +42,7 @@ const isYunNanProject = ref(projectId.value === '1904814720589430785')
 
 
 // 添加watch来更新isYunNanProject
-watch(() => projectId.value, (newProjectId) => {
+watch(() => store.getProjectId, (newProjectId) => {
     isYunNanProject.value = newProjectId === '1904814720589430785'
 })
 //监听

+ 1 - 1
src/layout/test-yn/MenuItem-yn.vue

@@ -70,7 +70,7 @@ const isYunNanProject = ref(projectId.value === '1904814720589430785')
 
 
 // 添加watch来更新isYunNanProject
-watch(() => projectId.value, (newProjectId) => {
+watch(() => store.getProjectId, (newProjectId) => {
     isYunNanProject.value = newProjectId === '1904814720589430785'
 })
 //初始变量

+ 1 - 1
src/layout/test-yn/index-yn.scss

@@ -39,7 +39,7 @@
             transition: opacity 0.3s;
             cursor: pointer;
             height: 100%;
-            // box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 0.4);
+         
             z-index: 222;
             #logo-icon {
                 height: 40px;

+ 15 - 0
src/store/modules/useProject.js

@@ -29,6 +29,8 @@ export function useProject() {
         console.log( projectId.value, ' projectId.value ')
         
         const id = '1891312830718746625'
+        const idCY = '1904814720589430785'
+        let isCY = pid === idCY
         let isYunNan = pid === id
         if (isYunNan) {
             useAppState.setThemeVal('light')
@@ -43,6 +45,19 @@ export function useProject() {
             })
             return
         }
+        if (isCY) {
+            useAppState.setThemeVal('light')
+            setElementMainColor('#204DA0')
+            let colorName = 'blue'
+            let theme = 'light'
+            nextTick(() => {
+                useAppState.setThemeVal('light')
+                useAppState.setTheme('light')
+                useAppState.setColorName('blue')
+                document.documentElement.setAttribute('class', `${theme} color-${colorName}`)
+            })
+            return
+        }
     }
     return {
         projectId,