This commit is contained in:
Xou 2024-04-28 09:22:34 +08:00
parent d5b1a47cbb
commit a295ca2166
9 changed files with 23 additions and 23 deletions

View File

@ -11,8 +11,8 @@ export function setupRouterGuard(router: Router) {
router.beforeEach(async (to, from, next) => { router.beforeEach(async (to, from, next) => {
// 判断是否是外链,如果是直接打开网页并拦截跳转 // 判断是否是外链,如果是直接打开网页并拦截跳转
if (to.meta.herf) { if (to.meta.href) {
window.open(to.meta.herf) window.open(to.meta.href)
return false return false
} }
// 开始 loadingBar // 开始 loadingBar

View File

@ -260,7 +260,7 @@ export const staticRoutes: AppRoute.RowRoute[] = [
'meta.title': 'VueUse外链', 'meta.title': 'VueUse外链',
'meta.requiresAuth': true, 'meta.requiresAuth': true,
'meta.icon': 'logos:vueuse', 'meta.icon': 'logos:vueuse',
'meta.herf': 'https://vueuse.org/guide/', 'meta.href': 'https://vueuse.org/guide/',
'componentPath': 'null', 'componentPath': 'null',
'id': 27, 'id': 27,
'pid': 24, 'pid': 24,

View File

@ -1,7 +1,7 @@
import { blankInstance, request } from '../http' import { blankInstance, request } from '../http'
/* get方法测试 */ /* get方法测试 */
export function fetachGet(params?: any) { export function fetchGet(params?: any) {
return request.Get('/getAPI', { params }) return request.Get('/getAPI', { params })
} }
@ -53,7 +53,7 @@ export function dictData() {
export function getBlob(url: string) { export function getBlob(url: string) {
const methodInstance = blankInstance.Get<Blob>(url) const methodInstance = blankInstance.Get<Blob>(url)
methodInstance.meta = { methodInstance.meta = {
// 标识为bolb数据 // 标识为blob数据
isBlob: true, isBlob: true,
} }
return methodInstance return methodInstance
@ -66,7 +66,7 @@ export function downloadFile(url: string) {
enableDownload: true, enableDownload: true,
}) })
methodInstance.meta = { methodInstance.meta = {
// 标识为bolb数据 // 标识为blob数据
isBlob: true, isBlob: true,
} }
return methodInstance return methodInstance

View File

@ -18,7 +18,7 @@ declare namespace AppRoute {
/* 菜单排序。 */ /* 菜单排序。 */
order?: number order?: number
/* 嵌套外链 */ /* 嵌套外链 */
herf?: string href?: string
/** 当前路由不在左侧菜单显示,但需要高亮某个菜单的情况 */ /** 当前路由不在左侧菜单显示,但需要高亮某个菜单的情况 */
activeMenu?: string activeMenu?: string
/** 当前路由是否会被添加到Tab中 */ /** 当前路由是否会被添加到Tab中 */

View File

@ -5,7 +5,7 @@ const text = ref('nova-admin')
<template> <template>
<n-card title="二维码"> <n-card title="二维码">
<n-alert :show-icon="false" type="info"> <n-alert :show-icon="false" type="info">
使用navieUI - QR Code 实现 使用naiveUI - QR Code 实现
</n-alert> </n-alert>
<n-qr-code :value="text" /> <n-qr-code :value="text" />
<n-input v-model:value="text" :maxlength="60" type="text" /> <n-input v-model:value="text" :maxlength="60" type="text" />

View File

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { import {
fetachGet, fetchGet,
} from '@/service' } from '@/service'
const emit = defineEmits<{ const emit = defineEmits<{
@ -8,7 +8,7 @@ const emit = defineEmits<{
}>() }>()
async function pinterEnv() { async function pinterEnv() {
const res = await fetachGet({ a: 112211, b: false }) const res = await fetchGet({ a: 112211, b: false })
emit('update', res) emit('update', res)
} }
</script> </script>

View File

@ -1,21 +1,21 @@
<script setup lang="ts"> <script setup lang="ts">
import { useRequest } from 'alova' import { useRequest } from 'alova'
import { import {
fetachGet, fetchGet,
} from '@/service' } from '@/service'
const emit = defineEmits<{ const emit = defineEmits<{
update: [data: any] // update: [data: any] //
}>() }>()
const { data: fetachGetData, send: sendFetachGet } = useRequest(fetachGet({ a: 112211 }), { const { data: fetchGetData, send: sendFetchGet } = useRequest(fetchGet({ a: 112211 }), {
// immediatefalse // immediatefalse
immediate: false, immediate: false,
}) })
async function handleRequestHook() { async function handleRequestHook() {
await sendFetachGet() await sendFetchGet()
emit('update', fetachGetData.value) emit('update', fetchGetData.value)
} }
</script> </script>

View File

@ -7,9 +7,9 @@ import {
dictData, dictData,
downloadFile, downloadFile,
expiredTokenRequest, expiredTokenRequest,
fetachGet,
fetchDelete, fetchDelete,
fetchFormPost, fetchFormPost,
fetchGet,
fetchPost, fetchPost,
fetchPut, fetchPut,
fetchUpdateToken, fetchUpdateToken,
@ -18,20 +18,20 @@ import {
} from '@/service' } from '@/service'
const msg = ref() const msg = ref()
const { data: fetachGetData, send: sendFetachGet } = useRequest(fetachGet({ a: 112211 }), { const { data: fetchGetData, send: sendFetchGet } = useRequest(fetchGet({ a: 112211 }), {
// immediatefalse // immediatefalse
immediate: false, immediate: false,
}) })
function handleRequestHook() { function handleRequestHook() {
sendFetachGet() sendFetchGet()
msg.value = fetachGetData.value msg.value = fetchGetData.value
} }
function pinterEnv() { function pinterEnv() {
msg.value = import.meta.env msg.value = import.meta.env
} }
async function get() { async function get() {
const res = await fetachGet({ a: 112211, b: false }) const res = await fetchGet({ a: 112211, b: false })
msg.value = res msg.value = res
} }
function delete2() { function delete2() {

View File

@ -32,7 +32,7 @@ const defaultFormModal: AppRoute.RowRoute = {
'meta.keepAlive': false, 'meta.keepAlive': false,
'meta.hide': false, 'meta.hide': false,
'meta.order': undefined, 'meta.order': undefined,
'meta.herf': undefined, 'meta.href': undefined,
'meta.activeMenu': undefined, 'meta.activeMenu': undefined,
'meta.withoutTab': true, 'meta.withoutTab': true,
'meta.pinTab': false, 'meta.pinTab': false,
@ -160,7 +160,7 @@ const rules = {
message: '请输入菜单标题', message: '请输入菜单标题',
trigger: 'blur', trigger: 'blur',
}, },
'meta.herf': { 'meta.href': {
validator(rule: FormItemRule, value: string) { validator(rule: FormItemRule, value: string) {
if (!new RegExp(Regex.Url).test(value)) if (!new RegExp(Regex.Url).test(value))
return new Error('请输入正确的URL地址') return new Error('请输入正确的URL地址')
@ -244,12 +244,12 @@ const options = [
</template> </template>
<n-input-number v-model:value="formModel['meta.order']" /> <n-input-number v-model:value="formModel['meta.order']" />
</n-form-item-grid-item> </n-form-item-grid-item>
<n-form-item-grid-item v-if="formModel['meta.menuType'] === 'page'" :span="1" path="meta.herf"> <n-form-item-grid-item v-if="formModel['meta.menuType'] === 'page'" :span="1" path="meta.href">
<template #label> <template #label>
外链页面 外链页面
<HelpInfo message="填写后,点击菜单将跳转到该地址,组件路径任意填写" /> <HelpInfo message="填写后,点击菜单将跳转到该地址,组件路径任意填写" />
</template> </template>
<n-input v-model:value="formModel['meta.herf']" placeholder="Eg: https://example.com" /> <n-input v-model:value="formModel['meta.href']" placeholder="Eg: https://example.com" />
</n-form-item-grid-item> </n-form-item-grid-item>
<n-form-item-grid-item :span="1" label="登录访问" path="meta.requiresAuth"> <n-form-item-grid-item :span="1" label="登录访问" path="meta.requiresAuth">
<n-switch v-model:value="formModel['meta.requiresAuth']" /> <n-switch v-model:value="formModel['meta.requiresAuth']" />