启用订阅缓存,大幅减少浏览器响应延迟

This commit is contained in:
Peng-YM 2020-09-01 12:08:14 +08:00
parent b2f9eb9989
commit 56b350a649
4 changed files with 94 additions and 80 deletions

View File

@ -20,20 +20,10 @@
</component>
<component name="ChangeListManager">
<list default="true" id="8b97a098-48b2-4e64-a9ef-522fe2d30b52" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/../web/src/components/KeywordDeleteOperator.vue" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../web/src/components/KeywordRenameOperator.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/sub-store.js" beforeDir="false" afterPath="$PROJECT_DIR$/sub-store.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/components/KeywordFilter.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/components/KeywordFilter.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/components/KeywordRename.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/components/RegexDeleteOperator.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/components/KeywordSort.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/components/KeywordSortOperator.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/components/RegexFilter.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/components/RegexFilter.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/components/RegexRename.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/components/RegexRenameOperator.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/components/RegionFilter.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/components/RegionFilter.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/components/Sort.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/components/SortOperator.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/components/TypeFilter.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/components/TypeFilter.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/config.js" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/config.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/views/SubEditor.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/views/SubEditor.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/components/ProxyList.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/components/ProxyList.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/views/Subscription.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/views/Subscription.vue" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -100,7 +90,8 @@
<workItem from="1598876594229" duration="1662000" />
<workItem from="1598887302218" duration="3200000" />
<workItem from="1598898694400" duration="1336000" />
<workItem from="1598900239005" duration="4051000" />
<workItem from="1598900239005" duration="4742000" />
<workItem from="1598931009084" duration="1869000" />
</task>
<servers />
</component>
@ -120,7 +111,7 @@
<option name="oldMeFiltersMigrated" value="true" />
</component>
<component name="WindowStateProjectService">
<state width="840" height="374" key="GridCell.Tab.0.bottom" timestamp="1598922564717">
<state width="1300" height="374" key="GridCell.Tab.0.bottom" timestamp="1598931659748">
<screen x="70" y="23" width="1722" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.0.bottom/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358068" />
@ -130,8 +121,8 @@
<state width="849" height="374" key="GridCell.Tab.0.bottom/60.23.1732.1097@60.23.1732.1097" timestamp="1598872847575" />
<state width="849" height="374" key="GridCell.Tab.0.bottom/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992684" />
<state width="849" height="374" key="GridCell.Tab.0.bottom/67.23.1725.1097@67.23.1725.1097" timestamp="1598900393008" />
<state width="840" height="374" key="GridCell.Tab.0.bottom/70.23.1722.1097@70.23.1722.1097" timestamp="1598922564717" />
<state width="840" height="374" key="GridCell.Tab.0.center" timestamp="1598922564716">
<state width="1300" height="374" key="GridCell.Tab.0.bottom/70.23.1722.1097@70.23.1722.1097" timestamp="1598931659748" />
<state width="1300" height="374" key="GridCell.Tab.0.center" timestamp="1598931659747">
<screen x="70" y="23" width="1722" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.0.center/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358067" />
@ -141,8 +132,8 @@
<state width="849" height="374" key="GridCell.Tab.0.center/60.23.1732.1097@60.23.1732.1097" timestamp="1598872847574" />
<state width="849" height="374" key="GridCell.Tab.0.center/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992684" />
<state width="849" height="374" key="GridCell.Tab.0.center/67.23.1725.1097@67.23.1725.1097" timestamp="1598900393007" />
<state width="840" height="374" key="GridCell.Tab.0.center/70.23.1722.1097@70.23.1722.1097" timestamp="1598922564716" />
<state width="840" height="374" key="GridCell.Tab.0.left" timestamp="1598922564716">
<state width="1300" height="374" key="GridCell.Tab.0.center/70.23.1722.1097@70.23.1722.1097" timestamp="1598931659747" />
<state width="1300" height="374" key="GridCell.Tab.0.left" timestamp="1598931659746">
<screen x="70" y="23" width="1722" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.0.left/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358067" />
@ -152,8 +143,8 @@
<state width="849" height="374" key="GridCell.Tab.0.left/60.23.1732.1097@60.23.1732.1097" timestamp="1598872847574" />
<state width="849" height="374" key="GridCell.Tab.0.left/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992683" />
<state width="849" height="374" key="GridCell.Tab.0.left/67.23.1725.1097@67.23.1725.1097" timestamp="1598900393005" />
<state width="840" height="374" key="GridCell.Tab.0.left/70.23.1722.1097@70.23.1722.1097" timestamp="1598922564716" />
<state width="840" height="374" key="GridCell.Tab.0.right" timestamp="1598922564717">
<state width="1300" height="374" key="GridCell.Tab.0.left/70.23.1722.1097@70.23.1722.1097" timestamp="1598931659746" />
<state width="1300" height="374" key="GridCell.Tab.0.right" timestamp="1598931659748">
<screen x="70" y="23" width="1722" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.0.right/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358068" />
@ -163,8 +154,8 @@
<state width="849" height="374" key="GridCell.Tab.0.right/60.23.1732.1097@60.23.1732.1097" timestamp="1598872847575" />
<state width="849" height="374" key="GridCell.Tab.0.right/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992684" />
<state width="849" height="374" key="GridCell.Tab.0.right/67.23.1725.1097@67.23.1725.1097" timestamp="1598900393007" />
<state width="840" height="374" key="GridCell.Tab.0.right/70.23.1722.1097@70.23.1722.1097" timestamp="1598922564717" />
<state width="840" height="374" key="GridCell.Tab.1.bottom" timestamp="1598922564621">
<state width="1300" height="374" key="GridCell.Tab.0.right/70.23.1722.1097@70.23.1722.1097" timestamp="1598931659748" />
<state width="840" height="374" key="GridCell.Tab.1.bottom" timestamp="1598932593853">
<screen x="70" y="23" width="1722" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.1.bottom/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358069" />
@ -174,8 +165,8 @@
<state width="849" height="374" key="GridCell.Tab.1.bottom/60.23.1732.1097@60.23.1732.1097" timestamp="1598872847575" />
<state width="849" height="374" key="GridCell.Tab.1.bottom/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992587" />
<state width="849" height="374" key="GridCell.Tab.1.bottom/67.23.1725.1097@67.23.1725.1097" timestamp="1598900392856" />
<state width="840" height="374" key="GridCell.Tab.1.bottom/70.23.1722.1097@70.23.1722.1097" timestamp="1598922564621" />
<state width="840" height="374" key="GridCell.Tab.1.center" timestamp="1598922564621">
<state width="840" height="374" key="GridCell.Tab.1.bottom/70.23.1722.1097@70.23.1722.1097" timestamp="1598932593853" />
<state width="840" height="374" key="GridCell.Tab.1.center" timestamp="1598932593853">
<screen x="70" y="23" width="1722" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.1.center/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358069" />
@ -185,8 +176,8 @@
<state width="849" height="374" key="GridCell.Tab.1.center/60.23.1732.1097@60.23.1732.1097" timestamp="1598872847575" />
<state width="849" height="374" key="GridCell.Tab.1.center/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992587" />
<state width="849" height="374" key="GridCell.Tab.1.center/67.23.1725.1097@67.23.1725.1097" timestamp="1598900392855" />
<state width="840" height="374" key="GridCell.Tab.1.center/70.23.1722.1097@70.23.1722.1097" timestamp="1598922564621" />
<state width="840" height="374" key="GridCell.Tab.1.left" timestamp="1598922564621">
<state width="840" height="374" key="GridCell.Tab.1.center/70.23.1722.1097@70.23.1722.1097" timestamp="1598932593853" />
<state width="840" height="374" key="GridCell.Tab.1.left" timestamp="1598932593852">
<screen x="70" y="23" width="1722" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.1.left/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358069" />
@ -196,8 +187,8 @@
<state width="849" height="374" key="GridCell.Tab.1.left/60.23.1732.1097@60.23.1732.1097" timestamp="1598872847575" />
<state width="849" height="374" key="GridCell.Tab.1.left/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992587" />
<state width="849" height="374" key="GridCell.Tab.1.left/67.23.1725.1097@67.23.1725.1097" timestamp="1598900392855" />
<state width="840" height="374" key="GridCell.Tab.1.left/70.23.1722.1097@70.23.1722.1097" timestamp="1598922564621" />
<state width="840" height="374" key="GridCell.Tab.1.right" timestamp="1598922564621">
<state width="840" height="374" key="GridCell.Tab.1.left/70.23.1722.1097@70.23.1722.1097" timestamp="1598932593852" />
<state width="840" height="374" key="GridCell.Tab.1.right" timestamp="1598932593853">
<screen x="70" y="23" width="1722" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.1.right/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358069" />
@ -207,8 +198,8 @@
<state width="849" height="374" key="GridCell.Tab.1.right/60.23.1732.1097@60.23.1732.1097" timestamp="1598872847575" />
<state width="849" height="374" key="GridCell.Tab.1.right/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992587" />
<state width="849" height="374" key="GridCell.Tab.1.right/67.23.1725.1097@67.23.1725.1097" timestamp="1598900392855" />
<state width="840" height="374" key="GridCell.Tab.1.right/70.23.1722.1097@70.23.1722.1097" timestamp="1598922564621" />
<state width="840" height="374" key="GridCell.Tab.2.bottom" timestamp="1598922564622">
<state width="840" height="374" key="GridCell.Tab.1.right/70.23.1722.1097@70.23.1722.1097" timestamp="1598932593853" />
<state width="1300" height="374" key="GridCell.Tab.2.bottom" timestamp="1598931659637">
<screen x="70" y="23" width="1722" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.2.bottom/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358071" />
@ -218,8 +209,8 @@
<state width="849" height="374" key="GridCell.Tab.2.bottom/60.23.1732.1097@60.23.1732.1097" timestamp="1598872847576" />
<state width="849" height="374" key="GridCell.Tab.2.bottom/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992588" />
<state width="849" height="374" key="GridCell.Tab.2.bottom/67.23.1725.1097@67.23.1725.1097" timestamp="1598900392857" />
<state width="840" height="374" key="GridCell.Tab.2.bottom/70.23.1722.1097@70.23.1722.1097" timestamp="1598922564622" />
<state width="840" height="374" key="GridCell.Tab.2.center" timestamp="1598922564622">
<state width="1300" height="374" key="GridCell.Tab.2.bottom/70.23.1722.1097@70.23.1722.1097" timestamp="1598931659637" />
<state width="1300" height="374" key="GridCell.Tab.2.center" timestamp="1598931659636">
<screen x="70" y="23" width="1722" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.2.center/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358070" />
@ -229,8 +220,8 @@
<state width="849" height="374" key="GridCell.Tab.2.center/60.23.1732.1097@60.23.1732.1097" timestamp="1598872847576" />
<state width="849" height="374" key="GridCell.Tab.2.center/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992588" />
<state width="849" height="374" key="GridCell.Tab.2.center/67.23.1725.1097@67.23.1725.1097" timestamp="1598900392856" />
<state width="840" height="374" key="GridCell.Tab.2.center/70.23.1722.1097@70.23.1722.1097" timestamp="1598922564622" />
<state width="840" height="374" key="GridCell.Tab.2.left" timestamp="1598922564622">
<state width="1300" height="374" key="GridCell.Tab.2.center/70.23.1722.1097@70.23.1722.1097" timestamp="1598931659636" />
<state width="1300" height="374" key="GridCell.Tab.2.left" timestamp="1598931659636">
<screen x="70" y="23" width="1722" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.2.left/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358070" />
@ -240,8 +231,8 @@
<state width="849" height="374" key="GridCell.Tab.2.left/60.23.1732.1097@60.23.1732.1097" timestamp="1598872847576" />
<state width="849" height="374" key="GridCell.Tab.2.left/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992587" />
<state width="849" height="374" key="GridCell.Tab.2.left/67.23.1725.1097@67.23.1725.1097" timestamp="1598900392856" />
<state width="840" height="374" key="GridCell.Tab.2.left/70.23.1722.1097@70.23.1722.1097" timestamp="1598922564622" />
<state width="840" height="374" key="GridCell.Tab.2.right" timestamp="1598922564622">
<state width="1300" height="374" key="GridCell.Tab.2.left/70.23.1722.1097@70.23.1722.1097" timestamp="1598931659636" />
<state width="1300" height="374" key="GridCell.Tab.2.right" timestamp="1598931659636">
<screen x="70" y="23" width="1722" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.2.right/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358070" />
@ -251,8 +242,8 @@
<state width="849" height="374" key="GridCell.Tab.2.right/60.23.1732.1097@60.23.1732.1097" timestamp="1598872847576" />
<state width="849" height="374" key="GridCell.Tab.2.right/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992588" />
<state width="849" height="374" key="GridCell.Tab.2.right/67.23.1725.1097@67.23.1725.1097" timestamp="1598900392857" />
<state width="840" height="374" key="GridCell.Tab.2.right/70.23.1722.1097@70.23.1722.1097" timestamp="1598922564622" />
<state width="840" height="374" key="GridCell.Tab.3.bottom" timestamp="1598922564623">
<state width="1300" height="374" key="GridCell.Tab.2.right/70.23.1722.1097@70.23.1722.1097" timestamp="1598931659636" />
<state width="1300" height="374" key="GridCell.Tab.3.bottom" timestamp="1598931659637">
<screen x="70" y="23" width="1722" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.3.bottom/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358072" />
@ -262,8 +253,8 @@
<state width="849" height="374" key="GridCell.Tab.3.bottom/60.23.1732.1097@60.23.1732.1097" timestamp="1598872847577" />
<state width="849" height="374" key="GridCell.Tab.3.bottom/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992588" />
<state width="849" height="374" key="GridCell.Tab.3.bottom/67.23.1725.1097@67.23.1725.1097" timestamp="1598900392858" />
<state width="840" height="374" key="GridCell.Tab.3.bottom/70.23.1722.1097@70.23.1722.1097" timestamp="1598922564623" />
<state width="840" height="374" key="GridCell.Tab.3.center" timestamp="1598922564622">
<state width="1300" height="374" key="GridCell.Tab.3.bottom/70.23.1722.1097@70.23.1722.1097" timestamp="1598931659637" />
<state width="1300" height="374" key="GridCell.Tab.3.center" timestamp="1598931659637">
<screen x="70" y="23" width="1722" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.3.center/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358071" />
@ -273,8 +264,8 @@
<state width="849" height="374" key="GridCell.Tab.3.center/60.23.1732.1097@60.23.1732.1097" timestamp="1598872847576" />
<state width="849" height="374" key="GridCell.Tab.3.center/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992588" />
<state width="849" height="374" key="GridCell.Tab.3.center/67.23.1725.1097@67.23.1725.1097" timestamp="1598900392857" />
<state width="840" height="374" key="GridCell.Tab.3.center/70.23.1722.1097@70.23.1722.1097" timestamp="1598922564622" />
<state width="840" height="374" key="GridCell.Tab.3.left" timestamp="1598922564622">
<state width="1300" height="374" key="GridCell.Tab.3.center/70.23.1722.1097@70.23.1722.1097" timestamp="1598931659637" />
<state width="1300" height="374" key="GridCell.Tab.3.left" timestamp="1598931659637">
<screen x="70" y="23" width="1722" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.3.left/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358071" />
@ -284,8 +275,8 @@
<state width="849" height="374" key="GridCell.Tab.3.left/60.23.1732.1097@60.23.1732.1097" timestamp="1598872847576" />
<state width="849" height="374" key="GridCell.Tab.3.left/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992588" />
<state width="849" height="374" key="GridCell.Tab.3.left/67.23.1725.1097@67.23.1725.1097" timestamp="1598900392857" />
<state width="840" height="374" key="GridCell.Tab.3.left/70.23.1722.1097@70.23.1722.1097" timestamp="1598922564622" />
<state width="840" height="374" key="GridCell.Tab.3.right" timestamp="1598922564622">
<state width="1300" height="374" key="GridCell.Tab.3.left/70.23.1722.1097@70.23.1722.1097" timestamp="1598931659637" />
<state width="1300" height="374" key="GridCell.Tab.3.right" timestamp="1598931659637">
<screen x="70" y="23" width="1722" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.3.right/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358072" />
@ -295,7 +286,7 @@
<state width="849" height="374" key="GridCell.Tab.3.right/60.23.1732.1097@60.23.1732.1097" timestamp="1598872847577" />
<state width="849" height="374" key="GridCell.Tab.3.right/62.23.1730.1097@62.23.1730.1097" timestamp="1598899992588" />
<state width="849" height="374" key="GridCell.Tab.3.right/67.23.1725.1097@67.23.1725.1097" timestamp="1598900392858" />
<state width="840" height="374" key="GridCell.Tab.3.right/70.23.1722.1097@70.23.1722.1097" timestamp="1598922564622" />
<state width="1300" height="374" key="GridCell.Tab.3.right/70.23.1722.1097@70.23.1722.1097" timestamp="1598931659637" />
<state x="161" y="268" width="670" height="676" key="search.everywhere.popup" timestamp="1598787117227">
<screen x="53" y="23" width="1739" height="1097" />
</state>

