1
0
mirror of https://github.com/zclzone/vue-naive-admin.git synced 2025-04-30 22:29:01 +08:00

feat: 外链可内嵌打开

This commit is contained in:
zclzone 2024-03-15 16:20:38 +08:00
parent fd9480e92f
commit 04723ffbfa
6 changed files with 86 additions and 5 deletions

View File

@ -0,0 +1,16 @@
<svg
t="1710490574771"
class="icon"
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
p-id="4141"
width="200"
height="200"
>
<path
d="M1022.934187 429.44a446.122667 446.122667 0 0 0-19.456-100.437333 175.786667 175.786667 0 0 1-15.530667 31.701333 401.92 401.92 0 0 0-164.224-267.264A399.701333 399.701333 0 0 0 724.566187 41.770667a313.6 313.6 0 0 0-14.421334-4.778667 300.458667 300.458667 0 0 1 60.8 148.096c0.256 1.877333 0.469333 3.754667 0.64 5.674667a2.56 2.56 0 0 1 0 0.426666c0.213333 1.92 0.426667 3.882667 0.554667 5.845334v1.024a223.957333 223.957333 0 0 1 0.426667 5.845333 246.357333 246.357333 0 0 1 0.426666 10.026667 8.277333 8.277333 0 0 0 0 0.682666v6.997334a300.672 300.672 0 0 1-54.101333 172.458666 270.293333 270.293333 0 0 1 3.2 93.653334 263.552 263.552 0 0 0 49.664-17.109334 263.850667 263.850667 0 0 0 34.133333-18.773333 268.074667 268.074667 0 0 1 10.368 74.410667 269.525333 269.525333 0 0 1-2.986666 40.362666 266.197333 266.197333 0 0 0 68.906666-16.64c11.605333-4.522667 22.869333-9.813333 33.706667-15.914666a266.410667 266.410667 0 0 1 4.266667 47.701333 269.141333 269.141333 0 0 1-5.76 55.381333 266.752 266.752 0 0 0 81.322666-16.213333A446.165333 446.165333 0 0 0 1024.000853 464.213333a366.933333 366.933333 0 0 0-1.024-34.816z m-119.808 247.210667a242.56 242.56 0 0 1-16.64 0.512h-5.504a266.666667 266.666667 0 0 0 8.448-66.858667 269.653333 269.653333 0 0 0-1.706667-30.08 265.813333 265.813333 0 0 1-82.944 25.344 257.152 257.152 0 0 1-24.448 2.133333 264.618667 264.618667 0 0 0 4.906667-39.594666 276.352 276.352 0 0 0 0.341333-13.312 268.373333 268.373333 0 0 0-6.058667-56.832 265.984 265.984 0 0 1-90.453333 33.109333l-0.213333-0.298667a263.594667 263.594667 0 0 0 4.736-37.802666 239.658667 239.658667 0 0 0 0.426666-14.506667c0-16.128-1.450667-32.256-4.352-48.128a301.098667 301.098667 0 0 1-218.325333 93.354667 300.501333 300.501333 0 0 1-138.538667-33.621334 267.221333 267.221333 0 0 0 55.210667-29.226666 268.8 268.8 0 0 1-152.448-242.346667 268.629333 268.629333 0 0 1 4.352-48.426667 264.362667 264.362667 0 0 1 12.885333-46.421333 264.832 264.832 0 0 1 20.650667-42.752A267.221333 267.221333 0 0 1 305.664853 37.546667 521.045333 521.045333 0 0 0 191.14752 108.8 520.832 520.832 0 0 0 13.99552 391.722667 520.362667 520.362667 0 0 0 0.000853 512.042667a518.528 518.528 0 0 0 63.573334 249.642666 266.709333 266.709333 0 0 1 18.986666-73.088 497.450667 497.450667 0 0 0 366.293334 298.410667 266.069333 266.069333 0 0 1-34.304-59.050667 469.674667 469.674667 0 0 0 133.376 22.784c4.010667 0 8.021333 0.128 12.074666 0.128a468.650667 468.650667 0 0 0 207.658667-48.170666 263.509333 263.509333 0 0 1-30.890667-20.394667 448.298667 448.298667 0 0 0 184.32-132.010667 446.677333 446.677333 0 0 0 57.856-89.301333 267.008 267.008 0 0 1-75.818666 15.616z"
fill="#F44A53"
p-id="4142"
></path>
</svg>

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -0,0 +1,15 @@
<svg
t="1710490291582"
class="icon"
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
p-id="3145"
width="200"
height="200"
>
<path
d="M476.811454 234.638085S575.875862 38.761663 627.148553 9.152912A275.775 275.775 0 0 1 707.702374 0.204763c22.66728 0.839529 111.186386 4.218121 152.753304 63.804195a84.403367 84.403367 0 0 1 4.914315 7.719571 189.938291 189.938291 0 0 1-16.196764 145.996121 204.517427 204.517427 0 0 1-131.048411 98.900597l-179.822992 34.154493a62.616569 62.616569 0 0 0 51.190785 47.83267l163.953849-2.313824a443.353156 443.353156 0 0 1-66.302306 69.373753c-65.524206 55.081285-131.048411 85.242896-177.77536 91.140075-34.400208 2.3343-68.00184-1.474295-102.012998-2.190966 0 0 17.077246 96.812014 172.00104 79.734768a152.978544 152.978544 0 0 1-17.363915 47.382191 166.861485 166.861485 0 0 1-111.432102 79.243336c-52.624128 4.607171-103.917295 2.047631-155.88618 3.173829 0 0-52.378412 189.037333-84.260034 259.639665H176.956308s14.988662-92.143414 47.976004-262.956828A311.731408 311.731408 0 0 1 170.567698 423.634466s28.032074 159.838109 124.905517 181.481573c-7.350997-129.881261-43.55312-267.420664-15.930573-385.568997a382.907077 382.907077 0 0 1 50.105541-76.294747 400.844328 400.844328 0 0 1 166.533864-115.875463s-87.679578 63.763243-66.05659 214.100342z"
p-id="3146"
></path>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -39,8 +39,19 @@ watch(route, async () => {
})
function handleMenuSelect(key, item) {
if (isExternal(item.path)) {
window.open(item.path)
if (isExternal(item.originPath)) {
$dialog.confirm({
type: 'info',
title: `请选择打开方式`,
positiveText: '外链打开',
negativeText: '在本站内嵌打开',
confirm() {
window.open(item.originPath)
},
cancel: () => {
router.push(item.path)
},
})
} else {
router.push(item.path)
}

View File

@ -40,20 +40,40 @@ export const naiveThemeOverrides = {
export const basePermissions = [
{
code: 'ExternalLink',
name: '外链',
name: '外链(可内嵌打开)',
type: 'MENU',
icon: 'i-fe:external-link',
order: 98,
enable: true,
show: true,
children: [
{
code: 'ShowDocs',
name: '项目文档',
type: 'MENU',
path: 'https://docs.isme.top/web/#/624306705/188522224',
icon: 'i-me:docs',
order: 1,
enable: true,
show: true,
},
{
code: 'ApiFoxDocs',
name: '接口文档',
type: 'MENU',
path: 'https://apifox.com/apidoc/shared-ff4a4d32-c0d1-4caf-b0ee-6abc130f734a',
icon: 'i-me:apifox',
order: 2,
enable: true,
show: true,
},
{
code: 'MyBlog',
name: '博客-掘金',
type: 'MENU',
path: 'https://juejin.cn/user/1961184475483255',
path: 'https://juejin.cn/user/1961184475483255/posts',
icon: 'i-simple-icons:juejin',
order: 1,
order: 3,
enable: true,
show: true,
},

View File

@ -6,6 +6,8 @@
* Copyright © 2023 Ronnie Zhang(大脸怪) | https://isme.top
**********************************/
import { isExternal } from '@/utils'
import { hyphenate } from '@vueuse/core'
import { defineStore } from 'pinia'
export const usePermissionStore = defineStore('permission', {
@ -31,6 +33,7 @@ export const usePermissionStore = defineStore('permission', {
label: route.meta.title,
key: route.name,
path: route.path,
originPath: route.meta.originPath,
icon: () => h('i', { class: `${route.meta.icon}?mask text-16` }),
order: item.order ?? 0,
}
@ -45,12 +48,19 @@ export const usePermissionStore = defineStore('permission', {
return menuItem
},
generateRoute(item, parentKey) {
let originPath = undefined
if (isExternal(item.path)) {
originPath = item.path
item.component = '/src/views/iframe/index.vue'
item.path = `/iframe/${hyphenate(item.code)}`
}
return {
name: item.code,
path: item.path,
redirect: item.redirect,
component: item.component,
meta: {
originPath,
icon: item.icon,
title: item.name,
layout: item.layout,

View File

@ -0,0 +1,9 @@
<template>
<AppPage full>
<iframe :src="route.meta.originPath" frameborder="0" class="wh-full"></iframe>
</AppPage>
</template>
<script setup>
const route = useRoute()
</script>