sc
This commit is contained in:
@@ -4,8 +4,8 @@ VITE_NODE_ENV=development
|
|||||||
VITE_DEV=true
|
VITE_DEV=true
|
||||||
|
|
||||||
# 请求路径
|
# 请求路径
|
||||||
# VITE_BASE_URL='http://47.98.161.246:48080'
|
VITE_BASE_URL='http://47.98.161.246:48080'
|
||||||
VITE_BASE_URL='http://114.215.207.150:48080'
|
# VITE_BASE_URL='http://114.215.207.150:48080'
|
||||||
|
|
||||||
# 小程序接口请求路劲
|
# 小程序接口请求路劲
|
||||||
VITE_APPLET_URL='https://cloud.ahduima.com'
|
VITE_APPLET_URL='https://cloud.ahduima.com'
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ import { usePageLoading } from '@/hooks/web/usePageLoading'
|
|||||||
import { useDictStoreWithOut } from '@/store/modules/dict'
|
import { useDictStoreWithOut } from '@/store/modules/dict'
|
||||||
import { useUserStoreWithOut } from '@/store/modules/user'
|
import { useUserStoreWithOut } from '@/store/modules/user'
|
||||||
import { usePermissionStoreWithOut } from '@/store/modules/permission'
|
import { usePermissionStoreWithOut } from '@/store/modules/permission'
|
||||||
import { getTenantId, getAppId } from '@/utils/auth'
|
import { useAppStoreWithOut } from '@/store/modules/app'
|
||||||
|
import { getTenantId, getAppId, setTenantId, setAppId } from '@/utils/auth'
|
||||||
import cache from '@/plugins/cache'
|
import cache from '@/plugins/cache'
|
||||||
|
|
||||||
const { start, done } = useNProgress()
|
const { start, done } = useNProgress()
|
||||||
@@ -39,13 +40,20 @@ router.beforeEach(async (to, from, next) => {
|
|||||||
} else {
|
} else {
|
||||||
if (getAccessToken()) {
|
if (getAccessToken()) {
|
||||||
if (to.path === '/login') {
|
if (to.path === '/login') {
|
||||||
|
if (to.query?.tenantId && to.query?.appId) {
|
||||||
|
setApp(to.query.tenantId, to.query.appId)
|
||||||
|
setTimeout(() => {
|
||||||
next({ path: '/' })
|
next({ path: '/' })
|
||||||
|
}, 1500)
|
||||||
|
} else {
|
||||||
|
next({ path: '/' })
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// 获取所有字典
|
// 获取所有字典
|
||||||
const dictStore = useDictStoreWithOut()
|
const dictStore = useDictStoreWithOut()
|
||||||
const userStore = useUserStoreWithOut()
|
const userStore = useUserStoreWithOut()
|
||||||
const permissionStore = usePermissionStoreWithOut()
|
const permissionStore = usePermissionStoreWithOut()
|
||||||
if (!dictStore.getIsSetDict && to.path != '/nm-detail') {
|
if (!dictStore.getIsSetDict) {
|
||||||
await dictStore.setDictMap()
|
await dictStore.setDictMap()
|
||||||
}
|
}
|
||||||
if (!userStore.getIsSetUser) {
|
if (!userStore.getIsSetUser) {
|
||||||
@@ -72,15 +80,23 @@ router.beforeEach(async (to, from, next) => {
|
|||||||
const tenantId = getTenantId()
|
const tenantId = getTenantId()
|
||||||
const appId = getAppId()
|
const appId = getAppId()
|
||||||
if (tenantId && appId) {
|
if (tenantId && appId) {
|
||||||
next(`/crm/login?tenantId=${tenantId}&appId=${appId}&redirect=${to.fullPath}`) // 否则全部重定向到登录页
|
next(`/oa/login?tenantId=${tenantId}&appId=${appId}&redirect=${to.fullPath}`) // 否则全部重定向到登录页
|
||||||
} else {
|
} else {
|
||||||
next(`/crm/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
|
next(`/oa/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function setApp(tenantId, appId) {
|
||||||
|
setTenantId(tenantId)
|
||||||
|
|
||||||
|
setAppId(appId)
|
||||||
|
const appStore = useAppStoreWithOut()
|
||||||
|
appStore.setAppInfo(appId)
|
||||||
|
}
|
||||||
|
|
||||||
router.afterEach((to) => {
|
router.afterEach((to) => {
|
||||||
useTitle(to?.meta?.title)
|
useTitle(to?.meta?.title)
|
||||||
done() // 结束Progress
|
done() // 结束Progress
|
||||||
|
|||||||
@@ -51,14 +51,26 @@ const remainingRouter: AppRouteRecordRaw[] = [
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '',
|
path: '/',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
redirect: '/Home/index',
|
redirect: '/index',
|
||||||
name: '',
|
name: '',
|
||||||
|
meta: {
|
||||||
|
title: '首页'
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: '/index',
|
||||||
|
component: () => import('@/views/Home/index.vue'),
|
||||||
|
name: 'Home',
|
||||||
meta: {
|
meta: {
|
||||||
title: '首页',
|
title: '首页',
|
||||||
hidden: true
|
icon: 'ep:home-filled',
|
||||||
|
noTagsView: true,
|
||||||
|
affix: true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/swagger',
|
path: '/swagger',
|
||||||
@@ -137,7 +149,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
|
|||||||
// redirect: '/Basic/menu',
|
// redirect: '/Basic/menu',
|
||||||
// children: [
|
// children: [
|
||||||
// {
|
// {
|
||||||
// path: 'menu',
|
// path: '/menu',
|
||||||
// component: () => import('@/views/Basic/Menu/index.vue'),
|
// component: () => import('@/views/Basic/Menu/index.vue'),
|
||||||
// name: 'Menu',
|
// name: 'Menu',
|
||||||
// meta: {
|
// meta: {
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ export const useDictStore = defineStore('dict', {
|
|||||||
this.dictMap = dictMap
|
this.dictMap = dictMap
|
||||||
this.isSetDict = true
|
this.isSetDict = true
|
||||||
} else {
|
} else {
|
||||||
const res = await listSimpleDictData()
|
// const res = (await listSimpleDictData()) || []
|
||||||
|
const res = []
|
||||||
// 设置数据
|
// 设置数据
|
||||||
const dictDataMap = new Map<string, any>()
|
const dictDataMap = new Map<string, any>()
|
||||||
res.forEach((dictData: DictDataVO) => {
|
res.forEach((dictData: DictDataVO) => {
|
||||||
|
|||||||
@@ -8,26 +8,34 @@ const RefreshTokenKey = 'REFRESH_TOKEN'
|
|||||||
// 获取token
|
// 获取token
|
||||||
export const getAccessToken = () => {
|
export const getAccessToken = () => {
|
||||||
// 此处与TokenKey相同,此写法解决初始化时Cookies中不存在TokenKey报错
|
// 此处与TokenKey相同,此写法解决初始化时Cookies中不存在TokenKey报错
|
||||||
return cache.local.get(AccessTokenKey)
|
return localStorage.getItem(AccessTokenKey)
|
||||||
? cache.local.get(AccessTokenKey)
|
? localStorage.getItem(AccessTokenKey)
|
||||||
: cache.local.get('ACCESS_TOKEN')
|
: localStorage.getItem('ACCESS_TOKEN')
|
||||||
|
// return cache.local.get(AccessTokenKey)
|
||||||
|
// ? cache.local.get(AccessTokenKey)
|
||||||
|
// : cache.local.get('ACCESS_TOKEN')
|
||||||
}
|
}
|
||||||
|
|
||||||
// 刷新token
|
// 刷新token
|
||||||
export const getRefreshToken = () => {
|
export const getRefreshToken = () => {
|
||||||
return cache.local.get(RefreshTokenKey)
|
return localStorage.getItem(RefreshTokenKey)
|
||||||
|
// return cache.local.get(RefreshTokenKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置token
|
// 设置token
|
||||||
export const setToken = (token: TokenType) => {
|
export const setToken = (token: TokenType) => {
|
||||||
cache.local.set(RefreshTokenKey, token.refreshToken)
|
localStorage.setItem(AccessTokenKey, token.accessToken)
|
||||||
cache.local.set(AccessTokenKey, token.accessToken)
|
localStorage.setItem(RefreshTokenKey, token.refreshToken)
|
||||||
|
// cache.local.set(RefreshTokenKey, token.refreshToken)
|
||||||
|
// cache.local.set(AccessTokenKey, token.accessToken)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除token
|
// 删除token
|
||||||
export const removeToken = () => {
|
export const removeToken = () => {
|
||||||
cache.local.delete(AccessTokenKey)
|
localStorage.removeItem(AccessTokenKey)
|
||||||
cache.local.delete(RefreshTokenKey)
|
localStorage.removeItem(RefreshTokenKey)
|
||||||
|
// cache.local.delete(AccessTokenKey)
|
||||||
|
// cache.local.delete(RefreshTokenKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 格式化token(jwt格式) */
|
/** 格式化token(jwt格式) */
|
||||||
|
|||||||
Reference in New Issue
Block a user