fix: bug#18886
This commit is contained in:
parent
14bc5cf16f
commit
24a669adc6
|
@ -131,7 +131,7 @@ export const postStream = function(url: string, data = {}, params = {}) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const showNotification = (message: string, description: string, key?: string, show: boolean = true) => {
|
export const showNotification = (message: string, description: string, key?: string, show: boolean = true) => {
|
||||||
if (show) {
|
if (show) {
|
||||||
Notification.error({
|
Notification.error({
|
||||||
style: {
|
style: {
|
||||||
|
@ -144,6 +144,10 @@ const showNotification = (message: string, description: string, key?: string, sh
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const TokenLose = () => {
|
||||||
|
showNotification('Unauthorized', '用户未登录', '401')
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 异常拦截处理器
|
* 异常拦截处理器
|
||||||
* @param {Object} error
|
* @param {Object} error
|
||||||
|
@ -182,7 +186,7 @@ const errorHandler = (error: any) => {
|
||||||
} else if (status === 400) {
|
} else if (status === 400) {
|
||||||
showNotification('Request Error', (data.message + '').substr(0, 90), '400')
|
showNotification('Request Error', (data.message + '').substr(0, 90), '400')
|
||||||
} else if (status === 401) {
|
} else if (status === 401) {
|
||||||
showNotification('Unauthorized', '用户未登录', '401')
|
TokenLose()
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
cleanToken()
|
cleanToken()
|
||||||
router.replace({
|
router.replace({
|
||||||
|
|
|
@ -14,10 +14,14 @@
|
||||||
|
|
||||||
<script lang="ts" name="IframgePage" setup>
|
<script lang="ts" name="IframgePage" setup>
|
||||||
import { TOKEN_KEY } from '@/utils/variable';
|
import { TOKEN_KEY } from '@/utils/variable';
|
||||||
import { LocalStore, getToken } from '@/utils/comm';
|
import {LocalStore, getToken, cleanToken} from '@/utils/comm';
|
||||||
import { getAppInfo_api } from '@/api/system/apply';
|
import { getAppInfo_api } from '@/api/system/apply';
|
||||||
import { lowCodeUrl } from '@/api/comm'
|
import { lowCodeUrl } from '@/api/comm'
|
||||||
import FullPage from "components/Layout/FullPage.vue";
|
import FullPage from "components/Layout/FullPage.vue";
|
||||||
|
import {onUnmounted} from "vue";
|
||||||
|
import router from "@/router";
|
||||||
|
import {LoginPath} from "@/router/menu";
|
||||||
|
import { TokenLose} from "@/utils/request";
|
||||||
|
|
||||||
const iframeUrl = ref<string>('');
|
const iframeUrl = ref<string>('');
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
@ -47,8 +51,8 @@ const handle = async (appId: string, url: string) => {
|
||||||
const lowCode = () => {
|
const lowCode = () => {
|
||||||
lowCodeUrl().then(res => {
|
lowCodeUrl().then(res => {
|
||||||
if (res.success && res.result) {
|
if (res.success && res.result) {
|
||||||
const url = res.result['ui-addr']
|
// const url = res.result['ui-addr']
|
||||||
// const url = 'http://localhost:8080'
|
const url = 'http://localhost:8080'
|
||||||
iframeUrl.value = url + '/#' + route.path + '?&token=' + getToken()
|
iframeUrl.value = url + '/#' + route.path + '?&token=' + getToken()
|
||||||
console.log(iframeUrl.value)
|
console.log(iframeUrl.value)
|
||||||
loading.value = true
|
loading.value = true
|
||||||
|
@ -56,6 +60,27 @@ const lowCode = () => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onMessage = (msg: any) => {
|
||||||
|
console.log('onMessage',msg)
|
||||||
|
if (msg?.data?.token === 'LOSE') {
|
||||||
|
TokenLose()
|
||||||
|
setTimeout(() => {
|
||||||
|
cleanToken()
|
||||||
|
router.replace({
|
||||||
|
path: LoginPath
|
||||||
|
})
|
||||||
|
}, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
window.addEventListener('message', onMessage)
|
||||||
|
})
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
window.removeEventListener('message', onMessage)
|
||||||
|
})
|
||||||
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
const matchedItem: any = route.matched?.[0]
|
const matchedItem: any = route.matched?.[0]
|
||||||
if (route.meta?.isApp) {
|
if (route.meta?.isApp) {
|
||||||
|
|
Loading…
Reference in New Issue