vome-core 0.0.67 → 0.0.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/config/plugin-dev.js +1 -1
- package/dist/admin/crud/components/vm-json-editor.vue +32 -3
- package/dist/admin/crud/config.js +1 -1
- package/dist/admin/crud/confirm.js +1 -1
- package/dist/admin/crud/dict.js +1 -1
- package/dist/admin/crud/index.d.ts +1 -1
- package/dist/admin/crud/index.js +1 -1
- package/dist/admin/crud/key.js +1 -1
- package/dist/admin/crud/mitt.js +1 -1
- package/dist/admin/crud/plugins.js +1 -1
- package/dist/admin/crud/span.js +1 -1
- package/dist/admin/crud/style.d.ts +37 -0
- package/dist/admin/crud/style.js +1 -1
- package/dist/admin/crud/validate.js +1 -1
- package/dist/admin/crud/vm-add-btn.vue +2 -1
- package/dist/admin/crud/vm-adv-search.vue +5 -4
- package/dist/admin/crud/vm-crud.vue +14 -9
- package/dist/admin/crud/vm-export-btn.vue +2 -1
- package/dist/admin/crud/vm-import-btn.vue +2 -1
- package/dist/admin/crud/vm-multi-delete-btn.vue +2 -1
- package/dist/admin/crud/vm-pagination.vue +16 -7
- package/dist/admin/crud/vm-refresh-btn.vue +2 -1
- package/dist/admin/crud/vm-search-key.vue +3 -2
- package/dist/admin/crud/vm-search.vue +29 -20
- package/dist/admin/crud/vm-table.vue +55 -17
- package/dist/admin/crud/vm-toolbar.vue +12 -13
- package/dist/admin/crud/vm-upsert.vue +12 -6
- package/dist/admin/directives/perm.js +1 -1
- package/dist/admin/hooks/useUpload.js +1 -1
- package/dist/admin/index.d.ts +1 -1
- package/dist/admin/index.js +6 -1
- package/dist/admin/lib/browser.js +1 -1
- package/dist/admin/lib/cn.js +1 -1
- package/dist/admin/lib/dialog-float.js +1 -1
- package/dist/admin/lib/export-excel.js +1 -1
- package/dist/admin/lib/file-preview.js +1 -1
- package/dist/admin/lib/import-excel.js +1 -1
- package/dist/admin/lib/json.js +1 -1
- package/dist/admin/lib/menu.js +1 -1
- package/dist/admin/lib/tree.js +1 -1
- package/dist/admin/lib/upload.js +1 -1
- package/dist/admin/lib/video-frame.js +1 -1
- package/dist/admin/styles/base.css +33 -0
- package/dist/ai/index.js +28761 -0
- package/dist/ai.d.ts +1 -0
- package/dist/client/base.js +3 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +3 -5
- package/dist/client/locale-store.d.ts +59 -0
- package/dist/client/locale-store.js +159 -0
- package/dist/client/vite-plugin-eps.js +0 -21
- package/dist/index.js +1 -1
- package/dist/server/index.js +1 -1
- package/dist/shared/excel.js +1 -1
- package/dist/shared/index.js +1 -1
- package/dist/shared/locale-json.js +1 -0
- package/dist/shared/tree.js +1 -1
- package/dist/src/ai/adapters/anthropic-gemini.d.ts +5 -0
- package/dist/src/ai/adapters/auth-headers.d.ts +4 -0
- package/dist/src/ai/adapters/index.d.ts +3 -0
- package/dist/src/ai/adapters/openai-compatible.d.ts +4 -0
- package/dist/src/ai/call-log-helpers.d.ts +13 -0
- package/dist/src/ai/index.d.ts +10 -0
- package/dist/src/ai/normalize.d.ts +18 -0
- package/dist/src/ai/sse.d.ts +13 -0
- package/dist/src/ai/transport.d.ts +16 -0
- package/dist/src/ai/types.d.ts +194 -0
- package/dist/src/core/index.d.ts +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/orm/index.d.ts +1 -1
- package/dist/src/server/index.d.ts +3 -1
- package/dist/src/shared/index.d.ts +1 -0
- package/dist/src/shared/locale-json.d.ts +7 -0
- package/dist/typings/routing/eps.d.ts +2 -0
- package/package.json +7 -2
- package/src/shared/index.ts +6 -0
- package/src/shared/locale-json.ts +79 -0
- package/typings/admin/comm/crud.d.ts +12 -0
- package/typings/admin/comm/crud.ts +12 -0
- package/typings/admin/comm/eps.d.ts +3 -0
- package/typings/admin/comm/eps.ts +3 -0
- package/typings/admin/comm/request.d.ts +1 -1
- package/typings/admin/comm/request.ts +1 -1
- package/dist/client/ai-model.d.ts +0 -38
- package/dist/client/ai-model.js +0 -39
package/dist/ai.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src/ai/index'
|
package/dist/client/base.js
CHANGED
|
@@ -15,6 +15,8 @@ function resolveAiCallTimeoutMs(url, options) {
|
|
|
15
15
|
return options.timeoutMs;
|
|
16
16
|
if (/\/ai\/model\/test\/?$/.test(url))
|
|
17
17
|
return 120000;
|
|
18
|
+
if (/\/il8n\/pack\/translate\/?$/.test(url))
|
|
19
|
+
return 0;
|
|
18
20
|
if (!/\/ai\/model\/call\/?$/.test(url))
|
|
19
21
|
return;
|
|
20
22
|
const data = options.data;
|
|
@@ -25,7 +27,7 @@ function resolveAiCallTimeoutMs(url, options) {
|
|
|
25
27
|
return 5000;
|
|
26
28
|
if (data?.capability === "chat")
|
|
27
29
|
return 0;
|
|
28
|
-
return
|
|
30
|
+
return 360000;
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
export class BaseService {
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { configureClient, getClientRequest, type ClientHooks, type ClientRequestFn, } from './configure';
|
|
2
2
|
export { loadEps, loadAllEps, getEps, findEpsEntity, clearEpsCache, type EpsSide, } from './eps';
|
|
3
3
|
export { BaseService } from './base';
|
|
4
|
-
export { loadAiModelCatalog, findAiModelCatalog, clearAiModelCatalogCache, type AiInputFieldHint, type AiInputSchema, type AiResponseSpec, type AiModelCatalogItem, } from './ai-model';
|
|
5
4
|
export { service, getService, createEps, bindEpsHotReload, setServicePerms, resolveService, serviceOf, type CreateEpsOptions, type ServiceLeaf, type ServiceTree, } from './service';
|
|
5
|
+
export { createLocaleStore, type Il8nLangItem, type LocalePersist, type LocalePackApi, type CreateLocaleStoreOptions, } from './locale-store';
|
package/dist/client/index.js
CHANGED
|
@@ -10,11 +10,6 @@ export {
|
|
|
10
10
|
clearEpsCache
|
|
11
11
|
} from "./eps";
|
|
12
12
|
export { BaseService } from "./base";
|
|
13
|
-
export {
|
|
14
|
-
loadAiModelCatalog,
|
|
15
|
-
findAiModelCatalog,
|
|
16
|
-
clearAiModelCatalogCache
|
|
17
|
-
} from "./ai-model";
|
|
18
13
|
export {
|
|
19
14
|
service,
|
|
20
15
|
getService,
|
|
@@ -24,3 +19,6 @@ export {
|
|
|
24
19
|
resolveService,
|
|
25
20
|
serviceOf
|
|
26
21
|
} from "./service";
|
|
22
|
+
export {
|
|
23
|
+
createLocaleStore
|
|
24
|
+
} from "./locale-store";
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export type Il8nLangItem = {
|
|
2
|
+
code: string;
|
|
3
|
+
name: string;
|
|
4
|
+
flag?: string;
|
|
5
|
+
status?: number;
|
|
6
|
+
};
|
|
7
|
+
export type LocalePersist = {
|
|
8
|
+
get: (key: string) => string | null | undefined;
|
|
9
|
+
set: (key: string, value: string) => void;
|
|
10
|
+
};
|
|
11
|
+
export type LocalePackApi = {
|
|
12
|
+
locales?: (q: {
|
|
13
|
+
scopeKey: string;
|
|
14
|
+
}) => Promise<Il8nLangItem[] | null>;
|
|
15
|
+
hostLocales?: (q?: {
|
|
16
|
+
scopeKey?: string;
|
|
17
|
+
}) => Promise<Il8nLangItem[] | null>;
|
|
18
|
+
active?: (q: {
|
|
19
|
+
langCode: string;
|
|
20
|
+
scopeKey: string;
|
|
21
|
+
scopeType?: string;
|
|
22
|
+
}) => Promise<{
|
|
23
|
+
packJson?: Record<string, unknown>;
|
|
24
|
+
version?: number;
|
|
25
|
+
} | null>;
|
|
26
|
+
list?: (q: Record<string, unknown>) => Promise<Array<{
|
|
27
|
+
langCode?: string;
|
|
28
|
+
}>>;
|
|
29
|
+
};
|
|
30
|
+
export type CreateLocaleStoreOptions = {
|
|
31
|
+
/** pinia store id,默认 locale */
|
|
32
|
+
id?: string;
|
|
33
|
+
storageKey: string;
|
|
34
|
+
scopeKey: string;
|
|
35
|
+
defaultLocale?: string;
|
|
36
|
+
/** web/uniapp 静态源包;admin 可空 */
|
|
37
|
+
defaultPack?: Record<string, unknown>;
|
|
38
|
+
persist: LocalePersist;
|
|
39
|
+
getPackApi: () => LocalePackApi | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* admin:优先 hostLocales;app:locales({ scopeKey })
|
|
42
|
+
* 默认按 scopeKey===admin 分支
|
|
43
|
+
*/
|
|
44
|
+
langMode?: 'admin' | 'app';
|
|
45
|
+
/** 切换语种时缓存已拉过的包(web/uniapp) */
|
|
46
|
+
cachePacks?: boolean;
|
|
47
|
+
/** admin:注入 CRUD 翻译 */
|
|
48
|
+
onPackLoaded?: (ctx: {
|
|
49
|
+
t: (key: string, fallback?: string, ...args: Array<string | number>) => string;
|
|
50
|
+
}) => void;
|
|
51
|
+
/** admin:菜单名 tMenu */
|
|
52
|
+
enableMenu?: boolean;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* 三端共用 locale store 工厂
|
|
56
|
+
* - admin:langMode=admin + onPackLoaded(setCrudTranslator) + enableMenu
|
|
57
|
+
* - web/uniapp:defaultPack + cachePacks + langMode=app
|
|
58
|
+
*/
|
|
59
|
+
export declare function createLocaleStore(options: CreateLocaleStoreOptions): any;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { defineStore } from "pinia";
|
|
2
|
+
function getByPath(obj, path) {
|
|
3
|
+
if (!obj || typeof obj !== "object")
|
|
4
|
+
return;
|
|
5
|
+
const parts = path.split(".").filter(Boolean);
|
|
6
|
+
let cur = obj;
|
|
7
|
+
for (const p of parts) {
|
|
8
|
+
if (!cur || typeof cur !== "object")
|
|
9
|
+
return;
|
|
10
|
+
cur = cur[p];
|
|
11
|
+
}
|
|
12
|
+
return typeof cur === "string" ? cur : undefined;
|
|
13
|
+
}
|
|
14
|
+
function formatTpl(tpl, args) {
|
|
15
|
+
let out = tpl;
|
|
16
|
+
for (let i = 0;i < args.length; i++) {
|
|
17
|
+
out = out.replace(new RegExp(`\\{${i}\\}`, "g"), String(args[i]));
|
|
18
|
+
}
|
|
19
|
+
return out;
|
|
20
|
+
}
|
|
21
|
+
const FALLBACK_LANGS = [
|
|
22
|
+
{ code: "zh-CN", name: "简体中文", flag: "\uD83C\uDDE8\uD83C\uDDF3" }
|
|
23
|
+
];
|
|
24
|
+
export function createLocaleStore(options) {
|
|
25
|
+
const {
|
|
26
|
+
id = "locale",
|
|
27
|
+
storageKey,
|
|
28
|
+
scopeKey,
|
|
29
|
+
defaultLocale = "zh-CN",
|
|
30
|
+
defaultPack,
|
|
31
|
+
persist,
|
|
32
|
+
getPackApi,
|
|
33
|
+
langMode = scopeKey === "admin" ? "admin" : "app",
|
|
34
|
+
cachePacks = Boolean(defaultPack),
|
|
35
|
+
onPackLoaded,
|
|
36
|
+
enableMenu = false
|
|
37
|
+
} = options;
|
|
38
|
+
const initialPack = defaultPack ? { ...defaultPack } : {};
|
|
39
|
+
return defineStore(id, {
|
|
40
|
+
state: () => ({
|
|
41
|
+
locale: String(persist.get(storageKey) || defaultLocale),
|
|
42
|
+
langs: [],
|
|
43
|
+
messages: { ...initialPack },
|
|
44
|
+
packCache: cachePacks && defaultPack ? { [defaultLocale]: { ...initialPack } } : {},
|
|
45
|
+
version: 0,
|
|
46
|
+
loaded: false
|
|
47
|
+
}),
|
|
48
|
+
getters: {
|
|
49
|
+
currentLang(state) {
|
|
50
|
+
return state.langs.find((l) => l.code === state.locale);
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
actions: {
|
|
54
|
+
t(key, fallback, ...args) {
|
|
55
|
+
const v = getByPath(this.messages, key);
|
|
56
|
+
const raw = v != null && v !== "" ? v : fallback ?? key;
|
|
57
|
+
return args.length ? formatTpl(raw, args) : raw;
|
|
58
|
+
},
|
|
59
|
+
tMenu(item) {
|
|
60
|
+
if (!enableMenu)
|
|
61
|
+
return String(item?.name ?? "");
|
|
62
|
+
const mid = item?.id;
|
|
63
|
+
if (mid != null) {
|
|
64
|
+
const v = this.t(`menu.${mid}`, "");
|
|
65
|
+
if (v)
|
|
66
|
+
return v;
|
|
67
|
+
}
|
|
68
|
+
return String(item?.name ?? "");
|
|
69
|
+
},
|
|
70
|
+
applyCrudLocale() {
|
|
71
|
+
onPackLoaded?.({ t: this.t.bind(this) });
|
|
72
|
+
},
|
|
73
|
+
async loadLangs() {
|
|
74
|
+
const packApi = getPackApi();
|
|
75
|
+
if (!packApi) {
|
|
76
|
+
this.langs = FALLBACK_LANGS;
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
let list = [];
|
|
81
|
+
if (langMode === "admin") {
|
|
82
|
+
if (typeof packApi.hostLocales === "function") {
|
|
83
|
+
list = await packApi.hostLocales();
|
|
84
|
+
} else if (typeof packApi.list === "function") {
|
|
85
|
+
const rows = await packApi.list({
|
|
86
|
+
scopeType: "host",
|
|
87
|
+
scopeKey
|
|
88
|
+
});
|
|
89
|
+
const codes = [
|
|
90
|
+
...new Set((rows ?? []).map((r) => String(r.langCode || "").trim()).filter(Boolean))
|
|
91
|
+
];
|
|
92
|
+
list = codes.map((code) => ({ code, name: code, flag: "\uD83C\uDFF3️" }));
|
|
93
|
+
}
|
|
94
|
+
} else if (typeof packApi.locales === "function") {
|
|
95
|
+
list = await packApi.locales({ scopeKey });
|
|
96
|
+
}
|
|
97
|
+
this.langs = Array.isArray(list) && list.length ? list : FALLBACK_LANGS;
|
|
98
|
+
} catch {
|
|
99
|
+
this.langs = FALLBACK_LANGS;
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
async loadPack(locale) {
|
|
103
|
+
const code = locale ?? this.locale;
|
|
104
|
+
if (cachePacks && this.packCache[code]) {
|
|
105
|
+
this.messages = { ...this.packCache[code] };
|
|
106
|
+
this.loaded = true;
|
|
107
|
+
this.applyCrudLocale();
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (defaultPack && code === defaultLocale) {
|
|
111
|
+
const pack = { ...initialPack };
|
|
112
|
+
if (cachePacks)
|
|
113
|
+
this.packCache[code] = pack;
|
|
114
|
+
this.messages = { ...pack };
|
|
115
|
+
this.loaded = true;
|
|
116
|
+
this.applyCrudLocale();
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const api = getPackApi();
|
|
120
|
+
if (!api?.active) {
|
|
121
|
+
this.messages = defaultPack ? { ...initialPack } : {};
|
|
122
|
+
this.loaded = true;
|
|
123
|
+
this.applyCrudLocale();
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
try {
|
|
127
|
+
const row = await api.active({
|
|
128
|
+
langCode: code,
|
|
129
|
+
scopeKey,
|
|
130
|
+
...langMode === "admin" ? { scopeType: "host" } : {}
|
|
131
|
+
});
|
|
132
|
+
const pack = row?.packJson && typeof row.packJson === "object" && Object.keys(row.packJson).length ? row.packJson : defaultPack ? { ...initialPack } : {};
|
|
133
|
+
if (cachePacks)
|
|
134
|
+
this.packCache[code] = pack;
|
|
135
|
+
this.messages = { ...pack };
|
|
136
|
+
this.version = Number(row?.version ?? 0);
|
|
137
|
+
} catch {
|
|
138
|
+
this.messages = defaultPack ? { ...initialPack } : {};
|
|
139
|
+
}
|
|
140
|
+
this.loaded = true;
|
|
141
|
+
this.applyCrudLocale();
|
|
142
|
+
},
|
|
143
|
+
async initLocale() {
|
|
144
|
+
await this.loadLangs();
|
|
145
|
+
if (!this.langs.some((l) => l.code === this.locale)) {
|
|
146
|
+
this.locale = this.langs.find((l) => l.code === defaultLocale)?.code || this.langs[0]?.code || defaultLocale;
|
|
147
|
+
persist.set(storageKey, this.locale);
|
|
148
|
+
}
|
|
149
|
+
await this.loadPack(this.locale);
|
|
150
|
+
},
|
|
151
|
+
async setLocale(code) {
|
|
152
|
+
const next = String(code || "").trim() || defaultLocale;
|
|
153
|
+
this.locale = next;
|
|
154
|
+
persist.set(storageKey, next);
|
|
155
|
+
await this.loadPack(next);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
@@ -11,27 +11,6 @@ function methodName(p) {
|
|
|
11
11
|
return p.replace(/^\//, "").replace(/[:,\s/-]/g, "");
|
|
12
12
|
}
|
|
13
13
|
function tsType(col) {
|
|
14
|
-
const name = col.propertyName;
|
|
15
|
-
if (name === "inputSchema") {
|
|
16
|
-
return `{
|
|
17
|
-
fields?: Array<{
|
|
18
|
-
key: string;
|
|
19
|
-
type: 'string' | 'number' | 'boolean' | 'object' | 'array';
|
|
20
|
-
required?: boolean;
|
|
21
|
-
description?: string;
|
|
22
|
-
enum?: string[];
|
|
23
|
-
system?: boolean;
|
|
24
|
-
}>;
|
|
25
|
-
} | null`;
|
|
26
|
-
}
|
|
27
|
-
if (name === "responseSpec") {
|
|
28
|
-
return `{
|
|
29
|
-
textPath?: string;
|
|
30
|
-
assetsPath?: string;
|
|
31
|
-
binary?: boolean;
|
|
32
|
-
[key: string]: unknown;
|
|
33
|
-
} | null`;
|
|
34
|
-
}
|
|
35
14
|
const t = String(col.type || "string").toLowerCase();
|
|
36
15
|
if (["int", "integer", "bigint", "number", "float", "double", "decimal"].some((x) => t.includes(x)))
|
|
37
16
|
return "number";
|