统一模型库前端基础依赖

This commit is contained in:
zhangshun
2026-05-29 11:21:15 +08:00
parent 771e290fb9
commit 71496de8e3
9 changed files with 29015 additions and 75 deletions

53
web/src/vendor/w2ui.ts vendored Normal file
View File

@@ -0,0 +1,53 @@
// 与主程序 src/publicJs/w2ui 保持同步的模型库本地副本,这里只做类型适配。
// @ts-expect-error w2ui 本地 JS 暂无配套 d.ts运行时由 Vite 正常打包。
import * as w2uiLocal from "./w2ui/w2ui.es6.js";
type W2EventHandler = (event: unknown) => void;
type W2EventHost = {
on(eventName: string, handler: W2EventHandler): W2EventHost;
};
type W2Popup = {
open(options: {
title?: string;
width?: number;
height?: number;
modal?: boolean;
body?: string;
actions?: Record<string, () => void | Promise<void>>;
}): {
self: W2EventHost;
};
close(): void;
};
type W2LayoutOptions = {
name: string;
padding?: number;
panels: Array<{
type: "left" | "right" | "top" | "bottom" | "main" | "preview";
size?: number | string;
minSize?: number;
maxSize?: number | false;
resizable?: boolean;
overflow?: string;
html?: string;
}>;
};
type W2Layout = {
render(target: HTMLElement): void;
destroy(): void;
};
const local = w2uiLocal as Record<string, unknown>;
export const w2popup = local.w2popup as W2Popup;
export const w2layout = local.w2layout as new (options: W2LayoutOptions) => W2Layout;
export const w2ui = local.w2ui as Record<string, { destroy?: () => void } | undefined>;
export const w2alert = local.w2alert as (message: string, title?: string) => unknown;
export const w2confirm = local.w2confirm as (
message: string | { msg: string; title?: string; yes?: string; no?: string },
title?: string,
callback?: (action: string) => void
) => unknown;