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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # 更新日志
2
2
 
3
+ ## 1.0.4
4
+
5
+ ### 修复
6
+ - 1.0.3 里注入版本号那段把中间件里的 `const` 又赋了一次值,导致 `/kkk/assets/*.js`(主题/布局那几个包)返回 500、面板打不开;
7
+ 现在改成用新变量承接,已回归正常。
8
+
3
9
  ## 1.0.3
4
10
 
5
11
  ### 变更
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 file = relative ? readWebFile(relative) : null;
323
- if (!file) {
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
- if (pluginVersion && relative.endsWith('.js') && file.includes('__KKK_VERSION__')) {
332
- file = Buffer.from(file.toString('utf-8').replace(/__KKK_VERSION__/g, pluginVersion));
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koishi-plugin-kkk",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "抖音 / B站 / 快手 / 小红书 视频解析与动态推送,带 QQ 交互面板与弹幕烧录(karin-plugin-kkk 的 Koishi 移植版)",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
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 file = relative ? readWebFile(relative) : null
332
- if (!file) {
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
- if (pluginVersion && relative.endsWith('.js') && file.includes('__KKK_VERSION__')) {
341
- file = Buffer.from(file.toString('utf-8').replace(/__KKK_VERSION__/g, pluginVersion))
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