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 30d40572
authored
Jul 20, 2024
by
vben
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat: add tabs demo
1 parent
1fbf69e6
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
47 additions
and
39 deletions
apps/backend-mock/utils/mock-data.ts
apps/web-antd/src/views/demos/features/tabs/index.vue
internal/tailwind-config/package.json
internal/tailwind-config/src/index.ts
packages/@core/forward/stores/src/modules/tabbar.ts
packages/@core/hooks/src/use-tabs.ts
packages/@core/ui-kit/tabs-ui/src/components/tabs-chrome/tabs.vue
packages/@core/ui-kit/tabs-ui/src/components/tabs/tabs.vue
packages/effects/layouts/src/basic/tabbar/use-tabbar.ts
pnpm-lock.yaml
apps/backend-mock/utils/mock-data.ts
View file @
30d4057
...
@@ -114,7 +114,7 @@ const createDemosMenus = (role: 'admin' | 'super' | 'user') => {
...
@@ -114,7 +114,7 @@ const createDemosMenus = (role: 'admin' | 'super' | 'user') => {
},
},
name
:
'Demos'
,
name
:
'Demos'
,
path
:
'/demos'
,
path
:
'/demos'
,
redirect
:
'/access'
,
redirect
:
'/
demos/
access'
,
children
:
[
children
:
[
{
{
name
:
'Access'
,
name
:
'Access'
,
...
@@ -173,6 +173,6 @@ export const MOCK_MENUS = [
...
@@ -173,6 +173,6 @@ export const MOCK_MENUS = [
},
},
{
{
menus
:
[...
dashboardMenus
,
...
createDemosMenus
(
'user'
)],
menus
:
[...
dashboardMenus
,
...
createDemosMenus
(
'user'
)],
username
:
'
user
'
,
username
:
'
jack
'
,
},
},
];
];
apps/web-antd/src/views/demos/features/tabs/index.vue
View file @
30d4057
<
script
lang=
"ts"
setup
>
<
script
lang=
"ts"
setup
>
import
{
ref
}
from
'vue'
;
import
{
useRouter
}
from
'vue-router'
;
import
{
useRouter
}
from
'vue-router'
;
import
{
useTabs
}
from
'@vben/hooks'
;
import
{
useTabs
}
from
'@vben/hooks'
;
import
{
Button
}
from
'ant-design-vue'
;
import
{
Input
as
AInput
,
Button
}
from
'ant-design-vue'
;
defineOptions
({
name
:
'FeatureTabsDemo'
});
defineOptions
({
name
:
'FeatureTabsDemo'
});
const
router
=
useRouter
();
const
router
=
useRouter
();
// const newTabTitle = ref('');
const
newTabTitle
=
ref
(
''
);
const
{
const
{
closeAllTabs
,
closeAllTabs
,
closeCurrentTab
,
closeCurrentTab
,
...
@@ -17,12 +19,19 @@ const {
...
@@ -17,12 +19,19 @@ const {
closeRightTabs
,
closeRightTabs
,
closeTabByKey
,
closeTabByKey
,
refreshTab
,
refreshTab
,
resetTabTitle
,
setTabTitle
,
}
=
useTabs
();
}
=
useTabs
();
function
openTab
()
{
function
openTab
()
{
// 这里就是路由跳转,也可以用path
// 这里就是路由跳转,也可以用path
router
.
push
({
name
:
'VbenAbout'
});
router
.
push
({
name
:
'VbenAbout'
});
}
}
function
reset
()
{
newTabTitle
.
value
=
''
;
resetTabTitle
();
}
</
script
>
</
script
>
<
template
>
<
template
>
...
@@ -58,7 +67,7 @@ function openTab() {
...
@@ -58,7 +67,7 @@ function openTab() {
<Button
type=
"primary"
@
click=
"closeRightTabs()"
>
<Button
type=
"primary"
@
click=
"closeRightTabs()"
>
关闭右侧标签页
关闭右侧标签页
</Button>
</Button>
<Button
type=
"primary"
@
click=
"closeAllTabs()"
>
打开
所有标签页
</Button>
<Button
type=
"primary"
@
click=
"closeAllTabs()"
>
关闭
所有标签页
</Button>
<Button
type=
"primary"
@
click=
"closeOtherTabs()"
>
<Button
type=
"primary"
@
click=
"closeOtherTabs()"
>
关闭其他标签页
关闭其他标签页
</Button>
</Button>
...
@@ -71,16 +80,17 @@ function openTab() {
...
@@ -71,16 +80,17 @@ function openTab() {
<div
class=
"text-foreground/80 my-3"
>
<div
class=
"text-foreground/80 my-3"
>
该操作不会影响页面标题,仅修改Tab标题
该操作不会影响页面标题,仅修改Tab标题
</div>
</div>
<
!--
<
div
class=
"flex flex-wrap items-center gap-3"
>
<div
class=
"flex flex-wrap items-center gap-3"
>
<Input
<
A
Input
v-model=
"newTabTitle"
v-model
:value
=
"newTabTitle"
class=
"w-
3
0"
class=
"w-
4
0"
placeholder=
"请输入新
的
标题"
placeholder=
"请输入新标题"
/>
/>
<Button
type=
"primary"
@
click=
"
closeCurrentTab(
)"
>
<Button
type=
"primary"
@
click=
"
() => setTabTitle(newTabTitle
)"
>
关闭当前标签页
{{
newTabTitle
}}
修改
</Button>
</Button>
</div>
-->
<Button
@
click=
"reset"
>
重置
</Button>
</div>
</div>
</div>
</div>
</div>
</
template
>
</
template
>
internal/tailwind-config/package.json
View file @
30d4057
...
@@ -49,7 +49,6 @@
...
@@ -49,7 +49,6 @@
"dependencies"
:
{
"dependencies"
:
{
"@iconify/json"
:
"^2.2.229"
,
"@iconify/json"
:
"^2.2.229"
,
"@iconify/tailwind"
:
"^1.1.1"
,
"@iconify/tailwind"
:
"^1.1.1"
,
"@tailwindcss/forms"
:
"^0.5.7"
,
"@tailwindcss/nesting"
:
"0.0.0-insiders.565cd3e"
,
"@tailwindcss/nesting"
:
"0.0.0-insiders.565cd3e"
,
"@tailwindcss/typography"
:
"^0.5.13"
,
"@tailwindcss/typography"
:
"^0.5.13"
,
"autoprefixer"
:
"^10.4.19"
,
"autoprefixer"
:
"^10.4.19"
,
...
...
internal/tailwind-config/src/index.ts
View file @
30d4057
...
@@ -5,7 +5,6 @@ import path from 'node:path';
...
@@ -5,7 +5,6 @@ import path from 'node:path';
import
{
fs
,
getPackagesSync
}
from
'@vben/node-utils'
;
import
{
fs
,
getPackagesSync
}
from
'@vben/node-utils'
;
import
{
addDynamicIconSelectors
}
from
'@iconify/tailwind'
;
import
{
addDynamicIconSelectors
}
from
'@iconify/tailwind'
;
import
formsPlugin
from
'@tailwindcss/forms'
;
import
typographyPlugin
from
'@tailwindcss/typography'
;
import
typographyPlugin
from
'@tailwindcss/typography'
;
import
animate
from
'tailwindcss-animate'
;
import
animate
from
'tailwindcss-animate'
;
...
@@ -123,7 +122,6 @@ export default {
...
@@ -123,7 +122,6 @@ export default {
darkMode
:
'selector'
,
darkMode
:
'selector'
,
plugins
:
[
plugins
:
[
animate
,
animate
,
formsPlugin
,
typographyPlugin
,
typographyPlugin
,
addDynamicIconSelectors
(),
addDynamicIconSelectors
(),
enterAnimationPlugin
,
enterAnimationPlugin
,
...
...
packages/@core/forward/stores/src/modules/tabbar.ts
View file @
30d4057
...
@@ -28,6 +28,10 @@ interface TabsState {
...
@@ -28,6 +28,10 @@ interface TabsState {
* @zh_CN 当前打开的标签页列表
* @zh_CN 当前打开的标签页列表
*/
*/
tabs
:
TabDefinition
[];
tabs
:
TabDefinition
[];
/**
* @zh_CN 更新时间,用于一些更新场景,使用watch深度监听的话,会损耗性能
*/
updateTime
?:
number
;
}
}
/**
/**
...
@@ -306,11 +310,17 @@ const useCoreTabbarStore = defineStore('core-tabbar', {
...
@@ -306,11 +310,17 @@ const useCoreTabbarStore = defineStore('core-tabbar', {
const
findTab
=
this
.
tabs
.
find
(
const
findTab
=
this
.
tabs
.
find
(
(
item
)
=>
getTabPath
(
item
)
===
getTabPath
(
tab
),
(
item
)
=>
getTabPath
(
item
)
===
getTabPath
(
tab
),
);
);
if
(
findTab
)
{
if
(
findTab
)
{
findTab
.
meta
.
newTabTitle
=
title
;
findTab
.
meta
.
newTabTitle
=
title
;
await
this
.
updateCacheTab
();
await
this
.
updateCacheTab
();
}
}
},
},
async
setUpdateTime
()
{
this
.
updateTime
=
Date
.
now
();
},
/**
/**
* @zh_CN 设置标签页顺序
* @zh_CN 设置标签页顺序
* @param oldIndex
* @param oldIndex
...
@@ -399,6 +409,7 @@ const useCoreTabbarStore = defineStore('core-tabbar', {
...
@@ -399,6 +409,7 @@ const useCoreTabbarStore = defineStore('core-tabbar', {
excludeCachedTabs
:
new
Set
(),
excludeCachedTabs
:
new
Set
(),
renderRouteView
:
true
,
renderRouteView
:
true
,
tabs
:
[],
tabs
:
[],
updateTime
:
Date
.
now
(),
}),
}),
});
});
...
...
packages/@core/hooks/src/use-tabs.ts
View file @
30d4057
...
@@ -52,10 +52,12 @@ export function useTabs() {
...
@@ -52,10 +52,12 @@ export function useTabs() {
}
}
async
function
setTabTitle
(
title
:
string
)
{
async
function
setTabTitle
(
title
:
string
)
{
coreTabbarStore
.
setUpdateTime
();
await
coreTabbarStore
.
setTabTitle
(
route
,
title
);
await
coreTabbarStore
.
setTabTitle
(
route
,
title
);
}
}
async
function
resetTabTitle
()
{
async
function
resetTabTitle
()
{
coreTabbarStore
.
setUpdateTime
();
await
coreTabbarStore
.
resetTabTitle
(
route
);
await
coreTabbarStore
.
resetTabTitle
(
route
);
}
}
...
...
packages/@core/ui-kit/tabs-ui/src/components/tabs-chrome/tabs.vue
View file @
30d4057
...
@@ -49,7 +49,7 @@ const tabsView = computed((): TabConfig[] => {
...
@@ -49,7 +49,7 @@ const tabsView = computed((): TabConfig[] => {
:
true
,
:
true
,
icon
:
tab
.
meta
.
icon
as
string
,
icon
:
tab
.
meta
.
icon
as
string
,
key
:
tab
.
fullPath
||
tab
.
path
,
key
:
tab
.
fullPath
||
tab
.
path
,
title
:
(
tab
.
meta
?.
title
||
tab
.
name
)
as
string
,
title
:
(
tab
.
meta
?.
newTabTitle
||
tab
.
meta
?.
title
||
tab
.
name
)
as
string
,
};
};
});
});
});
});
...
...
packages/@core/ui-kit/tabs-ui/src/components/tabs/tabs.vue
View file @
30d4057
...
@@ -50,7 +50,7 @@ const tabsView = computed((): TabConfig[] => {
...
@@ -50,7 +50,7 @@ const tabsView = computed((): TabConfig[] => {
:
true
,
:
true
,
icon
:
tab
.
meta
.
icon
as
string
,
icon
:
tab
.
meta
.
icon
as
string
,
key
:
tab
.
fullPath
||
tab
.
path
,
key
:
tab
.
fullPath
||
tab
.
path
,
title
:
(
tab
.
meta
?.
title
||
tab
.
name
)
as
string
,
title
:
(
tab
.
meta
?.
newTabTitle
||
tab
.
meta
?.
title
||
tab
.
name
)
as
string
,
};
};
});
});
});
});
...
...
packages/effects/layouts/src/basic/tabbar/use-tabbar.ts
View file @
30d4057
...
@@ -55,9 +55,16 @@ export function useTabbar() {
...
@@ -55,9 +55,16 @@ export function useTabbar() {
const
{
locale
}
=
useI18n
();
const
{
locale
}
=
useI18n
();
const
currentTabs
=
ref
<
RouteLocationNormalizedGeneric
[]
>
();
const
currentTabs
=
ref
<
RouteLocationNormalizedGeneric
[]
>
();
watch
([()
=>
coreTabbarStore
.
getTabs
,
()
=>
locale
.
value
],
([
tabs
,
_
])
=>
{
watch
(
[
()
=>
coreTabbarStore
.
getTabs
,
()
=>
coreTabbarStore
.
updateTime
,
()
=>
locale
.
value
,
],
([
tabs
])
=>
{
currentTabs
.
value
=
tabs
.
map
((
item
)
=>
wrapperTabLocale
(
item
));
currentTabs
.
value
=
tabs
.
map
((
item
)
=>
wrapperTabLocale
(
item
));
});
},
);
/**
/**
* 初始化固定标签页
* 初始化固定标签页
...
...
pnpm-lock.yaml
View file @
30d4057
...
@@ -368,9 +368,6 @@ importers:
...
@@ -368,9 +368,6 @@ importers:
'
@iconify/tailwind'
:
'
@iconify/tailwind'
:
specifier
:
^1.1.1
specifier
:
^1.1.1
version
:
1.1.1
version
:
1.1.1
'
@tailwindcss/forms'
:
specifier
:
^0.5.7
version
:
0.5.7(tailwindcss@3.4.6(ts-node@10.9.2(@types/node@20.14.11)(typescript@5.5.3)))
'
@tailwindcss/nesting'
:
'
@tailwindcss/nesting'
:
specifier
:
0.0.0-insiders.565cd3e
specifier
:
0.0.0-insiders.565cd3e
version
:
0.0.0-insiders.565cd3e(postcss@8.4.39)
version
:
0.0.0-insiders.565cd3e(postcss@8.4.39)
...
@@ -3498,11 +3495,6 @@ packages:
...
@@ -3498,11 +3495,6 @@ packages:
'
@swc/helpers@0.5.12'
:
'
@swc/helpers@0.5.12'
:
resolution
:
{
integrity
:
sha512-KMZNXiGibsW9kvZAO1Pam2JPTDBm+KSHMMHWdsyI/1DbIZjT2A6Gy3hblVXUMEDvUAKq+e0vL0X0o54owWji7g==
}
resolution
:
{
integrity
:
sha512-KMZNXiGibsW9kvZAO1Pam2JPTDBm+KSHMMHWdsyI/1DbIZjT2A6Gy3hblVXUMEDvUAKq+e0vL0X0o54owWji7g==
}
'
@tailwindcss/forms@0.5.7'
:
resolution
:
{
integrity
:
sha512-QE7X69iQI+ZXwldE+rzasvbJiyV/ju1FGHH0Qn2W3FKbuYtqp8LKcy6iSw79fVUT5/Vvf+0XgLCeYVG+UV6hOw==
}
peerDependencies
:
tailwindcss
:
'
>=3.0.0
||
>=
3.0.0-alpha.1'
'
@tailwindcss/nesting@0.0.0-insiders.565cd3e'
:
'
@tailwindcss/nesting@0.0.0-insiders.565cd3e'
:
resolution
:
{
integrity
:
sha512-WhHoFBx19TnH/c+xLwT/sxei6+4RpdfiyG3MYXfmLaMsADmVqBkF7B6lDalgZD9YdM459MF7DtxVbWkOrV7IaQ==
}
resolution
:
{
integrity
:
sha512-WhHoFBx19TnH/c+xLwT/sxei6+4RpdfiyG3MYXfmLaMsADmVqBkF7B6lDalgZD9YdM459MF7DtxVbWkOrV7IaQ==
}
peerDependencies
:
peerDependencies
:
...
@@ -6511,10 +6503,6 @@ packages:
...
@@ -6511,10 +6503,6 @@ packages:
resolution
:
{
integrity
:
sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==
}
resolution
:
{
integrity
:
sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==
}
engines
:
{
node
:
'
>=4'
}
engines
:
{
node
:
'
>=4'
}
mini-svg-data-uri@1.4.4
:
resolution
:
{
integrity
:
sha512-r9deDe9p5FJUPZAk3A59wGH7Ii9YrjjWw0jmw/liSbHl2CHiyXj6FcDXDu2K3TjVAXqiJdaw3xxwlZZr9E6nHg==
}
hasBin
:
true
minimatch@10.0.1
:
minimatch@10.0.1
:
resolution
:
{
integrity
:
sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==
}
resolution
:
{
integrity
:
sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==
}
engines
:
{
node
:
20 || >=22
}
engines
:
{
node
:
20 || >=22
}
...
@@ -11971,11 +11959,6 @@ snapshots:
...
@@ -11971,11 +11959,6 @@ snapshots:
dependencies
:
dependencies
:
tslib
:
2.6.3
tslib
:
2.6.3
'
@tailwindcss/forms@0.5.7(tailwindcss@3.4.6(ts-node@10.9.2(@types/node@20.14.11)(typescript@5.5.3)))'
:
dependencies
:
mini-svg-data-uri
:
1.4.4
tailwindcss
:
3.4.6(ts-node@10.9.2(@types/node@20.14.11)(typescript@5.5.3))
'
@tailwindcss/nesting@0.0.0-insiders.565cd3e(postcss@8.4.39)'
:
'
@tailwindcss/nesting@0.0.0-insiders.565cd3e(postcss@8.4.39)'
:
dependencies
:
dependencies
:
postcss
:
8.4.39
postcss
:
8.4.39
...
@@ -15417,8 +15400,6 @@ snapshots:
...
@@ -15417,8 +15400,6 @@ snapshots:
min-indent@1.0.1
:
{}
min-indent@1.0.1
:
{}
mini-svg-data-uri@1.4.4
:
{}
minimatch@10.0.1
:
minimatch@10.0.1
:
dependencies
:
dependencies
:
brace-expansion
:
2.0.1
brace-expansion
:
2.0.1
...
...
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