Commit ab46207ea2134f6482437502113cbad2ea124320
Merge branch 'fix/app-login' into 'main_dev'
perf: 优化小程序访问组态需要获取token See merge request yunteng/thingskit-scada!165
Showing
3 changed files
with
15 additions
and
2 deletions
... | ... | @@ -8,6 +8,7 @@ enum Api { |
8 | 8 | SHARE_LOGIN = '/auth/login/public', |
9 | 9 | SHARE_MODE_CHECK = '/share/check/SCADA/', |
10 | 10 | GET_SHARE_DATA = '/share/SCADA/share_data/', |
11 | + APP_GET_TOKEN = '/third/login/id/', | |
11 | 12 | } |
12 | 13 | |
13 | 14 | export const getConfigurationContent = (id: string = useParseParams().configurationId) => { |
... | ... | @@ -49,3 +50,9 @@ export const getShareDataByAccessCredentials = (id: string, accessCredentials?: |
49 | 50 | params: { accessCredentials }, |
50 | 51 | }) |
51 | 52 | } |
53 | + | |
54 | +export const doAppLogin = (userId: string) => { | |
55 | + return defHttp.get<Record<'refreshToken' | 'token', string>>({ | |
56 | + url: `${Api.APP_GET_TOKEN}${userId}`, | |
57 | + }) | |
58 | +} | ... | ... |
1 | 1 | import { h, render } from 'vue' |
2 | 2 | import { useParseParams, usePlatform } from '..' |
3 | -import { checkShareModeNeedPassword, getConfigurationContent as getContent, getShareDataByAccessCredentials, getShareToken, saveConfigurationContent as saveData } from '@/api/content' | |
3 | +import { checkShareModeNeedPassword, doAppLogin, getConfigurationContent as getContent, getShareDataByAccessCredentials, getShareToken, saveConfigurationContent as saveData } from '@/api/content' | |
4 | 4 | import type { ConfigurationContentType } from '@/api/content/model' |
5 | 5 | import { ShareLoginModal } from '@/core/Share' |
6 | 6 | import { PageModeEnum } from '@/enums/modeEnum' |
... | ... | @@ -11,7 +11,7 @@ import { MessageEnum } from '@/enums/messageEnum' |
11 | 11 | |
12 | 12 | export function useContentData() { |
13 | 13 | const contentDataStore = useContentDataStoreWithOut() |
14 | - const { mode, publicId, configurationId } = useParseParams() | |
14 | + const { mode, publicId, configurationId, userId } = useParseParams() | |
15 | 15 | const userStore = useUserStoreWithOut() |
16 | 16 | const { createMessage } = useMessage() |
17 | 17 | |
... | ... | @@ -37,6 +37,11 @@ export function useContentData() { |
37 | 37 | } |
38 | 38 | |
39 | 39 | const doGetConfigurationContent = async () => { |
40 | + if (userId) { | |
41 | + const { token, refreshToken } = await doAppLogin(userId) | |
42 | + userStore.storeToken(token, refreshToken) | |
43 | + } | |
44 | + | |
40 | 45 | const result = mode === PageModeEnum.SHARE ? await shareModeBootstrap() : await getContent() |
41 | 46 | |
42 | 47 | if (result) { | ... | ... |