fix: 增加相对路径跳转

This commit is contained in:
huanghao1412 2024-08-17 11:07:50 +08:00
parent d6d626a5c4
commit 60befc3362
4 changed files with 12 additions and 6 deletions

4
.env
View File

@ -3,9 +3,9 @@ VITE_DEV_PORT = '8080'
# development path # development path
# VITE_DEV_PATH = 'http://192.168.0.34:11887' # VITE_DEV_PATH = 'http://192.168.0.34:11887'
VITE_DEV_PATH = 'http://192.168.0.34:8102/' VITE_DEV_PATH = 'http://114.115.222.135:9015/'
# VITE_DEV_PATH = 'http://192.168.0.120:3001' # VITE_DEV_PATH = 'http://192.168.0.120:3001'
VITE_DEV_TOKEN = '09c7cb6a-ab85-4c92-ad0f-5a25d72d71f7' VITE_DEV_TOKEN = 'a170d26c-477f-4b17-a344-997a20d3bab0'
# production path # production path
VITE_PRO_PATH = 'http://192.168.0.235:8177' VITE_PRO_PATH = 'http://192.168.0.235:8177'

View File

@ -395,7 +395,7 @@ export interface commonDataType {
// customEvent事件 // customEvent事件
export interface CustomEventType { export interface CustomEventType {
click: { click: {
linkHead: 'http://' | 'https://' linkHead: 'http://' | 'https://' | '/'
link: string link: string
isBlank: boolean isBlank: boolean
} }

View File

@ -69,21 +69,24 @@ const showModal = ref(false)
// init() // init()
// }) // })
const linkHeadOptions = ['http://', 'https://'].map(_ => ({label: _, value: _})) const linkHeadOptions = ['http://', 'https://', '/'].map(_ => ({label: _, value: _}))
const finallyLink = computed(() => { const finallyLink = computed(() => {
return targetData.value.customEvent.click.linkHead + (targetData.value as any).customEvent.click.link return targetData.value.customEvent.click.linkHead + (targetData.value as any).customEvent.click.link
}) })
const handleClick = () => { const handleClick = () => {
if(!finallyLink.value) return if(!finallyLink.value) return
let isRelativePath = targetData.value.customEvent.click.linkHead === '/'
if(targetData.value.customEvent.click.isBlank) postMessageToParent({ if(targetData.value.customEvent.click.isBlank) postMessageToParent({
type: 'windowOpen', type: 'windowOpen',
url: finallyLink.value, url: finallyLink.value,
openNew: true openNew: true,
isRelativePath
}) })
else postMessageToParent({ else postMessageToParent({
type: 'windowOpen', type: 'windowOpen',
url: finallyLink.value, url: finallyLink.value,
isRelativePath
}) })
} }
</script> </script>

View File

@ -7,14 +7,17 @@ const bindEvent = (item:any) => {
obj = { obj = {
click: () => { click: () => {
if(!link) return if(!link) return
let isRelativePath = linkHead === '/'
if(isBlank) postMessageToParent({ if(isBlank) postMessageToParent({
type: 'windowOpen', type: 'windowOpen',
url: `${linkHead}${link}`, url: `${linkHead}${link}`,
openNew: true openNew: true,
isRelativePath
}) })
else postMessageToParent({ else postMessageToParent({
type: 'windowOpen', type: 'windowOpen',
url: `${linkHead}${link}`, url: `${linkHead}${link}`,
isRelativePath
}) })
} }
} }