fix(plugins): 市场请求改走原生 HTTP(绕开 WebView 的 CORS/代理限制)+ http 允许市场域名
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 45s
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 45s
This commit is contained in:
1 parent
51bc9c581a
commit
09d4284d81
2 files changed
+17
-2
No files matched your search
@@ -8523,8 +8523,14 @@ items.push(el('button', { key: 'bgc', className: 'iwb-ctx-item', onClick: (e) =>
|
||||
|
||||
// ---- 插件市场(P2):静态索引 market.maqiart.eu.org/index.json → 下载 → sha256 校验 → 写入 plugins/ ----
|
||||
const W_MARKET_URL = 'https://market.maqiart.eu.org/index.json'
|
||||
// 桌面端优先用 Tauri 的原生 HTTP(Rust 侧):WKWebView 在代理/fake-IP 环境下直连会 Load failed
|
||||
function wMarketFetch(url) {
|
||||
const T = (typeof window !== 'undefined' && window.__TAURI__ && window.__TAURI__.http) ? window.__TAURI__.http : null
|
||||
if (T && typeof T.fetch === 'function') return T.fetch(url)
|
||||
return fetch(url, { cache: 'no-store' })
|
||||
}
|
||||
async function wMarketList() {
|
||||
const resp = await fetch(W_MARKET_URL, { cache: 'no-store' })
|
||||
const resp = await wMarketFetch(W_MARKET_URL)
|
||||
if (!resp.ok) throw new Error('市场不可达:HTTP ' + resp.status)
|
||||
const j = await resp.json()
|
||||
return Array.isArray(j && j.plugins) ? j.plugins : []
|
||||
@@ -8540,7 +8546,7 @@ items.push(el('button', { key: 'bgc', className: 'iwb-ctx-item', onClick: (e) =>
|
||||
const item = list.find((p) => p && p.id === id)
|
||||
if (!item) return { ok: false, error: '市场里没有这个插件' }
|
||||
const base = W_MARKET_URL.replace(/index\.json$/, '')
|
||||
const resp = await fetch(base + item.file, { cache: 'no-store' })
|
||||
const resp = await wMarketFetch(base + item.file)
|
||||
if (!resp.ok) throw new Error('下载失败:HTTP ' + resp.status)
|
||||
const text = await resp.text()
|
||||
const buf = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(text))
|
||||
|
||||
@@ -47,6 +47,15 @@
|
||||
},
|
||||
{
|
||||
"url": "https://*.blob.core.windows.net/**"
|
||||
},
|
||||
{
|
||||
"url": "https://market.maqiart.eu.org/**"
|
||||
},
|
||||
{
|
||||
"url": "https://download.maqiart.eu.org/**"
|
||||
},
|
||||
{
|
||||
"url": "https://git.maqiart.eu.org/**"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user