@opengis/admin 0.1.7 → 0.1.8
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/{add-page-C3Wh2-Ml.js → add-page-DSvX-3Xh.js} +1 -1
- package/dist/{admin-interface-C4m7uvG2.js → admin-interface-Oa0z-BVX.js} +1 -1
- package/dist/{admin-view-YtM2-LrW.js → admin-view-BqbD6bLH.js} +1 -1
- package/dist/admin.js +1 -1
- package/dist/admin.umd.cjs +9 -9
- package/dist/{card-page-WrYs8chM.js → card-page-CURo3EUe.js} +1 -1
- package/dist/{card-view-BwtqUSFP.js → card-view-D-SaZyIS.js} +1 -1
- package/dist/{edit-page-CMTqsvJf.js → edit-page-C3JRp601.js} +1 -1
- package/dist/{import-file-bdYAo8iW.js → import-file-DpWVoe-P.js} +555 -623
- package/package.json +1 -1
- package/server/plugins/vite.js +5 -5
- package/server/routes/menu/controllers/getMenu.js +7 -6
package/package.json
CHANGED
package/server/plugins/vite.js
CHANGED
|
@@ -16,14 +16,14 @@ async function plugin(fastify) {
|
|
|
16
16
|
server: {
|
|
17
17
|
middlewareMode: true,
|
|
18
18
|
},
|
|
19
|
-
});
|
|
19
|
+
});
|
|
20
20
|
// hot reload
|
|
21
|
-
viteServer.watcher.on('all', function (d, t) {
|
|
22
|
-
if (!t.includes('module')) return;
|
|
21
|
+
viteServer.watcher.on('all', function (d, t) {
|
|
22
|
+
if (!t.includes('module')) return;
|
|
23
23
|
console.log(d, t);
|
|
24
|
-
viteServer.ws.send({type: 'full-reload' });
|
|
24
|
+
viteServer.ws.send({ type: 'full-reload' });
|
|
25
25
|
});
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
// this is middleware for vite's dev servert
|
|
28
28
|
fastify.addHook('onRequest', async (req, reply) => {
|
|
29
29
|
const { user } = req.session?.passport || {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
import { join } from 'path';
|
|
3
|
+
import { readFile } from 'fs/promises';
|
|
3
4
|
import userTemplateDir from '@opengis/fastify-table/table/controllers/utils/userTemplateDir.js'
|
|
4
|
-
import { existsSync, readdirSync } from 'fs';
|
|
5
|
-
|
|
5
|
+
import { existsSync, readdirSync, readFileSync } from 'fs';
|
|
6
|
+
const menuCache = [];
|
|
6
7
|
// check module dir
|
|
7
8
|
const moduleDir = join(process.cwd(), 'module');
|
|
8
9
|
const dirs = existsSync(moduleDir) ?
|
|
@@ -15,10 +16,11 @@ const menuList = dirs.concat(userTemplateDir)
|
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
const isProduction = process.env.NODE_ENV === 'production';
|
|
18
|
-
|
|
19
|
+
readMenu();
|
|
19
20
|
|
|
20
21
|
async function readMenu() {
|
|
21
|
-
const list =
|
|
22
|
+
// const list = menuList.map(el => readFileSync(el, 'utf-8')); // sync
|
|
23
|
+
const list = await Promise.all(menuList.map(el => readFileSync(el, 'utf-8'))); // sync
|
|
22
24
|
const menus = list.reduce((p, el) => p.concat(JSON.parse(el)), [])
|
|
23
25
|
.map(el => ({ order: 0, ...el }))
|
|
24
26
|
.sort((a, b) => (a.order > b.order) ? 1 : ((b.order > a.order) ? -1 : 0))
|
|
@@ -28,6 +30,5 @@ async function readMenu() {
|
|
|
28
30
|
}
|
|
29
31
|
export default async function adminMenu() {
|
|
30
32
|
const menus = isProduction && menuCache.length ? menuCache : await readMenu();
|
|
31
|
-
|
|
32
33
|
return menus;
|
|
33
34
|
}
|