From 349139daaf8b6c0ac7497af90bd29f38172d8bd0 Mon Sep 17 00:00:00 2001 From: wf <2547096351@qq.com> Date: Mon, 22 Jul 2024 19:07:37 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=94=9F=E4=BA=A7=E3=80=81=E5=BC=80?= =?UTF-8?q?=E5=8F=91=E3=80=81=E6=B5=8B=E8=AF=95=E7=8E=AF=E5=A2=83=E6=89=93?= =?UTF-8?q?=E5=8C=85=E6=B5=8B=E8=AF=95=EF=BC=8C=E5=8E=BB=E6=8E=89=E9=A2=9C?= =?UTF-8?q?=E8=89=B2=E9=80=89=E6=8B=A9=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 12 ++++++---- .env.production | 12 ++++++---- .env.test | 4 +++- package.json | 3 +++ src/directives/index.ts | 2 ++ src/directives/modules/custom.ts | 9 +++++++ src/lang/modules/enUS.ts | 1 + src/lang/modules/zhCN.ts | 1 + .../components/system-settings/index.vue | 2 +- .../components/theme-settings/index.vue | 19 ++++++++------- src/router/route.ts | 17 +++++++++++++ .../test-instruction/test-instruction.vue | 9 +++++++ src/vite-env.d.ts | 1 + vite.config.ts | 24 +++++++++---------- 14 files changed, 83 insertions(+), 33 deletions(-) create mode 100644 src/directives/modules/custom.ts create mode 100644 src/views/custom-instruction/test-instruction/test-instruction.vue diff --git a/.env.development b/.env.development index a3ae4d4..1641112 100644 --- a/.env.development +++ b/.env.development @@ -1,5 +1,7 @@ -# 开发环境 -VITE_USER_NODE_ENV = development - -# 开发环境地址前缀 (一般 '/' 或 './' 都可以) -VITE_PUBLIC_PATH = '/' \ No newline at end of file +# 开发环境 +VITE_USER_NODE_ENV = development + +# 开发环境地址前缀 (一般 '/' 或 './' 都可以) +VITE_PUBLIC_PATH = '/' + +VITE_GLOB_APP_TITLE = SnowAdmin \ No newline at end of file diff --git a/.env.production b/.env.production index 0387852..98bbd57 100644 --- a/.env.production +++ b/.env.production @@ -1,5 +1,7 @@ -# 生产环境 -VITE_USER_NODE_ENV = production - -# 打包路径 (就是网站前缀, 例如部署到 http://dcodes.gitee.io/dc-admin/ 域名下, 就需要填写 /dc-admin/), 一般填一个斜杠 / -VITE_PUBLIC_PATH = '/dc-admin/' \ No newline at end of file +# 生产环境 +VITE_USER_NODE_ENV = production + +# 打包路径 (就是网站前缀, 例如部署到 http://dcodes.gitee.io/dc-admin/ 域名下, 就需要填写 /dc-admin/), 一般填一个斜杠 / +VITE_PUBLIC_PATH = '/dc-admin/' + +VITE_GLOB_APP_TITLE = SnowAdmin \ No newline at end of file diff --git a/.env.test b/.env.test index 7a393e7..1641112 100644 --- a/.env.test +++ b/.env.test @@ -2,4 +2,6 @@ VITE_USER_NODE_ENV = development # 开发环境地址前缀 (一般 '/' 或 './' 都可以) -VITE_PUBLIC_PATH = '/' \ No newline at end of file +VITE_PUBLIC_PATH = '/' + +VITE_GLOB_APP_TITLE = SnowAdmin \ No newline at end of file diff --git a/package.json b/package.json index 7c48708..9246658 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,9 @@ "scripts": { "dev": "vite", "build": "vue-tsc && vite build", + "build:dev": "vue-tsc && vite build --mode development", + "build:prod": "vue-tsc && vite build --mode production", + "build:test": "vue-tsc && vite build --mode test", "preview": "vite preview", "lint:eslint": "eslint --fix --ext .js,.ts,.vue ./src", "lint:prettier": "prettier --write \"src/**/*.{js,ts,json,tsx,css,less,scss,vue,html,md}\"", diff --git a/src/directives/index.ts b/src/directives/index.ts index f41138c..4aca441 100644 --- a/src/directives/index.ts +++ b/src/directives/index.ts @@ -1,6 +1,7 @@ import { App } from "vue"; import antiShake from "@/directives/modules/anti-shake"; import throttle from "@/directives/modules/throttle"; +import custom from "@/directives/modules/custom"; // 定义安装函数 // install 函数是一个对象中的方法,其作用是将一系列指令对象安装到 Vue 应用实例中,它自带两个参数:app 和 options @@ -11,6 +12,7 @@ const directives = { // 将一系列自定义指令对象安装到 Vue 应用实例中 app.directive("antiShake", antiShake); app.directive("throttle", throttle); + app.directive("custom", custom); } }; diff --git a/src/directives/modules/custom.ts b/src/directives/modules/custom.ts new file mode 100644 index 0000000..3711cd7 --- /dev/null +++ b/src/directives/modules/custom.ts @@ -0,0 +1,9 @@ +import { Directive } from "vue"; + +const custom: Directive = { + mounted(el, binding) { + el.style.color = binding.value; + } +}; + +export default custom; diff --git a/src/lang/modules/enUS.ts b/src/lang/modules/enUS.ts index eb81fa5..7685968 100644 --- a/src/lang/modules/enUS.ts +++ b/src/lang/modules/enUS.ts @@ -31,6 +31,7 @@ export default { ["custom-instruction"]: "custom instruction", ["anti-shake"]: "anti shake", ["throttle"]: "throttle", + ["test-instruction"]: "test instruction", ["personal-center"]: "personal center", ["userinfo"]: "userinfo", ["user-settings"]: "user settings", diff --git a/src/lang/modules/zhCN.ts b/src/lang/modules/zhCN.ts index bbe1531..899867e 100644 --- a/src/lang/modules/zhCN.ts +++ b/src/lang/modules/zhCN.ts @@ -31,6 +31,7 @@ export default { ["custom-instruction"]: "自定义指令", ["anti-shake"]: "防抖", ["throttle"]: "节流", + ["test-instruction"]: "测试指令", ["personal-center"]: "个人中心", ["userinfo"]: "用户信息", ["user-settings"]: "用户设置", diff --git a/src/layout/components/Header/components/system-settings/index.vue b/src/layout/components/Header/components/system-settings/index.vue index 1509d79..c82542f 100644 --- a/src/layout/components/Header/components/system-settings/index.vue +++ b/src/layout/components/Header/components/system-settings/index.vue @@ -29,7 +29,7 @@
水印设置
水印颜色
- +
水印文案
diff --git a/src/layout/components/Header/components/theme-settings/index.vue b/src/layout/components/Header/components/theme-settings/index.vue index 5eb8c99..6f16d80 100644 --- a/src/layout/components/Header/components/theme-settings/index.vue +++ b/src/layout/components/Header/components/theme-settings/index.vue @@ -18,13 +18,13 @@
主题设置
- + /> -->
@@ -57,8 +57,9 @@ import { useThemeConfig } from "@/store/modules/theme-config"; import { useThemeMethods } from "@/hooks/useThemeMethods"; const themeStore = useThemeConfig(); -const { layoutType, themeColor, presetColors, colorWeakMode, grayMode, darkMode, asideDark, transitionPage } = - storeToRefs(themeStore); +// themeColor, +// presetColors, +const { layoutType, colorWeakMode, grayMode, darkMode, asideDark, transitionPage } = storeToRefs(themeStore); const layoutList = reactive({ layoutDefaults: { @@ -83,11 +84,11 @@ const transitions = ref([ { value: "cardInOut", label: "卡片" } ]); // 主题色设置 -const themeColorChange = (value: string) => { - themeColor.value = value; - const { setThemeColor } = useThemeMethods(); - setThemeColor(); -}; +// const themeColorChange = (value: string) => { +// themeColor.value = value; +// const { setThemeColor } = useThemeMethods(); +// setThemeColor(); +// }; // 色弱模式 const onColorWeak = () => { diff --git a/src/router/route.ts b/src/router/route.ts index 4cd1312..2286d4c 100644 --- a/src/router/route.ts +++ b/src/router/route.ts @@ -406,6 +406,23 @@ export const dynamicRoutes: RouteRecordRaw[] = [ sort: 2 }, children: [] + }, + { + path: "/custom-instruction/test-instruction", + name: "test-instruction", + component: () => import("@/views/custom-instruction/test-instruction/test-instruction.vue"), + meta: { + title: "test-instruction", + hide: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 3 + }, + children: [] } ] }, diff --git a/src/views/custom-instruction/test-instruction/test-instruction.vue b/src/views/custom-instruction/test-instruction/test-instruction.vue new file mode 100644 index 0000000..16352b5 --- /dev/null +++ b/src/views/custom-instruction/test-instruction/test-instruction.vue @@ -0,0 +1,9 @@ + + + + + diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts index 3d6616b..cc1f825 100644 --- a/src/vite-env.d.ts +++ b/src/vite-env.d.ts @@ -15,3 +15,4 @@ declare module "@codemirror/lang-javascript"; declare module "@codemirror/lang-vue"; declare module "nprogress"; declare module "@wangeditor/editor-for-vue"; +declare module "@/directives/modules/custom"; diff --git a/vite.config.ts b/vite.config.ts index f33a2a2..2deb6d1 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -91,18 +91,18 @@ export default defineConfig(({ mode }) => { }, build: { outDir: "dist", // 指定打包路径,默认为项目根目录下的dist目录 - minify: "esbuild", // esbuild打包更快但是不能去除console.log,terser打包慢但能去除console.log - // minify: "terser", // Vite 2.6.x 以上需要配置 minify:"terser",terserOptions才能生效,terser可以去除 console.log - // terserOptions: { - // compress: { - // keep_infinity: true, // 防止 Infinity 被压缩成 1/0,这可能会导致 Chrome 上的性能问题 - // drop_console: true, // 生产环境去除 console - // drop_debugger: true // 生产环境去除 debugger - // }, - // format: { - // comments: false // 删除注释 - // } - // }, + // minify: "esbuild", // esbuild打包更快但是不能去除console.log,terser打包慢但能去除console.log + minify: "terser", // Vite 2.6.x 以上需要配置 minify:"terser",terserOptions才能生效,terser可以去除 console.log + terserOptions: { + compress: { + keep_infinity: true, // 防止 Infinity 被压缩成 1/0,这可能会导致 Chrome 上的性能问题 + drop_console: true, // 生产环境去除 console + drop_debugger: true // 生产环境去除 debugger + }, + format: { + comments: false // 删除注释 + } + }, assetsInlineLimit: 4 * 1024, // 打包内联阈值4kb chunkSizeWarningLimit: 2000, // 规定触发警告的 chunk 大小, 消除打包大小超过500kb警告 // 静态资源打包到dist下的不同目录,将文件类型css、js、jpg等文件分开存储