feat: 提升交互体验

This commit is contained in:
手瓜一十雪
2024-11-16 10:55:26 +08:00
parent 8bc0403139
commit 6382b29da8
2 changed files with 44 additions and 5 deletions
napcat.webui/src/pages

@@ -1,15 +1,16 @@
<template> <template>
<t-space> <t-space class="full-space">
<t-tabs v-model="activeTab" :addable="true" theme="card" @add="showAddTabDialog" @remove="removeTab"> <t-tabs v-model="activeTab" :addable="true" theme="card" @add="showAddTabDialog" @remove="removeTab" class="full-tabs">
<t-tab-panel <t-tab-panel
v-for="(config, idx) in clientPanelData" v-for="(config, idx) in clientPanelData"
:key="idx" :key="idx"
:label="config.name" :label="config.name"
:removable="true" :removable="true"
:value="idx" :value="idx"
class="full-tab-panel"
> >
<component :is="resolveDynamicComponent(getComponent(config.key))" :config="config.data" /> <component :is="resolveDynamicComponent(getComponent(config.key))" :config="config.data" />
<t-button @click="saveConfig">保存</t-button> <t-button @click="saveConfig" style="width: 100px; height: 40px;">保存</t-button>
</t-tab-panel> </t-tab-panel>
</t-tabs> </t-tabs>
<t-dialog <t-dialog
@@ -37,6 +38,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, resolveDynamicComponent, nextTick, Ref, onMounted, reactive, Reactive } from 'vue'; import { ref, resolveDynamicComponent, nextTick, Ref, onMounted, reactive, Reactive } from 'vue';
import { MessagePlugin } from 'tdesign-vue-next';
import { import {
httpServerDefaultConfigs, httpServerDefaultConfigs,
httpClientDefaultConfigs, httpClientDefaultConfigs,
@@ -164,7 +166,12 @@ const saveConfig = async () => {
const userConfig = await getOB11Config(); const userConfig = await getOB11Config();
if (!userConfig) return; if (!userConfig) return;
userConfig.network = config; userConfig.network = config;
await setOB11Config(userConfig); const success = await setOB11Config(userConfig);
if (success) {
MessagePlugin.success('配置保存成功');
} else {
MessagePlugin.error('配置保存失败');
}
}; };
const showAddTabDialog = () => { const showAddTabDialog = () => {
@@ -180,6 +187,7 @@ const addTab = async () => {
isDialogVisible.value = false; isDialogVisible.value = false;
await nextTick(); await nextTick();
activeTab.value = clientPanelData.length - 1; activeTab.value = clientPanelData.length - 1;
MessagePlugin.success('选项卡添加成功');
}; };
const removeTab = (payload: { value: string; index: number; e: PointerEvent }) => { const removeTab = (payload: { value: string; index: number; e: PointerEvent }) => {
@@ -191,3 +199,27 @@ onMounted(() => {
loadConfig(); loadConfig();
}); });
</script> </script>
<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;
}
</style>

@@ -17,6 +17,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted } from 'vue'; import { ref, onMounted } from 'vue';
import { MessagePlugin } from 'tdesign-vue-next';
import { OneBotConfig } from '../../../src/onebot/config/config'; import { OneBotConfig } from '../../../src/onebot/config/config';
import { QQLoginManager } from '@/backend/shell'; import { QQLoginManager } from '@/backend/shell';
@@ -63,10 +64,16 @@ const saveConfig = async () => {
if (userConfig) { if (userConfig) {
userConfig.musicSignUrl = otherConfig.value.musicSignUrl || ''; userConfig.musicSignUrl = otherConfig.value.musicSignUrl || '';
userConfig.enableLocalFile2Url = otherConfig.value.enableLocalFile2Url ?? false; userConfig.enableLocalFile2Url = otherConfig.value.enableLocalFile2Url ?? false;
await setOB11Config(userConfig); const success = await setOB11Config(userConfig);
if (success) {
MessagePlugin.success('配置保存成功');
} else {
MessagePlugin.error('配置保存失败');
}
} }
} catch (error) { } catch (error) {
console.error('Error saving config:', error); console.error('Error saving config:', error);
MessagePlugin.error('配置保存失败');
} }
}; };