From 520db7ec6e55dde0e531b4c251975f1fa9f17db7 Mon Sep 17 00:00:00 2001 From: zclzone Date: Fri, 6 Sep 2024 14:46:07 +0800 Subject: [PATCH] style: lint --- build/plugin-isme/index.js | 2 +- src/App.vue | 4 +- src/components/common/LayoutSetting.vue | 2 +- src/components/common/ThemeSetting.vue | 2 +- src/components/common/ToggleTheme.vue | 2 +- src/components/common/index.js | 2 +- src/components/me/index.js | 2 +- src/composables/index.js | 2 +- src/layouts/components/UserAvatar.vue | 4 +- src/layouts/components/index.js | 10 +-- src/layouts/components/tab/index.vue | 2 +- src/layouts/full/index.vue | 6 +- src/layouts/normal/index.vue | 4 +- src/layouts/simple/index.vue | 2 +- src/main.js | 10 +-- src/router/guards/permission-guard.js | 2 +- src/router/index.js | 2 +- src/store/helper.js | 2 +- src/store/modules/app.js | 6 +- src/store/modules/auth.js | 2 +- src/store/modules/index.js | 2 +- src/store/modules/permission.js | 2 +- src/utils/http/interceptors.js | 72 +++++++++---------- src/utils/naiveTools.js | 4 +- src/views/base/test-modal.vue | 2 +- src/views/home/index.vue | 6 +- src/views/login/index.vue | 4 +- src/views/pms/resource/api.js | 2 +- .../pms/resource/components/MenuTree.vue | 2 +- .../pms/resource/components/ResAddOrEdit.vue | 8 +-- src/views/pms/resource/index.vue | 6 +- src/views/pms/role/index.vue | 4 +- src/views/pms/role/role-user.vue | 4 +- src/views/pms/user/index.vue | 6 +- src/views/profile/index.vue | 2 +- uno.config.js | 4 +- vite.config.js | 8 +-- 37 files changed, 104 insertions(+), 104 deletions(-) diff --git a/build/plugin-isme/index.js b/build/plugin-isme/index.js index 326b960..8f57e90 100644 --- a/build/plugin-isme/index.js +++ b/build/plugin-isme/index.js @@ -6,5 +6,5 @@ * Copyright © 2023 Ronnie Zhang(大脸怪) | https://isme.top **********************************/ -export { pluginPagePathes } from './page-pathes' export { pluginIcons } from './icons' +export { pluginPagePathes } from './page-pathes' diff --git a/src/App.vue b/src/App.vue index 77008a0..d5bee84 100644 --- a/src/App.vue +++ b/src/App.vue @@ -29,10 +29,10 @@ diff --git a/src/layouts/normal/index.vue b/src/layouts/normal/index.vue index 12fb6de..b108231 100644 --- a/src/layouts/normal/index.vue +++ b/src/layouts/normal/index.vue @@ -24,9 +24,9 @@ diff --git a/src/layouts/simple/index.vue b/src/layouts/simple/index.vue index ef192dd..09d64fc 100644 --- a/src/layouts/simple/index.vue +++ b/src/layouts/simple/index.vue @@ -23,8 +23,8 @@ diff --git a/src/main.js b/src/main.js index 4669624..6f7d309 100644 --- a/src/main.js +++ b/src/main.js @@ -8,16 +8,16 @@ * Copyright © 2023 Ronnie Zhang(大脸怪) | https://isme.top **********************************/ -import 'uno.css' -import '@/styles/reset.css' -import '@/styles/global.scss' - import { createApp } from 'vue' import App from './App.vue' +import { setupDirectives } from './directives' + import { setupRouter } from './router' import { setupStore } from './store' import { setupNaiveDiscreteApi } from './utils' -import { setupDirectives } from './directives' +import '@/styles/global.scss' +import '@/styles/reset.css' +import 'uno.css' async function bootstrap() { const app = createApp(App) diff --git a/src/router/guards/permission-guard.js b/src/router/guards/permission-guard.js index b317a08..6e0115d 100644 --- a/src/router/guards/permission-guard.js +++ b/src/router/guards/permission-guard.js @@ -6,8 +6,8 @@ * Copyright © 2023 Ronnie Zhang(大脸怪) | https://isme.top **********************************/ -import { useAuthStore, usePermissionStore, useUserStore } from '@/store' import api from '@/api' +import { useAuthStore, usePermissionStore, useUserStore } from '@/store' import { getPermissions, getUserInfo } from '@/store/helper' const WHITE_LIST = ['/login', '/404'] diff --git a/src/router/index.js b/src/router/index.js index 994157b..b914027 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -7,8 +7,8 @@ **********************************/ import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router' -import { setupRouterGuards } from './guards' import { basicRoutes } from './basic-routes' +import { setupRouterGuards } from './guards' export const router = createRouter({ history: diff --git a/src/store/helper.js b/src/store/helper.js index dd8fd26..00f5af9 100644 --- a/src/store/helper.js +++ b/src/store/helper.js @@ -1,5 +1,5 @@ -import { basePermissions } from '@/settings' import api from '@/api' +import { basePermissions } from '@/settings' export async function getUserInfo() { const res = await api.getUser() diff --git a/src/store/modules/app.js b/src/store/modules/app.js index d16aca3..f2282f3 100644 --- a/src/store/modules/app.js +++ b/src/store/modules/app.js @@ -6,10 +6,10 @@ * Copyright © 2023 Ronnie Zhang(大脸怪) | https://isme.top **********************************/ -import { defineStore } from 'pinia' -import { useDark } from '@vueuse/core' -import { generate, getRgbStr } from '@arco-design/color' import { defaultLayout, defaultPrimaryColor, naiveThemeOverrides } from '@/settings' +import { generate, getRgbStr } from '@arco-design/color' +import { useDark } from '@vueuse/core' +import { defineStore } from 'pinia' export const useAppStore = defineStore('app', { state: () => ({ diff --git a/src/store/modules/auth.js b/src/store/modules/auth.js index aea8f0e..a2fb8aa 100644 --- a/src/store/modules/auth.js +++ b/src/store/modules/auth.js @@ -6,8 +6,8 @@ * Copyright © 2023 Ronnie Zhang(大脸怪) | https://isme.top **********************************/ -import { defineStore } from 'pinia' import { usePermissionStore, useRouterStore, useTabStore, useUserStore } from '@/store' +import { defineStore } from 'pinia' export const useAuthStore = defineStore('auth', { state: () => ({ diff --git a/src/store/modules/index.js b/src/store/modules/index.js index 9672b79..943cd32 100644 --- a/src/store/modules/index.js +++ b/src/store/modules/index.js @@ -1,6 +1,6 @@ export * from './app' export * from './auth' export * from './permission' +export * from './router' export * from './tab' export * from './user' -export * from './router' diff --git a/src/store/modules/permission.js b/src/store/modules/permission.js index b61a039..e08a314 100644 --- a/src/store/modules/permission.js +++ b/src/store/modules/permission.js @@ -6,9 +6,9 @@ * Copyright © 2023 Ronnie Zhang(大脸怪) | https://isme.top **********************************/ +import { isExternal } from '@/utils' import { hyphenate } from '@vueuse/core' import { defineStore } from 'pinia' -import { isExternal } from '@/utils' export const usePermissionStore = defineStore('permission', { state: () => ({ diff --git a/src/utils/http/interceptors.js b/src/utils/http/interceptors.js index d048d3d..26585c0 100644 --- a/src/utils/http/interceptors.js +++ b/src/utils/http/interceptors.js @@ -7,29 +7,10 @@ * Copyright © 2023 Ronnie Zhang(大脸怪) | https://isme.top **********************************/ -import { resolveResError } from './helpers' import { useAuthStore } from '@/store' +import { resolveResError } from './helpers' export function setupInterceptors(axiosInstance) { - function reqResolve(config) { - // 处理不需要token的请求 - if (config.needToken === false) { - return config - } - - const { accessToken } = useAuthStore() - if (accessToken) { - // token: Bearer + xxx - config.headers.Authorization = `Bearer ${accessToken}` - } - - return config - } - - function reqReject(error) { - return Promise.reject(error) - } - const SUCCESS_CODES = [0, 200] function resResolve(response) { const { data, status, config, statusText, headers } = response @@ -49,22 +30,41 @@ export function setupInterceptors(axiosInstance) { return Promise.resolve(data ?? response) } - async function resReject(error) { - if (!error || !error.response) { - const code = error?.code - /** 根据code处理对应的操作,并返回处理后的message */ - const message = resolveResError(code, error.message) - return Promise.reject({ code, message, error }) - } - - const { data, status, config } = error.response - const code = data?.code ?? status - - const needTip = config?.needTip !== false - const message = resolveResError(code, data?.message ?? error.message, needTip) - return Promise.reject({ code, message, error: error.response?.data || error.response }) - } - axiosInstance.interceptors.request.use(reqResolve, reqReject) axiosInstance.interceptors.response.use(resResolve, resReject) } + +function reqResolve(config) { + // 处理不需要token的请求 + if (config.needToken === false) { + return config + } + + const { accessToken } = useAuthStore() + if (accessToken) { + // token: Bearer + xxx + config.headers.Authorization = `Bearer ${accessToken}` + } + + return config +} + +function reqReject(error) { + return Promise.reject(error) +} + +async function resReject(error) { + if (!error || !error.response) { + const code = error?.code + /** 根据code处理对应的操作,并返回处理后的message */ + const message = resolveResError(code, error.message) + return Promise.reject({ code, message, error }) + } + + const { data, status, config } = error.response + const code = data?.code ?? status + + const needTip = config?.needTip !== false + const message = resolveResError(code, data?.message ?? error.message, needTip) + return Promise.reject({ code, message, error: error.response?.data || error.response }) +} diff --git a/src/utils/naiveTools.js b/src/utils/naiveTools.js index 20efe5e..cc483fb 100644 --- a/src/utils/naiveTools.js +++ b/src/utils/naiveTools.js @@ -7,9 +7,9 @@ * Copyright © 2023 Ronnie Zhang(大脸怪) | https://isme.top **********************************/ -import * as NaiveUI from 'naive-ui' -import { isNullOrUndef } from '@/utils' import { useAppStore } from '@/store' +import { isNullOrUndef } from '@/utils' +import * as NaiveUI from 'naive-ui' export function setupMessage(NMessage) { class Message { diff --git a/src/views/base/test-modal.vue b/src/views/base/test-modal.vue index 2013550..b0c258e 100644 --- a/src/views/base/test-modal.vue +++ b/src/views/base/test-modal.vue @@ -22,8 +22,8 @@