koishi-plugin-kkk 1.0.3 → 1.0.4
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/CHANGELOG.md +6 -0
- package/lib/webui.js +5 -5
- package/package.json +1 -1
- package/src/webui.ts +5 -5
package/CHANGELOG.md
CHANGED
package/lib/webui.js
CHANGED
|
@@ -319,8 +319,8 @@ function registerWebUi({ ctx, config, rawConfig, logger, pluginRoot }) {
|
|
|
319
319
|
if (await pageDenied(response))
|
|
320
320
|
return;
|
|
321
321
|
const relative = decodeURIComponent(requestPath.slice('/kkk/assets/'.length));
|
|
322
|
-
const
|
|
323
|
-
if (!
|
|
322
|
+
const raw = relative ? readWebFile(relative) : null;
|
|
323
|
+
if (!raw) {
|
|
324
324
|
// SPA 自己的前端路由(/kkk/assets/config、/kkk/assets/about 等)→ 回 index.html
|
|
325
325
|
response.type = 'text/html; charset=utf-8';
|
|
326
326
|
response.body = indexHtml();
|
|
@@ -328,9 +328,9 @@ function registerWebUi({ ctx, config, rawConfig, logger, pluginRoot }) {
|
|
|
328
328
|
}
|
|
329
329
|
response.type = MIME[node_path_1.default.extname(relative).toLowerCase()] ?? 'application/octet-stream';
|
|
330
330
|
// 前端包里带 __KKK_VERSION__ 占位符的文件,按真实版本号替换后再发
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
331
|
+
const file = pluginVersion && relative.endsWith('.js') && raw.includes('__KKK_VERSION__')
|
|
332
|
+
? Buffer.from(raw.toString('utf-8').replace(/__KKK_VERSION__/g, pluginVersion))
|
|
333
|
+
: raw;
|
|
334
334
|
// 不缓存:面板的前端包会被我们改动(接口路径等),浏览器缓存旧包会直接导致「打不开/接口报错」
|
|
335
335
|
response.set('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0');
|
|
336
336
|
response.body = file;
|
package/package.json
CHANGED
package/src/webui.ts
CHANGED
|
@@ -328,8 +328,8 @@ export function registerWebUi ({ ctx, config, rawConfig, logger, pluginRoot }: W
|
|
|
328
328
|
if (!requestPath.startsWith('/kkk/assets/')) return next()
|
|
329
329
|
if (await pageDenied(response)) return
|
|
330
330
|
const relative = decodeURIComponent(requestPath.slice('/kkk/assets/'.length))
|
|
331
|
-
const
|
|
332
|
-
if (!
|
|
331
|
+
const raw = relative ? readWebFile(relative) : null
|
|
332
|
+
if (!raw) {
|
|
333
333
|
// SPA 自己的前端路由(/kkk/assets/config、/kkk/assets/about 等)→ 回 index.html
|
|
334
334
|
response.type = 'text/html; charset=utf-8'
|
|
335
335
|
response.body = indexHtml()
|
|
@@ -337,9 +337,9 @@ export function registerWebUi ({ ctx, config, rawConfig, logger, pluginRoot }: W
|
|
|
337
337
|
}
|
|
338
338
|
response.type = MIME[path.extname(relative).toLowerCase()] ?? 'application/octet-stream'
|
|
339
339
|
// 前端包里带 __KKK_VERSION__ 占位符的文件,按真实版本号替换后再发
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
340
|
+
const file = pluginVersion && relative.endsWith('.js') && raw.includes('__KKK_VERSION__')
|
|
341
|
+
? Buffer.from(raw.toString('utf-8').replace(/__KKK_VERSION__/g, pluginVersion))
|
|
342
|
+
: raw
|
|
343
343
|
// 不缓存:面板的前端包会被我们改动(接口路径等),浏览器缓存旧包会直接导致「打不开/接口报错」
|
|
344
344
|
response.set('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0')
|
|
345
345
|
response.body = file
|