View File

@ -17,7 +17,6 @@ $.http = HTTP("", {
// Constants
const SUBS_KEY = "subs";
const COLLECTIONS_KEY = "collections";
const RESOURCE_CACHE_KEY = "resources";
// SOME INITIALIZATIONS
if (!$.read(SUBS_KEY)) $.write({}, SUBS_KEY);
@ -97,14 +96,13 @@ const AVAILABLE_OPERATORS = {
// refresh resource
async function refreshResource(req, res) {
const {url} = req.body;
const cachedResources = $.read(RESOURCE_CACHE_KEY);
cachedResources[url] = await $.http.get(url).then(resp => resp.body).catch(err => {
const raw = await $.http.get(url).then(resp => resp.body).catch(err => {
res.status(500).json({
status: "failed",
message: `Cannot refresh remote resource: ${url}\n Reason: ${err}`
});
});
$.write(cachedResources, RESOURCE_CACHE_KEY);
$.write(raw, `#${url}`);
res.json({
status: "success"
});
@ -119,9 +117,7 @@ async function downloadSub(req, res) {
const sub = allSubs[name];
try {
const output = await parseSub(sub, platform);
const {key, value} = getFlowHeaders(output.headers, []);
res.set(key, value)
res.send(output.proxies);
res.send(output);
} catch (err) {
res.status(500).json({
status: "failed",
@ -137,15 +133,24 @@ async function downloadSub(req, res) {
}
async function parseSub(sub, platform) {
// always download from url
const {raw, headers} = await $.http.get(sub.url).then(resp => {
return {
raw: resp.body,
headers: resp.headers
}
}).catch(err => {
let raw;
if (platform === 'Raw') {
const cache = $.read(`#${sub.url}`);
if (!cache) {
raw = await $.http.get(sub.url).then(resp => resp.body).catch(err => {
throw new Error(err);
});
$.write(raw, `#${sub.url}`);
} else {
raw = cache;
}
} else {
// always download from url
raw = await $.http.get(sub.url).then(resp => resp.body).catch(err => {
throw new Error(err);
});
$.write(raw, `#${sub.url}`);
}
$.log("=======================================================================");
$.log(`Processing subscription: ${sub.name}, target platform ==> ${platform}.`);
@ -203,10 +208,7 @@ async function parseSub(sub, platform) {
$parser.addProducers([
QX_Producer, Loon_Producer, Surge_Producer, Raw_Producer
]);
return {
proxies: $parser.produce(proxies),
headers
};
return $parser.produce(proxies);
}
function getFlowHeaders(headers, proxies) {
@ -363,7 +365,7 @@ async function downloadCollection(req, res) {
const output = await Promise.all(subs.map(async id => {
const sub = $.read(SUBS_KEY)[id];
try {
return parseSub(sub, platform).then(res => res.proxies);
return parseSub(sub, platform);
} catch (err) {
console.log(`ERROR when process subscription: ${id}`);
return "";
@ -827,7 +829,7 @@ function URI_VMess() {
cipher: "auto", // V2rayN has no default cipher! use aes-128-gcm as default.
uuid: params.id,
alterId: params.aid || 0,
tls: JSON.parse(params.tls || "false"),
tls: params.tls === 'tls' || params.tls === true,
supported
}
// handle obfs

View File

@ -32,11 +32,34 @@
</template>
<script>
import {axios} from "@/utils";
export default {
name: "ProxyList",
props: ['proxies'],
props: ['url'],
data: function (){
return {
proxies: []
}
},
methods: {
refresh() {
axios.post(`/refresh`, {url: this.url}).then(() => {
this.fetch();
})
},
fetch() {
axios.get(this.url).then(resp => {
const {data} = resp;
this.proxies = data.split("\n").map(p => JSON.parse(p));
}).catch(err => {
this.$store.commit("SET_ERROR_MESSAGE", err);
});
}
},
created() {
this.fetch();
}
}
</script>

View File

@ -138,6 +138,9 @@
<v-toolbar-title>节点列表</v-toolbar-title>
<v-spacer></v-spacer>
<v-toolbar-items>
<v-btn icon @click="refreshProxyList">
<v-icon>refresh</v-icon>
</v-btn>
<v-btn icon @click="showProxyList = false">
<v-icon>mdi-close</v-icon>
</v-btn>
@ -145,7 +148,7 @@
</v-toolbar>
</v-card-title>
<v-card-text class="pl-0 pr-0">
<proxy-list :proxies="proxies"></proxy-list>
<proxy-list :url="url" ref="proxyList" :key="url"></proxy-list>
</v-card-text>
</v-card>
</v-dialog>
@ -155,7 +158,6 @@
<script>
import ProxyList from "@/components/ProxyList";
import {BACKEND_BASE} from "@/config";
import {axios} from "@/utils";
export default {
components: {ProxyList},
@ -163,7 +165,7 @@ export default {
return {
opened: false,
showProxyList: false,
proxies: [],
url: "",
editMenu: [
{
title: "复制",
@ -224,25 +226,21 @@ export default {
}
},
preview(item, type = 'sub') {
let url;
if (type === 'sub') {
url = `${BACKEND_BASE}/download/${item.name}`
this.url = `${BACKEND_BASE}/download/${item.name}`
} else {
url = `${BACKEND_BASE}/download/collection/${item.name}`
this.url = `${BACKEND_BASE}/download/collection/${item.name}`
}
axios.get(url).then(resp => {
const {data} = resp;
this.proxies = data.split("\n").map(p => JSON.parse(p));
this.showProxyList = true;
}).catch(err => {
this.$store.commit("SET_ERROR_MESSAGE", err);
})
},
createSub() {
this.$router.push("/sub-edit/UNTITLED");
},
createCol() {
this.$router.push("/collection-edit/UNTITLED")
},
refreshProxyList() {
this.$refs.proxyList.refresh();
}
}
}