Merge pull request #11367 from dataease/pr@dev-v2@feat_embedded_token_args

feat(X-Pack): 嵌入式token增加传参功能
This commit is contained in:
fit2cloud-chenyw 2024-08-05 18:53:03 +08:00 committed by GitHub
commit 48592ccccb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 25 additions and 3 deletions

View File

@ -13,6 +13,7 @@ import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
import { useI18n } from '@/hooks/web/useI18n' import { useI18n } from '@/hooks/web/useI18n'
import VanSticky from 'vant/es/sticky' import VanSticky from 'vant/es/sticky'
import VanNavBar from 'vant/es/nav-bar' import VanNavBar from 'vant/es/nav-bar'
import request from '@/config/axios'
import 'vant/es/nav-bar/style' import 'vant/es/nav-bar/style'
import 'vant/es/sticky/style' import 'vant/es/sticky/style'
const { wsCache } = useCache() const { wsCache } = useCache()
@ -44,6 +45,12 @@ onBeforeMount(async () => {
if (!checkResult) { if (!checkResult) {
return return
} }
let tokenInfo = null
if (embeddedStore.getToken && !Object.keys((tokenInfo = embeddedStore.getTokenInfo)).length) {
const res = await request.get({ url: '/embedded/getTokenArgs' })
embeddedStore.setTokenInfo(res.data)
tokenInfo = embeddedStore.getTokenInfo
}
// //
let attachParams let attachParams
await getOuterParamsInfo(embeddedStore.dvId).then(rsp => { await getOuterParamsInfo(embeddedStore.dvId).then(rsp => {
@ -61,6 +68,9 @@ onBeforeMount(async () => {
ElMessage.error(t('visualization.outer_param_decode_error')) ElMessage.error(t('visualization.outer_param_decode_error'))
} }
} }
if (tokenInfo && Object.keys(tokenInfo).length) {
attachParams = Object.assign({}, attachParams, tokenInfo)
}
isPc.value = !isMobile() isPc.value = !isMobile()
const req = isPc.value ? initCanvasData : initCanvasDataMobile const req = isPc.value ? initCanvasData : initCanvasDataMobile

View File

@ -20,6 +20,7 @@ interface AppState {
datasetId: string datasetId: string
datasetCopyId: string datasetCopyId: string
datasetPid: string datasetPid: string
tokenInfo?: Map<string, object>
} }
export const userStore = defineStore('embedded', { export const userStore = defineStore('embedded', {
@ -43,7 +44,8 @@ export const userStore = defineStore('embedded', {
tableName: '', tableName: '',
datasetId: '', datasetId: '',
datasetCopyId: '', datasetCopyId: '',
datasetPid: '' datasetPid: '',
tokenInfo: new Map()
} }
}, },
getters: { getters: {
@ -89,6 +91,9 @@ export const userStore = defineStore('embedded', {
getOpt(): string { getOpt(): string {
return this.opt return this.opt
}, },
getTokenInfo(): Map<string, object> {
return this.tokenInfo
},
getIframeData(): any { getIframeData(): any {
return { return {
embeddedToken: this.token, embeddedToken: this.token,
@ -160,7 +165,7 @@ export const userStore = defineStore('embedded', {
setOpt(opt: string) { setOpt(opt: string) {
this.opt = opt this.opt = opt
}, },
setIframeData(data: any) { async setIframeData(data: any) {
this.type = data['type'] this.type = data['type']
this.token = data['embeddedToken'] this.token = data['embeddedToken']
this.busiFlag = data['busiFlag'] this.busiFlag = data['busiFlag']
@ -170,6 +175,9 @@ export const userStore = defineStore('embedded', {
this.pid = data['pid'] this.pid = data['pid']
this.resourceId = data['resourceId'] this.resourceId = data['resourceId']
}, },
async setTokenInfo(tokenInfo: Map<string, object>) {
this.tokenInfo = tokenInfo
},
clearState() { clearState() {
this.setPid('') this.setPid('')
this.setOpt('') this.setOpt('')

@ -1 +1 @@
Subproject commit 38c32d17acda1963abb19ecc0afd926caefa375d Subproject commit 11b651cfa73e22195c36887672539a6a7ee0dddc

View File

@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import java.util.List; import java.util.List;
import java.util.Map;
@Tag(name = "嵌入式") @Tag(name = "嵌入式")
@ApiSupport(order = 883, author = "fit2cloud-someone") @ApiSupport(order = 883, author = "fit2cloud-someone")
@ -57,4 +58,7 @@ public interface EmbeddedApi {
@Hidden @Hidden
@PostMapping("/initIframe") @PostMapping("/initIframe")
void initIframe(@RequestBody EmbeddedOrigin origin); void initIframe(@RequestBody EmbeddedOrigin origin);
@GetMapping("/getTokenArgs")
Map<String, Object> getTokenArgs();
} }