|
@@ -10,23 +10,44 @@ import useUserStore from './stores/modules/user'
|
|
|
import { INDEX_ROUTE, INDEX_ROUTE_NAME } from './router/routes'
|
|
import { INDEX_ROUTE, INDEX_ROUTE_NAME } from './router/routes'
|
|
|
import { PageEnum } from './enums/pageEnum'
|
|
import { PageEnum } from './enums/pageEnum'
|
|
|
import useTabsStore from './stores/modules/multipleTabs'
|
|
import useTabsStore from './stores/modules/multipleTabs'
|
|
|
-import { clearAuthInfo } from './utils/auth'
|
|
|
|
|
|
|
+import { clearAuthInfo, getShopId } from './utils/auth'
|
|
|
import config from './config'
|
|
import config from './config'
|
|
|
|
|
|
|
|
// NProgress配置
|
|
// NProgress配置
|
|
|
NProgress.configure({ showSpinner: false })
|
|
NProgress.configure({ showSpinner: false })
|
|
|
|
|
|
|
|
|
|
+var shopId = getShopId();
|
|
|
const loginPath = PageEnum.LOGIN
|
|
const loginPath = PageEnum.LOGIN
|
|
|
const defaultPath = PageEnum.INDEX
|
|
const defaultPath = PageEnum.INDEX
|
|
|
// 免登录白名单
|
|
// 免登录白名单
|
|
|
const whiteList: string[] = [PageEnum.LOGIN, PageEnum.ERROR_403]
|
|
const whiteList: string[] = [PageEnum.LOGIN, PageEnum.ERROR_403]
|
|
|
|
|
+
|
|
|
|
|
+// 检测店铺ID变化并刷新页面的函数
|
|
|
|
|
+function checkShopIdChange() {
|
|
|
|
|
+ const currentShopId = getShopId();
|
|
|
|
|
+ if (shopId !== currentShopId && currentShopId !== '') {
|
|
|
|
|
+ console.log('检测到店铺ID变化:', shopId, '->', currentShopId);
|
|
|
|
|
+ shopId = currentShopId;
|
|
|
|
|
+ // 刷新页面以更新数据
|
|
|
|
|
+ window.location.reload();
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
router.beforeEach(async (to, from, next) => {
|
|
router.beforeEach(async (to, from, next) => {
|
|
|
// 开始 Progress Bar
|
|
// 开始 Progress Bar
|
|
|
NProgress.start()
|
|
NProgress.start()
|
|
|
|
|
+
|
|
|
|
|
+ // 检测店铺ID变化
|
|
|
|
|
+ if (checkShopIdChange()) {
|
|
|
|
|
+ return; // 如果检测到变化并刷新页面,直接返回
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
document.title = to.meta.title ?? config.title
|
|
document.title = to.meta.title ?? config.title
|
|
|
const userStore = useUserStore()
|
|
const userStore = useUserStore()
|
|
|
const tabsStore = useTabsStore()
|
|
const tabsStore = useTabsStore()
|
|
|
- console.warn("***userStore***",userStore.token,to.path)
|
|
|
|
|
|
|
+ console.warn("***userStore***",shopId,userStore.token,to.path)
|
|
|
if (whiteList.includes(to.path)) {
|
|
if (whiteList.includes(to.path)) {
|
|
|
// 在免登录白名单,直接进入
|
|
// 在免登录白名单,直接进入
|
|
|
next()
|
|
next()
|