vome-core 0.0.87 → 0.0.89

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.
Files changed (45) hide show
  1. package/dist/admin/api/client.js +2 -2
  2. package/dist/admin/config/plugin-dev.js +1 -1
  3. package/dist/admin/crud/config.js +1 -1
  4. package/dist/admin/crud/confirm.js +1 -1
  5. package/dist/admin/crud/dict.js +1 -1
  6. package/dist/admin/crud/index.js +1 -1
  7. package/dist/admin/crud/key.js +1 -1
  8. package/dist/admin/crud/mitt.js +1 -1
  9. package/dist/admin/crud/plugins.js +1 -1
  10. package/dist/admin/crud/span.js +1 -1
  11. package/dist/admin/crud/style.js +1 -1
  12. package/dist/admin/crud/validate.js +1 -1
  13. package/dist/admin/crud/vm-table.vue +10 -5
  14. package/dist/admin/directives/perm.js +1 -1
  15. package/dist/admin/hooks/useUpload.js +1 -1
  16. package/dist/admin/lib/browser.js +1 -1
  17. package/dist/admin/lib/cn.js +1 -1
  18. package/dist/admin/lib/dialog-float.js +1 -1
  19. package/dist/admin/lib/export-excel.js +1 -1
  20. package/dist/admin/lib/import-excel.js +1 -1
  21. package/dist/admin/lib/json.js +1 -1
  22. package/dist/admin/lib/menu.js +1 -1
  23. package/dist/admin/lib/tree.js +1 -1
  24. package/dist/admin/lib/upload.js +1 -1
  25. package/dist/admin/lib/video-frame.js +1 -1
  26. package/dist/admin/service/index.js +2 -1
  27. package/dist/client/configure.d.ts +23 -2
  28. package/dist/client/configure.js +14 -1
  29. package/dist/client/eps-payload.js +1 -0
  30. package/dist/client/eps.d.ts +5 -1
  31. package/dist/client/eps.js +77 -8
  32. package/dist/client/index.d.ts +1 -1
  33. package/dist/client/index.js +3 -1
  34. package/dist/client/vite-plugin-eps.d.ts +2 -1
  35. package/dist/client/vite-plugin-eps.js +62 -16
  36. package/dist/index.js +1 -1
  37. package/dist/server/index.js +1 -1
  38. package/dist/shared/excel.js +1 -1
  39. package/dist/shared/index.js +1 -1
  40. package/dist/shared/locale-json.js +1 -1
  41. package/dist/shared/tree.js +1 -1
  42. package/dist/typings/routing/eps.d.ts +2 -0
  43. package/package.json +1 -1
  44. package/typings/admin/comm/eps.d.ts +2 -0
  45. package/typings/admin/comm/eps.ts +2 -0
@@ -144,9 +144,13 @@ async function fetchEps(apiUrl) {
144
144
  return null;
145
145
  }
146
146
  const data = json.data;
147
- const modules = "modules" in data && data.modules && typeof data.modules === "object" ? data.modules : data;
148
- if (modules && Object.keys(modules).length)
149
- return modules;
147
+ const rawModules = !Array.isArray(data) && "modules" in data && data.modules && typeof data.modules === "object" && !Array.isArray(data.modules) ? data.modules : !Array.isArray(data) ? data : null;
148
+ const modules = rawModules;
149
+ if (!modules || !Object.keys(modules).length)
150
+ return null;
151
+ const dict = !Array.isArray(data) && "dict" in data && data.dict && typeof data.dict === "object" && !Array.isArray(data.dict) ? data.dict : {};
152
+ const eps = !Array.isArray(data) && "eps" in data && typeof data.eps === "boolean" ? data.eps : true;
153
+ return { eps, modules, dict };
150
154
  } catch {}
151
155
  return null;
152
156
  }
