|
@@ -7,7 +7,7 @@ import tokenData from '~src/router/modules/token'
|
|
import { getStoreValue, setStoreValue } from '~src/utils/storage'
|
|
import { getStoreValue, setStoreValue } from '~src/utils/storage'
|
|
import { logout, refreshToken, userLogin } from '~api/user'
|
|
import { logout, refreshToken, userLogin } from '~api/user'
|
|
import { userConfigInfo, userConfigSave } from '~api/other'
|
|
import { userConfigInfo, userConfigSave } from '~api/other'
|
|
-import { ArrToOneObj, arrIndex, getArrValue, getObjValue } from 'js-fast-way'
|
|
|
|
|
|
+import { ArrToOneObj, arrIndex, getArrValue, getObjValue, isNullES } from 'js-fast-way'
|
|
import { useOsTheme } from 'hc-vue3-ui'
|
|
import { useOsTheme } from 'hc-vue3-ui'
|
|
import { setAppName } from '~uti/tools'
|
|
import { setAppName } from '~uti/tools'
|
|
import logoIcon from '~src/assets/logo/icon.png'
|
|
import logoIcon from '~src/assets/logo/icon.png'
|
|
@@ -127,19 +127,35 @@ export const setRouterData = async () => {
|
|
|
|
|
|
//获取路由菜单的主入口路径
|
|
//获取路由菜单的主入口路径
|
|
const getHomeRouter = async () => {
|
|
const getHomeRouter = async () => {
|
|
- const routes = getStoreValue('routesArr') ?? []
|
|
|
|
|
|
+ const routesArr = getStoreValue('routesArr') ?? []
|
|
|
|
+ const routes = store.menus
|
|
//没有菜单路由数据
|
|
//没有菜单路由数据
|
|
- if (routes.length <= 0) {
|
|
|
|
|
|
+ if (routesArr.length <= 0 || routes.length <= 0) {
|
|
store.setHomeUrl('home')
|
|
store.setHomeUrl('home')
|
|
return 'home'
|
|
return 'home'
|
|
}
|
|
}
|
|
//设置主入口
|
|
//设置主入口
|
|
- const isUsingStats = routes.indexOf('using-stats')
|
|
|
|
- const code = isUsingStats !== -1 ? 'using-stats' : routes[0]
|
|
|
|
|
|
+ const isUsingStats = routesArr.indexOf('using-stats')
|
|
|
|
+ if (isUsingStats !== -1) {
|
|
|
|
+ store.setHomeUrl('using-stats')
|
|
|
|
+ return 'using-stats'
|
|
|
|
+ }
|
|
|
|
+ //没有或不存在
|
|
|
|
+ const code = await getRoutesHomeUrl(routes)
|
|
store.setHomeUrl(code)
|
|
store.setHomeUrl(code)
|
|
return code
|
|
return code
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+//递归获取最子级的菜单
|
|
|
|
+const getRoutesHomeUrl = async (arr) => {
|
|
|
|
+ const item = arr[0]
|
|
|
|
+ if (!isNullES(item.children) && item.children.length > 0) {
|
|
|
|
+ return await getRoutesHomeUrl(item.children)
|
|
|
|
+ } else {
|
|
|
|
+ return item.code
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
//刷新token
|
|
//刷新token
|
|
export const RefreshToken = async () => {
|
|
export const RefreshToken = async () => {
|
|
try {
|
|
try {
|