fix: 外链支持

This commit is contained in:
JaguarJack 2023-05-28 14:22:01 +08:00
parent 9abd62b801
commit 03ea4759af
3 changed files with 14 additions and 11 deletions

View File

@ -13,13 +13,16 @@
<el-icon>
<Icon :name="menu?.meta?.icon" v-if="menu?.meta?.icon" class="text-sm" />
</el-icon>
<span>{{ menu?.meta?.title }}</span>
<span v-if="menu?.path.indexOf('https://') !== -1 || menu?.path.indexOf('http://') !== -1">
<span @click="openUrl(menu?.path as string)">{{ menu?.meta?.title }}</span>
</span>
<span v-else>{{ menu?.meta?.title }}</span>
</el-menu-item>
</template>
<script lang="ts" name="MenuItem" setup>
<script lang="ts" setup>
import { Menu } from '/admin/types/Menu'
import { onMounted, PropType, ref } from 'vue'
import { PropType } from 'vue'
import { useAppStore } from '/admin/stores/modules/app'
import { isMiniScreen } from '/admin/support/helper'
@ -37,6 +40,12 @@ defineProps({
require: true,
},
})
const openUrl = (path: string) => {
const start = path.indexOf('https://') || path.indexOf('http://')
window.open(path.substring(start))
return false
}
</script>
<style scoped lang="scss">

View File

@ -7,22 +7,15 @@
:collapse="!appStore.isExpand"
:collapse-transition="false"
:router="true"
@select="selectMenu"
:unique-opened="true"
>
<slot />
</el-menu>
</template>
<script lang="ts" setup name="menus">
<script lang="ts" setup>
import { useAppStore } from '/admin/stores/modules/app'
const appStore = useAppStore()
const selectMenu = (index: string) => {
if (index.startsWith('http') || index.startsWith('https')) {
window.open(index)
}
}
</script>
<style scoped lang="scss">

View File

@ -49,6 +49,7 @@ const guard = (router: Router) => {
}
next({ ...to, replace: true })
} catch (e) {
alert(e)
removeAuthToken()
next({ path: `${WhiteListPage.LOGIN_PATH}?redirect=/${to.path}` })
}