hexo-swpp 2.4.1 → 2.4.3
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/lib/jsonBuilder.js +5 -6
- package/lib/sw-template.js +4 -15
- package/package.json +1 -1
package/lib/jsonBuilder.js
CHANGED
|
@@ -267,22 +267,21 @@ module.exports = (hexo, config, pluginConfig, swRules) => {
|
|
|
267
267
|
const isMerge = (pathname, tidied) => {
|
|
268
268
|
// noinspection JSUnresolvedVariable
|
|
269
269
|
const optional = pluginConfig.json?.merge
|
|
270
|
-
if (!optional) return false
|
|
271
270
|
const {tag_dir, archive_dir, category_dir} = config
|
|
272
271
|
if (pathname.includes(`/${tag_dir}/`)) {
|
|
273
|
-
if (optional
|
|
272
|
+
if (optional?.tags ?? true)
|
|
274
273
|
return tidied.tags = true
|
|
275
274
|
} else if (pathname.includes(`/${archive_dir}/`)) {
|
|
276
|
-
if (optional
|
|
275
|
+
if (optional?.archives ?? true)
|
|
277
276
|
return tidied.archives = true
|
|
278
277
|
} else if (pathname.includes(`/${category_dir}/`)) {
|
|
279
|
-
if (optional
|
|
278
|
+
if (optional?.categories ?? true)
|
|
280
279
|
return tidied.categories = true
|
|
281
280
|
} else if (pathname.startsWith('/page/') || pathname.length <= 1) {
|
|
282
|
-
if (optional
|
|
281
|
+
if (optional?.index ?? true)
|
|
283
282
|
return tidied.index = true
|
|
284
283
|
} else {
|
|
285
|
-
const list = optional
|
|
284
|
+
const list = optional?.custom
|
|
286
285
|
if (!list) return false
|
|
287
286
|
for (let reg of list) {
|
|
288
287
|
if (pathname.startsWith(`/${reg}/`))
|
package/lib/sw-template.js
CHANGED
|
@@ -19,21 +19,10 @@
|
|
|
19
19
|
dbVersion.read().then(oldVersion => {
|
|
20
20
|
if (oldVersion && oldVersion.escape !== escape) {
|
|
21
21
|
oldVersion.escape = escape
|
|
22
|
-
const rules = new VersionList()
|
|
23
|
-
rules.refresh = true
|
|
24
22
|
// noinspection JSUnresolvedVariable
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
updateJson(true)
|
|
29
|
-
]).then(
|
|
30
|
-
args => clients.matchAll().then(
|
|
31
|
-
list => list.forEach(client => client.postMessage({
|
|
32
|
-
type: 'escape',
|
|
33
|
-
version: args[2].version
|
|
34
|
-
}))
|
|
35
|
-
)
|
|
36
|
-
)
|
|
23
|
+
caches.delete(CACHE_NAME)
|
|
24
|
+
.then(() => clients.matchAll())
|
|
25
|
+
.then(list => list.forEach(client => client.postMessage({type: 'escape'})))
|
|
37
26
|
}
|
|
38
27
|
})
|
|
39
28
|
})
|
|
@@ -138,7 +127,7 @@
|
|
|
138
127
|
/** 解析字符串 */
|
|
139
128
|
const parseJson = json => dbVersion.read().then(oldVersion => {
|
|
140
129
|
const {info, global} = json
|
|
141
|
-
const newVersion = {global, local: info[0].version, escape: oldVersion
|
|
130
|
+
const newVersion = {global, local: info[0].version, escape: oldVersion?.escape}
|
|
142
131
|
//新用户不进行更新操作
|
|
143
132
|
if (!oldVersion || skip) {
|
|
144
133
|
dbVersion.write(newVersion)
|