Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 外部页面 (#50) #58

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions src/layouts/default/sidebar/components/Menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,24 @@
404页面
</a-menu-item>
</a-sub-menu>
<a-menu-item key="sub3" @click="handleClick('/about')">
<a-sub-menu key="sub3">
<template #icon>
<CompassOutlined />
</template>
<template #title>
外部页面
</template>
<a-menu-item key="22" @click="inlineClick('inline', src.projectDocumentation)">
项目文档(内嵌)
</a-menu-item>
<a-menu-item key="23" @click="inlineClick('inline', src.componentDocumentation)">
组件库文档(内嵌)
</a-menu-item>
<a-menu-item key="24" @click="externalLinkClick(src.projectDocumentation)">
项目文档(外链)
</a-menu-item>
</a-sub-menu>
<a-menu-item key="sub4" @click="handleClick('/about')">
<template #icon>
<SettingOutlined />
</template>
Expand All @@ -61,7 +78,8 @@
import {
AppstoreOutlined,
ChromeOutlined,
SettingOutlined
SettingOutlined,
CompassOutlined
} from '@ant-design/icons-vue'

import { useCollapsed } from '~/layouts/default/useCollapsed'
Expand All @@ -72,8 +90,17 @@ const selectedKeys = ref(['1'])
const openKeys = ref(['sub1'])

const router = useRouter()

const src = {
projectDocumentation: 'https://vue-hbs-admin-docs.netlify.app/',
componentDocumentation: 'https://antdv.com/components/overview-cn'
}
const handleClick = (path: string) => {
router.push(path)
}
const inlineClick = (path: string, data: string) => {
router.push({ name: path, params: { src: data } })
}
const externalLinkClick = (path: string) => {
window.open(path)
}
</script>
6 changes: 6 additions & 0 deletions src/router/routes/modules/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ const route: RouteRecordRaw = {
path: '404',
name: '404',
component: () => import('~/views/page/not-found/index.vue')
},
{
path: 'inline',
name: 'inline',
component: () => import('~/views/page/inline/index.vue'),
props: true
}
]
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以新增一个 views/docs 目录来做文档页面,page 一开始的目的是存放错误页面,后续可能会改动。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改好提交啦

Expand Down
20 changes: 20 additions & 0 deletions src/views/page/inline/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<template>
<div class="inline">
<iframe :src="src" scrolling="auto" frameborder="0" class="inline-iframe" />
</div>
</template>
<script setup lang="ts">
defineProps({
src: { type: String }
})
</script>
<style lang="less" scoped>
.inline {
height: 100%;
width: 100%;
.inline-iframe {
width: 100%;
height: 100%;
}
}
</style>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

使用 unocss

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改好提交啦