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 c432e0ac
authored
Oct 17, 2024
by
Netfan
Committed by
GitHub
Oct 17, 2024
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat: limit the drag range of tabs, fixed #4640 (#4659)
1 parent
719c9a8f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
2 deletions
packages/@core/ui-kit/tabs-ui/src/components/tabs-chrome/tabs.vue
packages/@core/ui-kit/tabs-ui/src/components/tabs/tabs.vue
packages/@core/ui-kit/tabs-ui/src/use-tabs-drag.ts
packages/@core/ui-kit/tabs-ui/src/components/tabs-chrome/tabs.vue
View file @
c432e0a
...
@@ -69,7 +69,13 @@ const tabsView = computed((): TabConfig[] => {
...
@@ -69,7 +69,13 @@ const tabsView = computed((): TabConfig[] => {
v-for=
"(tab, i) in tabsView"
v-for=
"(tab, i) in tabsView"
:key=
"tab.key"
:key=
"tab.key"
ref=
"tabRef"
ref=
"tabRef"
:class=
"[
{ 'is-active': tab.key === active, draggable: !tab.affixTab }]"
:class=
"[
{
'is-active': tab.key === active,
draggable: !tab.affixTab,
'affix-tab': tab.affixTab,
},
]"
:data-active-tab="active"
:data-active-tab="active"
:data-index="i"
:data-index="i"
class="tabs-chrome__item draggable translate-all group relative -mr-3 flex h-full select-none items-center"
class="tabs-chrome__item draggable translate-all group relative -mr-3 flex h-full select-none items-center"
...
...
packages/@core/ui-kit/tabs-ui/src/components/tabs/tabs.vue
View file @
c432e0a
...
@@ -76,6 +76,7 @@ const tabsView = computed((): TabConfig[] => {
...
@@ -76,6 +76,7 @@ const tabsView = computed((): TabConfig[] => {
{
{
'is-active dark:bg-accent bg-primary/15': tab.key === active,
'is-active dark:bg-accent bg-primary/15': tab.key === active,
draggable: !tab.affixTab,
draggable: !tab.affixTab,
'affix-tab': tab.affixTab,
},
},
typeWithClass.content,
typeWithClass.content,
]"
]"
...
...
packages/@core/ui-kit/tabs-ui/src/use-tabs-drag.ts
View file @
c432e0a
...
@@ -81,7 +81,14 @@ export function useTabsDrag(props: TabsProps, emit: EmitType) {
...
@@ -81,7 +81,14 @@ export function useTabsDrag(props: TabsProps, emit: EmitType) {
},
},
onMove
(
evt
)
{
onMove
(
evt
)
{
const
parent
=
findParentElement
(
evt
.
related
);
const
parent
=
findParentElement
(
evt
.
related
);
return
parent
?.
classList
.
contains
(
'draggable'
)
&&
props
.
draggable
;
if
(
parent
?.
classList
.
contains
(
'draggable'
)
&&
props
.
draggable
)
{
const
isCurrentAffix
=
evt
.
dragged
.
classList
.
contains
(
'affix-tab'
);
const
isRelatedAffix
=
evt
.
related
.
classList
.
contains
(
'affix-tab'
);
// 不允许在固定的tab和非固定的tab之间互相拖拽
return
isCurrentAffix
===
isRelatedAffix
;
}
else
{
return
false
;
}
},
},
onStart
:
()
=>
{
onStart
:
()
=>
{
el
.
style
.
cursor
=
'grabbing'
;
el
.
style
.
cursor
=
'grabbing'
;
...
...
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