forked from github/dataease
feat(X-Pack): 嵌入式token增加传参功能
This commit is contained in:
parent
3e7abe2d1f
commit
19af415bf9
@ -13,6 +13,7 @@ import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
|
||||
import { useI18n } from '@/hooks/web/useI18n'
|
||||
import VanSticky from 'vant/es/sticky'
|
||||
import VanNavBar from 'vant/es/nav-bar'
|
||||
import request from '@/config/axios'
|
||||
import 'vant/es/nav-bar/style'
|
||||
import 'vant/es/sticky/style'
|
||||
const { wsCache } = useCache()
|
||||
@ -44,6 +45,12 @@ onBeforeMount(async () => {
|
||||
if (!checkResult) {
|
||||
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
|
||||
await getOuterParamsInfo(embeddedStore.dvId).then(rsp => {
|
||||
@ -61,6 +68,9 @@ onBeforeMount(async () => {
|
||||
ElMessage.error(t('visualization.outer_param_decode_error'))
|
||||
}
|
||||
}
|
||||
if (tokenInfo && Object.keys(tokenInfo).length) {
|
||||
attachParams = Object.assign({}, attachParams, tokenInfo)
|
||||
}
|
||||
|
||||
isPc.value = !isMobile()
|
||||
const req = isPc.value ? initCanvasData : initCanvasDataMobile
|
||||
|
@ -20,6 +20,7 @@ interface AppState {
|
||||
datasetId: string
|
||||
datasetCopyId: string
|
||||
datasetPid: string
|
||||
tokenInfo?: Map<string, object>
|
||||
}
|
||||
|
||||
export const userStore = defineStore('embedded', {
|
||||
@ -43,7 +44,8 @@ export const userStore = defineStore('embedded', {
|
||||
tableName: '',
|
||||
datasetId: '',
|
||||
datasetCopyId: '',
|
||||
datasetPid: ''
|
||||
datasetPid: '',
|
||||
tokenInfo: new Map()
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
@ -89,6 +91,9 @@ export const userStore = defineStore('embedded', {
|
||||
getOpt(): string {
|
||||
return this.opt
|
||||
},
|
||||
getTokenInfo(): Map<string, object> {
|
||||
return this.tokenInfo
|
||||
},
|
||||
getIframeData(): any {
|
||||
return {
|
||||
embeddedToken: this.token,
|
||||
@ -160,7 +165,7 @@ export const userStore = defineStore('embedded', {
|
||||
setOpt(opt: string) {
|
||||
this.opt = opt
|
||||
},
|
||||
setIframeData(data: any) {
|
||||
async setIframeData(data: any) {
|
||||
this.type = data['type']
|
||||
this.token = data['embeddedToken']
|
||||
this.busiFlag = data['busiFlag']
|
||||
@ -170,6 +175,9 @@ export const userStore = defineStore('embedded', {
|
||||
this.pid = data['pid']
|
||||
this.resourceId = data['resourceId']
|
||||
},
|
||||
async setTokenInfo(tokenInfo: Map<string, object>) {
|
||||
this.tokenInfo = tokenInfo
|
||||
},
|
||||
clearState() {
|
||||
this.setPid('')
|
||||
this.setOpt('')
|
||||
|
2
de-xpack
2
de-xpack
@ -1 +1 @@
|
||||
Subproject commit 38c32d17acda1963abb19ecc0afd926caefa375d
|
||||
Subproject commit 11b651cfa73e22195c36887672539a6a7ee0dddc
|
@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Tag(name = "嵌入式")
|
||||
@ApiSupport(order = 883, author = "fit2cloud-someone")
|
||||
@ -57,4 +58,7 @@ public interface EmbeddedApi {
|
||||
@Hidden
|
||||
@PostMapping("/initIframe")
|
||||
void initIframe(@RequestBody EmbeddedOrigin origin);
|
||||
|
||||
@GetMapping("/getTokenArgs")
|
||||
Map<String, Object> getTokenArgs();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user