forked from github/dataease
Merge pull request #11725 from dataease/pr@dev-v2@fix_mobile_ticket
fix(仪表板): 移动端公共链接ticket无效
This commit is contained in:
commit
f0c1b41648
@ -38,7 +38,16 @@ router.beforeEach(async (to, from, next) => {
|
||||
done()
|
||||
loadDone()
|
||||
if (to.name === 'link') {
|
||||
window.location.href = window.origin + '/mobile.html#' + to.path
|
||||
let linkQuery = ''
|
||||
if (Object.keys(to.query)) {
|
||||
const tempQuery = Object.keys(to.query)
|
||||
.map(key => key + '=' + to.query[key])
|
||||
.join('&')
|
||||
if (tempQuery) {
|
||||
linkQuery = '?' + tempQuery
|
||||
}
|
||||
}
|
||||
window.location.href = window.origin + '/mobile.html#' + to.path + linkQuery
|
||||
} else if (to.path === '/dvCanvas') {
|
||||
next('/notSupport')
|
||||
} else if (
|
||||
|
@ -11,6 +11,7 @@ import { ElMessage } from 'element-plus-secondary'
|
||||
import { useEmbedded } from '@/store/modules/embedded'
|
||||
import { useI18n } from '@/hooks/web/useI18n'
|
||||
import { XpackComponent } from '@/components/plugin'
|
||||
import { propTypes } from '@/utils/propTypes'
|
||||
|
||||
const dvMainStore = dvMainStoreWithOut()
|
||||
const { t } = useI18n()
|
||||
@ -32,7 +33,8 @@ const props = defineProps({
|
||||
isSelector: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
ticketArgs: propTypes.string.def(null)
|
||||
})
|
||||
|
||||
const loadCanvasDataAsync = async (dvId, dvType) => {
|
||||
@ -56,6 +58,13 @@ const loadCanvasDataAsync = async (dvId, dvType) => {
|
||||
console.error(e)
|
||||
}
|
||||
}
|
||||
let argsObject = null
|
||||
try {
|
||||
argsObject = JSON.parse(props.ticketArgs)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
const hasTicketArgs = argsObject && Object.keys(argsObject)
|
||||
|
||||
// 添加外部参数
|
||||
let attachParam
|
||||
@ -65,9 +74,14 @@ const loadCanvasDataAsync = async (dvId, dvType) => {
|
||||
|
||||
// 外部参数(iframe 或者 iframe嵌入)
|
||||
const attachParamsEncode = router.currentRoute.value.query.attachParams
|
||||
if (attachParamsEncode) {
|
||||
if (attachParamsEncode || hasTicketArgs) {
|
||||
try {
|
||||
attachParam = JSON.parse(Base64.decode(decodeURIComponent(attachParamsEncode as string)))
|
||||
if (!!attachParamsEncode) {
|
||||
attachParam = JSON.parse(Base64.decode(decodeURIComponent(attachParamsEncode as string)))
|
||||
}
|
||||
if (hasTicketArgs) {
|
||||
attachParam = Object.assign({}, attachParam, argsObject)
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
ElMessage.error(t('visualization.outer_param_decode_error'))
|
||||
|
@ -3,13 +3,23 @@
|
||||
<LinkError v-if="!loading && !linkExist" />
|
||||
<Exp v-else-if="!loading && linkExp" />
|
||||
<PwdTips v-else-if="!loading && !pwdValid" />
|
||||
<PreviewCanvas v-else :class="{ 'hidden-link': loading }" ref="pcanvas" public-link-status />
|
||||
<TicketError
|
||||
v-else-if="!loading && (!state.ticketValidVO.ticketValid || state.ticketValidVO.ticketExp)"
|
||||
/>
|
||||
<PreviewCanvas
|
||||
v-else
|
||||
:class="{ 'hidden-link': loading }"
|
||||
ref="pcanvas"
|
||||
public-link-status
|
||||
:ticket-args="state.ticketValidVO.args"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { onMounted, nextTick, ref } from 'vue'
|
||||
import { onMounted, nextTick, ref, reactive } from 'vue'
|
||||
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
|
||||
import PreviewCanvas from '@/views/data-visualization/PreviewCanvasMobile.vue'
|
||||
import TicketError from './TicketError.vue'
|
||||
import { ProxyInfo, shareProxy } from './ShareProxy'
|
||||
import Exp from './exp.vue'
|
||||
import router from '@/router/mobile'
|
||||
@ -22,6 +32,13 @@ const pwdValid = ref(false)
|
||||
const dvMainStore = dvMainStoreWithOut()
|
||||
const pcanvas = ref(null)
|
||||
const curType = ref('')
|
||||
const state = reactive({
|
||||
ticketValidVO: {
|
||||
ticketValid: false,
|
||||
ticketExp: false,
|
||||
args: ''
|
||||
}
|
||||
})
|
||||
onMounted(async () => {
|
||||
const proxyInfo = (await shareProxy.loadProxy()) as ProxyInfo
|
||||
curType.value = proxyInfo.type || 'dashboard'
|
||||
@ -34,6 +51,7 @@ onMounted(async () => {
|
||||
linkExist.value = true
|
||||
linkExp.value = !!proxyInfo.exp
|
||||
pwdValid.value = !!proxyInfo.pwdValid
|
||||
state.ticketValidVO = proxyInfo.ticketValidVO
|
||||
nextTick(() => {
|
||||
if (curType.value === 'dashboard') {
|
||||
const method = pcanvas?.value?.loadCanvasDataAsync
|
||||
|
Loading…
Reference in New Issue
Block a user