feat: 支持自定义 Z-Library 镜像并发布 v2.1.5
在 Z-Library 账户设置内增加镜像站点编辑入口,一行一个 HTTPS 地址, 自定义地址经 origin 规范化后优先于内置列表。镜像配置与凭据分开处理, 退出登录后仍保留;移除当前会话依赖的镜像时清理旧会话和 Cookie。 版本更新到 2.1.5,并补充存储、校验、IPC、界面与真实 Electron 保存测试。
This commit is contained in:
@@ -124,6 +124,38 @@ $('zlibLogoutBtn').onclick = async () => {
|
||||
|
||||
refreshZlibStatus();
|
||||
|
||||
async function refreshZlibMirrors() {
|
||||
const r = await window.api.zlib.getMirrors();
|
||||
const custom = (r.ok && r.data && r.data.custom) || [];
|
||||
$('zlibMirrorStatus').textContent = custom.length
|
||||
? `已自定义 ${custom.length} 个镜像,优先于内置列表`
|
||||
: '使用内置镜像列表';
|
||||
}
|
||||
|
||||
$('zlibMirrorBtn').onclick = async () => {
|
||||
const current = await window.api.zlib.getMirrors();
|
||||
if (!current.ok) return;
|
||||
const custom = (current.data && current.data.custom) || [];
|
||||
const defaults = (current.data && current.data.defaults) || [];
|
||||
const r = await openModal('Z-Library 镜像站点', `
|
||||
<p style="margin-bottom:8px;">一行一个地址,必须是 HTTPS。自定义镜像会排在内置列表前面优先尝试;留空则只用内置列表。</p>
|
||||
<div style="display:flex;flex-direction:column;gap:8px;">
|
||||
<textarea id="zlibMirrorList" class="modal-input" rows="6" spellcheck="false"
|
||||
placeholder="https://example.org">${escapeHtml(custom.join('\n'))}</textarea>
|
||||
<div class="settings-item-desc">内置镜像:${escapeHtml(defaults.join('、'))}</div>
|
||||
<div id="zlibMirrorErr" class="note-form-error"></div>
|
||||
</div>
|
||||
`, async () => {
|
||||
const lines = $('zlibMirrorList').value.split('\n').map((s) => s.trim()).filter(Boolean);
|
||||
const res = await window.api.zlib.setMirrors(lines);
|
||||
if (!res.ok) { $('zlibMirrorErr').textContent = res.error || '保存失败'; return false; }
|
||||
return true;
|
||||
});
|
||||
if (r) { refreshZlibMirrors(); refreshZlibStatus(); }
|
||||
};
|
||||
|
||||
refreshZlibMirrors();
|
||||
|
||||
async function refreshLibraryDir() {
|
||||
const r = await window.api.library.getDir();
|
||||
if (r.ok && r.data) $('libDirPath').textContent = r.data.dir + (r.data.isDefault ? '(默认)' : '');
|
||||
|
||||
Reference in New Issue
Block a user