diff --git a/.env.development b/.env.development
index daa0fc6d3307463531e311af6c87afa56dd5b2f0..f4a99ec2e7b4ebd755b5f67966fd61cd9ebf7fa0 100644
--- a/.env.development
+++ b/.env.development
@@ -6,7 +6,7 @@ NODE_ENV='development'
VITE_APP_PORT = 3000
# API请求前缀
-VITE_APP_BASE_API = '/dev-api'
+VITE_APP_BASE_API = '/' # Mock需要去掉/api
# proxy代理配置
VITE_APP_API_URL = 'http://vapi.youlai.tech' # 线上接口
diff --git a/.eslintrc.cjs b/.eslintrc.cjs
index 8ae169a99adca3c8919a8e119ea3f0ebc241fb63..364aafade3e3cf957482493985482245e5cefaf5 100644
--- a/.eslintrc.cjs
+++ b/.eslintrc.cjs
@@ -3,86 +3,86 @@ module.exports = {
env: {
browser: true,
es2021: true,
- node: true,
+ node: true
},
- parser: "vue-eslint-parser",
+ parser: 'vue-eslint-parser',
extends: [
// https://eslint.vuejs.org/user-guide/#usage
- "plugin:vue/vue3-recommended",
- "./.eslintrc-auto-import.json",
- "prettier",
- "plugin:@typescript-eslint/recommended",
- "plugin:prettier/recommended",
+ 'plugin:vue/vue3-recommended',
+ './.eslintrc-auto-import.json',
+ 'prettier',
+ 'plugin:@typescript-eslint/recommended',
+ 'plugin:prettier/recommended'
],
parserOptions: {
- ecmaVersion: "latest",
- sourceType: "module",
- parser: "@typescript-eslint/parser",
- project: "./tsconfig.*?.json",
+ ecmaVersion: 'latest',
+ sourceType: 'module',
+ parser: '@typescript-eslint/parser',
+ project: './tsconfig.*?.json',
createDefaultProgram: false,
- extraFileExtensions: [".vue"],
+ extraFileExtensions: ['.vue']
},
- plugins: ["vue", "@typescript-eslint"],
+ plugins: ['vue', '@typescript-eslint'],
rules: {
// https://eslint.vuejs.org/rules/#priority-a-essential-error-prevention
- "vue/multi-word-component-names": "off",
- "vue/no-v-model-argument": "off",
- "vue/script-setup-uses-vars": "error",
- "vue/no-reserved-component-names": "off",
- "vue/custom-event-name-casing": "off",
- "vue/attributes-order": "off",
- "vue/one-component-per-file": "off",
- "vue/html-closing-bracket-newline": "off",
- "vue/max-attributes-per-line": "off",
- "vue/multiline-html-element-content-newline": "off",
- "vue/singleline-html-element-content-newline": "off",
- "vue/attribute-hyphenation": "off",
- "vue/require-default-prop": "off",
- "vue/require-explicit-emits": "off",
- "vue/html-self-closing": [
- "error",
+ 'vue/multi-word-component-names': 'off',
+ 'vue/no-v-model-argument': 'off',
+ 'vue/script-setup-uses-vars': 'error',
+ 'vue/no-reserved-component-names': 'off',
+ 'vue/custom-event-name-casing': 'off',
+ 'vue/attributes-order': 'off',
+ 'vue/one-component-per-file': 'off',
+ 'vue/html-closing-bracket-newline': 'off',
+ 'vue/max-attributes-per-line': 'off',
+ 'vue/multiline-html-element-content-newline': 'off',
+ 'vue/singleline-html-element-content-newline': 'off',
+ 'vue/attribute-hyphenation': 'off',
+ 'vue/require-default-prop': 'off',
+ 'vue/require-explicit-emits': 'off',
+ 'vue/html-self-closing': [
+ 'error',
{
html: {
- void: "always",
- normal: "never",
- component: "always",
+ void: 'always',
+ normal: 'never',
+ component: 'always'
},
- svg: "always",
- math: "always",
- },
+ svg: 'always',
+ math: 'always'
+ }
],
- "@typescript-eslint/no-empty-function": "off", // 关闭空方法检查
- "@typescript-eslint/no-explicit-any": "off", // 关闭any类型的警告
- "@typescript-eslint/no-non-null-assertion": "off",
- "@typescript-eslint/ban-ts-ignore": "off",
- "@typescript-eslint/ban-ts-comment": "off",
- "@typescript-eslint/ban-types": "off",
- "@typescript-eslint/explicit-function-return-type": "off",
- "@typescript-eslint/no-explicit-any": "off",
- "@typescript-eslint/no-var-requires": "off",
- "@typescript-eslint/no-empty-function": "off",
- "@typescript-eslint/no-use-before-define": "off",
- "@typescript-eslint/no-non-null-assertion": "off",
- "@typescript-eslint/explicit-module-boundary-types": "off",
- "@typescript-eslint/no-unused-vars": "off",
+ '@typescript-eslint/no-empty-function': 'off', // 关闭空方法检查
+ '@typescript-eslint/no-explicit-any': 'off', // 关闭any类型的警告
+ '@typescript-eslint/no-non-null-assertion': 'off',
+ '@typescript-eslint/ban-ts-ignore': 'off',
+ '@typescript-eslint/ban-ts-comment': 'off',
+ '@typescript-eslint/ban-types': 'off',
+ '@typescript-eslint/explicit-function-return-type': 'off',
+ '@typescript-eslint/no-explicit-any': 'off',
+ '@typescript-eslint/no-var-requires': 'off',
+ '@typescript-eslint/no-empty-function': 'off',
+ '@typescript-eslint/no-use-before-define': 'off',
+ '@typescript-eslint/no-non-null-assertion': 'off',
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
+ '@typescript-eslint/no-unused-vars': 'off',
- "prettier/prettier": [
- "error",
+ 'prettier/prettier': [
+ 'error',
{
- useTabs: false, // 不使用制表符
- },
- ],
+ useTabs: false // 不使用制表符
+ }
+ ]
},
// eslint不能对html文件生效
overrides: [
{
- files: ["*.html"],
- processor: "vue/.vue",
- },
+ files: ['*.html'],
+ processor: 'vue/.vue'
+ }
],
// https://eslint.org/docs/latest/use/configure/language-options#specifying-globals
globals: {
- OptionType: "readonly",
- },
-};
+ OptionType: 'readonly'
+ }
+}
diff --git a/.prettierrc.cjs b/.prettierrc.cjs
index 347fb32e916c99606c414e698418d8689aef29c0..e478c6633341f06b9c8518150c9784f0dd3f001f 100644
--- a/.prettierrc.cjs
+++ b/.prettierrc.cjs
@@ -1,14 +1,14 @@
module.exports = {
// (x)=>{},单个参数箭头函数是否显示小括号。(always:始终显示;avoid:省略括号。默认:always)
- arrowParens: "always",
+ arrowParens: 'always',
// 开始标签的右尖括号是否跟随在最后一行属性末尾,默认false
bracketSameLine: false,
// 对象字面量的括号之间打印空格 (true - Example: { foo: bar } ; false - Example: {foo:bar})
bracketSpacing: true,
// 是否格式化一些文件中被嵌入的代码片段的风格(auto|off;默认auto)
- embeddedLanguageFormatting: "auto",
+ embeddedLanguageFormatting: 'auto',
// 指定 HTML 文件的空格敏感度 (css|strict|ignore;默认css)
- htmlWhitespaceSensitivity: "css",
+ htmlWhitespaceSensitivity: 'css',
// 当文件已经被 Prettier 格式化之后,是否会在文件顶部插入一个特殊的 @format 标记,默认false
insertPragma: false,
// 在 JSX 中使用单引号替代双引号,默认false
@@ -16,31 +16,31 @@ module.exports = {
// 每行最多字符数量,超出换行(默认80)
printWidth: 80,
// 超出打印宽度 (always | never | preserve )
- proseWrap: "preserve",
+ proseWrap: 'preserve',
// 对象属性是否使用引号(as-needed | consistent | preserve;默认as-needed:对象的属性需要加引号才添加;)
- quoteProps: "as-needed",
+ quoteProps: 'as-needed',
// 是否只格式化在文件顶部包含特定注释(@prettier| @format)的文件,默认false
requirePragma: false,
// 结尾添加分号
- semi: true,
+ semi: false,
// 使用单引号 (true:单引号;false:双引号)
- singleQuote: false,
+ singleQuote: true,
// 缩进空格数,默认2个空格
tabWidth: 2,
// 元素末尾是否加逗号,默认es5: ES5中的 objects, arrays 等会添加逗号,TypeScript 中的 type 后不加逗号
- trailingComma: "es5",
+ trailingComma: 'none',
// 指定缩进方式,空格或tab,默认false,即使用空格
useTabs: false,
// vue 文件中是否缩进
diff --git a/src/directive/index.ts b/src/directive/index.ts
index 9c22eb69f123730bfb405a6e74c88ee538ea0dea..f50e66d7a3b9200e27d0da8b75f166bb1c8fb65d 100644
--- a/src/directive/index.ts
+++ b/src/directive/index.ts
@@ -1,9 +1,9 @@
-import type { App } from "vue";
+import type { App } from 'vue'
-import { hasPerm } from "./permission";
+import { hasPerm } from './permission'
// 全局注册 directive
export function setupDirective(app: App) {
// 使 v-hasPerm 在所有组件中都可用
- app.directive("hasPerm", hasPerm);
+ app.directive('hasPerm', hasPerm)
}
diff --git a/src/directive/permission/index.ts b/src/directive/permission/index.ts
index 2bd2c7054f514cf74c2776fa39de656c97213584..155e69d3ac42344175a8e2fed3db0be774d7b226 100644
--- a/src/directive/permission/index.ts
+++ b/src/directive/permission/index.ts
@@ -1,5 +1,5 @@
-import { useUserStoreHook } from "@/store/modules/user";
-import { Directive, DirectiveBinding } from "vue";
+import { useUserStoreHook } from '@/store/modules/user'
+import { Directive, DirectiveBinding } from 'vue'
/**
* 按钮权限
@@ -7,49 +7,49 @@ import { Directive, DirectiveBinding } from "vue";
export const hasPerm: Directive = {
mounted(el: HTMLElement, binding: DirectiveBinding) {
// 「超级管理员」拥有所有的按钮权限
- const { roles, perms } = useUserStoreHook().user;
- if (roles.includes("ROOT")) {
- return true;
+ const { roles, perms } = useUserStoreHook().user
+ if (roles.includes('ROOT')) {
+ return true
}
// 「其他角色」按钮权限校验
- const { value } = binding;
+ const { value } = binding
if (value) {
- const requiredPerms = value; // DOM绑定需要的按钮权限标识
+ const requiredPerms = value // DOM绑定需要的按钮权限标识
const hasPerm = perms?.some((perm) => {
- return requiredPerms.includes(perm);
- });
+ return requiredPerms.includes(perm)
+ })
if (!hasPerm) {
- el.parentNode && el.parentNode.removeChild(el);
+ el.parentNode && el.parentNode.removeChild(el)
}
} else {
throw new Error(
"need perms! Like v-has-perm=\"['sys:user:add','sys:user:edit']\""
- );
+ )
}
- },
-};
+ }
+}
/**
* 角色权限
*/
export const hasRole: Directive = {
mounted(el: HTMLElement, binding: DirectiveBinding) {
- const { value } = binding;
+ const { value } = binding
if (value) {
- const requiredRoles = value; // DOM绑定需要的角色编码
- const { roles } = useUserStoreHook().user;
+ const requiredRoles = value // DOM绑定需要的角色编码
+ const { roles } = useUserStoreHook().user
const hasRole = roles.some((perm) => {
- return requiredRoles.includes(perm);
- });
+ return requiredRoles.includes(perm)
+ })
if (!hasRole) {
- el.parentNode && el.parentNode.removeChild(el);
+ el.parentNode && el.parentNode.removeChild(el)
}
} else {
- throw new Error("need roles! Like v-has-role=\"['admin','test']\"");
+ throw new Error("need roles! Like v-has-role=\"['admin','test']\"")
}
- },
-};
+ }
+}
diff --git a/src/enums/MenuTypeEnum.ts b/src/enums/MenuTypeEnum.ts
index 65e591db0a1c8cd5c4a0bf91244de20d10cbc252..96c612e40a92f83ac41bd8c9309da01dfc880c38 100644
--- a/src/enums/MenuTypeEnum.ts
+++ b/src/enums/MenuTypeEnum.ts
@@ -2,18 +2,18 @@ export enum MenuTypeEnum {
/**
* 目录
*/
- CATALOG = "CATALOG",
+ CATALOG = 'CATALOG',
/**
* 菜单
*/
- MENU = "MENU",
+ MENU = 'MENU',
/**
* 按钮
*/
- BUTTON = "BUTTON",
+ BUTTON = 'BUTTON',
/**
* 外链
*/
- EXTLINK = "EXTLINK",
+ EXTLINK = 'EXTLINK'
}
diff --git a/src/lang/index.ts b/src/lang/index.ts
index 18c0231690481f1204637dabde7b2f9fab04bedf..7a0318a9d96cb3cc78d01122f39c337bcc4fb8f0 100644
--- a/src/lang/index.ts
+++ b/src/lang/index.ts
@@ -1,25 +1,25 @@
-import { createI18n } from "vue-i18n";
-import { useAppStore } from "@/store/modules/app";
+import { createI18n } from 'vue-i18n'
+import { useAppStore } from '@/store/modules/app'
// 本地语言包
-import enLocale from "./package/en";
-import zhCnLocale from "./package/zh-cn";
+import enLocale from './package/en'
+import zhCnLocale from './package/zh-cn'
-const appStore = useAppStore();
+const appStore = useAppStore()
const messages = {
- "zh-cn": {
- ...zhCnLocale,
+ 'zh-cn': {
+ ...zhCnLocale
},
en: {
- ...enLocale,
- },
-};
+ ...enLocale
+ }
+}
const i18n = createI18n({
legacy: false,
locale: appStore.language,
messages: messages,
- globalInjection: true,
-});
+ globalInjection: true
+})
-export default i18n;
+export default i18n
diff --git a/src/lang/package/en.ts b/src/lang/package/en.ts
index e7bbb53cfbd8b607f788241ba3ff55e57957cdbb..26c6bc90e00a1e33dd9c5743b793bf355ceb2e75 100644
--- a/src/lang/package/en.ts
+++ b/src/lang/package/en.ts
@@ -1,21 +1,21 @@
export default {
// 路由国际化
route: {
- dashboard: "Dashboard",
- document: "Document",
+ dashboard: 'Dashboard',
+ document: 'Document'
},
// 登录页面国际化
login: {
- username: "Username",
- password: "Password",
- login: "Login",
- captchaCode: "Verify Code",
+ username: 'Username',
+ password: 'Password',
+ login: 'Login',
+ captchaCode: 'Verify Code'
},
// 导航栏国际化
navbar: {
- dashboard: "Dashboard",
- logout: "Logout",
- document: "Document",
- gitee: "Gitee",
- },
-};
+ dashboard: 'Dashboard',
+ logout: 'Logout',
+ document: 'Document',
+ gitee: 'Gitee'
+ }
+}
diff --git a/src/lang/package/zh-cn.ts b/src/lang/package/zh-cn.ts
index ed901433f8072c10c483507a0b7c80d34351d296..7f27c307d6ce4d5420e6bb9d75835ff7c435e3c1 100644
--- a/src/lang/package/zh-cn.ts
+++ b/src/lang/package/zh-cn.ts
@@ -1,21 +1,21 @@
export default {
// 路由国际化
route: {
- dashboard: "首页",
- document: "项目文档",
+ dashboard: '首页',
+ document: '项目文档'
},
// 登录页面国际化
login: {
- username: "用户名",
- password: "密码",
- login: "登 录",
- captchaCode: "验证码",
+ username: '用户名',
+ password: '密码',
+ login: '登 录',
+ captchaCode: '验证码'
},
// 导航栏国际化
navbar: {
- dashboard: "首页",
- logout: "注销",
- document: "项目文档",
- gitee: "码云",
- },
-};
+ dashboard: '首页',
+ logout: '注销',
+ document: '项目文档',
+ gitee: '码云'
+ }
+}
diff --git a/src/layout/components/AppMain.vue b/src/layout/components/AppMain.vue
index 4d24b3ff07b7ed0e4ead73860a326af1a2bec4c0..61dcee7ce6d509193e77b576b274753716cb7b8a 100644
--- a/src/layout/components/AppMain.vue
+++ b/src/layout/components/AppMain.vue
@@ -1,7 +1,7 @@
diff --git a/src/layout/components/NavBar/NavRight.vue b/src/layout/components/NavBar/NavRight.vue
index 904f01825b119c1eac7ca7649c450a85d9b96907..171e6d23c9a86ec37f2c6df9d061ce5b6280fb33 100644
--- a/src/layout/components/NavBar/NavRight.vue
+++ b/src/layout/components/NavBar/NavRight.vue
@@ -20,7 +20,7 @@
- {{ $t("navbar.dashboard") }}
+ {{ $t('navbar.dashboard') }}
Github
- {{ $t("navbar.gitee") }}
+ {{ $t('navbar.gitee') }}
- {{ $t("navbar.document") }}
+ {{ $t('navbar.document') }}
- {{ $t("navbar.logout") }}
+ {{ $t('navbar.logout') }}