diff --git a/.env.development b/.env.development
index 08e52d3..068cbbf 100644
--- a/.env.development
+++ b/.env.development
@@ -1,5 +1,5 @@
# 页面标题
-VITE_APP_TITLE = 后台管理系统
+VITE_APP_TITLE = 智能一体机管理系统
# 接口请求地址,会设置到 axios 的 baseURL 参数上
VITE_APP_API_BASEURL = http://111.198.10.15:11411
# 调试工具,可设置 eruda 或 vconsole,如果不需要开启则留空
diff --git a/.env.development b/.env.development
index 08e52d3..068cbbf 100644
--- a/.env.development
+++ b/.env.development
@@ -1,5 +1,5 @@
# 页面标题
-VITE_APP_TITLE = 后台管理系统
+VITE_APP_TITLE = 智能一体机管理系统
# 接口请求地址,会设置到 axios 的 baseURL 参数上
VITE_APP_API_BASEURL = http://111.198.10.15:11411
# 调试工具,可设置 eruda 或 vconsole,如果不需要开启则留空
diff --git a/.env.production b/.env.production
index aac9caa..1612d11 100644
--- a/.env.production
+++ b/.env.production
@@ -1,7 +1,7 @@
NODE_ENV = production
# 页面标题
-VITE_APP_TITLE = 后台管理系统
+VITE_APP_TITLE = 智能一体机管理系统
# 接口请求地址,会设置到 axios 的 baseURL 参数上
VITE_APP_API_BASEURL = http://111.198.10.15:11411
# 调试工具,可设置 eruda 或 vconsole,如果不需要开启则留空
diff --git a/.env.development b/.env.development
index 08e52d3..068cbbf 100644
--- a/.env.development
+++ b/.env.development
@@ -1,5 +1,5 @@
# 页面标题
-VITE_APP_TITLE = 后台管理系统
+VITE_APP_TITLE = 智能一体机管理系统
# 接口请求地址,会设置到 axios 的 baseURL 参数上
VITE_APP_API_BASEURL = http://111.198.10.15:11411
# 调试工具,可设置 eruda 或 vconsole,如果不需要开启则留空
diff --git a/.env.production b/.env.production
index aac9caa..1612d11 100644
--- a/.env.production
+++ b/.env.production
@@ -1,7 +1,7 @@
NODE_ENV = production
# 页面标题
-VITE_APP_TITLE = 后台管理系统
+VITE_APP_TITLE = 智能一体机管理系统
# 接口请求地址,会设置到 axios 的 baseURL 参数上
VITE_APP_API_BASEURL = http://111.198.10.15:11411
# 调试工具,可设置 eruda 或 vconsole,如果不需要开启则留空
diff --git a/README.md b/README.md
index 45b0ff6..5469c98 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-
后台管理系统基础模板
+后台管理系统基础模板 --- 无登录无权限无系统管理
## 简要说明
diff --git a/.env.development b/.env.development
index 08e52d3..068cbbf 100644
--- a/.env.development
+++ b/.env.development
@@ -1,5 +1,5 @@
# 页面标题
-VITE_APP_TITLE = 后台管理系统
+VITE_APP_TITLE = 智能一体机管理系统
# 接口请求地址,会设置到 axios 的 baseURL 参数上
VITE_APP_API_BASEURL = http://111.198.10.15:11411
# 调试工具,可设置 eruda 或 vconsole,如果不需要开启则留空
diff --git a/.env.production b/.env.production
index aac9caa..1612d11 100644
--- a/.env.production
+++ b/.env.production
@@ -1,7 +1,7 @@
NODE_ENV = production
# 页面标题
-VITE_APP_TITLE = 后台管理系统
+VITE_APP_TITLE = 智能一体机管理系统
# 接口请求地址,会设置到 axios 的 baseURL 参数上
VITE_APP_API_BASEURL = http://111.198.10.15:11411
# 调试工具,可设置 eruda 或 vconsole,如果不需要开启则留空
diff --git a/README.md b/README.md
index 45b0ff6..5469c98 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-
后台管理系统基础模板
+后台管理系统基础模板 --- 无登录无权限无系统管理
## 简要说明
diff --git a/src/api/index.ts b/src/api/index.ts
index 9521010..6239617 100644
--- a/src/api/index.ts
+++ b/src/api/index.ts
@@ -1,28 +1,12 @@
import axios from 'axios'
-// import qs from 'qs'
import { ElMessage } from 'element-plus'
-import router from '@/router/index'
import useUserStore from '@/store/modules/user'
// 错误码枚举
enum responseCode {
success = 200, // 成功
- noPermission = 401, // 未授权
error = 500, // 服务器异常
}
-// 以下地址发生错误直接跳转至登录页
-const toLoginPath = ['/sys/user/permission', '/sys/user/info']
-
-// 跳转到登录页面
-const toLogin = () => {
- useUserStore().logout()
- router.push({
- path: '/login',
- query: {
- redirect: router.currentRoute.value.path !== '/login' ? router.currentRoute.value.fullPath : undefined,
- },
- })
-}
const request = axios.create({
baseURL: import.meta.env.DEV && import.meta.env.VITE_OPEN_PROXY === 'true' ? '/proxy/' : import.meta.env.VITE_APP_API_BASEURL,
@@ -41,11 +25,6 @@
request.headers.token = userStore.token
}
// 是否将 POST 请求参数进行字符串化处理
- if (request.method === 'post') {
- // request.data = qs.stringify(request.data, {
- // arrayFormat: 'brackets',
- // })
- }
return request
},
)
@@ -60,9 +39,6 @@
return Promise.resolve(response)
}
else if (response.data.code !== responseCode.success) {
- if (response.data.code === responseCode.noPermission) { // token失效状态跳转到登录页
- toLogin()
- }
// 这里做错误提示
ElMessage.error(response.data.message || '发生错误')
return Promise.reject(response.data)
@@ -84,18 +60,11 @@
}
}
else if (error.response && error.response.data) {
- // 如果是发生错误必须回到登录页的api
- const needLogin = toLoginPath.findIndex(path => error.request.responseURL.includes(path))
- if (needLogin > -1) {
- toLogin()
- }
- else {
- const message: string = error.response.data.message
- ElMessage({
- message,
- type: 'error',
- })
- }
+ const message: string = error.response.data.message
+ ElMessage({
+ message,
+ type: 'error',
+ })
}
else if (error.message) {
let message = error.message
diff --git a/.env.development b/.env.development
index 08e52d3..068cbbf 100644
--- a/.env.development
+++ b/.env.development
@@ -1,5 +1,5 @@
# 页面标题
-VITE_APP_TITLE = 后台管理系统
+VITE_APP_TITLE = 智能一体机管理系统
# 接口请求地址,会设置到 axios 的 baseURL 参数上
VITE_APP_API_BASEURL = http://111.198.10.15:11411
# 调试工具,可设置 eruda 或 vconsole,如果不需要开启则留空
diff --git a/.env.production b/.env.production
index aac9caa..1612d11 100644
--- a/.env.production
+++ b/.env.production
@@ -1,7 +1,7 @@
NODE_ENV = production
# 页面标题
-VITE_APP_TITLE = 后台管理系统
+VITE_APP_TITLE = 智能一体机管理系统
# 接口请求地址,会设置到 axios 的 baseURL 参数上
VITE_APP_API_BASEURL = http://111.198.10.15:11411
# 调试工具,可设置 eruda 或 vconsole,如果不需要开启则留空
diff --git a/README.md b/README.md
index 45b0ff6..5469c98 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-
后台管理系统基础模板
+后台管理系统基础模板 --- 无登录无权限无系统管理
## 简要说明
diff --git a/src/api/index.ts b/src/api/index.ts
index 9521010..6239617 100644
--- a/src/api/index.ts
+++ b/src/api/index.ts
@@ -1,28 +1,12 @@
import axios from 'axios'
-// import qs from 'qs'
import { ElMessage } from 'element-plus'
-import router from '@/router/index'
import useUserStore from '@/store/modules/user'
// 错误码枚举
enum responseCode {
success = 200, // 成功
- noPermission = 401, // 未授权
error = 500, // 服务器异常
}
-// 以下地址发生错误直接跳转至登录页
-const toLoginPath = ['/sys/user/permission', '/sys/user/info']
-
-// 跳转到登录页面
-const toLogin = () => {
- useUserStore().logout()
- router.push({
- path: '/login',
- query: {
- redirect: router.currentRoute.value.path !== '/login' ? router.currentRoute.value.fullPath : undefined,
- },
- })
-}
const request = axios.create({
baseURL: import.meta.env.DEV && import.meta.env.VITE_OPEN_PROXY === 'true' ? '/proxy/' : import.meta.env.VITE_APP_API_BASEURL,
@@ -41,11 +25,6 @@
request.headers.token = userStore.token
}
// 是否将 POST 请求参数进行字符串化处理
- if (request.method === 'post') {
- // request.data = qs.stringify(request.data, {
- // arrayFormat: 'brackets',
- // })
- }
return request
},
)
@@ -60,9 +39,6 @@
return Promise.resolve(response)
}
else if (response.data.code !== responseCode.success) {
- if (response.data.code === responseCode.noPermission) { // token失效状态跳转到登录页
- toLogin()
- }
// 这里做错误提示
ElMessage.error(response.data.message || '发生错误')
return Promise.reject(response.data)
@@ -84,18 +60,11 @@
}
}
else if (error.response && error.response.data) {
- // 如果是发生错误必须回到登录页的api
- const needLogin = toLoginPath.findIndex(path => error.request.responseURL.includes(path))
- if (needLogin > -1) {
- toLogin()
- }
- else {
- const message: string = error.response.data.message
- ElMessage({
- message,
- type: 'error',
- })
- }
+ const message: string = error.response.data.message
+ ElMessage({
+ message,
+ type: 'error',
+ })
}
else if (error.message) {
let message = error.message
diff --git a/src/layouts/components/Logo/index.vue b/src/layouts/components/Logo/index.vue
index bdcd228..68f74a0 100644
--- a/src/layouts/components/Logo/index.vue
+++ b/src/layouts/components/Logo/index.vue
@@ -31,7 +31,7 @@
-
+
{{ title }}
diff --git a/.env.development b/.env.development
index 08e52d3..068cbbf 100644
--- a/.env.development
+++ b/.env.development
@@ -1,5 +1,5 @@
# 页面标题
-VITE_APP_TITLE = 后台管理系统
+VITE_APP_TITLE = 智能一体机管理系统
# 接口请求地址,会设置到 axios 的 baseURL 参数上
VITE_APP_API_BASEURL = http://111.198.10.15:11411
# 调试工具,可设置 eruda 或 vconsole,如果不需要开启则留空
diff --git a/.env.production b/.env.production
index aac9caa..1612d11 100644
--- a/.env.production
+++ b/.env.production
@@ -1,7 +1,7 @@
NODE_ENV = production
# 页面标题
-VITE_APP_TITLE = 后台管理系统
+VITE_APP_TITLE = 智能一体机管理系统
# 接口请求地址,会设置到 axios 的 baseURL 参数上
VITE_APP_API_BASEURL = http://111.198.10.15:11411
# 调试工具,可设置 eruda 或 vconsole,如果不需要开启则留空
diff --git a/README.md b/README.md
index 45b0ff6..5469c98 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-
后台管理系统基础模板
+后台管理系统基础模板 --- 无登录无权限无系统管理
## 简要说明
diff --git a/src/api/index.ts b/src/api/index.ts
index 9521010..6239617 100644
--- a/src/api/index.ts
+++ b/src/api/index.ts
@@ -1,28 +1,12 @@
import axios from 'axios'
-// import qs from 'qs'
import { ElMessage } from 'element-plus'
-import router from '@/router/index'
import useUserStore from '@/store/modules/user'
// 错误码枚举
enum responseCode {
success = 200, // 成功
- noPermission = 401, // 未授权
error = 500, // 服务器异常
}
-// 以下地址发生错误直接跳转至登录页
-const toLoginPath = ['/sys/user/permission', '/sys/user/info']
-
-// 跳转到登录页面
-const toLogin = () => {
- useUserStore().logout()
- router.push({
- path: '/login',
- query: {
- redirect: router.currentRoute.value.path !== '/login' ? router.currentRoute.value.fullPath : undefined,
- },
- })
-}
const request = axios.create({
baseURL: import.meta.env.DEV && import.meta.env.VITE_OPEN_PROXY === 'true' ? '/proxy/' : import.meta.env.VITE_APP_API_BASEURL,
@@ -41,11 +25,6 @@
request.headers.token = userStore.token
}
// 是否将 POST 请求参数进行字符串化处理
- if (request.method === 'post') {
- // request.data = qs.stringify(request.data, {
- // arrayFormat: 'brackets',
- // })
- }
return request
},
)
@@ -60,9 +39,6 @@
return Promise.resolve(response)
}
else if (response.data.code !== responseCode.success) {
- if (response.data.code === responseCode.noPermission) { // token失效状态跳转到登录页
- toLogin()
- }
// 这里做错误提示
ElMessage.error(response.data.message || '发生错误')
return Promise.reject(response.data)
@@ -84,18 +60,11 @@
}
}
else if (error.response && error.response.data) {
- // 如果是发生错误必须回到登录页的api
- const needLogin = toLoginPath.findIndex(path => error.request.responseURL.includes(path))
- if (needLogin > -1) {
- toLogin()
- }
- else {
- const message: string = error.response.data.message
- ElMessage({
- message,
- type: 'error',
- })
- }
+ const message: string = error.response.data.message
+ ElMessage({
+ message,
+ type: 'error',
+ })
}
else if (error.message) {
let message = error.message
diff --git a/src/layouts/components/Logo/index.vue b/src/layouts/components/Logo/index.vue
index bdcd228..68f74a0 100644
--- a/src/layouts/components/Logo/index.vue
+++ b/src/layouts/components/Logo/index.vue
@@ -31,7 +31,7 @@
-
+
{{ title }}
diff --git a/src/layouts/components/Tools/index.vue b/src/layouts/components/Tools/index.vue
index fff759c..d5bc4c7 100644
--- a/src/layouts/components/Tools/index.vue
+++ b/src/layouts/components/Tools/index.vue
@@ -130,13 +130,13 @@
-->
-
+
+
{{ userStore.name }}
@@ -144,7 +144,7 @@
-
+
修改密码
@@ -161,8 +161,8 @@
-
-
+ -->
+
diff --git a/.env.development b/.env.development
index 08e52d3..068cbbf 100644
--- a/.env.development
+++ b/.env.development
@@ -1,5 +1,5 @@
# 页面标题
-VITE_APP_TITLE = 后台管理系统
+VITE_APP_TITLE = 智能一体机管理系统
# 接口请求地址,会设置到 axios 的 baseURL 参数上
VITE_APP_API_BASEURL = http://111.198.10.15:11411
# 调试工具,可设置 eruda 或 vconsole,如果不需要开启则留空
diff --git a/.env.production b/.env.production
index aac9caa..1612d11 100644
--- a/.env.production
+++ b/.env.production
@@ -1,7 +1,7 @@
NODE_ENV = production
# 页面标题
-VITE_APP_TITLE = 后台管理系统
+VITE_APP_TITLE = 智能一体机管理系统
# 接口请求地址,会设置到 axios 的 baseURL 参数上
VITE_APP_API_BASEURL = http://111.198.10.15:11411
# 调试工具,可设置 eruda 或 vconsole,如果不需要开启则留空
diff --git a/README.md b/README.md
index 45b0ff6..5469c98 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-
后台管理系统基础模板
+后台管理系统基础模板 --- 无登录无权限无系统管理
## 简要说明
diff --git a/src/api/index.ts b/src/api/index.ts
index 9521010..6239617 100644
--- a/src/api/index.ts
+++ b/src/api/index.ts
@@ -1,28 +1,12 @@
import axios from 'axios'
-// import qs from 'qs'
import { ElMessage } from 'element-plus'
-import router from '@/router/index'
import useUserStore from '@/store/modules/user'
// 错误码枚举
enum responseCode {
success = 200, // 成功
- noPermission = 401, // 未授权
error = 500, // 服务器异常
}
-// 以下地址发生错误直接跳转至登录页
-const toLoginPath = ['/sys/user/permission', '/sys/user/info']
-
-// 跳转到登录页面
-const toLogin = () => {
- useUserStore().logout()
- router.push({
- path: '/login',
- query: {
- redirect: router.currentRoute.value.path !== '/login' ? router.currentRoute.value.fullPath : undefined,
- },
- })
-}
const request = axios.create({
baseURL: import.meta.env.DEV && import.meta.env.VITE_OPEN_PROXY === 'true' ? '/proxy/' : import.meta.env.VITE_APP_API_BASEURL,
@@ -41,11 +25,6 @@
request.headers.token = userStore.token
}
// 是否将 POST 请求参数进行字符串化处理
- if (request.method === 'post') {
- // request.data = qs.stringify(request.data, {
- // arrayFormat: 'brackets',
- // })
- }
return request
},
)
@@ -60,9 +39,6 @@
return Promise.resolve(response)
}
else if (response.data.code !== responseCode.success) {
- if (response.data.code === responseCode.noPermission) { // token失效状态跳转到登录页
- toLogin()
- }
// 这里做错误提示
ElMessage.error(response.data.message || '发生错误')
return Promise.reject(response.data)
@@ -84,18 +60,11 @@
}
}
else if (error.response && error.response.data) {
- // 如果是发生错误必须回到登录页的api
- const needLogin = toLoginPath.findIndex(path => error.request.responseURL.includes(path))
- if (needLogin > -1) {
- toLogin()
- }
- else {
- const message: string = error.response.data.message
- ElMessage({
- message,
- type: 'error',
- })
- }
+ const message: string = error.response.data.message
+ ElMessage({
+ message,
+ type: 'error',
+ })
}
else if (error.message) {
let message = error.message
diff --git a/src/layouts/components/Logo/index.vue b/src/layouts/components/Logo/index.vue
index bdcd228..68f74a0 100644
--- a/src/layouts/components/Logo/index.vue
+++ b/src/layouts/components/Logo/index.vue
@@ -31,7 +31,7 @@
-
+
{{ title }}
diff --git a/src/layouts/components/Tools/index.vue b/src/layouts/components/Tools/index.vue
index fff759c..d5bc4c7 100644
--- a/src/layouts/components/Tools/index.vue
+++ b/src/layouts/components/Tools/index.vue
@@ -130,13 +130,13 @@
-->
-
+
+
{{ userStore.name }}
@@ -144,7 +144,7 @@
-
+
修改密码
@@ -161,8 +161,8 @@
-
-
+ -->
+
diff --git a/src/main.ts b/src/main.ts
index 695df5c..41643f0 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -1,11 +1,11 @@
import { createApp } from 'vue'
import ElementPlus from 'element-plus'
-import print from 'vue3-print-nb'
+// import print from 'vue3-print-nb'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import App from './App.vue'
import pinia from './store'
import router from './router'
-import useSettingsStore from './store/modules/settings'
+// import useSettingsStore from './store/modules/settings'
// 自定义指令
import directive from '@/utils/directive'
@@ -15,15 +15,15 @@
import '@/assets/styles/globals.scss'
// 加载 iconify 图标(element plus)
import { downloadAndInstall } from '@/iconify-ep'
-import { hasPermission } from '@/utils/composables/permission'
+// import { hasPermission } from '@/utils/composables/permission'
// 引入打印插件
-if (useSettingsStore().app.iconifyOfflineUse) {
- downloadAndInstall()
-}
+// if (useSettingsStore().app.iconifyOfflineUse) {
+downloadAndInstall()
+// }
const app = createApp(App)
-app.config.globalProperties.hasPerm = hasPermission
-app.use(print)
+// app.config.globalProperties.hasPerm = hasPermission
+// app.use(print)
app.use(ElementPlus)
app.use(pinia)
app.use(router)
diff --git a/.env.development b/.env.development
index 08e52d3..068cbbf 100644
--- a/.env.development
+++ b/.env.development
@@ -1,5 +1,5 @@
# 页面标题
-VITE_APP_TITLE = 后台管理系统
+VITE_APP_TITLE = 智能一体机管理系统
# 接口请求地址,会设置到 axios 的 baseURL 参数上
VITE_APP_API_BASEURL = http://111.198.10.15:11411
# 调试工具,可设置 eruda 或 vconsole,如果不需要开启则留空
diff --git a/.env.production b/.env.production
index aac9caa..1612d11 100644
--- a/.env.production
+++ b/.env.production
@@ -1,7 +1,7 @@
NODE_ENV = production
# 页面标题
-VITE_APP_TITLE = 后台管理系统
+VITE_APP_TITLE = 智能一体机管理系统
# 接口请求地址,会设置到 axios 的 baseURL 参数上
VITE_APP_API_BASEURL = http://111.198.10.15:11411
# 调试工具,可设置 eruda 或 vconsole,如果不需要开启则留空
diff --git a/README.md b/README.md
index 45b0ff6..5469c98 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-
后台管理系统基础模板
+后台管理系统基础模板 --- 无登录无权限无系统管理
## 简要说明
diff --git a/src/api/index.ts b/src/api/index.ts
index 9521010..6239617 100644
--- a/src/api/index.ts
+++ b/src/api/index.ts
@@ -1,28 +1,12 @@
import axios from 'axios'
-// import qs from 'qs'
import { ElMessage } from 'element-plus'
-import router from '@/router/index'
import useUserStore from '@/store/modules/user'
// 错误码枚举
enum responseCode {
success = 200, // 成功
- noPermission = 401, // 未授权
error = 500, // 服务器异常
}
-// 以下地址发生错误直接跳转至登录页
-const toLoginPath = ['/sys/user/permission', '/sys/user/info']
-
-// 跳转到登录页面
-const toLogin = () => {
- useUserStore().logout()
- router.push({
- path: '/login',
- query: {
- redirect: router.currentRoute.value.path !== '/login' ? router.currentRoute.value.fullPath : undefined,
- },
- })
-}
const request = axios.create({
baseURL: import.meta.env.DEV && import.meta.env.VITE_OPEN_PROXY === 'true' ? '/proxy/' : import.meta.env.VITE_APP_API_BASEURL,
@@ -41,11 +25,6 @@
request.headers.token = userStore.token
}
// 是否将 POST 请求参数进行字符串化处理
- if (request.method === 'post') {
- // request.data = qs.stringify(request.data, {
- // arrayFormat: 'brackets',
- // })
- }
return request
},
)
@@ -60,9 +39,6 @@
return Promise.resolve(response)
}
else if (response.data.code !== responseCode.success) {
- if (response.data.code === responseCode.noPermission) { // token失效状态跳转到登录页
- toLogin()
- }
// 这里做错误提示
ElMessage.error(response.data.message || '发生错误')
return Promise.reject(response.data)
@@ -84,18 +60,11 @@
}
}
else if (error.response && error.response.data) {
- // 如果是发生错误必须回到登录页的api
- const needLogin = toLoginPath.findIndex(path => error.request.responseURL.includes(path))
- if (needLogin > -1) {
- toLogin()
- }
- else {
- const message: string = error.response.data.message
- ElMessage({
- message,
- type: 'error',
- })
- }
+ const message: string = error.response.data.message
+ ElMessage({
+ message,
+ type: 'error',
+ })
}
else if (error.message) {
let message = error.message
diff --git a/src/layouts/components/Logo/index.vue b/src/layouts/components/Logo/index.vue
index bdcd228..68f74a0 100644
--- a/src/layouts/components/Logo/index.vue
+++ b/src/layouts/components/Logo/index.vue
@@ -31,7 +31,7 @@
-
+
{{ title }}
diff --git a/src/layouts/components/Tools/index.vue b/src/layouts/components/Tools/index.vue
index fff759c..d5bc4c7 100644
--- a/src/layouts/components/Tools/index.vue
+++ b/src/layouts/components/Tools/index.vue
@@ -130,13 +130,13 @@
-->
-
+
+
{{ userStore.name }}
@@ -144,7 +144,7 @@
-
+
修改密码
@@ -161,8 +161,8 @@
-
-
+ -->
+
diff --git a/src/main.ts b/src/main.ts
index 695df5c..41643f0 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -1,11 +1,11 @@
import { createApp } from 'vue'
import ElementPlus from 'element-plus'
-import print from 'vue3-print-nb'
+// import print from 'vue3-print-nb'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import App from './App.vue'
import pinia from './store'
import router from './router'
-import useSettingsStore from './store/modules/settings'
+// import useSettingsStore from './store/modules/settings'
// 自定义指令
import directive from '@/utils/directive'
@@ -15,15 +15,15 @@
import '@/assets/styles/globals.scss'
// 加载 iconify 图标(element plus)
import { downloadAndInstall } from '@/iconify-ep'
-import { hasPermission } from '@/utils/composables/permission'
+// import { hasPermission } from '@/utils/composables/permission'
// 引入打印插件
-if (useSettingsStore().app.iconifyOfflineUse) {
- downloadAndInstall()
-}
+// if (useSettingsStore().app.iconifyOfflineUse) {
+downloadAndInstall()
+// }
const app = createApp(App)
-app.config.globalProperties.hasPerm = hasPermission
-app.use(print)
+// app.config.globalProperties.hasPerm = hasPermission
+// app.use(print)
app.use(ElementPlus)
app.use(pinia)
app.use(router)
diff --git a/src/router/index.ts b/src/router/index.ts
index 6b9ba93..42f2cdd 100644
--- a/src/router/index.ts
+++ b/src/router/index.ts
@@ -3,135 +3,27 @@
import { useNProgress } from '@vueuse/integrations/useNProgress'
import '@/assets/styles/nprogress.scss'
// 路由相关数据
-import { asyncRoutes, asyncRoutesByFilesystem, constantRoutes, constantRoutesByFilesystem } from './routes'
-import pinia from '@/store'
+import { constantRoutes, systemRoutes } from './routes'
import useSettingsStore from '@/store/modules/settings'
import useKeepAliveStore from '@/store/modules/keepAlive'
-import useUserStore from '@/store/modules/user'
-import useMenuStore from '@/store/modules/menu'
-import useRouteStore from '@/store/modules/route'
const { isLoading } = useNProgress()
const router = createRouter({
history: createWebHashHistory(),
- routes: useSettingsStore(pinia).app.routeBaseOn === 'filesystem' ? constantRoutesByFilesystem : constantRoutes as RouteRecordRaw[],
+ routes: [...systemRoutes, ...constantRoutes] as RouteRecordRaw[],
})
router.beforeEach(async (to, from, next) => {
console.log('to:', to.path)
- const settingsStore = useSettingsStore()
- const userStore = useUserStore()
- const menuStore = useMenuStore()
- const routeStore = useRouteStore()
- settingsStore.app.enableProgress && (isLoading.value = true)
- // 是否已登录
- if (userStore.isLogin) {
- if (to.name === 'login') { // 如果还要进入登录页,直接跳转
- next()
- }
- else {
- if (!userStore.hasUserInfo) {
- // 获取用户信息
- await userStore.getUserInfo()
-
- console.log('index.ts-after userinfo', localStorage.token, userStore.username)
- }
- // 是否已根据权限动态生成并注册路由
- if (routeStore.isGenerate) {
- // 导航栏如果不是 single 模式,则需要根据 path 定位主导航的选中状态
- settingsStore.menu.menuMode !== 'single' && menuStore.setActived(to.path)
- // 如果已登录状态下,进入登录页会强制跳转到控制台页面
- if (to.name === 'login') {
- next({
- name: 'dashboard',
- replace: true,
- })
- }
- // 如果未开启控制台,但进入的是控制台页面,则会进入侧边栏导航第一个模块
- else if (!settingsStore.dashboard.enable && to.name === 'dashboard') {
- if (menuStore.sidebarMenus.length > 0) {
- next({
- path: menuStore.sidebarMenusFirstDeepestPath,
- replace: true,
- })
- }
- // 如果侧边栏导航第一个模块无法命中,则还是进入控制台页面
- else {
- next()
- }
- }
- // 正常访问页面
- else {
- next()
- }
- }
- else {
- // 生成动态路由
- switch (settingsStore.app.routeBaseOn) {
- case 'frontend':
- await routeStore.generateRoutesAtFront(asyncRoutes)
- break
- case 'backend':
- await routeStore.generateRoutesAtBack()
- break
- case 'filesystem':
- await routeStore.generateRoutesAtFilesystem(asyncRoutesByFilesystem)
- // 文件系统生成的路由,需要手动生成导航数据
- switch (settingsStore.menu.baseOn) {
- case 'frontend':
- await menuStore.generateMenusAtFront()
- break
- case 'backend':
- await menuStore.generateMenusAtBack()
- break
- }
- break
- }
- // 注册并记录路由数据
- // 记录的数据会在登出时会使用到,不使用 router.removeRoute 是考虑配置的路由可能不一定有设置 name ,则通过调用 router.addRoute() 返回的回调进行删除
- const removeRoutes: Function[] = []
- routeStore.flatRoutes.forEach((route) => {
- if (!/^(https?:|mailto:|tel:)/.test(route.path)) {
- removeRoutes.push(router.addRoute(route as RouteRecordRaw))
- }
- })
- // 添加静态路由
- if (settingsStore.app.routeBaseOn !== 'filesystem') {
- routeStore.flatSystemRoutes.forEach((route) => {
- removeRoutes.push(router.addRoute(route as RouteRecordRaw))
- })
- }
- routeStore.setCurrentRemoveRoutes(removeRoutes)
- // 动态路由生成并注册后,重新进入当前路由
- next({
- path: to.path,
- query: to.query,
- replace: true,
- })
- }
- }
- }
- else {
- // 未登录跳转到登录
- if (to.name !== 'login') {
- next({
- name: 'login',
- query: {
- redirect: to.fullPath,
- },
- })
- }
- else {
- next()
- }
- }
+ isLoading.value = true
+ next()
})
router.afterEach((to, from) => {
const settingsStore = useSettingsStore()
const keepAliveStore = useKeepAliveStore()
- settingsStore.app.enableProgress && (isLoading.value = false)
+ isLoading.value = false
// 设置页面 title
to.meta.title && settingsStore.setTitle(typeof to.meta.title === 'function' ? to.meta.title() : to.meta.title)
// 判断当前页面是否开启缓存,如果开启,则将当前页面的 name 信息存入 keep-alive 全局状态
diff --git a/.env.development b/.env.development
index 08e52d3..068cbbf 100644
--- a/.env.development
+++ b/.env.development
@@ -1,5 +1,5 @@
# 页面标题
-VITE_APP_TITLE = 后台管理系统
+VITE_APP_TITLE = 智能一体机管理系统
# 接口请求地址,会设置到 axios 的 baseURL 参数上
VITE_APP_API_BASEURL = http://111.198.10.15:11411
# 调试工具,可设置 eruda 或 vconsole,如果不需要开启则留空
diff --git a/.env.production b/.env.production
index aac9caa..1612d11 100644
--- a/.env.production
+++ b/.env.production
@@ -1,7 +1,7 @@
NODE_ENV = production
# 页面标题
-VITE_APP_TITLE = 后台管理系统
+VITE_APP_TITLE = 智能一体机管理系统
# 接口请求地址,会设置到 axios 的 baseURL 参数上
VITE_APP_API_BASEURL = http://111.198.10.15:11411
# 调试工具,可设置 eruda 或 vconsole,如果不需要开启则留空
diff --git a/README.md b/README.md
index 45b0ff6..5469c98 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-
后台管理系统基础模板
+后台管理系统基础模板 --- 无登录无权限无系统管理
## 简要说明
diff --git a/src/api/index.ts b/src/api/index.ts
index 9521010..6239617 100644
--- a/src/api/index.ts
+++ b/src/api/index.ts
@@ -1,28 +1,12 @@
import axios from 'axios'
-// import qs from 'qs'
import { ElMessage } from 'element-plus'
-import router from '@/router/index'
import useUserStore from '@/store/modules/user'
// 错误码枚举
enum responseCode {
success = 200, // 成功
- noPermission = 401, // 未授权
error = 500, // 服务器异常
}
-// 以下地址发生错误直接跳转至登录页
-const toLoginPath = ['/sys/user/permission', '/sys/user/info']
-
-// 跳转到登录页面
-const toLogin = () => {
- useUserStore().logout()
- router.push({
- path: '/login',
- query: {
- redirect: router.currentRoute.value.path !== '/login' ? router.currentRoute.value.fullPath : undefined,
- },
- })
-}
const request = axios.create({
baseURL: import.meta.env.DEV && import.meta.env.VITE_OPEN_PROXY === 'true' ? '/proxy/' : import.meta.env.VITE_APP_API_BASEURL,
@@ -41,11 +25,6 @@
request.headers.token = userStore.token
}
// 是否将 POST 请求参数进行字符串化处理
- if (request.method === 'post') {
- // request.data = qs.stringify(request.data, {
- // arrayFormat: 'brackets',
- // })
- }
return request
},
)
@@ -60,9 +39,6 @@
return Promise.resolve(response)
}
else if (response.data.code !== responseCode.success) {
- if (response.data.code === responseCode.noPermission) { // token失效状态跳转到登录页
- toLogin()
- }
// 这里做错误提示
ElMessage.error(response.data.message || '发生错误')
return Promise.reject(response.data)
@@ -84,18 +60,11 @@
}
}
else if (error.response && error.response.data) {
- // 如果是发生错误必须回到登录页的api
- const needLogin = toLoginPath.findIndex(path => error.request.responseURL.includes(path))
- if (needLogin > -1) {
- toLogin()
- }
- else {
- const message: string = error.response.data.message
- ElMessage({
- message,
- type: 'error',
- })
- }
+ const message: string = error.response.data.message
+ ElMessage({
+ message,
+ type: 'error',
+ })
}
else if (error.message) {
let message = error.message
diff --git a/src/layouts/components/Logo/index.vue b/src/layouts/components/Logo/index.vue
index bdcd228..68f74a0 100644
--- a/src/layouts/components/Logo/index.vue
+++ b/src/layouts/components/Logo/index.vue
@@ -31,7 +31,7 @@
-
+
{{ title }}
diff --git a/src/layouts/components/Tools/index.vue b/src/layouts/components/Tools/index.vue
index fff759c..d5bc4c7 100644
--- a/src/layouts/components/Tools/index.vue
+++ b/src/layouts/components/Tools/index.vue
@@ -130,13 +130,13 @@
-->
-
+
+
{{ userStore.name }}
@@ -144,7 +144,7 @@
-
+
修改密码
@@ -161,8 +161,8 @@
-
-
+ -->
+
diff --git a/src/main.ts b/src/main.ts
index 695df5c..41643f0 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -1,11 +1,11 @@
import { createApp } from 'vue'
import ElementPlus from 'element-plus'
-import print from 'vue3-print-nb'
+// import print from 'vue3-print-nb'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import App from './App.vue'
import pinia from './store'
import router from './router'
-import useSettingsStore from './store/modules/settings'
+// import useSettingsStore from './store/modules/settings'
// 自定义指令
import directive from '@/utils/directive'
@@ -15,15 +15,15 @@
import '@/assets/styles/globals.scss'
// 加载 iconify 图标(element plus)
import { downloadAndInstall } from '@/iconify-ep'
-import { hasPermission } from '@/utils/composables/permission'
+// import { hasPermission } from '@/utils/composables/permission'
// 引入打印插件
-if (useSettingsStore().app.iconifyOfflineUse) {
- downloadAndInstall()
-}
+// if (useSettingsStore().app.iconifyOfflineUse) {
+downloadAndInstall()
+// }
const app = createApp(App)
-app.config.globalProperties.hasPerm = hasPermission
-app.use(print)
+// app.config.globalProperties.hasPerm = hasPermission
+// app.use(print)
app.use(ElementPlus)
app.use(pinia)
app.use(router)
diff --git a/src/router/index.ts b/src/router/index.ts
index 6b9ba93..42f2cdd 100644
--- a/src/router/index.ts
+++ b/src/router/index.ts
@@ -3,135 +3,27 @@
import { useNProgress } from '@vueuse/integrations/useNProgress'
import '@/assets/styles/nprogress.scss'
// 路由相关数据
-import { asyncRoutes, asyncRoutesByFilesystem, constantRoutes, constantRoutesByFilesystem } from './routes'
-import pinia from '@/store'
+import { constantRoutes, systemRoutes } from './routes'
import useSettingsStore from '@/store/modules/settings'
import useKeepAliveStore from '@/store/modules/keepAlive'
-import useUserStore from '@/store/modules/user'
-import useMenuStore from '@/store/modules/menu'
-import useRouteStore from '@/store/modules/route'
const { isLoading } = useNProgress()
const router = createRouter({
history: createWebHashHistory(),
- routes: useSettingsStore(pinia).app.routeBaseOn === 'filesystem' ? constantRoutesByFilesystem : constantRoutes as RouteRecordRaw[],
+ routes: [...systemRoutes, ...constantRoutes] as RouteRecordRaw[],
})
router.beforeEach(async (to, from, next) => {
console.log('to:', to.path)
- const settingsStore = useSettingsStore()
- const userStore = useUserStore()
- const menuStore = useMenuStore()
- const routeStore = useRouteStore()
- settingsStore.app.enableProgress && (isLoading.value = true)
- // 是否已登录
- if (userStore.isLogin) {
- if (to.name === 'login') { // 如果还要进入登录页,直接跳转
- next()
- }
- else {
- if (!userStore.hasUserInfo) {
- // 获取用户信息
- await userStore.getUserInfo()
-
- console.log('index.ts-after userinfo', localStorage.token, userStore.username)
- }
- // 是否已根据权限动态生成并注册路由
- if (routeStore.isGenerate) {
- // 导航栏如果不是 single 模式,则需要根据 path 定位主导航的选中状态
- settingsStore.menu.menuMode !== 'single' && menuStore.setActived(to.path)
- // 如果已登录状态下,进入登录页会强制跳转到控制台页面
- if (to.name === 'login') {
- next({
- name: 'dashboard',
- replace: true,
- })
- }
- // 如果未开启控制台,但进入的是控制台页面,则会进入侧边栏导航第一个模块
- else if (!settingsStore.dashboard.enable && to.name === 'dashboard') {
- if (menuStore.sidebarMenus.length > 0) {
- next({
- path: menuStore.sidebarMenusFirstDeepestPath,
- replace: true,
- })
- }
- // 如果侧边栏导航第一个模块无法命中,则还是进入控制台页面
- else {
- next()
- }
- }
- // 正常访问页面
- else {
- next()
- }
- }
- else {
- // 生成动态路由
- switch (settingsStore.app.routeBaseOn) {
- case 'frontend':
- await routeStore.generateRoutesAtFront(asyncRoutes)
- break
- case 'backend':
- await routeStore.generateRoutesAtBack()
- break
- case 'filesystem':
- await routeStore.generateRoutesAtFilesystem(asyncRoutesByFilesystem)
- // 文件系统生成的路由,需要手动生成导航数据
- switch (settingsStore.menu.baseOn) {
- case 'frontend':
- await menuStore.generateMenusAtFront()
- break
- case 'backend':
- await menuStore.generateMenusAtBack()
- break
- }
- break
- }
- // 注册并记录路由数据
- // 记录的数据会在登出时会使用到,不使用 router.removeRoute 是考虑配置的路由可能不一定有设置 name ,则通过调用 router.addRoute() 返回的回调进行删除
- const removeRoutes: Function[] = []
- routeStore.flatRoutes.forEach((route) => {
- if (!/^(https?:|mailto:|tel:)/.test(route.path)) {
- removeRoutes.push(router.addRoute(route as RouteRecordRaw))
- }
- })
- // 添加静态路由
- if (settingsStore.app.routeBaseOn !== 'filesystem') {
- routeStore.flatSystemRoutes.forEach((route) => {
- removeRoutes.push(router.addRoute(route as RouteRecordRaw))
- })
- }
- routeStore.setCurrentRemoveRoutes(removeRoutes)
- // 动态路由生成并注册后,重新进入当前路由
- next({
- path: to.path,
- query: to.query,
- replace: true,
- })
- }
- }
- }
- else {
- // 未登录跳转到登录
- if (to.name !== 'login') {
- next({
- name: 'login',
- query: {
- redirect: to.fullPath,
- },
- })
- }
- else {
- next()
- }
- }
+ isLoading.value = true
+ next()
})
router.afterEach((to, from) => {
const settingsStore = useSettingsStore()
const keepAliveStore = useKeepAliveStore()
- settingsStore.app.enableProgress && (isLoading.value = false)
+ isLoading.value = false
// 设置页面 title
to.meta.title && settingsStore.setTitle(typeof to.meta.title === 'function' ? to.meta.title() : to.meta.title)
// 判断当前页面是否开启缓存,如果开启,则将当前页面的 name 信息存入 keep-alive 全局状态
diff --git a/src/router/routes.ts b/src/router/routes.ts
index 6b3a30b..fd701ee 100644
--- a/src/router/routes.ts
+++ b/src/router/routes.ts
@@ -1,6 +1,6 @@
import { setupLayouts } from 'virtual:generated-layouts'
import generatedRoutes from 'virtual:generated-pages'
-import systemRoute from './modules/system'
+// import systemRoute from './modules/system'
import type { Route } from '@/global'
import useSettingsStore from '@/store/modules/settings'
// 固定路由(默认路由)
@@ -13,14 +13,6 @@
},
},
{
- path: '/login',
- name: 'login',
- component: () => import('@/views/login.vue'),
- meta: {
- title: '登录',
- },
- },
- {
path: '/:all(.*)*',
name: 'notFound',
component: () => import('@/views/[...all].vue'),
@@ -52,34 +44,6 @@
],
},
{
- path: '/personal',
- component: () => import('@/layouts/index.vue'),
- redirect: '/personal/setting',
- meta: {
- title: '个人中心',
- breadcrumb: false,
- },
- children: [
- {
- path: 'setting',
- name: 'personalSetting',
- component: () => import('@/views/personal/setting.vue'),
- meta: {
- title: '个人设置',
- cache: 'personalEditPassword',
- },
- },
- {
- path: 'edit/password',
- name: 'personalEditPassword',
- component: () => import('@/views/personal/edit.password.vue'),
- meta: {
- title: '修改密码',
- },
- },
- ],
- },
- {
path: '/reload',
component: () => import('@/layouts/index.vue'),
meta: {
@@ -102,16 +66,16 @@
// 动态路由(异步路由、导航栏路由)
const asyncRoutes: Route.recordMainRaw[] = [
- {
- meta: {
- title: '系统设置',
- icon: '',
- auth: '/system',
- },
- children: [
- ...systemRoute,
- ],
- },
+ // {
+ // meta: {
+ // title: '系统设置',
+ // icon: '',
+ // auth: '/system',
+ // },
+ // children: [
+ // ...systemRoute,
+ // ],
+ // },
]
const constantRoutesByFilesystem = generatedRoutes.filter((item) => {
diff --git a/.env.development b/.env.development
index 08e52d3..068cbbf 100644
--- a/.env.development
+++ b/.env.development
@@ -1,5 +1,5 @@
# 页面标题
-VITE_APP_TITLE = 后台管理系统
+VITE_APP_TITLE = 智能一体机管理系统
# 接口请求地址,会设置到 axios 的 baseURL 参数上
VITE_APP_API_BASEURL = http://111.198.10.15:11411
# 调试工具,可设置 eruda 或 vconsole,如果不需要开启则留空
diff --git a/.env.production b/.env.production
index aac9caa..1612d11 100644
--- a/.env.production
+++ b/.env.production
@@ -1,7 +1,7 @@
NODE_ENV = production
# 页面标题
-VITE_APP_TITLE = 后台管理系统
+VITE_APP_TITLE = 智能一体机管理系统
# 接口请求地址,会设置到 axios 的 baseURL 参数上
VITE_APP_API_BASEURL = http://111.198.10.15:11411
# 调试工具,可设置 eruda 或 vconsole,如果不需要开启则留空
diff --git a/README.md b/README.md
index 45b0ff6..5469c98 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-
后台管理系统基础模板
+后台管理系统基础模板 --- 无登录无权限无系统管理
## 简要说明
diff --git a/src/api/index.ts b/src/api/index.ts
index 9521010..6239617 100644
--- a/src/api/index.ts
+++ b/src/api/index.ts
@@ -1,28 +1,12 @@
import axios from 'axios'
-// import qs from 'qs'
import { ElMessage } from 'element-plus'
-import router from '@/router/index'
import useUserStore from '@/store/modules/user'
// 错误码枚举
enum responseCode {
success = 200, // 成功
- noPermission = 401, // 未授权
error = 500, // 服务器异常
}
-// 以下地址发生错误直接跳转至登录页
-const toLoginPath = ['/sys/user/permission', '/sys/user/info']
-
-// 跳转到登录页面
-const toLogin = () => {
- useUserStore().logout()
- router.push({
- path: '/login',
- query: {
- redirect: router.currentRoute.value.path !== '/login' ? router.currentRoute.value.fullPath : undefined,
- },
- })
-}
const request = axios.create({
baseURL: import.meta.env.DEV && import.meta.env.VITE_OPEN_PROXY === 'true' ? '/proxy/' : import.meta.env.VITE_APP_API_BASEURL,
@@ -41,11 +25,6 @@
request.headers.token = userStore.token
}
// 是否将 POST 请求参数进行字符串化处理
- if (request.method === 'post') {
- // request.data = qs.stringify(request.data, {
- // arrayFormat: 'brackets',
- // })
- }
return request
},
)
@@ -60,9 +39,6 @@
return Promise.resolve(response)
}
else if (response.data.code !== responseCode.success) {
- if (response.data.code === responseCode.noPermission) { // token失效状态跳转到登录页
- toLogin()
- }
// 这里做错误提示
ElMessage.error(response.data.message || '发生错误')
return Promise.reject(response.data)
@@ -84,18 +60,11 @@
}
}
else if (error.response && error.response.data) {
- // 如果是发生错误必须回到登录页的api
- const needLogin = toLoginPath.findIndex(path => error.request.responseURL.includes(path))
- if (needLogin > -1) {
- toLogin()
- }
- else {
- const message: string = error.response.data.message
- ElMessage({
- message,
- type: 'error',
- })
- }
+ const message: string = error.response.data.message
+ ElMessage({
+ message,
+ type: 'error',
+ })
}
else if (error.message) {
let message = error.message
diff --git a/src/layouts/components/Logo/index.vue b/src/layouts/components/Logo/index.vue
index bdcd228..68f74a0 100644
--- a/src/layouts/components/Logo/index.vue
+++ b/src/layouts/components/Logo/index.vue
@@ -31,7 +31,7 @@
-
+
{{ title }}
diff --git a/src/layouts/components/Tools/index.vue b/src/layouts/components/Tools/index.vue
index fff759c..d5bc4c7 100644
--- a/src/layouts/components/Tools/index.vue
+++ b/src/layouts/components/Tools/index.vue
@@ -130,13 +130,13 @@
-->
-
+
+
{{ userStore.name }}
@@ -144,7 +144,7 @@
-
+
修改密码
@@ -161,8 +161,8 @@
-
-
+ -->
+
diff --git a/src/main.ts b/src/main.ts
index 695df5c..41643f0 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -1,11 +1,11 @@
import { createApp } from 'vue'
import ElementPlus from 'element-plus'
-import print from 'vue3-print-nb'
+// import print from 'vue3-print-nb'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import App from './App.vue'
import pinia from './store'
import router from './router'
-import useSettingsStore from './store/modules/settings'
+// import useSettingsStore from './store/modules/settings'
// 自定义指令
import directive from '@/utils/directive'
@@ -15,15 +15,15 @@
import '@/assets/styles/globals.scss'
// 加载 iconify 图标(element plus)
import { downloadAndInstall } from '@/iconify-ep'
-import { hasPermission } from '@/utils/composables/permission'
+// import { hasPermission } from '@/utils/composables/permission'
// 引入打印插件
-if (useSettingsStore().app.iconifyOfflineUse) {
- downloadAndInstall()
-}
+// if (useSettingsStore().app.iconifyOfflineUse) {
+downloadAndInstall()
+// }
const app = createApp(App)
-app.config.globalProperties.hasPerm = hasPermission
-app.use(print)
+// app.config.globalProperties.hasPerm = hasPermission
+// app.use(print)
app.use(ElementPlus)
app.use(pinia)
app.use(router)
diff --git a/src/router/index.ts b/src/router/index.ts
index 6b9ba93..42f2cdd 100644
--- a/src/router/index.ts
+++ b/src/router/index.ts
@@ -3,135 +3,27 @@
import { useNProgress } from '@vueuse/integrations/useNProgress'
import '@/assets/styles/nprogress.scss'
// 路由相关数据
-import { asyncRoutes, asyncRoutesByFilesystem, constantRoutes, constantRoutesByFilesystem } from './routes'
-import pinia from '@/store'
+import { constantRoutes, systemRoutes } from './routes'
import useSettingsStore from '@/store/modules/settings'
import useKeepAliveStore from '@/store/modules/keepAlive'
-import useUserStore from '@/store/modules/user'
-import useMenuStore from '@/store/modules/menu'
-import useRouteStore from '@/store/modules/route'
const { isLoading } = useNProgress()
const router = createRouter({
history: createWebHashHistory(),
- routes: useSettingsStore(pinia).app.routeBaseOn === 'filesystem' ? constantRoutesByFilesystem : constantRoutes as RouteRecordRaw[],
+ routes: [...systemRoutes, ...constantRoutes] as RouteRecordRaw[],
})
router.beforeEach(async (to, from, next) => {
console.log('to:', to.path)
- const settingsStore = useSettingsStore()
- const userStore = useUserStore()
- const menuStore = useMenuStore()
- const routeStore = useRouteStore()
- settingsStore.app.enableProgress && (isLoading.value = true)
- // 是否已登录
- if (userStore.isLogin) {
- if (to.name === 'login') { // 如果还要进入登录页,直接跳转
- next()
- }
- else {
- if (!userStore.hasUserInfo) {
- // 获取用户信息
- await userStore.getUserInfo()
-
- console.log('index.ts-after userinfo', localStorage.token, userStore.username)
- }
- // 是否已根据权限动态生成并注册路由
- if (routeStore.isGenerate) {
- // 导航栏如果不是 single 模式,则需要根据 path 定位主导航的选中状态
- settingsStore.menu.menuMode !== 'single' && menuStore.setActived(to.path)
- // 如果已登录状态下,进入登录页会强制跳转到控制台页面
- if (to.name === 'login') {
- next({
- name: 'dashboard',
- replace: true,
- })
- }
- // 如果未开启控制台,但进入的是控制台页面,则会进入侧边栏导航第一个模块
- else if (!settingsStore.dashboard.enable && to.name === 'dashboard') {
- if (menuStore.sidebarMenus.length > 0) {
- next({
- path: menuStore.sidebarMenusFirstDeepestPath,
- replace: true,
- })
- }
- // 如果侧边栏导航第一个模块无法命中,则还是进入控制台页面
- else {
- next()
- }
- }
- // 正常访问页面
- else {
- next()
- }
- }
- else {
- // 生成动态路由
- switch (settingsStore.app.routeBaseOn) {
- case 'frontend':
- await routeStore.generateRoutesAtFront(asyncRoutes)
- break
- case 'backend':
- await routeStore.generateRoutesAtBack()
- break
- case 'filesystem':
- await routeStore.generateRoutesAtFilesystem(asyncRoutesByFilesystem)
- // 文件系统生成的路由,需要手动生成导航数据
- switch (settingsStore.menu.baseOn) {
- case 'frontend':
- await menuStore.generateMenusAtFront()
- break
- case 'backend':
- await menuStore.generateMenusAtBack()
- break
- }
- break
- }
- // 注册并记录路由数据
- // 记录的数据会在登出时会使用到,不使用 router.removeRoute 是考虑配置的路由可能不一定有设置 name ,则通过调用 router.addRoute() 返回的回调进行删除
- const removeRoutes: Function[] = []
- routeStore.flatRoutes.forEach((route) => {
- if (!/^(https?:|mailto:|tel:)/.test(route.path)) {
- removeRoutes.push(router.addRoute(route as RouteRecordRaw))
- }
- })
- // 添加静态路由
- if (settingsStore.app.routeBaseOn !== 'filesystem') {
- routeStore.flatSystemRoutes.forEach((route) => {
- removeRoutes.push(router.addRoute(route as RouteRecordRaw))
- })
- }
- routeStore.setCurrentRemoveRoutes(removeRoutes)
- // 动态路由生成并注册后,重新进入当前路由
- next({
- path: to.path,
- query: to.query,
- replace: true,
- })
- }
- }
- }
- else {
- // 未登录跳转到登录
- if (to.name !== 'login') {
- next({
- name: 'login',
- query: {
- redirect: to.fullPath,
- },
- })
- }
- else {
- next()
- }
- }
+ isLoading.value = true
+ next()
})
router.afterEach((to, from) => {
const settingsStore = useSettingsStore()
const keepAliveStore = useKeepAliveStore()
- settingsStore.app.enableProgress && (isLoading.value = false)
+ isLoading.value = false
// 设置页面 title
to.meta.title && settingsStore.setTitle(typeof to.meta.title === 'function' ? to.meta.title() : to.meta.title)
// 判断当前页面是否开启缓存,如果开启,则将当前页面的 name 信息存入 keep-alive 全局状态
diff --git a/src/router/routes.ts b/src/router/routes.ts
index 6b3a30b..fd701ee 100644
--- a/src/router/routes.ts
+++ b/src/router/routes.ts
@@ -1,6 +1,6 @@
import { setupLayouts } from 'virtual:generated-layouts'
import generatedRoutes from 'virtual:generated-pages'
-import systemRoute from './modules/system'
+// import systemRoute from './modules/system'
import type { Route } from '@/global'
import useSettingsStore from '@/store/modules/settings'
// 固定路由(默认路由)
@@ -13,14 +13,6 @@
},
},
{
- path: '/login',
- name: 'login',
- component: () => import('@/views/login.vue'),
- meta: {
- title: '登录',
- },
- },
- {
path: '/:all(.*)*',
name: 'notFound',
component: () => import('@/views/[...all].vue'),
@@ -52,34 +44,6 @@
],
},
{
- path: '/personal',
- component: () => import('@/layouts/index.vue'),
- redirect: '/personal/setting',
- meta: {
- title: '个人中心',
- breadcrumb: false,
- },
- children: [
- {
- path: 'setting',
- name: 'personalSetting',
- component: () => import('@/views/personal/setting.vue'),
- meta: {
- title: '个人设置',
- cache: 'personalEditPassword',
- },
- },
- {
- path: 'edit/password',
- name: 'personalEditPassword',
- component: () => import('@/views/personal/edit.password.vue'),
- meta: {
- title: '修改密码',
- },
- },
- ],
- },
- {
path: '/reload',
component: () => import('@/layouts/index.vue'),
meta: {
@@ -102,16 +66,16 @@
// 动态路由(异步路由、导航栏路由)
const asyncRoutes: Route.recordMainRaw[] = [
- {
- meta: {
- title: '系统设置',
- icon: '',
- auth: '/system',
- },
- children: [
- ...systemRoute,
- ],
- },
+ // {
+ // meta: {
+ // title: '系统设置',
+ // icon: '',
+ // auth: '/system',
+ // },
+ // children: [
+ // ...systemRoute,
+ // ],
+ // },
]
const constantRoutesByFilesystem = generatedRoutes.filter((item) => {
diff --git a/src/store/modules/route.ts b/src/store/modules/route.ts
index 539c862..7013714 100644
--- a/src/store/modules/route.ts
+++ b/src/store/modules/route.ts
@@ -123,7 +123,7 @@
'route',
{
state: () => ({
- isGenerate: false,
+ isGenerate: true,
routes: [] as Route.recordMainRaw[],
fileSystemRoutes: [] as Route.recordRaw[],
currentRemoveRoutes: [] as Function[],