fix: 格式化代码

This commit is contained in:
戴业伟 2024-02-05 10:47:59 +08:00
parent 815f46af31
commit ef8c31fa29
23 changed files with 188 additions and 187 deletions

View File

@ -5,123 +5,123 @@ module.exports = {
es2021: true, es2021: true,
node: true, node: true,
}, },
parser: "vue-eslint-parser", parser: 'vue-eslint-parser',
extends: [ extends: [
// https://eslint.vuejs.org/user-guide/#usage // https://eslint.vuejs.org/user-guide/#usage
"plugin:vue/vue3-recommended", 'plugin:vue/vue3-recommended',
"./.eslintrc-auto-import.json", './.eslintrc-auto-import.json',
"prettier", 'prettier',
"plugin:@typescript-eslint/recommended", 'plugin:@typescript-eslint/recommended',
"plugin:prettier/recommended", 'plugin:prettier/recommended',
], ],
parserOptions: { parserOptions: {
ecmaVersion: "latest", ecmaVersion: 'latest',
sourceType: "module", sourceType: 'module',
parser: "@typescript-eslint/parser", parser: '@typescript-eslint/parser',
project: "./tsconfig.*?.json", project: './tsconfig.*?.json',
createDefaultProgram: false, createDefaultProgram: false,
extraFileExtensions: [".vue"], extraFileExtensions: ['.vue'],
}, },
plugins: ["vue", "@typescript-eslint"], plugins: ['vue', '@typescript-eslint'],
rules: { rules: {
// 禁止使用 var用 let 和 const 代替 // 禁止使用 var用 let 和 const 代替
"no-var": "error", 'no-var': 'error',
// 在 Vue 的 v-for 循环中要求使用 :key // 在 Vue 的 v-for 循环中要求使用 :key
"vue/require-v-for-key": "error", // vue的for循环是否必须有key 'vue/require-v-for-key': 'error', // vue的for循环是否必须有key
// 关闭 Vue 组件名必须多字的规则 // 关闭 Vue 组件名必须多字的规则
"vue/multi-word-component-names": "off", 'vue/multi-word-component-names': 'off',
// 关闭 Vue 的 v-model 中的参数规则 // 关闭 Vue 的 v-model 中的参数规则
"vue/no-v-model-argument": "off", 'vue/no-v-model-argument': 'off',
// Vue 的 setup() 函数必须使用的变量规则 // Vue 的 setup() 函数必须使用的变量规则
"vue/script-setup-uses-vars": "error", 'vue/script-setup-uses-vars': 'error',
// 关闭 Vue 组件名的保留规则 // 关闭 Vue 组件名的保留规则
"vue/no-reserved-component-names": "off", 'vue/no-reserved-component-names': 'off',
// 关闭 Vue 事件名的命名规则 // 关闭 Vue 事件名的命名规则
"vue/custom-event-name-casing": "off", 'vue/custom-event-name-casing': 'off',
// 关闭 Vue 属性的顺序规则 // 关闭 Vue 属性的顺序规则
"vue/attributes-order": "off", 'vue/attributes-order': 'off',
// 关闭一个文件只能有一个组件规则 // 关闭一个文件只能有一个组件规则
"vue/one-component-per-file": "off", 'vue/one-component-per-file': 'off',
// 关闭 HTML 标签闭合换行规则 // 关闭 HTML 标签闭合换行规则
"vue/html-closing-bracket-newline": "off", 'vue/html-closing-bracket-newline': 'off',
// 关闭 HTML 属性每行最大数量规则 // 关闭 HTML 属性每行最大数量规则
"vue/max-attributes-per-line": "off", 'vue/max-attributes-per-line': 'off',
// 关闭多行 HTML 元素内容的规则 // 关闭多行 HTML 元素内容的规则
"vue/multiline-html-element-content-newline": "off", 'vue/multiline-html-element-content-newline': 'off',
// 关闭单行 HTML 元素内容的规则 // 关闭单行 HTML 元素内容的规则
"vue/singleline-html-element-content-newline": "off", 'vue/singleline-html-element-content-newline': 'off',
// 关闭 HTML 属性连字符的规则 // 关闭 HTML 属性连字符的规则
"vue/attribute-hyphenation": "off", 'vue/attribute-hyphenation': 'off',
// 关闭要求 Vue 默认属性的规则 // 关闭要求 Vue 默认属性的规则
"vue/require-default-prop": "off", 'vue/require-default-prop': 'off',
// 关闭要求 Vue 显式触发事件的规则 // 关闭要求 Vue 显式触发事件的规则
"vue/require-explicit-emits": "off", 'vue/require-explicit-emits': 'off',
// HTML 标签自闭合规则 // HTML 标签自闭合规则
"vue/html-self-closing": [ 'vue/html-self-closing': [
"error", 'error',
{ {
html: { html: {
void: "always", // 自闭合标签必须自闭合 void: 'always', // 自闭合标签必须自闭合
normal: "never", // 普通标签不得自闭合 normal: 'never', // 普通标签不得自闭合
component: "always", // 组件标签必须自闭合 component: 'always', // 组件标签必须自闭合
}, },
svg: "always", svg: 'always',
math: "always", math: 'always',
}, },
], ],
// 警告空方法检查 // 警告空方法检查
"@typescript-eslint/no-empty-function": "warn", '@typescript-eslint/no-empty-function': 'warn',
// 关闭 any 类型的警告 // 关闭 any 类型的警告
"@typescript-eslint/no-explicit-any": "off", '@typescript-eslint/no-explicit-any': 'off',
// 关闭使用 @ts-ignore 的警告 // 关闭使用 @ts-ignore 的警告
"@typescript-eslint/ban-ts-ignore": "off", '@typescript-eslint/ban-ts-ignore': 'off',
// 关闭使用 @ts-comment 的警告 // 关闭使用 @ts-comment 的警告
"@typescript-eslint/ban-ts-comment": "off", '@typescript-eslint/ban-ts-comment': 'off',
// 关闭一些特定类型的警告 // 关闭一些特定类型的警告
"@typescript-eslint/ban-types": "off", '@typescript-eslint/ban-types': 'off',
// 关闭函数返回类型的警告 // 关闭函数返回类型的警告
"@typescript-eslint/explicit-function-return-type": "off", '@typescript-eslint/explicit-function-return-type': 'off',
// 关闭 any 类型的警告 // 关闭 any 类型的警告
"@typescript-eslint/no-explicit-any": "off", '@typescript-eslint/no-explicit-any': 'off',
// 关闭使用 require 的警告 // 关闭使用 require 的警告
"@typescript-eslint/no-var-requires": "off", '@typescript-eslint/no-var-requires': 'off',
// 关闭使用尚未定义的变量的警告 // 关闭使用尚未定义的变量的警告
"@typescript-eslint/no-use-before-define": "off", '@typescript-eslint/no-use-before-define': 'off',
// 关闭模块导出类型的警告 // 关闭模块导出类型的警告
"@typescript-eslint/explicit-module-boundary-types": "off", '@typescript-eslint/explicit-module-boundary-types': 'off',
// 未使用的变量的警告 // 未使用的变量的警告
"@typescript-eslint/no-unused-vars": "warn", '@typescript-eslint/no-unused-vars': 'warn',
// Prettier 配置 // Prettier 配置
"prettier/prettier": [ 'prettier/prettier': [
"error", 'error',
{ {
useTabs: false, // 不使用制表符 useTabs: false, // 不使用制表符
}, },
@ -130,12 +130,12 @@ module.exports = {
// eslint不能对html文件生效 // eslint不能对html文件生效
overrides: [ overrides: [
{ {
files: ["*.html"], files: ['*.html'],
processor: "vue/.vue", processor: 'vue/.vue',
}, },
], ],
// https://eslint.org/docs/latest/use/configure/language-options#specifying-globals // https://eslint.org/docs/latest/use/configure/language-options#specifying-globals
globals: { globals: {
OptionType: "readonly", OptionType: 'readonly',
}, },
}; };

View File

@ -24,7 +24,7 @@ module.exports = {
// 结尾添加分号 // 结尾添加分号
semi: true, semi: true,
// 使用单引号 (true:单引号;false:双引号) // 使用单引号 (true:单引号;false:双引号)
singleQuote: false, singleQuote: true,
// 缩进空格数默认2个空格 // 缩进空格数默认2个空格
tabWidth: 2, tabWidth: 2,
// 元素末尾是否加逗号默认es5: ES5中的 objects, arrays 等会添加逗号TypeScript 中的 type 后不加逗号 // 元素末尾是否加逗号默认es5: ES5中的 objects, arrays 等会添加逗号TypeScript 中的 type 后不加逗号

View File

@ -1,45 +1,45 @@
module.exports = { module.exports = {
// 继承的规则 // 继承的规则
extends: ["@commitlint/config-conventional"], extends: ['@commitlint/config-conventional'],
// 自定义规则 // 自定义规则
rules: { rules: {
// @see https://commitlint.js.org/#/reference-rules // @see https://commitlint.js.org/#/reference-rules
// 提交类型枚举git提交type必须是以下类型 // 提交类型枚举git提交type必须是以下类型
"type-enum": [ 'type-enum': [
2, 2,
"always", 'always',
[ [
"feat", // 新增功能 'feat', // 新增功能
"fix", // 修复缺陷 'fix', // 修复缺陷
"docs", // 文档变更 'docs', // 文档变更
"style", // 代码格式(不影响功能,例如空格、分号等格式修正) 'style', // 代码格式(不影响功能,例如空格、分号等格式修正)
"refactor", // 代码重构(不包括 bug 修复、功能新增) 'refactor', // 代码重构(不包括 bug 修复、功能新增)
"perf", // 性能优化 'perf', // 性能优化
"test", // 添加疏漏测试或已有测试改动 'test', // 添加疏漏测试或已有测试改动
"build", // 构建流程、外部依赖变更(如升级 npm 包、修改 webpack 配置等) 'build', // 构建流程、外部依赖变更(如升级 npm 包、修改 webpack 配置等)
"ci", // 修改 CI 配置、脚本 'ci', // 修改 CI 配置、脚本
"revert", // 回滚 commit 'revert', // 回滚 commit
"chore", // 对构建过程或辅助工具和库的更改(不影响源文件、测试用例) 'chore', // 对构建过程或辅助工具和库的更改(不影响源文件、测试用例)
], ],
], ],
"subject-case": [0], // subject大小写不做校验 'subject-case': [0], // subject大小写不做校验
}, },
prompt: { prompt: {
messages: { messages: {
type: "选择你要提交的类型 :", type: '选择你要提交的类型 :',
scope: "选择一个提交范围(可选):", scope: '选择一个提交范围(可选):',
customScope: "请输入自定义的提交范围 :", customScope: '请输入自定义的提交范围 :',
subject: "填写简短精炼的变更描述 :\n", subject: '填写简短精炼的变更描述 :\n',
body: '填写更加详细的变更描述(可选)。使用 "|" 换行 :\n', body: '填写更加详细的变更描述(可选)。使用 "|" 换行 :\n',
breaking: '列举非兼容性重大的变更(可选)。使用 "|" 换行 :\n', breaking: '列举非兼容性重大的变更(可选)。使用 "|" 换行 :\n',
footerPrefixesSelect: "选择关联issue前缀可选:", footerPrefixesSelect: '选择关联issue前缀可选:',
customFooterPrefix: "输入自定义issue前缀 :", customFooterPrefix: '输入自定义issue前缀 :',
footer: "列举关联issue (可选) 例如: #31, #I3244 :\n", footer: '列举关联issue (可选) 例如: #31, #I3244 :\n',
generatingByAI: "正在通过 AI 生成你的提交简短描述...", generatingByAI: '正在通过 AI 生成你的提交简短描述...',
generatedSelectByAI: "选择一个 AI 生成的简短描述:", generatedSelectByAI: '选择一个 AI 生成的简短描述:',
confirmCommit: "是否提交或修改commit ?", confirmCommit: '是否提交或修改commit ?',
}, },
// prettier-ignore // prettier-ignore
types: [ types: [
@ -56,28 +56,28 @@ module.exports = {
{ value: "chore", name: "其他: 🛠️ 对构建过程或辅助工具和库的更改(不影响源文件、测试用例)", emoji: ":hammer:"}, { value: "chore", name: "其他: 🛠️ 对构建过程或辅助工具和库的更改(不影响源文件、测试用例)", emoji: ":hammer:"},
], ],
useEmoji: true, useEmoji: true,
emojiAlign: "center", emojiAlign: 'center',
useAI: false, useAI: false,
aiNumber: 1, aiNumber: 1,
themeColorCode: "", themeColorCode: '',
scopes: [], scopes: [],
allowCustomScopes: true, allowCustomScopes: true,
allowEmptyScopes: true, allowEmptyScopes: true,
customScopesAlign: "bottom", customScopesAlign: 'bottom',
customScopesAlias: "custom", customScopesAlias: 'custom',
emptyScopesAlias: "empty", emptyScopesAlias: 'empty',
upperCaseSubject: false, upperCaseSubject: false,
markBreakingChangeMode: false, markBreakingChangeMode: false,
allowBreakingChanges: ["feat", "fix"], allowBreakingChanges: ['feat', 'fix'],
breaklineNumber: 100, breaklineNumber: 100,
breaklineChar: "|", breaklineChar: '|',
skipQuestions: [], skipQuestions: [],
issuePrefixes: [ issuePrefixes: [
{ value: "closed", name: "closed: ISSUES has been processed" }, { value: 'closed', name: 'closed: ISSUES has been processed' },
], ],
customIssuePrefixAlign: "top", customIssuePrefixAlign: 'top',
emptyIssuePrefixAlias: "skip", emptyIssuePrefixAlias: 'skip',
customIssuePrefixAlias: "custom", customIssuePrefixAlias: 'custom',
allowCustomIssuePrefix: true, allowCustomIssuePrefix: true,
allowEmptyIssuePrefix: true, allowEmptyIssuePrefix: true,
confirmColorize: true, confirmColorize: true,
@ -85,9 +85,9 @@ module.exports = {
maxSubjectLength: Infinity, maxSubjectLength: Infinity,
minSubjectLength: 0, minSubjectLength: 0,
scopeOverrides: undefined, scopeOverrides: undefined,
defaultBody: "", defaultBody: '',
defaultIssues: "", defaultIssues: '',
defaultScope: "", defaultScope: '',
defaultSubject: "", defaultSubject: '',
}, },
}; };

View File

@ -95,7 +95,7 @@
"stylelint-config-recommended-vue": "^1.5.0", "stylelint-config-recommended-vue": "^1.5.0",
"stylelint-config-standard": "^34.0.0", "stylelint-config-standard": "^34.0.0",
"stylelint-config-standard-scss": "^11.1.0", "stylelint-config-standard-scss": "^11.1.0",
"tailwindcss": "^3.3.3", "tailwindcss": "^3.4.1",
"typescript": "^5.3.2", "typescript": "^5.3.2",
"unplugin-auto-import": "^0.15.3", "unplugin-auto-import": "^0.15.3",
"unplugin-icons": "^0.16.6", "unplugin-icons": "^0.16.6",
@ -107,4 +107,4 @@
"engines": { "engines": {
"node": ">=16.0.0" "node": ">=16.0.0"
} }
} }

View File

@ -17,14 +17,14 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { computed, onMounted, onUnmounted } from "vue"; import { computed, onMounted, onUnmounted } from 'vue';
import { zhCN, dateZhCN, darkTheme } from "naive-ui"; import { zhCN, dateZhCN, darkTheme } from 'naive-ui';
import { LockScreen } from "@/components/Lockscreen"; import { LockScreen } from '@/components/Lockscreen';
import { AppProvider } from "@/components/Application"; import { AppProvider } from '@/components/Application';
import { useScreenLockStore } from "@/store/modules/screenLock.js"; import { useScreenLockStore } from '@/store/modules/screenLock.js';
import { useRoute } from "vue-router"; import { useRoute } from 'vue-router';
import { useDesignSettingStore } from "@/store/modules/designSetting"; import { useDesignSettingStore } from '@/store/modules/designSetting';
import { lighten } from "@/utils"; import { lighten } from '@/utils';
const route = useRoute(); const route = useRoute();
const useScreenLock = useScreenLockStore(); const useScreenLock = useScreenLockStore();
@ -59,7 +59,7 @@ let timer: any;
const timekeeping = () => { const timekeeping = () => {
clearInterval(timer); clearInterval(timer);
if (route.name == "login" || isLock.value) return; if (route.name == 'login' || isLock.value) return;
// //
useScreenLock.setLock(false); useScreenLock.setLock(false);
// //
@ -76,14 +76,14 @@ const timekeeping = () => {
}; };
onMounted(() => { onMounted(() => {
document.addEventListener("mousedown", timekeeping); document.addEventListener('mousedown', timekeeping);
}); });
onUnmounted(() => { onUnmounted(() => {
document.removeEventListener("mousedown", timekeeping); document.removeEventListener('mousedown', timekeeping);
}); });
</script> </script>
<style lang="scss"> <style lang="scss">
@import "styles/index"; @import 'styles/index';
</style> </style>

View File

@ -347,9 +347,9 @@ export default defineComponent({
} }
if (props.record) { if (props.record) {
initCbs("submitCbs", handleSubmit); initCbs('submitCbs', handleSubmit);
initCbs("validCbs", handleSubmiRule); initCbs('validCbs', handleSubmiRule);
initCbs("cancelCbs", handleCancel); initCbs('cancelCbs', handleCancel);
if (props.column.key) { if (props.column.key) {
if (!props.record.editValueRefs) props.record.editValueRefs = {}; if (!props.record.editValueRefs) props.record.editValueRefs = {};
@ -372,7 +372,7 @@ export default defineComponent({
if (!pass) return; if (!pass) return;
const submitFns = props.record?.submitCbs || []; const submitFns = props.record?.submitCbs || [];
submitFns.forEach((fn) => fn(false, false)); submitFns.forEach((fn) => fn(false, false));
table.emit?.("edit-row-end"); table.emit?.('edit-row-end');
return true; return true;
} }
}; };

View File

@ -1,6 +1,6 @@
:root { :root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, YouSheBiaoTiHei, font-family: Inter, system-ui, Avenir, Helvetica, Arial, YouSheBiaoTiHei,
"sans-serif "; 'sans-serif ';
font-weight: 400; font-weight: 400;
line-height: 1.5; line-height: 1.5;
color: rgb(255 255 255 / 87%); color: rgb(255 255 255 / 87%);

View File

@ -1 +1 @@
@import 'transition/index'; @import 'transition/index';

View File

@ -1,3 +1,3 @@
@tailwind base; @tailwind base;
@tailwind components; @tailwind components;
@tailwind utilities; @tailwind utilities;

View File

@ -15,4 +15,4 @@
.expand-x-transition { .expand-x-transition {
@include transition-default; @include transition-default;
} }

View File

@ -78,4 +78,4 @@
.fade-top-leave-to { .fade-top-leave-to {
opacity: 0; opacity: 0;
transform: translateY(-8%); transform: translateY(-8%);
} }

View File

@ -6,5 +6,6 @@
@import './zoom'; @import './zoom';
.collapse-transition { .collapse-transition {
transition: 0.2s height ease-in-out, 0.2s padding-top ease-in-out, 0.2s padding-bottom ease-in-out; transition: 0.2s height ease-in-out, 0.2s padding-top ease-in-out,
} 0.2s padding-bottom ease-in-out;
}

View File

@ -18,4 +18,4 @@
opacity: 0; opacity: 0;
transform: scale(0) rotate(-45deg); transform: scale(0) rotate(-45deg);
} }
} }

View File

@ -64,4 +64,4 @@
&-leave-to { &-leave-to {
transform: translateX(-15px); transform: translateX(-15px);
} }
} }

View File

@ -36,4 +36,4 @@
opacity: 0; opacity: 0;
transform: translateX(15px); transform: translateX(15px);
} }
} }

