14 changed files with 196 additions and 53 deletions
@ -1,22 +1,29 @@ |
|||
import { watch, unref } from 'vue'; |
|||
import { useI18n } from '/@/hooks/web/useI18n'; |
|||
import { useTitle as usePageTitle } from '@vueuse/core'; |
|||
import { useGlobSetting } from '/@/hooks/setting'; |
|||
import { useRouter } from 'vue-router'; |
|||
|
|||
import { REDIRECT_NAME } from '/@/router/constant'; |
|||
import { listenerRouteChange } from '/@/logics/mitt/routeChange'; |
|||
|
|||
export function useTitle() { |
|||
const { title } = useGlobSetting(); |
|||
const { t } = useI18n(); |
|||
const { currentRoute } = useRouter(); |
|||
|
|||
const pageTitle = usePageTitle(); |
|||
|
|||
listenerRouteChange((route) => { |
|||
if (route.name === REDIRECT_NAME) { |
|||
return; |
|||
} |
|||
watch( |
|||
() => currentRoute.value.path, |
|||
() => { |
|||
const route = unref(currentRoute); |
|||
if (route.name === REDIRECT_NAME) { |
|||
return; |
|||
} |
|||
|
|||
const tTitle = t(route?.meta?.title as string); |
|||
pageTitle.value = tTitle ? ` ${tTitle} - ${title} ` : `${title}`; |
|||
}); |
|||
const tTitle = t(route?.meta?.title as string); |
|||
pageTitle.value = tTitle ? ` ${tTitle} - ${title} ` : `${title}`; |
|||
}, |
|||
{ immediate: true } |
|||
); |
|||
} |
|||
|
|||
@ -1,6 +1,6 @@ |
|||
export default { |
|||
dashboard: 'Dashboard', |
|||
welcome: 'Home', |
|||
about: 'About', |
|||
workbench: 'Workbench', |
|||
analysis: 'Analysis', |
|||
}; |
|||
|
|||
@ -1,6 +1,6 @@ |
|||
export default { |
|||
dashboard: 'Dashboard', |
|||
welcome: '首页', |
|||
about: '关于', |
|||
workbench: '工作台', |
|||
analysis: '分析页', |
|||
}; |
|||
|
|||
@ -0,0 +1,11 @@ |
|||
import type { MenuModule } from '/@/router/types'; |
|||
import { t } from '/@/hooks/web/useI18n'; |
|||
|
|||
const about: MenuModule = { |
|||
orderNo: 100000, |
|||
menu: { |
|||
path: '/about/index', |
|||
name: t('routes.dashboard.about'), |
|||
}, |
|||
}; |
|||
export default about; |
|||
@ -1,11 +0,0 @@ |
|||
import type { MenuModule } from '/@/router/types'; |
|||
import { t } from '/@/hooks/web/useI18n'; |
|||
|
|||
const menu: MenuModule = { |
|||
orderNo: 0, |
|||
menu: { |
|||
path: '/home/welcome', |
|||
name: t('routes.dashboard.welcome'), |
|||
}, |
|||
}; |
|||
export default menu; |
|||
@ -0,0 +1,28 @@ |
|||
import type { AppRouteModule } from '/@/router/types'; |
|||
|
|||
import { LAYOUT } from '/@/router/constant'; |
|||
import { t } from '/@/hooks/web/useI18n'; |
|||
|
|||
const dashboard: AppRouteModule = { |
|||
path: '/about', |
|||
name: 'About', |
|||
component: LAYOUT, |
|||
redirect: '/about/index', |
|||
meta: { |
|||
icon: 'simple-icons:about-dot-me', |
|||
title: t('routes.dashboard.about'), |
|||
}, |
|||
children: [ |
|||
{ |
|||
path: 'index', |
|||
name: 'AboutPage', |
|||
component: () => import('/@/views/sys/about/index.vue'), |
|||
meta: { |
|||
title: t('routes.dashboard.about'), |
|||
icon: 'simple-icons:about-dot-me', |
|||
}, |
|||
}, |
|||
], |
|||
}; |
|||
|
|||
export default dashboard; |
|||
@ -1,29 +0,0 @@ |
|||
import type { AppRouteModule } from '/@/router/types'; |
|||
|
|||
import { LAYOUT } from '/@/router/constant'; |
|||
import { t } from '/@/hooks/web/useI18n'; |
|||
|
|||
const dashboard: AppRouteModule = { |
|||
path: '/home', |
|||
name: 'Home', |
|||
component: LAYOUT, |
|||
redirect: '/home/welcome', |
|||
meta: { |
|||
icon: 'ion:home-outline', |
|||
title: t('routes.dashboard.welcome'), |
|||
}, |
|||
children: [ |
|||
{ |
|||
path: 'welcome', |
|||
name: 'Welcome', |
|||
component: () => import('/@/views/dashboard/welcome/index.vue'), |
|||
meta: { |
|||
title: t('routes.dashboard.welcome'), |
|||
affix: true, |
|||
icon: 'bx:bx-home', |
|||
}, |
|||
}, |
|||
], |
|||
}; |
|||
|
|||
export default dashboard; |
|||
@ -0,0 +1,102 @@ |
|||
<template> |
|||
<PageWrapper title="关于"> |
|||
<template #headerContent> |
|||
<div class="flex justify-between items-center"> |
|||
<span class="flex-1"> |
|||
<a :href="GITHUB_URL" target="_blank">{{ name }}</a> |
|||
是一个基于Vue3.0、Vite、 Ant-Design-Vue 、TypeScript |
|||
的后台解决方案,目标是为中大型项目开发,提供现成的开箱解决方案及丰富的示例,原则上不会限制任何代码用于商用。 |
|||
</span> |
|||
</div> |
|||
</template> |
|||
<Description @register="infoRegister" /> |
|||
<Description @register="register" class="my-4" /> |
|||
<Description @register="registerDev" /> |
|||
</PageWrapper> |
|||
</template> |
|||
<script lang="ts"> |
|||
import { defineComponent, h } from 'vue'; |
|||
|
|||
import { Tag } from 'ant-design-vue'; |
|||
import { PageWrapper } from '/@/components/Page'; |
|||
import { Description, DescItem, useDescription } from '/@/components/Description/index'; |
|||
|
|||
import { GITHUB_URL, SITE_URL, DOC_URL } from '/@/settings/siteSetting'; |
|||
export default defineComponent({ |
|||
name: 'AboutPage', |
|||
components: { Description, PageWrapper }, |
|||
setup() { |
|||
const { pkg, lastBuildTime } = window.__APP_INFO__; |
|||
|
|||
const { dependencies, devDependencies, name, version } = pkg; |
|||
|
|||
const schema: DescItem[] = []; |
|||
const devSchema: DescItem[] = []; |
|||
const commonTagRender = (color: string) => (curVal) => h(Tag, { color }, () => curVal); |
|||
const commonLinkRender = (text: string) => (href) => h('a', { href, target: '_blank' }, text); |
|||
const infoSchema: DescItem[] = [ |
|||
{ |
|||
label: '版本', |
|||
field: 'version', |
|||
render: commonTagRender('blue'), |
|||
}, |
|||
{ |
|||
label: '最后编译时间', |
|||
field: 'lastBuildTime', |
|||
render: commonTagRender('blue'), |
|||
}, |
|||
{ |
|||
label: '文档地址', |
|||
field: 'doc', |
|||
render: commonLinkRender('文档地址'), |
|||
}, |
|||
{ |
|||
label: '预览地址', |
|||
field: 'preview', |
|||
render: commonLinkRender('预览地址'), |
|||
}, |
|||
{ |
|||
label: 'Github', |
|||
field: 'github', |
|||
render: commonLinkRender('Github'), |
|||
}, |
|||
]; |
|||
|
|||
const infoData = { |
|||
version, |
|||
lastBuildTime, |
|||
doc: DOC_URL, |
|||
preview: SITE_URL, |
|||
github: GITHUB_URL, |
|||
}; |
|||
|
|||
Object.keys(dependencies).forEach((key) => { |
|||
schema.push({ field: key, label: key }); |
|||
}); |
|||
|
|||
Object.keys(devDependencies).forEach((key) => { |
|||
devSchema.push({ field: key, label: key }); |
|||
}); |
|||
const [register] = useDescription({ |
|||
title: '生产环境依赖', |
|||
data: dependencies, |
|||
schema: schema, |
|||
column: 3, |
|||
}); |
|||
const [registerDev] = useDescription({ |
|||
title: '开发环境依赖', |
|||
data: devDependencies, |
|||
schema: devSchema, |
|||
column: 3, |
|||
}); |
|||
const [infoRegister] = useDescription({ |
|||
title: '项目信息', |
|||
data: infoData, |
|||
schema: infoSchema, |
|||
column: 2, |
|||
}); |
|||
|
|||
return { register, registerDev, infoRegister, name, GITHUB_URL }; |
|||
}, |
|||
}); |
|||
</script> |
|||
Loading…
Reference in new issue