diff --git a/.eslintrc.cjs b/.eslintrc.cjs index bdbae1d..571f0a1 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -7,7 +7,7 @@ module.exports = { 'plugin:react/jsx-runtime', 'plugin:react-hooks/recommended', ], - ignorePatterns: ['dist', '.eslintrc.cjs'], + ignorePatterns: ['node_modules/*', 'dist', '.eslintrc.cjs'], parserOptions: { ecmaVersion: 'latest', sourceType: 'module' }, settings: { react: { version: '18.2' } }, plugins: ['react-refresh'], diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..dda75ab --- /dev/null +++ b/.prettierrc @@ -0,0 +1,8 @@ +{ + "singleQuote": true, + "trailingComma": "all", + "printWidth": 80, + "tabWidth": 2, + "useTabs": false, + "semi": false +} \ No newline at end of file diff --git a/src/stores/AuthStore.js b/src/stores/AuthStore.js index 4c903f4..9888c29 100644 --- a/src/stores/AuthStore.js +++ b/src/stores/AuthStore.js @@ -1,12 +1,11 @@ import { create } from 'zustand' import { fetchJSON } from '@/utils/request' -import { isEmpty, isNotEmpty, } from '@/utils/commons' +import { isEmpty, isNotEmpty } from '@/utils/commons' export const PERM_MERGE_CONVERSATION = 'merge-conversation' export const PERM_ASSIGN_NEW_CONVERSATION = 'assign-new-conversation' const useAuthStore = create((set, get) => ({ - loginUser: { userId: -1, userIdStr: '-1', @@ -42,24 +41,27 @@ const useAuthStore = create((set, get) => ({ // } // return false; // }); - }, login: async (authCode) => { - const { saveUserSession, setLoginStatus } = get() setLoginStatus(200) - const json = await fetchJSON(`https://p9axztuwd7x8a7.mycht.cn/dingtalk/dingtalkwork/WhatsAppAuth`, { authCode }) + const json = await fetchJSON( + `https://p9axztuwd7x8a7.mycht.cn/dingtalk/dingtalkwork/WhatsAppAuth`, + { authCode }, + ) if (json.errcode === 0 && isNotEmpty(json.result.opisn)) { set(() => ({ loginUser: { userId: json.result.opisn, - userIdStr: json.result?.accountlist.map(acc => { - return acc.OPI_SN - }).join(','), + userIdStr: json.result?.accountlist + .map((acc) => { + return acc.OPI_SN + }) + .join(','), accountName: json.result.opicode, username: json.result.nick, avatarUrl: json.result.avatarUrl, @@ -67,7 +69,7 @@ const useAuthStore = create((set, get) => ({ email: json.result.email, openId: json.result.openId, accountList: json.result.accountlist, - } + }, })) saveUserSession() setLoginStatus(302) @@ -78,7 +80,7 @@ const useAuthStore = create((set, get) => ({ setLoginStatus: (code) => { set(() => ({ - loginStatus: code + loginStatus: code, })) }, @@ -96,9 +98,8 @@ const useAuthStore = create((set, get) => ({ openId: '', accountList: [], permissionList: [], - } + }, })) - }, loadUserSession: () => { @@ -109,16 +110,19 @@ const useAuthStore = create((set, get) => ({ } if (sessionData !== null) { - const sesstionObj = JSON.parse(sessionData); + const sesstionObj = JSON.parse(sessionData) set(() => ({ loginUser: sesstionObj, - })); + })) } }, saveUserSession: () => { const { loginUser } = get() - window.sessionStorage.setItem('GLOBAL_SALES_LOGIN_USER', JSON.stringify(loginUser)) + window.sessionStorage.setItem( + 'GLOBAL_SALES_LOGIN_USER', + JSON.stringify(loginUser), + ) }, copyUserSession: () => { @@ -126,8 +130,7 @@ const useAuthStore = create((set, get) => ({ if (sessionData !== null) { navigator.clipboard.writeText(sessionData) } - } - + }, })) export default useAuthStore diff --git a/src/views/accounts/Profile.jsx b/src/views/accounts/Profile.jsx index dd00f4d..98c3b80 100644 --- a/src/views/accounts/Profile.jsx +++ b/src/views/accounts/Profile.jsx @@ -13,18 +13,18 @@ function Profile() { useEffect(() => { // 测试错误捕获: - // throw new Error('💥 CABOOM 💥') + // throw new Error('💥 CABOOM 💥') }, []) - - return ( - + + return ( + } onClick={() => { message.success('复制成功,请粘贴给开发人员,谢谢😀') copyUserSession() }} /> - {loginUser.username.substring(1)}{loginUser.username}​ + {loginUser.username.substring(1)}{loginUser.username} {loginUser.accountList?.map(a => { return ( } bordered={false}>{a.OPI_Code}