hexo-swpp 1.5.5 → 1.6.1

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/README.md CHANGED
@@ -2,4 +2,12 @@
2
2
 
3
3
    具体说明见:[小白也能用的 SW 构建插件 - 山岳库博](https://kmar.top/posts/73014407/)
4
4
 
5
-   请务必使用最新版插件!
5
+ ---
6
+
7
+   插件版本:A.B.C:
8
+
9
+ + A:重大功能更新时变化
10
+ + B:修改配置文件或功能更新时变化
11
+ + C:BUG 修复时变化
12
+
13
+   所以 C 修改时务必更新版本,A、B 修改时可酌情追更,由于本人不会维护旧版本的代码,所以仍然建议使用最新版本的插件。
package/index.js CHANGED
@@ -43,7 +43,8 @@ if (pluginConfig?.enable) {
43
43
  .replaceAll('module.exports.replaceList', 'const replaceList')
44
44
  const swContent = fs.readFileSync(relativePath, 'utf8')
45
45
  .replaceAll('const { cacheList, replaceList } = require(\'../sw-cache\')', cache)
46
- .replaceAll("'@$$[escape]'", (pluginConfig.escape ?? 0).toString())
46
+ .replaceAll("'@$$[escape]'", (pluginConfig.sw.escape ?? 0).toString())
47
+ .replaceAll("'@$$[cacheName]'", `'${pluginConfig.sw.cacheName ?? 'kmarBlogCache'}'`)
47
48
  return {
48
49
  path: 'sw.js',
49
50
  data: swContent
@@ -249,7 +250,7 @@ const fetchFile = link => new Promise((resolve, reject) => {
249
250
  referer: new URL(link).hostname,
250
251
  'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 Edg/107.0.1418.62'
251
252
  },
252
- timeout: pluginConfig.timeout ?? 1500
253
+ timeout: pluginConfig.external.timeout ?? 1500
253
254
  }).then(response => {
254
255
  switch (response.status) {
255
256
  case 200: case 301: case 302:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-swpp",
3
- "version": "1.5.5",
3
+ "version": "1.6.1",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "hexo-log": "^3.0.0",
package/sw-template.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  (() => {
4
4
  /** 缓存库名称 */
5
- const CACHE_NAME = 'kmarBlogCache'
5
+ const CACHE_NAME = '@$$[cacheName]'
6
6
  /** 版本名称存储地址(必须以`/`结尾) */
7
7
  const VERSION_PATH = 'https://id.v3/'
8
8