fix: 逻辑操作

This commit is contained in:
手瓜一十雪
2024-11-16 11:14:21 +08:00
parent 41db435ef5
commit 34e96b1089
2 changed files with 69 additions and 14 deletions

View File

@@ -183,6 +183,10 @@ const showAddTabDialog = () => {
const addTab = async () => {
const { name, type } = newTab.value;
if (clientPanelData.some(panel => panel.name === name)) {
MessagePlugin.error('选项卡名称已存在');
return;
}
const defaultConfig = structuredClone(defaultConfigs[type]);
defaultConfig.name = name;
clientPanelData.push({ name, data: defaultConfig, key: type });
@@ -192,9 +196,10 @@ const addTab = async () => {
MessagePlugin.success('选项卡添加成功');
};
const removeTab = (payload: { value: string; index: number; e: PointerEvent }) => {
const removeTab = async (payload: { value: string; index: number; e: PointerEvent }) => {
clientPanelData.splice(payload.index, 1);
activeTab.value = Math.max(0, activeTab.value - 1);
await saveConfig();
};
onMounted(() => {
@@ -225,6 +230,35 @@ onMounted(() => {
flex-direction: column;
}
.button-container {
display: flex;
justify-content: center;
margin-top: 20px;
}
</style>
<style scoped>
.full-space {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: flex-start;
}
.full-tabs {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
}
.full-tab-panel {
flex: 1;
display: flex;
flex-direction: column;
}
.button-container {
display: flex;
justify-content: center;