截图模块优化调整

This commit is contained in:
zhongluofeng
2026-08-03 17:36:07 +08:00
parent f51a7f894e
commit c913379e2b
19 changed files with 1744 additions and 300 deletions
+33 -2
View File
@@ -1,5 +1,5 @@
import { defineStore } from 'pinia'
import { ref } from 'vue'
import { ref, computed } from 'vue'
/**
* 模块标签栏跨组件状态。
@@ -28,6 +28,13 @@ export const useModuleTabsStore = defineStore('moduleTabs', () => {
/** 是否显示浮动切换器(TabsList 滚出可视区时为 true */
const floatingVisible = ref<boolean>(false)
/** 当前模块注册的保存处理函数(null 表示无保存按钮,如自动保存模块) */
const saveHandler = ref<(() => unknown) | null>(null)
/** 保存中状态(驱动按钮 disabled + loading 图标) */
const saving = ref<boolean>(false)
/** 是否显示保存按钮(当前在设置 tab 且注册了保存处理函数) */
const saveVisible = computed(() => saveHandler.value !== null && activeTab.value === 'settings')
/** 模块注册标签(onMounted 时调用) */
const registerTabs = (tabList: ModuleTab[], current: string) => {
tabs.value = tabList
@@ -40,6 +47,8 @@ export const useModuleTabsStore = defineStore('moduleTabs', () => {
tabs.value = []
activeTab.value = ''
floatingVisible.value = false
saveHandler.value = null
saving.value = false
}
/** 设置浮动切换器可见性 */
@@ -63,13 +72,35 @@ export const useModuleTabsStore = defineStore('moduleTabs', () => {
activeTab.value = value
}
/** 模块注册保存处理函数(setup 中定义保存方法后调用) */
const registerSave = (handler: (() => unknown) | null) => {
saveHandler.value = handler
saving.value = false
}
/** 执行保存(TitleBar 按钮点击时调用) */
const runSave = async () => {
if (!saveHandler.value || saving.value) return
saving.value = true
try {
await saveHandler.value()
} finally {
saving.value = false
}
}
return {
tabs,
activeTab,
floatingVisible,
saveHandler,
saving,
saveVisible,
registerTabs,
unregisterTabs,
setFloatingVisible,
setActiveTab
setActiveTab,
registerSave,
runSave
}
})