feat: 辅料功能、康正源拉取价格接口

This commit is contained in:
李琦
2026-09-30 17:02:54 +08:00
parent bfe50a8d67
commit 87c480f391
51 changed files with 4086 additions and 380 deletions

View File

@@ -36,12 +36,14 @@ function api() {
return typeof window === 'undefined' ? undefined : window.desktopAPI;
}
// onNavigate / onUpdateEvent 的桥接层每调用一次就会新增一个 ipc 监听,
// onNavigate / onUpdateEvent / onOpenSwitchAccount 的桥接层每调用一次就会新增一个 ipc 监听,
// 而布局组件会随登录/登出反复挂载。这里用「模块级单次桥接 + 可替换回调」避免监听器堆积
let navigateCallback: ((route: string) => void) | null = null;
let navigateBridged = false;
let updateCallback: ((payload: DesktopUpdateEvent) => void) | null = null;
let updateBridged = false;
let switchAccountCallback: (() => void) | null = null;
let switchAccountBridged = false;
export const desktop = {
/** 发送系统通知;route 为点击通知后要跳转的前端路由(不传则仅唤起窗口) */
@@ -95,6 +97,14 @@ export const desktop = {
checkUpdate(): void {
api()?.checkUpdate();
},
/** 刷新主窗口 */
reload(): void {
api()?.reload();
},
/** 关于弹窗 */
showAbout(): void {
api()?.showAbout();
},
/** 唤起并聚焦主窗口 */
focusWindow(): void {
api()?.focusWindow();
@@ -111,6 +121,18 @@ export const desktop = {
offNavigate(): void {
navigateCallback = null;
},
/** 监听托盘「切换账号」请求(重复调用只替换回调,不会堆积监听器) */
onOpenSwitchAccount(callback: () => void): void {
switchAccountCallback = callback;
if (!switchAccountBridged && api()) {
switchAccountBridged = true;
api()!.onOpenSwitchAccount(() => switchAccountCallback?.());
}
},
/** 解绑切换账号回调:登出卸载布局时调用 */
offOpenSwitchAccount(): void {
switchAccountCallback = null;
},
/** 监听自动更新事件(重复调用只替换回调,不会堆积监听器) */
onUpdateEvent(callback: (payload: DesktopUpdateEvent) => void): void {
updateCallback = callback;