Skip to content

Commit 26455cd

Browse files
perf: EsLint & Auto format
1 parent 2512276 commit 26455cd

File tree

6 files changed

+79
-13
lines changed

6 files changed

+79
-13
lines changed

frontend/.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
insert_final_newline = false
13+
trim_trailing_whitespace = false

frontend/.eslintignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/node_modules/
2+
/dist/
3+
/public/
4+
*.md
5+
*.woff
6+
*.ttf
7+
.vscode/
8+
.DS_Store

frontend/.eslintrc.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
node: true,
5+
},
6+
extends: [
7+
'plugin:vue/vue3-recommended',
8+
'eslint:recommended',
9+
'@vue/typescript/recommended',
10+
'plugin:@typescript-eslint/recommended',
11+
'plugin:prettier/recommended',
12+
],
13+
parserOptions: {
14+
ecmaVersion: 2020,
15+
},
16+
rules: {
17+
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
18+
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
19+
'vue/multi-word-component-names': 'off',
20+
'@typescript-eslint/no-explicit-any': 'off',
21+
'prettier/prettier': [
22+
'warn',
23+
{
24+
singleQuote: true,
25+
semi: false,
26+
trailingComma: 'es5',
27+
printWidth: 100,
28+
tabWidth: 2,
29+
endOfLine: 'auto',
30+
},
31+
],
32+
},
33+
}

frontend/.prettierrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"singleQuote": true,
3+
"semi": false,
4+
"trailingComma": "es5",
5+
"printWidth": 100,
6+
"tabWidth": 2,
7+
"endOfLine": "auto"
8+
}

frontend/package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,19 @@
3131
"@types/crypto-js": "^4.2.2",
3232
"@types/element-resize-detector": "^1.1.6",
3333
"@types/node": "^22.14.1",
34+
"@typescript-eslint/eslint-plugin": "^8.34.0",
35+
"@typescript-eslint/parser": "^8.34.0",
3436
"@vitejs/plugin-vue": "^5.2.2",
3537
"@vue/tsconfig": "^0.7.0",
3638
"axios": "^1.8.4",
3739
"crypto-js": "^4.2.0",
40+
"eslint": "^9.28.0",
41+
"eslint-config-prettier": "^10.1.5",
42+
"eslint-plugin-prettier": "^5.4.1",
43+
"eslint-plugin-vue": "^10.2.0",
3844
"less": "^4.3.0",
3945
"pinia": "^3.0.2",
46+
"prettier": "^3.5.3",
4047
"typescript": "~5.7.2",
4148
"unplugin-auto-import": "^19.1.2",
4249
"unplugin-vue-components-secondary": "^0.24.6",

frontend/src/stores/user.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import { store } from './index'
77

88
const { wsCache } = useCache()
99

10-
11-
1210
interface UserState {
1311
token: string
1412
uid: string
@@ -17,7 +15,7 @@ interface UserState {
1715
language: string
1816
exp: number
1917
time: number
20-
[key: string]: string | number
18+
[key: string]: string | number
2119
}
2220

2321
export const UserStore = defineStore('user', {
@@ -29,7 +27,7 @@ export const UserStore = defineStore('user', {
2927
oid: '',
3028
language: 'zh-CN',
3129
exp: 0,
32-
time: 0
30+
time: 0,
3331
}
3432
},
3533
getters: {
@@ -53,10 +51,9 @@ export const UserStore = defineStore('user', {
5351
},
5452
getTime(): number {
5553
return this.time
56-
}
54+
},
5755
},
5856
actions: {
59-
6057
async login(formData: { username: string; password: string }) {
6158
const res: any = await AuthApi.login(formData)
6259
this.setToken(res.access_token)
@@ -66,13 +63,13 @@ export const UserStore = defineStore('user', {
6663
this.clear()
6764
},
6865

69-
async info () {
66+
async info() {
7067
const res: any = await AuthApi.info()
7168
const res_data = res || {}
7269

7370
const keys = ['uid', 'name', 'oid', 'language', 'exp', 'time'] as const
74-
75-
keys.forEach(key => {
71+
72+
keys.forEach((key) => {
7673
const dkey = key === 'uid' ? 'id' : key
7774
const value = res_data[dkey]
7875
if (key === 'exp' || key === 'time') {
@@ -122,11 +119,11 @@ export const UserStore = defineStore('user', {
122119
},
123120
clear() {
124121
const keys: string[] = ['token', 'uid', 'name', 'oid', 'language', 'exp', 'time']
125-
keys.forEach(key => wsCache.delete('user.' + key))
126-
}
127-
}
122+
keys.forEach((key) => wsCache.delete('user.' + key))
123+
},
124+
},
128125
})
129126

130127
export const useUserStore = () => {
131128
return UserStore(store)
132-
}
129+
}

0 commit comments

Comments
 (0)