版本管理,优化
This commit is contained in:
@@ -4,6 +4,19 @@ import { invoke as __TAURI_INVOKE } from "@tauri-apps/api/core";
|
||||
|
||||
/** Commands */
|
||||
export const commands = {
|
||||
/** 获取当前应用版本 */
|
||||
appVersion: () => __TAURI_INVOKE<string>("app_version"),
|
||||
/** 检查 Gitea 最新 release,返回版本对比与可用资产 */
|
||||
updateCheck: () => __TAURI_INVOKE<UpdateCheckResult>("update_check"),
|
||||
/**
|
||||
* 更新应用本体。
|
||||
* 便携版:下载 thing_{v}_x64.exe → update.bat 覆盖重启;
|
||||
* 安装版:下载 thing_{v}_x64-setup.exe → 提权静默安装 /S。
|
||||
* 下载进度通过 UPDATE_PROGRESS 事件上报,调用方返回前会触发应用退出。
|
||||
*/
|
||||
updateInstall: () => __TAURI_INVOKE<null>("update_install"),
|
||||
/** 更新 ThingHK 内核:下载 thing-hk_{v}.zip → 停止监控内核 → 覆盖内核文件 */
|
||||
updateThinghk: () => __TAURI_INVOKE<null>("update_thinghk"),
|
||||
proxyActivateProfile: (id: string) => __TAURI_INVOKE<null>("proxy_activate_profile", { id }),
|
||||
proxyCheckKernelUpdate: () => __TAURI_INVOKE<KernelUpdateInfo>("proxy_check_kernel_update"),
|
||||
proxyClearSystemProxy: () => __TAURI_INVOKE<null>("proxy_clear_system_proxy"),
|
||||
@@ -480,6 +493,25 @@ export type TaskStatus =
|
||||
/** 错误 */
|
||||
"error";
|
||||
|
||||
/** release 中的一个资产 */
|
||||
export type UpdateAsset = {
|
||||
name: string,
|
||||
size: number,
|
||||
browserDownloadUrl: string,
|
||||
};
|
||||
|
||||
/** 检查更新的结果 */
|
||||
export type UpdateCheckResult = {
|
||||
currentVersion: string,
|
||||
latestVersion: string,
|
||||
hasUpdate: boolean,
|
||||
/** portable | installed */
|
||||
installType: string,
|
||||
releaseName: string,
|
||||
releaseBody: string,
|
||||
assets: UpdateAsset[],
|
||||
};
|
||||
|
||||
/** 窗口信息(窗口拾取 / 枚举) */
|
||||
export type WindowInfo = {
|
||||
hwnd: number,
|
||||
|
||||
@@ -38,6 +38,8 @@ export const EVENTS = {
|
||||
screenshotExported: 'screenshot-exported',
|
||||
// 内核安装进度
|
||||
kernelInstallProgress: 'kernel-install-progress',
|
||||
// 应用更新进度
|
||||
updateProgress: 'update-progress',
|
||||
// 监控 OSD
|
||||
osdStateUpdate: 'osd-state-update',
|
||||
osdContentSize: 'osd-content-size',
|
||||
|
||||
@@ -12,12 +12,15 @@ import { useModuleTabsStore, type ModuleTab } from '@/stores/moduleTabsStore'
|
||||
* ```ts
|
||||
* // 模块 <script setup> 顶部
|
||||
* const activeTab = ref('overview')
|
||||
* const tabsListRef = useModuleTabs(activeTab, [
|
||||
* const tabsListRef = useModuleTabs('proxy', activeTab, [
|
||||
* { value: 'overview', label: '概览' },
|
||||
* { value: 'settings', label: '设置' }
|
||||
* ])
|
||||
* ```
|
||||
*
|
||||
* 第一个参数为模块 id:搜索导航跳转时,模块挂载后会自动
|
||||
* 消费 moduleTabsStore 中对应的待跳转 tab(pendingTab)。
|
||||
*
|
||||
* ```vue
|
||||
* <!-- 模板中给 TabsList 包一层带 ref 的 div -->
|
||||
* <div ref="tabsListRef">
|
||||
@@ -29,7 +32,8 @@ import { useModuleTabsStore, type ModuleTab } from '@/stores/moduleTabsStore'
|
||||
* 1. onMounted 时注册标签到 moduleTabsStore,TitleBar 据此渲染浮动切换器
|
||||
* 2. 用 IntersectionObserver 监听 TabsList 可见性(rootMargin 裁剪 TitleBar 高度)
|
||||
* 3. 双向 watch 同步本地 activeTab 与 store.activeTab
|
||||
* 4. onUnmounted 时清理 observer 并注销标签
|
||||
* 4. 消费搜索导航的待跳转 tab(模块尚未挂载的场景)
|
||||
* 5. onUnmounted 时清理 observer 并注销标签
|
||||
*
|
||||
* ## 约束
|
||||
* - TitleBar 高度固定为 40px (h-10),composable 内部已用 44px 裁剪(含缓冲)
|
||||
@@ -37,6 +41,7 @@ import { useModuleTabsStore, type ModuleTab } from '@/stores/moduleTabsStore'
|
||||
* - 模块卸载时务必让 composable 的 onUnmounted 执行(已自动处理,无需手动调用)
|
||||
*/
|
||||
export function useModuleTabs(
|
||||
moduleId: string,
|
||||
activeTab: Ref<string>,
|
||||
tabs: ModuleTab[]
|
||||
): Ref<HTMLElement | null> {
|
||||
@@ -45,6 +50,15 @@ export function useModuleTabs(
|
||||
|
||||
let observer: IntersectionObserver | null = null
|
||||
|
||||
/** 应用待跳转 tab(若属于当前模块的 tab 列表) */
|
||||
const applyPendingTab = () => {
|
||||
const pending = tabsStore.consumePendingTab(moduleId)
|
||||
if (pending && tabs.some(t => t.value === pending)) {
|
||||
activeTab.value = pending
|
||||
tabsStore.setActiveTab(pending)
|
||||
}
|
||||
}
|
||||
|
||||
const setupObserver = () => {
|
||||
const el = tabsListRef.value
|
||||
if (!el || observer) return
|
||||
@@ -75,10 +89,19 @@ export function useModuleTabs(
|
||||
}
|
||||
})
|
||||
|
||||
// 模块已挂载时(搜索结果选中同一模块),pendingTab 变化 → 直接切换 tab
|
||||
watch(() => tabsStore.pendingTab, (p) => {
|
||||
if (p?.moduleId === moduleId) {
|
||||
applyPendingTab()
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
tabsStore.registerTabs(tabs, activeTab.value)
|
||||
await nextTick()
|
||||
setupObserver()
|
||||
// 搜索导航跳转:模块刚挂载,消费待跳转 tab
|
||||
applyPendingTab()
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
|
||||
Reference in New Issue
Block a user