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 @@