diff --git a/README.md b/README.md index 678681401f2c0cace695bac9aad5c4265d402c7d..c943d1acdb18c381091256025246d3e440dbb561 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ quick-vue3-admin 是一款免费开源快速搭建中后台系统框架。本框 ## 预览 -- [quick-vue3-admin](https://ainiteam.com:3101/) - 框架演示 +- [quick-vue3-admin](http://quick.ainiteam.com/) - 框架演示 演示账号密码:admin/123456 diff --git a/src/components/QuickCrud/index.vue b/src/components/QuickCrud/index.vue index ddfaa179e40808f498a0e3d493aa193ec91f1099..43da0533f32fb33fdabe8b1e826fe65ba2eb7dbd 100644 --- a/src/components/QuickCrud/index.vue +++ b/src/components/QuickCrud/index.vue @@ -201,6 +201,7 @@ const refresh = () => { if (leftTree.value && leftTreeRefresh.value) { treeLoad() } else { + load() } } /** diff --git a/src/layout/index.vue b/src/layout/index.vue index 712889336d37d682d1f963d31a249764cc7bd0d6..cd8ef4682ca66bfe9d687aabc5adaa7bb40ccc8e 100644 --- a/src/layout/index.vue +++ b/src/layout/index.vue @@ -23,7 +23,6 @@ const { t } = useI18n() console.log('i18n', t('title')) const isCollapse = computed(() => appStore.getCollapse) -// router.push('/home') /** * 选项卡 */ @@ -42,8 +41,12 @@ const handleClick = (activeName: string) => { if (index !== -1) { tabStore.setActiveTab(tabList.value[index]) menuStore.setActiveMenuId(activeName) + editableTabsValue.value = activeName } } +if (activeTab.value.id) { + handleClick(activeTab.value.id) +} watch(activeTab, (val) => { if (val) { const { id, path } = val diff --git a/src/pages/login/index.vue b/src/pages/login/index.vue index 2c63ce290e09eb3199e910830cc00b286bc856b9..204604da4b48986f9b4fd61f9606d2b98469a2a5 100644 --- a/src/pages/login/index.vue +++ b/src/pages/login/index.vue @@ -77,7 +77,7 @@ const handleLogin = async (): Promise => { align-items: center; justify-content: center; // background-color: green; - background: url('public/images/login-bg.jpeg') no-repeat center center; + background: url('/images/login-bg.jpeg') no-repeat center center; background-size: 100% 100%; border-radius: 5px; .form { diff --git a/src/router/dynamicRouter.ts b/src/router/dynamicRouter.ts index cd3a92a75c57d4a0f4977a014277054c766d0a59..15e606ba45b6cd6c2484923f111eeb63891d2da7 100644 --- a/src/router/dynamicRouter.ts +++ b/src/router/dynamicRouter.ts @@ -1,16 +1,16 @@ -import layout from '../layout/index.vue' +import layout from '@/layout/index.vue' const dynamicRouter = [ { path: '/', - // name: '', + name: 'fist', component: layout, redirect: '/home', children: [ { path: '/home', name: 'home', - component: () => import('../views/home/index.vue'), + component: () => import('@/views/home/index.vue'), }, ], }, diff --git a/src/router/index.ts b/src/router/index.ts index a9172a2339e8a8dacf69431dd674e199ab244120..5b9391bce29b75c338026a7dcfe9ef1ce29cc5f7 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -12,10 +12,10 @@ export const router = createRouter({ history: createWebHashHistory(), routes: [...staticRouter, ...dynamicRouter], }) -const modules = import.meta.glob('../views/*/*.vue') -export const formatRouter = (data: Menu[]) => { - console.log('data', data) +const modules = import.meta.glob('../views/**/*.vue') +const layout = import.meta.glob('../layout/*.vue') +export const formatRouter = (data: Menu[]) => { const arr: RouteRecordRaw[] = [] const firstMenuArr: Menu[] = [] const secondMenuArr: Menu[] = [] @@ -30,7 +30,7 @@ export const formatRouter = (data: Menu[]) => { const routerObj: RouteRecordRaw = { name: element.menuId, path: element.path, - component: import('@/layout/index.vue'), + component: layout['../layout/index.vue'], redirect: '', children: [], meta: { @@ -79,13 +79,15 @@ router.beforeEach(async (to, from, next) => { const loginStore = useLoginStore(pinia) if (loginStore.getToken) { if (to.path === '/login') { + isRefresh = true next() } else if (to.name && !isRefresh) { + isRefresh = true next() } else { + isRefresh = false await addRoutes() next({ ...to, replace: true }) - isRefresh = false } } else if (to.path === '/login') { next() diff --git a/src/store/modules/tab.ts b/src/store/modules/tab.ts index 56c1aa3af54d0f1a01359d9b37e578aa49ae41c3..5734a25a973fef192cf949b9e01e3942e0eba2e3 100644 --- a/src/store/modules/tab.ts +++ b/src/store/modules/tab.ts @@ -50,7 +50,7 @@ export const useTabStore = defineStore('tabStore', { } }, }, - // persist: { - // enabled: true, - // }, + persist: { + enabled: true, + }, }) diff --git a/src/utils/request.ts b/src/utils/request.ts index 8eba8f5fce223b2c487233cb78ba1efc8971676a..0a4000f805ee77b3433e342b40ec575fb471cd59 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -22,11 +22,14 @@ const quickRequest: AxiosInstance = axios.create({ // 请求拦截器 quickRequest.interceptors.request.use( (config) => { + const cfg = config const loginStore = useLoginStore() - console.log('request', config) const token = loginStore.getToken - config.headers.authorization = `Bearer ${token}` - return config + if (cfg.headers) { + cfg.headers.authorization = `Bearer ${token}` + } + console.log('request', cfg) + return cfg }, (error) => { console.error(error) diff --git a/tsconfig.json b/tsconfig.json index 8262897db2300e947ec9953a710ac669e90afe2c..9c0e2500e75bc013350db3078d426c0f1dd45d35 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,7 +14,7 @@ "skipLibCheck": true, "types": ["element-plus/global"], "suppressImplicitAnyIndexErrors": true, - "baseUrl": ".", + "baseUrl": "./", "paths": { "@/*": ["src/*"] }, diff --git a/vite.config.ts b/vite.config.ts index e864dcd80031429b4dd398e2d343675c7197aa41..25137546384a7953d2add4f2769c4bbab737d202 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -10,7 +10,7 @@ export default ({ command, mode }) => { const env = loadEnv(mode, root) const { VITE_APP_TITLE, VITE_PORT, VITE_APP_BASE_URL } = env return { - base: './', + base: '/', plugins: [ vue(), DefineOptions(), @@ -45,9 +45,10 @@ export default ({ command, mode }) => { https: false, // 运行服务是否以https方式 host: true, port: VITE_PORT, + open: true, proxy: { [VITE_APP_BASE_URL]: { - // target: 'http://localhost:3002/', // 代理的目标地址-本地 + // target: 'http://localhost:3102/', // 代理的目标地址-本地 target: 'http://110.42.130.88:3102/', // 代理的目标地址-线上 changeOrigin: false, // 开发模式,默认的origin是真实的 origin:localhost:3000 代理服务会把origin修改为目标地址 secure: false, // 是否https接口 @@ -56,5 +57,21 @@ export default ({ command, mode }) => { }, }, }, + preview: { + https: false, // 运行服务是否以https方式 + host: true, + port: 3103, + open: true, + proxy: { + [VITE_APP_BASE_URL]: { + // target: 'http://localhost:3102/', // 代理的目标地址-本地 + target: 'http://110.42.130.88:3102/', // 代理的目标地址-线上 + changeOrigin: false, // 开发模式,默认的origin是真实的 origin:localhost:3000 代理服务会把origin修改为目标地址 + secure: false, // 是否https接口 + ws: false, // 是否代理websockets + rewrite: (path) => path.replace(/^\/prod-api/, ''), // 路径重写 + }, + }, + }, } }