perf: EsLint & Auto format

This commit is contained in:
fit2cloud-chenyw
2025-06-11 17:28:22 +08:00
parent 2512276152
commit 26455cd5c6
6 changed files with 79 additions and 13 deletions
+13
View File
@@ -0,0 +1,13 @@
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
insert_final_newline = false
trim_trailing_whitespace = false
+8
View File
@@ -0,0 +1,8 @@
/node_modules/
/dist/
/public/
*.md
*.woff
*.ttf
.vscode/
.DS_Store
+33
View File
@@ -0,0 +1,33 @@
module.exports = {
root: true,
env: {
node: true,
},
extends: [
'plugin:vue/vue3-recommended',
'eslint:recommended',
'@vue/typescript/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
parserOptions: {
ecmaVersion: 2020,
},
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'vue/multi-word-component-names': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'prettier/prettier': [
'warn',
{
singleQuote: true,
semi: false,
trailingComma: 'es5',
printWidth: 100,
tabWidth: 2,
endOfLine: 'auto',
},
],
},
}
+8
View File
@@ -0,0 +1,8 @@
{
"singleQuote": true,
"semi": false,
"trailingComma": "es5",
"printWidth": 100,
"tabWidth": 2,
"endOfLine": "auto"
}
+7
View File
@@ -31,12 +31,19 @@
"@types/crypto-js": "^4.2.2",
"@types/element-resize-detector": "^1.1.6",
"@types/node": "^22.14.1",
"@typescript-eslint/eslint-plugin": "^8.34.0",
"@typescript-eslint/parser": "^8.34.0",
"@vitejs/plugin-vue": "^5.2.2",
"@vue/tsconfig": "^0.7.0",
"axios": "^1.8.4",
"crypto-js": "^4.2.0",
"eslint": "^9.28.0",
"eslint-config-prettier": "^10.1.5",
"eslint-plugin-prettier": "^5.4.1",
"eslint-plugin-vue": "^10.2.0",
"less": "^4.3.0",
"pinia": "^3.0.2",
"prettier": "^3.5.3",
"typescript": "~5.7.2",
"unplugin-auto-import": "^19.1.2",
"unplugin-vue-components-secondary": "^0.24.6",
+10 -13
View File
@@ -7,8 +7,6 @@ import { store } from './index'
const { wsCache } = useCache()
interface UserState {
token: string
uid: string
@@ -17,7 +15,7 @@ interface UserState {
language: string
exp: number
time: number
[key: string]: string | number
[key: string]: string | number
}
export const UserStore = defineStore('user', {
@@ -29,7 +27,7 @@ export const UserStore = defineStore('user', {
oid: '',
language: 'zh-CN',
exp: 0,
time: 0
time: 0,
}
},
getters: {
@@ -53,10 +51,9 @@ export const UserStore = defineStore('user', {
},
getTime(): number {
return this.time
}
},
},
actions: {
async login(formData: { username: string; password: string }) {
const res: any = await AuthApi.login(formData)
this.setToken(res.access_token)
@@ -66,13 +63,13 @@ export const UserStore = defineStore('user', {
this.clear()
},
async info () {
async info() {
const res: any = await AuthApi.info()
const res_data = res || {}
const keys = ['uid', 'name', 'oid', 'language', 'exp', 'time'] as const
keys.forEach(key => {
keys.forEach((key) => {
const dkey = key === 'uid' ? 'id' : key
const value = res_data[dkey]
if (key === 'exp' || key === 'time') {
@@ -122,11 +119,11 @@ export const UserStore = defineStore('user', {
},
clear() {
const keys: string[] = ['token', 'uid', 'name', 'oid', 'language', 'exp', 'time']
keys.forEach(key => wsCache.delete('user.' + key))
}
}
keys.forEach((key) => wsCache.delete('user.' + key))
},
},
})
export const useUserStore = () => {
return UserStore(store)
}
}