Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
monorepo
/
venus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit d1cdea43
authored
May 22, 2024
by
vben
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat(project): support dynamic title
1 parent
e83adf06
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
44 additions
and
4 deletions
apps/antd-view/package.json
apps/antd-view/src/router/guard/index.ts
apps/antd-view/vite.config.mts
packages/@vben-core/shared/design-tokens/src/dark/index.scss
packages/@vben-core/shared/typings/src/preference.ts
packages/@vben-core/shared/typings/src/tools.ts
packages/@vben-core/uikit/shadcn-ui/src/components/logo/logo.vue
packages/business/common-ui/package.json
packages/business/common-ui/src/preference/blocks/general/general.vue
packages/business/common-ui/src/preference/preference-widget.vue
packages/business/common-ui/src/preference/preference.vue
packages/locales/src/langs/en-US.yaml
packages/locales/src/langs/zh-CN.yaml
packages/preference/src/config.ts
pnpm-lock.yaml
apps/antd-view/package.json
View file @
d1cdea4
...
...
@@ -35,6 +35,7 @@
"@vben/styles"
:
"workspace:*"
,
"@vben/types"
:
"workspace:*"
,
"@vben/utils"
:
"workspace:*"
,
"@vueuse/core"
:
"^10.9.0"
,
"ant-design-vue"
:
"^4.2.1"
,
"axios"
:
"^1.7.1"
,
"dayjs"
:
"^1.11.11"
,
...
...
apps/antd-view/src/router/guard/index.ts
View file @
d1cdea4
import
type
{
Router
}
from
'vue-router'
;
import
{
$t
}
from
'@vben/locales'
;
import
{
preference
}
from
'@vben/preference'
;
import
{
startProgress
,
stopProgress
}
from
'@vben/utils'
;
import
{
useTitle
}
from
'@vueuse/core'
;
import
{
configAccessGuard
}
from
'./access'
;
...
...
@@ -26,6 +28,12 @@ function configCommonGuard(router: Router) {
if
(
preference
.
pageProgress
)
{
stopProgress
();
}
// 动态修改标题
if
(
preference
.
dynamicTitle
)
{
const
{
title
}
=
to
.
meta
;
useTitle
(
`
${
$t
(
title
)}
-
${
preference
.
appName
}
`
);
}
});
}
...
...
apps/antd-view/vite.config.mts
View file @
d1cdea4
...
...
@@ -18,7 +18,7 @@ export default defineConfig({
{ name: 'vue-demi' },
],
},
visualizer:
tru
e,
visualizer:
fals
e,
},
vite: {
server: {
...
...
packages/@vben-core/shared/design-tokens/src/dark/index.scss
View file @
d1cdea4
.dark
{
:root
.dark
{
/* 基础背景颜色颜色 */
/* --color-background: 240 6% 18%; */
...
...
packages/@vben-core/shared/typings/src/preference.ts
View file @
d1cdea4
...
...
@@ -55,6 +55,8 @@ interface Preference {
copyright
:
string
;
/** 应用默认头像 */
defaultAvatar
:
string
;
/** 开启动态标题 */
dynamicTitle
:
boolean
;
/** 页脚是否固定 */
footerFixed
:
boolean
;
/** 页脚是否可见 */
...
...
packages/@vben-core/shared/typings/src/tools.ts
View file @
d1cdea4
import
{
type
ComputedRef
,
type
MaybeRef
}
from
'vue'
;
/**
* 深
度部分类型
* 深
层递归所有属性为可选
*/
type
DeepPartial
<
T
>
=
T
extends
object
?
{
...
...
@@ -10,6 +10,13 @@ type DeepPartial<T> = T extends object
:
T
;
/**
* 深层递归所有属性为只读
*/
type
DeepReadonly
<
T
>
=
{
readonly
[
P
in
keyof
T
]:
T
[
P
]
extends
object
?
DeepReadonly
<
T
[
P
]
>
:
T
[
P
];
};
/**
* 任意类型的异步函数
*/
...
...
@@ -78,6 +85,7 @@ export {
type
AnyNormalFunction
,
type
AnyPromiseFunction
,
type
DeepPartial
,
type
DeepReadonly
,
type
IntervalHandle
,
type
MaybeComputedRef
,
type
MaybeReadonlyRef
,
...
...
packages/@vben-core/uikit/shadcn-ui/src/components/logo/logo.vue
View file @
d1cdea4
...
...
@@ -69,6 +69,7 @@ const logoClass = computed(() => {
/>
<span
v-if=
"!collapse"
class=
"truncate text-nowrap"
>
{{
text
}}
<!--
<span
class=
"text-primary ml-1 align-super text-[smaller]"
>
Pro
</span>
-->
</span>
</a>
</div>
...
...
packages/business/common-ui/package.json
View file @
d1cdea4
...
...
@@ -42,6 +42,9 @@
}
}
},
"peerDependencies"
:
{
"@vben-core/design"
:
"workspace:*"
},
"dependencies"
:
{
"@vben-core/design"
:
"workspace:*"
,
"@vben-core/iconify"
:
"workspace:*"
,
...
...
packages/business/common-ui/src/preference/blocks/general/general.vue
View file @
d1cdea4
...
...
@@ -5,12 +5,14 @@ import { $t } from '@vben/locales';
import
{
staticPreference
}
from
'@vben/preference'
;
import
SelectItem
from
'../select-item.vue'
;
import
SwitchItem
from
'../switch-item.vue'
;
defineOptions
({
name
:
'PreferenceGeneralConfig'
,
});
const
locale
=
defineModel
<
string
>
(
'locale'
);
const
dynamicTitle
=
defineModel
<
boolean
>
(
'dynamicTitle'
);
const
localeItems
:
SelectListItem
[]
=
staticPreference
.
supportLanguages
.
map
(
(
item
)
=>
({
...
...
@@ -24,4 +26,7 @@ const localeItems: SelectListItem[] = staticPreference.supportLanguages.map(
<SelectItem
v-model=
"locale"
:items=
"localeItems"
>
{{
$t
(
'preference.language'
)
}}
</SelectItem>
<SwitchItem
v-model=
"dynamicTitle"
>
{{
$t
(
'preference.dynamic-title'
)
}}
</SwitchItem>
</
template
>
packages/business/common-ui/src/preference/preference-widget.vue
View file @
d1cdea4
...
...
@@ -46,6 +46,7 @@ function updateLocale(value: string) {
:footer-fixed=
"preference.footerFixed"
:header-mode=
"preference.headerMode"
:theme=
"preference.theme"
:dynamic-title=
"preference.dynamicTitle"
:breadcrumb-hide-only-one=
"preference.breadcrumbHideOnlyOne"
:page-transition=
"preference.pageTransition"
:page-progress=
"preference.pageProgress"
...
...
@@ -55,6 +56,7 @@ function updateLocale(value: string) {
:side-collapse-show-title=
"preference.sideCollapseShowTitle"
:page-transition-enable=
"preference.pageTransitionEnable"
@
update:navigation-style=
"(value) => handleUpdate('navigationStyle', value)"
@
update:dynamic-title=
"(value) => handleUpdate('dynamicTitle', value)"
@
update:tabs-icon=
"(value) => handleUpdate('tabsIcon', value)"
@
update:side-collapse=
"(value) => handleUpdate('sideCollapse', value)"
@
update:locale=
"updateLocale"
...
...
packages/business/common-ui/src/preference/preference.vue
View file @
d1cdea4
...
...
@@ -40,6 +40,7 @@ withDefaults(defineProps<{ colorPrimaryPresets: string[] }>(), {
const
theme
=
defineModel
<
string
>
(
'theme'
);
const
locale
=
defineModel
<
string
>
(
'locale'
);
const
dynamicTitle
=
defineModel
<
boolean
>
(
'dynamicTitle'
);
const
semiDarkMenu
=
defineModel
<
boolean
>
(
'semiDarkMenu'
);
const
breadcrumbVisible
=
defineModel
<
boolean
>
(
'breadcrumbVisible'
);
const
breadcrumbIcon
=
defineModel
<
boolean
>
(
'breadcrumbIcon'
);
...
...
@@ -210,7 +211,10 @@ function handleReset() {
</
template
>
<
template
#
general
>
<Block
:title=
"$t('preference.general')"
>
<General
v-model:locale=
"locale"
/>
<General
v-model:locale=
"locale"
v-model:dynamic-title=
"dynamicTitle"
/>
</Block>
<Block
:title=
"$t('preference.navigation-menu')"
>
<Navigation
...
...
packages/locales/src/langs/en-US.yaml
View file @
d1cdea4
...
...
@@ -69,6 +69,7 @@ preference:
gray-mode
:
Gray Mode
animation
:
Animation
language
:
Language
dynamic-title
:
Dynamic Title
normal
:
Normal
rounded
:
Rounded
collapse
:
Collpase Menu
...
...
packages/locales/src/langs/zh-CN.yaml
View file @
d1cdea4
...
...
@@ -51,6 +51,7 @@ preference:
dark
:
深色
dark-menu
:
深色菜单
language
:
语言
dynamic-title
:
动态标题
collapse
:
折叠菜单
collapse-show-title
:
显示菜单名
wide
:
流式
...
...
packages/preference/src/config.ts
View file @
d1cdea4
...
...
@@ -16,6 +16,7 @@ const defaultPreference: Preference = {
copyright
:
'Copyright © 2024 Vben Admin PRO'
,
defaultAvatar
:
'https://cdn.jsdelivr.net/gh/vbenjs/vben-cdn-static@0.1.2/vben-admin/pro-avatar.webp'
,
dynamicTitle
:
true
,
footerFixed
:
true
,
footerVisible
:
true
,
headerMode
:
'fixed'
,
...
...
pnpm-lock.yaml
View file @
d1cdea4
...
...
@@ -126,6 +126,9 @@ importers:
'
@vben/utils'
:
specifier
:
workspace:*
version
:
link:../../packages/utils
'
@vueuse/core'
:
specifier
:
^10.9.0
version
:
10.9.0(vue@3.4.27(typescript@5.4.5))
ant-design-vue
:
specifier
:
^4.2.1
version
:
4.2.1(vue@3.4.27(typescript@5.4.5))
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment