统一模型库前端基础依赖
This commit is contained in:
53
web/src/vendor/w2ui.ts
vendored
Normal file
53
web/src/vendor/w2ui.ts
vendored
Normal 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;
|
||||
Reference in New Issue
Block a user