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

View File

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

View File

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