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

Dev/tabs #329

Closed
wants to merge 1 commit into from
Closed
Changes from all 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
20 changes: 7 additions & 13 deletions src/components/CodemirrorEditor/CssEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,20 @@ function handleTabsEdit(targetName, action) {
store.addCssContentTab(value)
ElMessage.success(`新建成功~`)
})
.catch(() => {
})
}
else if (action === `remove`) {
const tabs = store.cssContentConfig.tabs
if (tabs.length === 1) {
if (tabs.length < 2) {
ElMessage.warning(`至少保留一个方案`)
return
}
let activeName = store.cssContentConfig.active
if (activeName === targetName) {
tabs.forEach((tab, index) => {
if (tab.name === targetName) {
const nextTab = tabs[index + 1] || tabs[index - 1]
if (nextTab) {
activeName = nextTab.name
}
}
})
if (store.cssContentConfig.active === targetName) {
const currentIndex = tabs.findIndex(tab => tab.name === targetName);
const nextTab = tabs[currentIndex + 1] || tabs[currentIndex - 1];
store.cssContentConfig.active = nextTab ? nextTab.name : '';
}

store.cssContentConfig.active = activeName
store.cssContentConfig.tabs = tabs.filter(tab => tab.name !== targetName)
}
}
Expand Down
Loading