|
1 | | -import { useMessage, defineService, getMetaApi, META_SERVICE } from '@opentiny/tiny-engine-meta-register' |
| 1 | +import { |
| 2 | + useCanvas, |
| 3 | + useResource, |
| 4 | + useMessage, |
| 5 | + defineService, |
| 6 | + getMetaApi, |
| 7 | + META_SERVICE |
| 8 | +} from '@opentiny/tiny-engine-meta-register' |
2 | 9 | import { reactive, watch } from 'vue' |
3 | 10 |
|
4 | 11 | const getBaseInfo = () => { |
@@ -55,24 +62,25 @@ const userState = reactive({ |
55 | 62 | needToLogin: false |
56 | 63 | }) |
57 | 64 |
|
| 65 | +const { subscribe, publish } = useMessage() |
| 66 | + |
58 | 67 | const getLoginStatus = () => userState.needToLogin |
59 | 68 |
|
60 | 69 | const setNeedToLogin = (value: boolean) => { |
61 | 70 | userState.needToLogin = value |
| 71 | + |
62 | 72 | if (!value) { |
63 | | - const defaultTenantId = userState.userInfo.tenant?.[0]?.id |
64 | | - if (defaultTenantId) { |
65 | | - const currentUrl = new URL(window.location.href) |
66 | | - const currentTenant = getBaseInfo().tenantId |
67 | | - |
68 | | - const filterList = userState.userInfo.tenant.filter((item) => item.id === currentTenant) || [] |
69 | | - // 只有当tenant值不存在时才更新 |
70 | | - if (!filterList?.length) { |
71 | | - currentUrl.searchParams.set('tenant', String(defaultTenantId)) |
72 | | - window.history.replaceState(window.history.state, '', currentUrl.href) |
| 73 | + watch( |
| 74 | + useCanvas().isCanvasApiReady, |
| 75 | + (ready) => { |
| 76 | + if (ready) { |
| 77 | + useResource().fetchResource() |
| 78 | + } |
| 79 | + }, |
| 80 | + { |
| 81 | + immediate: true |
73 | 82 | } |
74 | | - } |
75 | | - window.location.reload() |
| 83 | + ) |
76 | 84 | } |
77 | 85 | } |
78 | 86 |
|
@@ -104,8 +112,6 @@ const fetchAppInfo = (appId: string) => getMetaApi(META_SERVICE.Http).get(`/app- |
104 | 112 | const fetchAppList = (platformId: string) => |
105 | 113 | getMetaApi(META_SERVICE.Http).get(`/app-center/api/apps/list/${platformId}`) |
106 | 114 |
|
107 | | -const { subscribe, publish } = useMessage() |
108 | | - |
109 | 115 | const postLocationHistoryChanged = (data: any) => publish({ topic: 'locationHistoryChanged', data }) |
110 | 116 |
|
111 | 117 | /** |
|
0 commit comments