@@ -160,10 +164,30 @@ export function createEpsVitePlugin(options) {
160
164
  const dtsSide = options.dtsSide ?? (sideMode === "both" ? "admin" : sideMode);
161
165
  const apiBase = raw.replace(/\/$/, "");
162
166
  let root = "";
167
+ let outDir = "";
163
168
  let bootOk = false;
164
169
  let bootTried = false;
165
170
  let timer = null;
166
171
  let running = null;
172
+ function readBundleFromJson(rawJson) {
173
+ if (!rawJson || typeof rawJson !== "object")
174
+ return null;
175
+ const obj = rawJson;
176
+ if (obj.admin || obj.app) {
177
+ return {
178
+ eps: typeof obj.eps === "boolean" ? obj.eps : false,
179
+ admin: obj.admin || {},
180
+ app: obj.app || {},
181
+ dict: obj.dict && typeof obj.dict === "object" ? obj.dict : {}
182
+ };
183
+ }
184
+ return {
185
+ eps: false,
186
+ admin: dtsSide === "admin" ? obj : {},
187
+ app: dtsSide === "app" ? obj : {},
188
+ dict: {}
189
+ };
190
+ }
167
191
  async function generate(reason = "start") {
168
192
  if (!root)
169
193
  return { changed: false };
@@ -174,24 +198,22 @@ export function createEpsVitePlugin(options) {
174
198
  const jsonPath = path.join(distDir, "eps.json");
175
199
  const needAdmin = sideMode === "admin" || sideMode === "both";
176
200
  const needApp = sideMode === "app" || sideMode === "both";
177
- const [adminMap, appMap] = await Promise.all([
201
+ const [adminHit, appHit] = await Promise.all([
178
202
  needAdmin ? fetchEps(`${apiBase}/admin/base/open/eps`) : Promise.resolve(null),
179
203
  needApp ? fetchEps(`${apiBase}/app/base/open/eps`) : Promise.resolve(null)
180
204
  ]);
181
205
  let bundle = null;
182
- if (adminMap || appMap) {
183
- bundle = { admin: adminMap || {}, app: appMap || {} };
206
+ if (adminHit || appHit) {
207
+ const epsFlag = typeof adminHit?.eps === "boolean" ? adminHit.eps : typeof appHit?.eps === "boolean" ? appHit.eps : true;
208
+ bundle = {
209
+ eps: epsFlag,
210
+ admin: adminHit?.modules || {},
211
+ app: appHit?.modules || {},
212
+ dict: adminHit?.dict || appHit?.dict || {}
213
+ };
184
214
  } else if (reason !== "hot") {
185
215
  try {
186
- const raw = JSON.parse(fs.readFileSync(jsonPath, "utf8"));
187
- if (raw.admin || raw.app) {
188
- bundle = { admin: raw.admin || {}, app: raw.app || {} };
189
- } else {
190
- bundle = {
191
- admin: dtsSide === "admin" ? raw : {},
192
- app: dtsSide === "app" ? raw : {}
193
- };
194
- }
216
+ bundle = readBundleFromJson(JSON.parse(fs.readFileSync(jsonPath, "utf8")));
195
217
  } catch {
196
218
  bundle = null;
197
219
  }
@@ -245,6 +267,7 @@ export function createEpsVitePlugin(options) {
245
267
  name: "vome-eps",
246
268
  configResolved(cfg) {
247
269
  root = cfg.root;
270
+ outDir = path.resolve(cfg.root, cfg.build.outDir || "dist");
248
271
  },
249
272
  async buildStart() {
250
273
  await generate("start");
@@ -253,7 +276,17 @@ export function createEpsVitePlugin(options) {
253
276
  if (!bootOk) {
254
277
  setTimeout(() => void generate("retry"), 3000);
255
278
  }
256
- server.middlewares.use((req, _res, next) => {
279
+ const distDir = path.resolve(root, options.dist || "build");
280
+ const jsonPath = path.join(distDir, "eps.json");
281
+ server.middlewares.use((req, res, next) => {
282
+ const url = req.url?.split("?")[0] ?? "";
283
+ if (url === "/eps.json" || url.endsWith("/eps.json")) {
284
+ try {
285
+ res.setHeader("Content-Type", "application/json; charset=utf-8");
286
+ res.end(fs.readFileSync(jsonPath));
287
+ return;
288
+ } catch {}
289
+ }
257
290
  if (req.url === "/@vite/client") {
258
291
  scheduleHot((payload) => {
259
292
  (server.hot || server.ws).send(payload);
@@ -262,6 +295,19 @@ export function createEpsVitePlugin(options) {
262
295
  next();
263
296
  });
264
297
  },
298
+ closeBundle() {
299
+ const distDir = path.resolve(root, options.dist || "build");
300
+ const src = path.join(distDir, "eps.json");
301
+ if (!outDir || !fs.existsSync(src))
302
+ return;
303
+ try {
304
+ fs.mkdirSync(outDir, { recursive: true });
305
+ fs.copyFileSync(src, path.join(outDir, "eps.json"));
306
+ console.log("[vome-eps] copied eps.json →", path.join(outDir, "eps.json"));
307
+ } catch (e) {
308
+ console.warn("[vome-eps] copy eps.json to dist failed", e);
309
+ }
310
+ },
265
311
  handleHotUpdate({ file, server }) {
266
312
  const f = file.replace(/\\/g, "/");
267
313
  if (SKIP_HOT.some((x) => f.includes(x)))