mirror of
https://github.com/gedoor/legado.git
synced 2024-09-01 09:34:25 +08:00
优化web
This commit is contained in:
parent
5f44eb7f06
commit
73799f1c52
@ -35,17 +35,17 @@
|
||||
<div>
|
||||
<div>源分组 :</div>
|
||||
<textarea rows="1" id="sourceGroup" class="base" title="sourceGroup"
|
||||
placeholder="<选填>描述书源的特征信息"></textarea>
|
||||
placeholder="<选填>描述源的特征信息"></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<div>源注释 :</div>
|
||||
<textarea rows="1" id="sourceComment" class="base" title="sourceComment"
|
||||
placeholder="<选填>描述书源作者和状态"></textarea>
|
||||
placeholder="<选填>描述源作者和状态"></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<div>登录地址:</div>
|
||||
<textarea rows="1" id="loginUrl" class="base" title="loginUrl"
|
||||
placeholder="<选填>填写网站登录网址,仅在需要登录的书源有用"></textarea>
|
||||
placeholder="<选填>填写网站登录网址,仅在需要登录的源有用"></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<div>登录界面:</div>
|
||||
@ -152,19 +152,19 @@
|
||||
</div>
|
||||
<div class="menu">
|
||||
<svg class="button">
|
||||
<text x="50%" y="55%">⇈推送书源</text>
|
||||
<text x="50%" y="55%">⇈推送源</text>
|
||||
<rect id="push"></rect>
|
||||
</svg>
|
||||
<svg class="button">
|
||||
<text x="50%" y="55%">⇊拉取书源</text>
|
||||
<text x="50%" y="55%">⇊拉取源</text>
|
||||
<rect id="pull"></rect>
|
||||
</svg>
|
||||
<svg class="button">
|
||||
<text x="50%" y="55%">⋘编辑书源</text>
|
||||
<text x="50%" y="55%">⋘编辑源</text>
|
||||
<rect id="editor"></rect>
|
||||
</svg>
|
||||
<svg class="button">
|
||||
<text x="50%" y="55%">⋙生成书源</text>
|
||||
<text x="50%" y="55%">⋙生成源</text>
|
||||
<rect id="conver"></rect>
|
||||
</svg>
|
||||
<svg class="button">
|
||||
@ -180,20 +180,20 @@
|
||||
<rect id="redo"></rect>
|
||||
</svg>
|
||||
<svg class="button">
|
||||
<text x="50%" y="55%">⇏调试书源</text>
|
||||
<text x="50%" y="55%">⇏调试源</text>
|
||||
<rect id="debug"></rect>
|
||||
</svg>
|
||||
<svg class="button">
|
||||
<text x="50%" y="55%">✓保存书源</text>
|
||||
<text x="50%" y="55%">✓保存源</text>
|
||||
<rect id="accept"></rect>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="outbox">
|
||||
<div class="tabbox">
|
||||
<div class="tabtitle">
|
||||
<div name="编辑书源" class="tab1 this">编辑书源</div>
|
||||
<div name="调试书源" class="tab2">调试书源</div>
|
||||
<div name="书源列表" class="tab3">书源列表</div>
|
||||
<div name="编辑源" class="tab1 this">编辑源</div>
|
||||
<div name="调试源" class="tab2">调试源</div>
|
||||
<div name="源列表" class="tab3">源列表</div>
|
||||
<div name="帮助信息" class="tab4">帮助信息</div>
|
||||
</div>
|
||||
<div class="tabbody">
|
||||
@ -209,9 +209,9 @@
|
||||
<input type="text" class="inputbox" id="Filter"
|
||||
placeholder="输入筛选关键词(源名称、源URL或源分组)后按回车筛选源">
|
||||
<div class="titlebar">
|
||||
<button id="Import">导入书源文件</button>
|
||||
<button id="Export">导出书源文件</button>
|
||||
<button id="Delete">删除选中书源</button>
|
||||
<button id="Import">导入源文件</button>
|
||||
<button id="Export">导出源文件</button>
|
||||
<button id="Delete">删除选中源</button>
|
||||
<button id="ClrAll">清空当前列表</button>
|
||||
</div>
|
||||
<div class="context" id="RuleList"></div>
|
||||
|
@ -17,7 +17,7 @@ function hashParam(key, val) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// 创建书源规则容器对象
|
||||
// 创建源规则容器对象
|
||||
function Container() {
|
||||
let ruleJson = {};
|
||||
|
||||
@ -36,7 +36,7 @@ function showTab(tabName) {
|
||||
$(`.tabtitle>*[name=${tabName}]`).className += ' this';
|
||||
hashParam('tab', tabName);
|
||||
}
|
||||
// 书源列表列表标签构造函数
|
||||
// 源列表列表标签构造函数
|
||||
function newRule(rule) {
|
||||
return `<label for="${rule.sourceUrl}"><input type="radio" name="rule" id="${rule.sourceUrl}"><div>${rule.sourceName}<br>${rule.sourceUrl}</div></label>`;
|
||||
}
|
||||
@ -71,7 +71,7 @@ function HttpPost(url, data) {
|
||||
})
|
||||
}).then(res => res.json()).catch(err => console.error('Error:', err));
|
||||
}
|
||||
// 将书源表单转化为书源对象
|
||||
// 将源表单转化为源对象
|
||||
function rule2json() {
|
||||
let RuleJSON = Container();
|
||||
// 转换base
|
||||
@ -86,7 +86,7 @@ function rule2json() {
|
||||
RuleJSON.enabled = RuleJSON.enabled == '' || String(RuleJSON.enabled).toLocaleLowerCase().replace(/^\s*|\s*$/g, '') == 'true';
|
||||
return RuleJSON;
|
||||
}
|
||||
// 将书源对象填充到书源表单
|
||||
// 将源对象填充到源表单
|
||||
function json2rule(RuleEditor) {
|
||||
let RuleJSON = Container();
|
||||
// 转换base
|
||||
@ -214,23 +214,23 @@ $('.menu').addEventListener('click', e => {
|
||||
if (okData.find(x => x.sourceUrl == item.sourceUrl)) { }
|
||||
else { $(`#RuleList #${item.sourceUrl}+*`).className += 'isError'; }
|
||||
});
|
||||
failMsg = '\n推送失败的书源将用红色字体标注!';
|
||||
failMsg = '\n推送失败的源将用红色字体标注!';
|
||||
}
|
||||
alert(`批量推送书源到「阅读3.0APP」\n共计: ${RuleSources.length} 条\n成功: ${okData.length} 条\n失败: ${RuleSources.length - okData.length} 条${failMsg}`);
|
||||
alert(`批量推送源到「阅读3.0APP」\n共计: ${RuleSources.length} 条\n成功: ${okData.length} 条\n失败: ${RuleSources.length - okData.length} 条${failMsg}`);
|
||||
}
|
||||
else {
|
||||
alert(`批量推送书源到「阅读3.0APP」成功!\n共计: ${RuleSources.length} 条`);
|
||||
alert(`批量推送源到「阅读3.0APP」成功!\n共计: ${RuleSources.length} 条`);
|
||||
}
|
||||
}
|
||||
else {
|
||||
alert(`批量推送书源失败!\nErrorMsg: ${json.errorMsg}`);
|
||||
alert(`批量推送源失败!\nErrorMsg: ${json.errorMsg}`);
|
||||
}
|
||||
}).catch(err => { alert(`批量推送书源失败,无法连接到「阅读3.0APP」!\n${err}`); });
|
||||
}).catch(err => { alert(`批量推送源失败,无法连接到「阅读3.0APP」!\n${err}`); });
|
||||
thisNode.setAttribute('class', '');
|
||||
})();
|
||||
return;
|
||||
case 'pull':
|
||||
showTab('书源列表');
|
||||
showTab('源列表');
|
||||
(async () => {
|
||||
await HttpGet(`/getRssSources`).then(json => {
|
||||
if (json.isSuccess) {
|
||||
@ -239,12 +239,12 @@ $('.menu').addEventListener('click', e => {
|
||||
RuleSources.forEach(item => {
|
||||
$('#RuleList').innerHTML += newRule(item);
|
||||
});
|
||||
alert(`成功拉取 ${RuleSources.length} 条书源`);
|
||||
alert(`成功拉取 ${RuleSources.length} 条源`);
|
||||
}
|
||||
else {
|
||||
alert(`批量拉取书源失败!\nErrorMsg: ${json.errorMsg}`);
|
||||
alert(`批量拉取源失败!\nErrorMsg: ${json.errorMsg}`);
|
||||
}
|
||||
}).catch(err => { alert(`批量拉取书源失败,无法连接到「阅读3.0APP」!\n${err}`); });
|
||||
}).catch(err => { alert(`批量拉取源失败,无法连接到「阅读3.0APP」!\n${err}`); });
|
||||
thisNode.setAttribute('class', '');
|
||||
})();
|
||||
return;
|
||||
@ -259,7 +259,7 @@ $('.menu').addEventListener('click', e => {
|
||||
}
|
||||
break;
|
||||
case 'conver':
|
||||
showTab('编辑书源');
|
||||
showTab('编辑源');
|
||||
$('#RuleJsonString').value = JSON.stringify(rule2json(), null, 4);
|
||||
break;
|
||||
case 'initial':
|
||||
@ -273,7 +273,7 @@ $('.menu').addEventListener('click', e => {
|
||||
redo()
|
||||
break;
|
||||
case 'debug':
|
||||
showTab('调试书源');
|
||||
showTab('调试源');
|
||||
let wsOrigin = (hashParam('domain') || location.origin).replace(/^.*?:/, 'ws:').replace(/\d+$/, (port) => (parseInt(port) + 1));
|
||||
let DebugInfos = $('#DebugConsole');
|
||||
function DebugPrint(msg) { DebugInfos.value += `\n${msg}`; DebugInfos.scrollTop = DebugInfos.scrollHeight; }
|
||||
@ -281,7 +281,7 @@ $('.menu').addEventListener('click', e => {
|
||||
HttpPost(`/saveRssSources`, saveRule).then(sResult => {
|
||||
if (sResult.isSuccess) {
|
||||
let sKey = DebugKey.value ? DebugKey.value : '我的';
|
||||
$('#DebugConsole').value = `书源《${saveRule[0].sourceName}》保存成功!使用搜索关键字“${sKey}”开始调试...`;
|
||||
$('#DebugConsole').value = `源《${saveRule[0].sourceName}》保存成功!使用搜索关键字“${sKey}”开始调试...`;
|
||||
let ws = new WebSocket(`${wsOrigin}/sourceDebug`);
|
||||
ws.onopen = () => {
|
||||
ws.send(`{"tag":"${saveRule[0].sourceUrl}", "key":"${sKey}"}`);
|
||||
@ -307,9 +307,9 @@ $('.menu').addEventListener('click', e => {
|
||||
(async () => {
|
||||
let saveRule = [rule2json()];
|
||||
await HttpPost(`/saveRssSources`, saveRule).then(json => {
|
||||
alert(json.isSuccess ? `书源《${saveRule[0].sourceName}》已成功保存到「阅读3.0APP」` : `书源《${saveRule[0].sourceName}》保存失败!\nErrorMsg: ${json.errorMsg}`);
|
||||
alert(json.isSuccess ? `源《${saveRule[0].sourceName}》已成功保存到「阅读3.0APP」` : `源《${saveRule[0].sourceName}》保存失败!\nErrorMsg: ${json.errorMsg}`);
|
||||
setRule(saveRule[0]);
|
||||
}).catch(err => { alert(`保存书源失败,无法连接到「阅读3.0APP」!\n${err}`); });
|
||||
}).catch(err => { alert(`保存源失败,无法连接到「阅读3.0APP」!\n${err}`); });
|
||||
thisNode.setAttribute('class', '');
|
||||
})();
|
||||
return;
|
||||
@ -376,7 +376,7 @@ $('.tab3>.titlebar').addEventListener('click', e => {
|
||||
let fileJson = JSON.parse(fileText);
|
||||
let newSources = [];
|
||||
newSources.push(...fileJson);
|
||||
if (window.confirm(`如何处理导入的书源?\n"确定": 覆盖当前列表(不会删除APP源)\n"取消": 插入列表尾部(自动忽略重复源)`)) {
|
||||
if (window.confirm(`如何处理导入的源?\n"确定": 覆盖当前列表(不会删除APP源)\n"取消": 插入列表尾部(自动忽略重复源)`)) {
|
||||
localStorage.setItem('RssSources', JSON.stringify(RuleSources = newSources));
|
||||
$('#RuleList').innerHTML = ''
|
||||
RuleSources.forEach(item => {
|
||||
@ -391,10 +391,10 @@ $('.tab3>.titlebar').addEventListener('click', e => {
|
||||
$('#RuleList').innerHTML += newRule(item);
|
||||
});
|
||||
}
|
||||
alert(`成功导入 ${newSources.length} 条书源`);
|
||||
alert(`成功导入 ${newSources.length} 条源`);
|
||||
}
|
||||
catch (err) {
|
||||
alert(`导入书源文件失败!\n${err}`);
|
||||
alert(`导入源文件失败!\n${err}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -412,13 +412,13 @@ $('.tab3>.titlebar').addEventListener('click', e => {
|
||||
case 'Delete':
|
||||
let selectRule = $('#RuleList input:checked');
|
||||
if (!selectRule) {
|
||||
alert(`没有书源被选中!`);
|
||||
alert(`没有源被选中!`);
|
||||
return;
|
||||
}
|
||||
if (confirm(`确定要删除选定书源吗?\n(同时删除APP内书源)`)) {
|
||||
if (confirm(`确定要删除选定源吗?\n(同时删除APP内源)`)) {
|
||||
let selectRuleUrl = selectRule.id;
|
||||
let deleteSources = RuleSources.filter(item => item.sourceUrl == selectRuleUrl); // 提取待删除的书源
|
||||
let laveSources = RuleSources.filter(item => !(item.sourceUrl == selectRuleUrl)); // 提取待留下的书源
|
||||
let deleteSources = RuleSources.filter(item => item.sourceUrl == selectRuleUrl); // 提取待删除的源
|
||||
let laveSources = RuleSources.filter(item => !(item.sourceUrl == selectRuleUrl)); // 提取待留下的源
|
||||
HttpPost(`/deleteRssSources`, deleteSources).then(json => {
|
||||
if (json.isSuccess) {
|
||||
let selectNode = document.getElementById(selectRuleUrl).parentNode;
|
||||
@ -429,13 +429,13 @@ $('.tab3>.titlebar').addEventListener('click', e => {
|
||||
todo();
|
||||
}
|
||||
console.log(deleteSources);
|
||||
console.log(`以上书源已删除!`)
|
||||
console.log(`以上源已删除!`)
|
||||
}
|
||||
}).catch(err => { alert(`删除书源失败,无法连接到「阅读3.0APP」!\n${err}`); });
|
||||
}).catch(err => { alert(`删除源失败,无法连接到「阅读3.0APP」!\n${err}`); });
|
||||
}
|
||||
break;
|
||||
case 'ClrAll':
|
||||
if (confirm(`确定要清空当前书源列表吗?\n(不会删除APP内书源)`)) {
|
||||
if (confirm(`确定要清空当前源列表吗?\n(不会删除APP内源)`)) {
|
||||
localStorage.setItem('RssSources', JSON.stringify(RuleSources = []));
|
||||
$('#RuleList').innerHTML = ''
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user