From f1721d8b7187061244fd86ed85f32e8ea5f702b4 Mon Sep 17 00:00:00 2001 From: wangzenghua <1048523306@qq.com> Date: Thu, 27 Feb 2025 01:17:19 +0000 Subject: [PATCH] fix:main --- main/package.json | 1 + .../components/custom-import-excel/index.vue | 1 - main/src/main.js | 4 +- main/src/router/index.js | 6 -- main/src/store/modules/setting.js | 52 ++++++++++++++ main/src/store/modules/user.js | 8 +-- main/src/styles/style.scss | 2 +- main/src/views/index.vue | 2 +- main/vite.config.js | 72 +++++++------------ main/yarn.lock | 19 ++++- 10 files changed, 104 insertions(+), 63 deletions(-) diff --git a/main/package.json b/main/package.json index f45644c..ba77e38 100644 --- a/main/package.json +++ b/main/package.json @@ -18,6 +18,7 @@ }, "dependencies": { "@element-plus/icons-vue": "^2.3.1", + "@smallwei/avue": "^3.6.2", "@vueuse/core": "^12.4.0", "axios": "^1.6.5", "dayjs": "^1.11.11", diff --git a/main/src/components/custom-import-excel/index.vue b/main/src/components/custom-import-excel/index.vue index 7abd779..7529540 100644 --- a/main/src/components/custom-import-excel/index.vue +++ b/main/src/components/custom-import-excel/index.vue @@ -4,7 +4,6 @@ draggable title="文件导入" width="50%" - top="10px" :close-on-click-modal="false" :close-on-press-escape="false" @close="onClose" diff --git a/main/src/main.js b/main/src/main.js index 9105699..08bbed6 100644 --- a/main/src/main.js +++ b/main/src/main.js @@ -5,11 +5,13 @@ import router from './router'; import pinia from './store'; import ElementPlus from 'element-plus'; import 'element-plus/dist/index.css'; +import Avue from '@smallwei/avue'; +import '@smallwei/avue/lib/index.css'; import { registerGlobalMicroApps } from './micro'; import { registerElIcons } from './plugins/icon'; import './utils/permission'; const app = createApp(App); -app.use(pinia).use(router).use(ElementPlus).mount('#root'); +app.use(pinia).use(router).use(ElementPlus).use(Avue).mount('#root'); registerElIcons(app); registerGlobalMicroApps(); diff --git a/main/src/router/index.js b/main/src/router/index.js index 00bc19a..0ec93ba 100644 --- a/main/src/router/index.js +++ b/main/src/router/index.js @@ -27,12 +27,6 @@ export const constantRoutes = [ }, ], }, - // { - // path: '/sub-government-affairs-service/:pathMatch(.*)', - // name: 'sub-government-affairs-service', - // component: Layout, - // redirect: '/sub-government-affairs-service/home', - // }, ]; const router = createRouter({ diff --git a/main/src/store/modules/setting.js b/main/src/store/modules/setting.js index 35aef83..b12e32d 100644 --- a/main/src/store/modules/setting.js +++ b/main/src/store/modules/setting.js @@ -1,12 +1,64 @@ import { defineStore } from 'pinia'; +import { CONSTANTS } from '@/config'; export const useSettingStore = defineStore({ id: 'settingStore', state: () => ({ + // menu 是否收缩 + isCollapse: true, + // + withoutAnimation: false, + device: 'desktop', + // 刷新当前页 isReload: true, + // 主题设置 + themeConfig: { + // 显示设置 + showSetting: false, + // 菜单展示模式 默认 vertical horizontal / vertical /columns + mode: 'vertical', + // tagsView 是否展示 默认展示 + showTag: true, + // 页脚 + footer: true, + // 深色模式 切换暗黑模式 + isDark: false, + // 显示侧边栏Logo + showLogo: true, + // 主题颜色 + primary: CONSTANTS.PRIMARY, + // element组件大小 + globalComSize: 'default', + // 是否只保持一个子菜单的展开 + uniqueOpened: true, + // 固定header + fixedHeader: true, + // 灰色模式 + gray: false, + // 色弱模式 + weak: false, + }, }), getters: {}, actions: { + // 设置主题 + setThemeConfig({ key, val }) { + this.themeConfig[key] = val; + }, + // 切换 Collapse + setCollapse(value) { + this.isCollapse = value; + this.withoutAnimation = false; + }, + // 关闭侧边栏 + closeSideBar({ withoutAnimation }) { + this.isCollapse = false; + this.withoutAnimation = withoutAnimation; + }, + toggleDevice(device) { + this.device = device; + }, + // 刷新 setReload() { this.isReload = false; setTimeout(() => { diff --git a/main/src/store/modules/user.js b/main/src/store/modules/user.js index 0f1d48e..fd325d8 100644 --- a/main/src/store/modules/user.js +++ b/main/src/store/modules/user.js @@ -3,7 +3,7 @@ import { GenKey } from '@/config'; import { isEmpty, encode, decode } from '@/utils'; export const useUserStore = defineStore({ - id: GenKey('user_store'), + id: GenKey('userStore'), state: () => ({ token: null, userInfo: {}, @@ -52,14 +52,14 @@ export const useUserStore = defineStore({ this.currentOrg = null; this.orgList = []; this.menus = []; - localStorage.removeItem(GenKey('user_store')); + localStorage.removeItem(GenKey('userStore')); }, clear() { - localStorage.removeItem(GenKey('user_store')); + localStorage.removeItem(GenKey('userStore')); }, }, persist: { - key: GenKey('user_store'), + key: GenKey('userStore'), storage: window.localStorage, }, }); diff --git a/main/src/styles/style.scss b/main/src/styles/style.scss index 517b558..0898ec0 100644 --- a/main/src/styles/style.scss +++ b/main/src/styles/style.scss @@ -1,6 +1,6 @@ @import 'common/base.scss'; @import 'common/define.scss'; -// @import "@/assets/fonts/iconfont.css"; +@import "@/assets/fonts/iconfont.css"; #root, #app { diff --git a/main/src/views/index.vue b/main/src/views/index.vue index b0399ab..84e4b52 100644 --- a/main/src/views/index.vue +++ b/main/src/views/index.vue @@ -41,7 +41,7 @@ const gotoPage = (row) => { // curentApp, // }); // console.log('===', actions.getGlobalState('user')); - if (row.name !== 'sub-government-affairs-service') return; + // if (row.name !== 'sub-government-affairs-service') return; window.history.pushState({}, row.name, row.activeRule); }; diff --git a/main/vite.config.js b/main/vite.config.js index febc33b..749cd3a 100644 --- a/main/vite.config.js +++ b/main/vite.config.js @@ -14,46 +14,37 @@ import { resolve } from 'path'; export default defineConfig(({ command, mode }) => { console.log('vite.config.js', command, mode, loadEnv(mode, process.cwd())); - const { - VITE_PORT, - VITE_APP_NAME, - VITE_APP_BASE_API, - VITE_APP_BASE_URL, - VITE_APP_UPLOAD_API, - VITE_APP_UPLOAD_URL, - VITE_APP_SYSTEM_API, - VITE_APP_SYSTEM_URL, - } = loadEnv(mode, process.cwd()); + const { VITE_PORT, VITE_APP_NAME, VITE_APP_BASE_API, VITE_APP_BASE_URL, VITE_APP_UPLOAD_API, VITE_APP_UPLOAD_URL } = loadEnv(mode, process.cwd()); const config = { base: './', build: { target: 'ESNext', outDir: 'dist', minify: 'terser', - // terserOptions: { - // compress: { - // drop_console: true, - // drop_debugger: true, - // pure_funcs: ['console.log'], - // }, - // output: { - // comments: true, - // }, - // }, - // reportCompressedSize: false, - // chunkSizeWarningLimit: 2000, - // rollupOptions: { - // output: { - // manualChunks(id) { - // if (id.includes('node_modules')) { - // return id.toString().split('node_modules/')[1].split('/')[1].toString(); - // } - // }, - // chunkFileNames: 'assets/js/[name]-[hash].js', - // entryFileNames: 'assets/js/[name]-[hash].js', - // assetFileNames: 'assets/[ext]/[name]-[hash].[ext]', - // }, - // }, + terserOptions: { + compress: { + drop_console: true, + drop_debugger: true, + pure_funcs: ['console.log'], + }, + output: { + comments: true, + }, + }, + reportCompressedSize: false, + chunkSizeWarningLimit: 2000, + rollupOptions: { + output: { + manualChunks(id) { + if (id.includes('node_modules')) { + return id.toString().split('node_modules/')[1].split('/')[1].toString(); + } + }, + chunkFileNames: 'assets/js/[name]-[hash].js', + entryFileNames: 'assets/js/[name]-[hash].js', + assetFileNames: 'assets/[ext]/[name]-[hash].[ext]', + }, + }, }, server: { host: '0.0.0.0', @@ -74,11 +65,6 @@ export default defineConfig(({ command, mode }) => { changeOrigin: true, rewrite: (path) => path.replace(/^\/uploadApis/, ''), }, - [VITE_APP_SYSTEM_API]: { - target: VITE_APP_SYSTEM_URL, - changeOrigin: true, - rewrite: (path) => path.replace(/^\/systemApis/, ''), - }, }, }, resolve: { @@ -133,13 +119,5 @@ export default defineConfig(({ command, mode }) => { }), ], }; - if (mode === 'production') { - config.build.terserOptions = { - compress: { - drop_console: true, - drop_debugger: true, - }, - }; - } return config; }); diff --git a/main/yarn.lock b/main/yarn.lock index 7cefbf8..c6e9f15 100644 --- a/main/yarn.lock +++ b/main/yarn.lock @@ -195,7 +195,7 @@ resolved "https://registry.npmmirror.com/@dual-bundle/import-meta-resolve/-/import-meta-resolve-4.1.0.tgz#519c1549b0e147759e7825701ecffd25e5819f7b" integrity sha512-+nxncfwHM5SgAtrVzgpzJOI1ol0PkumhVo469KCf9lUi21IGcY90G98VuHm9VRrUypmAzawAHO9bs6hqeADaVg== -"@element-plus/icons-vue@^2.3.1": +"@element-plus/icons-vue@^2.0.6", "@element-plus/icons-vue@^2.3.1": version "2.3.1" resolved "https://registry.npmmirror.com/@element-plus/icons-vue/-/icons-vue-2.3.1.tgz#1f635ad5fdd5c85ed936481525570e82b5a8307a" integrity sha512-XxVUZv48RZAd87ucGS48jPf6pKu0yV5UCg9f4FFwtrYxXOwWuVJo6wOvSLKEoMQKjv8GsX/mhP6UsC1lRwbUWg== @@ -678,6 +678,16 @@ resolved "https://registry.npmmirror.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.29.2.tgz#dc89d92418ae2efa1d70e071c686cffbcf788147" integrity sha512-p6fTArexECPf6KnOHvJXRpAEq0ON1CBtzG/EY4zw08kCHk/kivBc5vUEtnCFNCHOpJZ2ne77fxwRLIKD4wuW2Q== +"@smallwei/avue@^3.6.2": + version "3.6.2" + resolved "https://registry.npmmirror.com/@smallwei/avue/-/avue-3.6.2.tgz#a9397aa1ae0863fe7e142f0893d570e5a5225d9d" + integrity sha512-Ifkt0o7KLsAMptfoNMG7qYS86OL2pEet761wWZyZGu8e48wuNNPOfqx5jnibGjx2oIoKtYUFh7tFdllOCth2EQ== + dependencies: + "@element-plus/icons-vue" "^2.0.6" + countup.js "^1.9.3" + dayjs "^1.10.4" + lodash "^4.17.21" + "@transloadit/prettier-bytes@0.0.7": version "0.0.7" resolved "https://registry.npmmirror.com/@transloadit/prettier-bytes/-/prettier-bytes-0.0.7.tgz#cdb5399f445fdd606ed833872fa0cabdbc51686b" @@ -1800,6 +1810,11 @@ cosmiconfig@^9.0.0: js-yaml "^4.1.0" parse-json "^5.2.0" +countup.js@^1.9.3: + version "1.9.3" + resolved "https://registry.npmmirror.com/countup.js/-/countup.js-1.9.3.tgz#ce3e50cd7160441e478f07da31895edcc0f1c9dd" + integrity sha512-UHf2P/mFKaESqdPq+UdBJm/1y8lYdlcDd0nTZHNC8cxWoJwZr1Eldm1PpWui446vDl5Pd8PtRYkr3q6K4+Qa5A== + cross-spawn@^7.0.2, cross-spawn@^7.0.3: version "7.0.6" resolved "https://registry.npmmirror.com/cross-spawn/-/cross-spawn-7.0.6.tgz#8a58fe78f00dcd70c370451759dfbfaf03e8ee9f" @@ -1916,7 +1931,7 @@ data-view-byte-offset@^1.0.1: es-errors "^1.3.0" is-data-view "^1.0.1" -dayjs@^1.11.11, dayjs@^1.11.13: +dayjs@^1.10.4, dayjs@^1.11.11, dayjs@^1.11.13: version "1.11.13" resolved "https://registry.npmmirror.com/dayjs/-/dayjs-1.11.13.tgz#92430b0139055c3ebb60150aa13e860a4b5a366c" integrity sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg==