fix: CSP nonce 导致动态 style 全丢(插件样式失效)v3.26.9 / promptlib 1.4.5
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 2m52s

This commit is contained in:
qiqi committed 2026-11-21 22:43:41 +08:00
1 parent a3edc81f55
commit 5f8f4d229f
22 files changed
+135 -43

No files matched your search

+2 -2
View File
@@ -44,9 +44,9 @@
"dir": "promptlib",
"main": "main.js",
"style": "styles.css",
"version": "1.4.2",
"version": "1.4.5",
"files": {
"main.js": "62e09d2e882addf28d379e66167e2f95ffd4b10b8eb0795d3c8ebf0a093edf4d",
"main.js": "ca3640b2982ca649dad721fca26cdcef47e3eb8951bec4e5ab1e411a742a375c",
"styles.css": "c0bbcb3274c98a62465e10090102fdcbd86d645ffdaf258db8732ca90a91d555"
}
},
+8 -4
View File
@@ -141,8 +141,9 @@ var PLP_CSS = '/* promptlib(提示词库)自带样式\n 作用域全部带
if (document.querySelector('style[data-plugin="promptlib-inline"]')) return
var n = document.createElement('style')
n.setAttribute('data-plugin', 'promptlib-inline')
try { const n0 = document.querySelector('style[nonce], link[nonce]'); if (n0 && n0.nonce) n.setAttribute('nonce', n0.nonce) } catch (e) { /* ignore */ }
n.textContent = PLP_CSS
document.head.appendChild(n)
;(document.body || document.head).appendChild(n)
} catch (e) { /* ignore */ }
}
ensureStyle()
@@ -343,7 +344,10 @@ var PLP_CSS = '/* promptlib(提示词库)自带样式\n 作用域全部带
var coverPending = {}
function coverOf (p) {
if (!p || !p.cover) return ''
var ck = (p.cover && typeof p.cover === 'object') ? ('b:' + String(p.cover.__blob || p.cover.__cache || 'obj')) : ('s:' + String(p.cover).slice(-32))
var cov = p.cover
if (typeof cov === 'string' && cov.charAt(0) === '{') { try { cov = JSON.parse(cov) } catch (e) { cov = '' } }
if (!cov) return ''
var ck = (typeof cov === 'object') ? ('b:' + String(cov.__blob || cov.__cache || 'obj')) : ('s:' + String(cov).slice(-32))
var key = p.id + '|' + ck
var hit = coverCache[key]
if (hit) return hit
@@ -351,7 +355,7 @@ var PLP_CSS = '/* promptlib(提示词库)自带样式\n 作用域全部带
if (!coverPending[key]) {
coverPending[key] = 1
try {
Promise.resolve(api.coverUrl(p.cover)).then(function (r) {
Promise.resolve(api.coverUrl(cov)).then(function (r) {
delete coverPending[key]
if (r && r.ok && r.url) { coverCache[key] = r.url; render() }
}).catch(function () { delete coverPending[key] })
@@ -729,7 +733,7 @@ var PLP_CSS = '/* promptlib(提示词库)自带样式\n 作用域全部带
global.IWBPluginHost.register({
id: 'promptlib',
name: '提示词库',
version: '1.4.2',
version: '1.4.5',
apiVersion: 1,
capabilities: ['panels', 'promptlib'],
data: { schemaVersion: 1, maxBytes: 65536 },
+2 -2
View File
@@ -1,7 +1,7 @@
{
"id": "promptlib",
"name": "提示词库",
"version": "1.4.2",
"version": "1.4.5",
"apiVersion": 1,
"main": "main.js",
"style": "styles.css",
@@ -13,7 +13,7 @@
"提示词"
],
"files": {
"main.js": "62e09d2e882addf28d379e66167e2f95ffd4b10b8eb0795d3c8ebf0a093edf4d",
"main.js": "ca3640b2982ca649dad721fca26cdcef47e3eb8951bec4e5ab1e411a742a375c",
"styles.css": "c0bbcb3274c98a62465e10090102fdcbd86d645ffdaf258db8732ca90a91d555"
}
}