View File

@ -24,4 +24,4 @@
.zoom-fade-leave-to { .zoom-fade-leave-to {
opacity: 0; opacity: 0;
transform: scale(1.06); transform: scale(1.06);
} }

View File

@ -1,10 +1,10 @@
<script lang="tsx"> <script lang="tsx">
import { defineComponent, onBeforeMount } from "vue"; import { defineComponent, onBeforeMount } from 'vue';
import { useRoute, useRouter } from "vue-router"; import { useRoute, useRouter } from 'vue-router';
import { NEmpty } from "naive-ui"; import { NEmpty } from 'naive-ui';
export default defineComponent({ export default defineComponent({
name: "Redirect", name: 'Redirect',
setup() { setup() {
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
@ -12,7 +12,7 @@ export default defineComponent({
const { params, query } = route; const { params, query } = route;
const { path } = params; const { path } = params;
router.replace({ router.replace({
path: "/" + (Array.isArray(path) ? path.join("/") : path), path: '/' + (Array.isArray(path) ? path.join('/') : path),
query, query,
}); });
}); });

View File

@ -1,58 +1,58 @@
module.exports = { module.exports = {
// 继承推荐规范配置 // 继承推荐规范配置
extends: [ extends: [
"stylelint-config-standard", 'stylelint-config-standard',
"stylelint-config-recommended-scss", 'stylelint-config-recommended-scss',
"stylelint-config-recommended-vue/scss", 'stylelint-config-recommended-vue/scss',
"stylelint-config-html/vue", 'stylelint-config-html/vue',
"stylelint-config-recess-order", 'stylelint-config-recess-order',
], ],
// 指定不同文件对应的解析器 // 指定不同文件对应的解析器
overrides: [ overrides: [
{ {
files: ["**/*.{vue,html}"], files: ['**/*.{vue,html}'],
customSyntax: "postcss-html", customSyntax: 'postcss-html',
}, },
{ {
files: ["**/*.{css,scss}"], files: ['**/*.{css,scss}'],
customSyntax: "postcss-scss", customSyntax: 'postcss-scss',
}, },
], ],
// 自定义规则 // 自定义规则
rules: { rules: {
"import-notation": "string", // 指定导入CSS文件的方式("string"|"url") 'import-notation': 'string', // 指定导入CSS文件的方式("string"|"url")
"selector-class-pattern": null, // 选择器类名命名规则 'selector-class-pattern': null, // 选择器类名命名规则
"custom-property-pattern": null, // 自定义属性命名规则 'custom-property-pattern': null, // 自定义属性命名规则
"keyframes-name-pattern": null, // 动画帧节点样式命名规则 'keyframes-name-pattern': null, // 动画帧节点样式命名规则
"no-descending-specificity": null, // 允许无降序特异性 'no-descending-specificity': null, // 允许无降序特异性
// 允许 global 、export 、deep伪类 // 允许 global 、export 、deep伪类
"selector-pseudo-class-no-unknown": [ 'selector-pseudo-class-no-unknown': [
true, true,
{ {
ignorePseudoClasses: ["global", "export", "deep"], ignorePseudoClasses: ['global', 'export', 'deep'],
}, },
], ],
// 允许未知属性 // 允许未知属性
"property-no-unknown": [ 'property-no-unknown': [
true, true,
{ {
// ignoreProperties: ["menuBg", "menuText", "menuActiveText"], // ignoreProperties: ["menuBg", "menuText", "menuActiveText"],
}, },
], ],
"at-rule-no-unknown": [ 'at-rule-no-unknown': [
true, true,
{ {
ignoreAtRules: [ ignoreAtRules: [
"tailwind", 'tailwind',
"apply", 'apply',
"variants", 'variants',
"responsive", 'responsive',
"screen", 'screen',
"function", 'function',
"if", 'if',
"each", 'each',
"include", 'include',
"mixin", 'mixin',
], ],
}, },
], ],

View File

@ -1,5 +1,5 @@
module.exports = { module.exports = {
content: ["./index.html", "./src/**/*.{vue,ts,tsx}"], content: ['./index.html', './src/**/*.{vue,ts,tsx}'],
important: true, important: true,
theme: { theme: {
extend: {}, extend: {},

4
types/env.d.ts vendored
View File

@ -1,7 +1,7 @@
/// <reference types="vite/client" /> /// <reference types="vite/client" />
declare module "*.vue" { declare module '*.vue' {
import { DefineComponent } from "vue"; import { DefineComponent } from 'vue';
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
const component: DefineComponent<{}, {}, any>; const component: DefineComponent<{}, {}, any>;
export default component; export default component;

4
types/router.d.ts vendored
View File

@ -1,6 +1,6 @@
import "vue-router"; import 'vue-router';
declare module "vue-router" { declare module 'vue-router' {
// https://router.vuejs.org/zh/guide/advanced/meta.html#typescript // https://router.vuejs.org/zh/guide/advanced/meta.html#typescript
// 可以通过扩展 RouteMeta 接口来输入 meta 字段 // 可以通过扩展 RouteMeta 接口来输入 meta 字段
interface RouteMeta { interface RouteMeta {

View File

@ -1 +1 @@
declare module "xlsx/xlsx.mjs"; declare module 'xlsx/xlsx.mjs';

View File

@ -1,25 +1,25 @@
import vue from "@vitejs/plugin-vue"; import vue from '@vitejs/plugin-vue';
import { UserConfig, ConfigEnv, loadEnv, defineConfig } from "vite"; import { UserConfig, ConfigEnv, loadEnv, defineConfig } from 'vite';
import AutoImport from "unplugin-auto-import/vite"; import AutoImport from 'unplugin-auto-import/vite';
import Components from "unplugin-vue-components/vite"; import Components from 'unplugin-vue-components/vite';
import Icons from "unplugin-icons/vite"; import Icons from 'unplugin-icons/vite';
import { createSvgIconsPlugin } from "vite-plugin-svg-icons"; import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
import vueJsx from "@vitejs/plugin-vue-jsx"; import vueJsx from '@vitejs/plugin-vue-jsx';
import { resolve } from "path"; import { resolve } from 'path';
const pathSrc = resolve(__dirname, "src"); const pathSrc = resolve(__dirname, 'src');
// https://cn.vitejs.dev/config // https://cn.vitejs.dev/config
export default defineConfig(({ mode }: ConfigEnv): UserConfig => { export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
const env = loadEnv(mode, process.cwd()); const env = loadEnv(mode, process.cwd());
return { return {
resolve: { resolve: {
alias: { alias: {
"@": pathSrc, '@': pathSrc,
}, },
}, },
css: { css: {
@ -36,7 +36,7 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
}, },
server: { server: {
// 允许IP访问 // 允许IP访问
host: "0.0.0.0", host: '0.0.0.0',
// 应用端口 (默认:3000) // 应用端口 (默认:3000)
port: Number(env.VITE_APP_PORT), port: Number(env.VITE_APP_PORT),
// 运行是否自动打开浏览器 // 运行是否自动打开浏览器
@ -53,7 +53,7 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
changeOrigin: true, changeOrigin: true,
target: env.VITE_APP_API_URL, target: env.VITE_APP_API_URL,
rewrite: (path) => rewrite: (path) =>
path.replace(new RegExp("^" + env.VITE_APP_BASE_API), ""), path.replace(new RegExp('^' + env.VITE_APP_BASE_API), ''),
}, },
}, },
}, },
@ -64,24 +64,24 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
// 自动导入参考: https://github.com/sxzz/element-plus-best-practices/blob/main/vite.config.ts // 自动导入参考: https://github.com/sxzz/element-plus-best-practices/blob/main/vite.config.ts
AutoImport({ AutoImport({
// 自动导入 Vue 相关函数ref, reactive, toRef 等 // 自动导入 Vue 相关函数ref, reactive, toRef 等
imports: ["vue", "@vueuse/core"], imports: ['vue', '@vueuse/core'],
eslintrc: { eslintrc: {
enabled: false, enabled: false,
filepath: "./.eslintrc-auto-import.json", filepath: './.eslintrc-auto-import.json',
globalsPropValue: true, globalsPropValue: true,
}, },
vueTemplate: true, vueTemplate: true,
// 配置文件生成位置(false:关闭自动生成) // 配置文件生成位置(false:关闭自动生成)
dts: "types/auto-imports.d.ts", dts: 'types/auto-imports.d.ts',
}), }),
Components({ Components({
resolvers: [], resolvers: [],
// 指定自定义组件位置(默认:src/components) // 指定自定义组件位置(默认:src/components)
dirs: ["src/components", "src/**/components"], dirs: ['src/components', 'src/**/components'],
// 配置文件位置 (false:关闭自动生成) // 配置文件位置 (false:关闭自动生成)
dts: "types/components.d.ts", dts: 'types/components.d.ts',
}), }),
Icons({ Icons({
@ -89,27 +89,27 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
}), }),
createSvgIconsPlugin({ createSvgIconsPlugin({
// 指定需要缓存的图标文件夹 // 指定需要缓存的图标文件夹
iconDirs: [resolve(pathSrc, "assets/svgs")], iconDirs: [resolve(pathSrc, 'assets/svgs')],
// 指定symbolId格式 // 指定symbolId格式
symbolId: "icon-[dir]-[name]", symbolId: 'icon-[dir]-[name]',
}), }),
], ],
// 预加载项目必需的组件 // 预加载项目必需的组件
optimizeDeps: { optimizeDeps: {
include: [ include: [
"vue", 'vue',
"vue-router", 'vue-router',
"pinia", 'pinia',
"axios", 'axios',
"@vueuse/core", '@vueuse/core',
"path-to-regexp", 'path-to-regexp',
"echarts", 'echarts',
], ],
}, },
// 构建配置 // 构建配置
build: { build: {
chunkSizeWarningLimit: 2000, // 消除打包大小超过500kb警告 chunkSizeWarningLimit: 2000, // 消除打包大小超过500kb警告
minify: "terser", // Vite 2.6.x 以上需要配置 minify: "terser", terserOptions 才能生效 minify: 'terser', // Vite 2.6.x 以上需要配置 minify: "terser", terserOptions 才能生效
terserOptions: { terserOptions: {
compress: { compress: {
keep_infinity: true, // 防止 Infinity 被压缩成 1/0这可能会导致 Chrome 上的性能问题 keep_infinity: true, // 防止 Infinity 被压缩成 1/0这可能会导致 Chrome 上的性能问题