Add cache

This commit is contained in:
Peng-YM 2020-08-26 21:09:34 +08:00
parent 1b0f8f124e
commit 1fcc1f77d7
5 changed files with 164 additions and 106 deletions

View File

@ -20,15 +20,11 @@
</component>
<component name="ChangeListManager">
<list default="true" id="8b97a098-48b2-4e64-a9ef-522fe2d30b52" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/../web/src/config.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../web/src/views/ProxyList.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/TopToolbar.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/components/TopToolbar.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/store/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/store/index.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/utils/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/utils/index.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/views/PopUpProxyList.vue" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/views/Subscription.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/views/Subscription.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/public/index.html" beforeDir="false" afterPath="$PROJECT_DIR$/../web/public/index.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/App.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/App.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/config.js" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/config.js" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -83,7 +79,8 @@
<workItem from="1598154453014" duration="3238000" />
<workItem from="1598235270977" duration="126000" />
<workItem from="1598235738199" duration="3192000" />
<workItem from="1598323737081" duration="1554000" />
<workItem from="1598323737081" duration="1913000" />
<workItem from="1598442849645" duration="4206000" />
</task>
<servers />
</component>
@ -103,101 +100,133 @@
<option name="oldMeFiltersMigrated" value="true" />
</component>
<component name="WindowStateProjectService">
<state width="842" height="374" key="GridCell.Tab.0.bottom" timestamp="1598325254472">
<screen x="67" y="23" width="1725" height="1097" />
<state width="1709" height="374" key="GridCell.Tab.0.bottom" timestamp="1598446615905">
<screen x="60" y="23" width="1732" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.0.bottom/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358068" />
<state width="842" height="374" key="GridCell.Tab.0.bottom/67.23.1725.1097@67.23.1725.1097" timestamp="1598325254472" />
<state width="1709" height="374" key="GridCell.Tab.0.bottom/60.23.1732.1097@60.23.1732.1097" timestamp="1598446615905" />
<state width="1709" height="374" key="GridCell.Tab.0.bottom/62.23.1730.1097@62.23.1730.1097" timestamp="1598445328168" />
<state width="1704" height="374" key="GridCell.Tab.0.bottom/67.23.1725.1097@67.23.1725.1097" timestamp="1598325654695" />
<state width="840" height="374" key="GridCell.Tab.0.bottom/70.23.1722.1097@70.23.1722.1097" timestamp="1598324500703" />
<state width="842" height="374" key="GridCell.Tab.0.center" timestamp="1598325254471">
<screen x="67" y="23" width="1725" height="1097" />
<state width="1709" height="374" key="GridCell.Tab.0.center" timestamp="1598446615903">
<screen x="60" y="23" width="1732" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.0.center/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358067" />
<state width="842" height="374" key="GridCell.Tab.0.center/67.23.1725.1097@67.23.1725.1097" timestamp="1598325254471" />
<state width="1709" height="374" key="GridCell.Tab.0.center/60.23.1732.1097@60.23.1732.1097" timestamp="1598446615903" />
<state width="1709" height="374" key="GridCell.Tab.0.center/62.23.1730.1097@62.23.1730.1097" timestamp="1598445328167" />
<state width="1704" height="374" key="GridCell.Tab.0.center/67.23.1725.1097@67.23.1725.1097" timestamp="1598325654695" />
<state width="840" height="374" key="GridCell.Tab.0.center/70.23.1722.1097@70.23.1722.1097" timestamp="1598324500702" />
<state width="842" height="374" key="GridCell.Tab.0.left" timestamp="1598325254470">
<screen x="67" y="23" width="1725" height="1097" />
<state width="1709" height="374" key="GridCell.Tab.0.left" timestamp="1598446615899">
<screen x="60" y="23" width="1732" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.0.left/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358067" />
<state width="842" height="374" key="GridCell.Tab.0.left/67.23.1725.1097@67.23.1725.1097" timestamp="1598325254470" />
<state width="1709" height="374" key="GridCell.Tab.0.left/60.23.1732.1097@60.23.1732.1097" timestamp="1598446615899" />
<state width="1709" height="374" key="GridCell.Tab.0.left/62.23.1730.1097@62.23.1730.1097" timestamp="1598445328167" />
<state width="1704" height="374" key="GridCell.Tab.0.left/67.23.1725.1097@67.23.1725.1097" timestamp="1598325654694" />
<state width="840" height="374" key="GridCell.Tab.0.left/70.23.1722.1097@70.23.1722.1097" timestamp="1598324500701" />
<state width="842" height="374" key="GridCell.Tab.0.right" timestamp="1598325254472">
<screen x="67" y="23" width="1725" height="1097" />
<state width="1709" height="374" key="GridCell.Tab.0.right" timestamp="1598446615904">
<screen x="60" y="23" width="1732" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.0.right/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358068" />
<state width="842" height="374" key="GridCell.Tab.0.right/67.23.1725.1097@67.23.1725.1097" timestamp="1598325254472" />
<state width="1709" height="374" key="GridCell.Tab.0.right/60.23.1732.1097@60.23.1732.1097" timestamp="1598446615904" />
<state width="1709" height="374" key="GridCell.Tab.0.right/62.23.1730.1097@62.23.1730.1097" timestamp="1598445328168" />
<state width="1704" height="374" key="GridCell.Tab.0.right/67.23.1725.1097@67.23.1725.1097" timestamp="1598325654695" />
<state width="840" height="374" key="GridCell.Tab.0.right/70.23.1722.1097@70.23.1722.1097" timestamp="1598324500702" />
<state width="842" height="374" key="GridCell.Tab.1.bottom" timestamp="1598325254381">
<screen x="67" y="23" width="1725" height="1097" />
<state width="1709" height="374" key="GridCell.Tab.1.bottom" timestamp="1598446615752">
<screen x="60" y="23" width="1732" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.1.bottom/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358069" />
<state width="842" height="374" key="GridCell.Tab.1.bottom/67.23.1725.1097@67.23.1725.1097" timestamp="1598325254381" />
<state width="1709" height="374" key="GridCell.Tab.1.bottom/60.23.1732.1097@60.23.1732.1097" timestamp="1598446615752" />
<state width="1709" height="374" key="GridCell.Tab.1.bottom/62.23.1730.1097@62.23.1730.1097" timestamp="1598445328169" />
<state width="1704" height="374" key="GridCell.Tab.1.bottom/67.23.1725.1097@67.23.1725.1097" timestamp="1598325654696" />
<state width="840" height="374" key="GridCell.Tab.1.bottom/70.23.1722.1097@70.23.1722.1097" timestamp="1598233292666" />
<state width="842" height="374" key="GridCell.Tab.1.center" timestamp="1598325254380">
<screen x="67" y="23" width="1725" height="1097" />
<state width="1709" height="374" key="GridCell.Tab.1.center" timestamp="1598446615751">
<screen x="60" y="23" width="1732" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.1.center/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358069" />
<state width="842" height="374" key="GridCell.Tab.1.center/67.23.1725.1097@67.23.1725.1097" timestamp="1598325254380" />
<state width="1709" height="374" key="GridCell.Tab.1.center/60.23.1732.1097@60.23.1732.1097" timestamp="1598446615751" />
<state width="1709" height="374" key="GridCell.Tab.1.center/62.23.1730.1097@62.23.1730.1097" timestamp="1598445328168" />
<state width="1704" height="374" key="GridCell.Tab.1.center/67.23.1725.1097@67.23.1725.1097" timestamp="1598325654696" />
<state width="840" height="374" key="GridCell.Tab.1.center/70.23.1722.1097@70.23.1722.1097" timestamp="1598233292666" />
<state width="842" height="374" key="GridCell.Tab.1.left" timestamp="1598325254380">
<screen x="67" y="23" width="1725" height="1097" />
<state width="1709" height="374" key="GridCell.Tab.1.left" timestamp="1598446615751">
<screen x="60" y="23" width="1732" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.1.left/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358069" />
<state width="842" height="374" key="GridCell.Tab.1.left/67.23.1725.1097@67.23.1725.1097" timestamp="1598325254380" />
<state width="1709" height="374" key="GridCell.Tab.1.left/60.23.1732.1097@60.23.1732.1097" timestamp="1598446615751" />
<state width="1709" height="374" key="GridCell.Tab.1.left/62.23.1730.1097@62.23.1730.1097" timestamp="1598445328168" />
<state width="1704" height="374" key="GridCell.Tab.1.left/67.23.1725.1097@67.23.1725.1097" timestamp="1598325654696" />
<state width="840" height="374" key="GridCell.Tab.1.left/70.23.1722.1097@70.23.1722.1097" timestamp="1598233292665" />
<state width="842" height="374" key="GridCell.Tab.1.right" timestamp="1598325254380">
<screen x="67" y="23" width="1725" height="1097" />
<state width="1709" height="374" key="GridCell.Tab.1.right" timestamp="1598446615752">
<screen x="60" y="23" width="1732" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.1.right/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358069" />
<state width="842" height="374" key="GridCell.Tab.1.right/67.23.1725.1097@67.23.1725.1097" timestamp="1598325254380" />
<state width="1709" height="374" key="GridCell.Tab.1.right/60.23.1732.1097@60.23.1732.1097" timestamp="1598446615752" />
<state width="1709" height="374" key="GridCell.Tab.1.right/62.23.1730.1097@62.23.1730.1097" timestamp="1598445328168" />
<state width="1704" height="374" key="GridCell.Tab.1.right/67.23.1725.1097@67.23.1725.1097" timestamp="1598325654696" />
<state width="840" height="374" key="GridCell.Tab.1.right/70.23.1722.1097@70.23.1722.1097" timestamp="1598233292666" />
<state width="842" height="374" key="GridCell.Tab.2.bottom" timestamp="1598325254381">
<screen x="67" y="23" width="1725" height="1097" />
<state width="1709" height="374" key="GridCell.Tab.2.bottom" timestamp="1598446615753">
<screen x="60" y="23" width="1732" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.2.bottom/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358071" />
<state width="842" height="374" key="GridCell.Tab.2.bottom/67.23.1725.1097@67.23.1725.1097" timestamp="1598325254381" />
<state width="1709" height="374" key="GridCell.Tab.2.bottom/60.23.1732.1097@60.23.1732.1097" timestamp="1598446615753" />
<state width="1709" height="374" key="GridCell.Tab.2.bottom/62.23.1730.1097@62.23.1730.1097" timestamp="1598445328169" />
<state width="1704" height="374" key="GridCell.Tab.2.bottom/67.23.1725.1097@67.23.1725.1097" timestamp="1598325654697" />
<state width="840" height="374" key="GridCell.Tab.2.bottom/70.23.1722.1097@70.23.1722.1097" timestamp="1598233292666" />
<state width="842" height="374" key="GridCell.Tab.2.center" timestamp="1598325254381">
<screen x="67" y="23" width="1725" height="1097" />
<state width="1709" height="374" key="GridCell.Tab.2.center" timestamp="1598446615753">
<screen x="60" y="23" width="1732" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.2.center/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358070" />
<state width="842" height="374" key="GridCell.Tab.2.center/67.23.1725.1097@67.23.1725.1097" timestamp="1598325254381" />
<state width="1709" height="374" key="GridCell.Tab.2.center/60.23.1732.1097@60.23.1732.1097" timestamp="1598446615753" />
<state width="1709" height="374" key="GridCell.Tab.2.center/62.23.1730.1097@62.23.1730.1097" timestamp="1598445328169" />
<state width="1704" height="374" key="GridCell.Tab.2.center/67.23.1725.1097@67.23.1725.1097" timestamp="1598325654696" />
<state width="840" height="374" key="GridCell.Tab.2.center/70.23.1722.1097@70.23.1722.1097" timestamp="1598233292666" />
<state width="842" height="374" key="GridCell.Tab.2.left" timestamp="1598325254381">
<screen x="67" y="23" width="1725" height="1097" />
<state width="1709" height="374" key="GridCell.Tab.2.left" timestamp="1598446615752">
<screen x="60" y="23" width="1732" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.2.left/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358070" />
<state width="842" height="374" key="GridCell.Tab.2.left/67.23.1725.1097@67.23.1725.1097" timestamp="1598325254381" />
<state width="1709" height="374" key="GridCell.Tab.2.left/60.23.1732.1097@60.23.1732.1097" timestamp="1598446615752" />
<state width="1709" height="374" key="GridCell.Tab.2.left/62.23.1730.1097@62.23.1730.1097" timestamp="1598445328169" />
<state width="1704" height="374" key="GridCell.Tab.2.left/67.23.1725.1097@67.23.1725.1097" timestamp="1598325654696" />
<state width="840" height="374" key="GridCell.Tab.2.left/70.23.1722.1097@70.23.1722.1097" timestamp="1598233292666" />
<state width="842" height="374" key="GridCell.Tab.2.right" timestamp="1598325254381">
<screen x="67" y="23" width="1725" height="1097" />
<state width="1709" height="374" key="GridCell.Tab.2.right" timestamp="1598446615753">
<screen x="60" y="23" width="1732" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.2.right/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358070" />
<state width="842" height="374" key="GridCell.Tab.2.right/67.23.1725.1097@67.23.1725.1097" timestamp="1598325254381" />
<state width="1709" height="374" key="GridCell.Tab.2.right/60.23.1732.1097@60.23.1732.1097" timestamp="1598446615753" />
<state width="1709" height="374" key="GridCell.Tab.2.right/62.23.1730.1097@62.23.1730.1097" timestamp="1598445328169" />
<state width="1704" height="374" key="GridCell.Tab.2.right/67.23.1725.1097@67.23.1725.1097" timestamp="1598325654697" />
<state width="840" height="374" key="GridCell.Tab.2.right/70.23.1722.1097@70.23.1722.1097" timestamp="1598233292666" />
<state width="842" height="374" key="GridCell.Tab.3.bottom" timestamp="1598325254382">
<screen x="67" y="23" width="1725" height="1097" />
<state width="1709" height="374" key="GridCell.Tab.3.bottom" timestamp="1598446615755">
<screen x="60" y="23" width="1732" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.3.bottom/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358072" />
<state width="842" height="374" key="GridCell.Tab.3.bottom/67.23.1725.1097@67.23.1725.1097" timestamp="1598325254382" />
<state width="1709" height="374" key="GridCell.Tab.3.bottom/60.23.1732.1097@60.23.1732.1097" timestamp="1598446615755" />
<state width="1709" height="374" key="GridCell.Tab.3.bottom/62.23.1730.1097@62.23.1730.1097" timestamp="1598445328170" />
<state width="1704" height="374" key="GridCell.Tab.3.bottom/67.23.1725.1097@67.23.1725.1097" timestamp="1598325654697" />
<state width="840" height="374" key="GridCell.Tab.3.bottom/70.23.1722.1097@70.23.1722.1097" timestamp="1598233292667" />
<state width="842" height="374" key="GridCell.Tab.3.center" timestamp="1598325254382">
<screen x="67" y="23" width="1725" height="1097" />
<state width="1709" height="374" key="GridCell.Tab.3.center" timestamp="1598446615754">
<screen x="60" y="23" width="1732" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.3.center/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358071" />
<state width="842" height="374" key="GridCell.Tab.3.center/67.23.1725.1097@67.23.1725.1097" timestamp="1598325254382" />
<state width="1709" height="374" key="GridCell.Tab.3.center/60.23.1732.1097@60.23.1732.1097" timestamp="1598446615754" />
<state width="1709" height="374" key="GridCell.Tab.3.center/62.23.1730.1097@62.23.1730.1097" timestamp="1598445328170" />
<state width="1704" height="374" key="GridCell.Tab.3.center/67.23.1725.1097@67.23.1725.1097" timestamp="1598325654697" />
<state width="840" height="374" key="GridCell.Tab.3.center/70.23.1722.1097@70.23.1722.1097" timestamp="1598233292667" />
<state width="842" height="374" key="GridCell.Tab.3.left" timestamp="1598325254381">
<screen x="67" y="23" width="1725" height="1097" />
<state width="1709" height="374" key="GridCell.Tab.3.left" timestamp="1598446615753">
<screen x="60" y="23" width="1732" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.3.left/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358071" />
<state width="842" height="374" key="GridCell.Tab.3.left/67.23.1725.1097@67.23.1725.1097" timestamp="1598325254381" />
<state width="1709" height="374" key="GridCell.Tab.3.left/60.23.1732.1097@60.23.1732.1097" timestamp="1598446615753" />
<state width="1709" height="374" key="GridCell.Tab.3.left/62.23.1730.1097@62.23.1730.1097" timestamp="1598445328170" />
<state width="1704" height="374" key="GridCell.Tab.3.left/67.23.1725.1097@67.23.1725.1097" timestamp="1598325654697" />
<state width="840" height="374" key="GridCell.Tab.3.left/70.23.1722.1097@70.23.1722.1097" timestamp="1598233292667" />
<state width="842" height="374" key="GridCell.Tab.3.right" timestamp="1598325254382">
<screen x="67" y="23" width="1725" height="1097" />
<state width="1709" height="374" key="GridCell.Tab.3.right" timestamp="1598446615754">
<screen x="60" y="23" width="1732" height="1097" />
</state>
<state width="840" height="374" key="GridCell.Tab.3.right/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358072" />
<state width="842" height="374" key="GridCell.Tab.3.right/67.23.1725.1097@67.23.1725.1097" timestamp="1598325254382" />
<state width="1709" height="374" key="GridCell.Tab.3.right/60.23.1732.1097@60.23.1732.1097" timestamp="1598446615754" />
<state width="1709" height="374" key="GridCell.Tab.3.right/62.23.1730.1097@62.23.1730.1097" timestamp="1598445328170" />
<state width="1704" height="374" key="GridCell.Tab.3.right/67.23.1725.1097@67.23.1725.1097" timestamp="1598325654697" />
<state width="840" height="374" key="GridCell.Tab.3.right/70.23.1722.1097@70.23.1722.1097" timestamp="1598233292667" />
</component>
</project>

View File

@ -4,22 +4,32 @@
* @Description:
* 适用于QXLoonSurge的订阅管理工具
* - 功能
* 1. 订阅转换支持SS, SSR, V2RayN, QX, Loon, Surge格式的互相转换
* 1. 订阅转换支持SS, SSR, V2RayN, QX, Loon, Surge, Clash格式的互相转换
* 2. 节点过滤重命名排序等
* 3. 订阅拆分组合
*/
const $ = API("sub-store");
const $ = API("sub-store", true);
// Constants
const SUBS_KEY = "subs";
const COLLECTIONS_KEY = "collections";
const RESOURCE_CACHE_KEY = "resources";
// SOME INITIALIZATIONS
if (!$.read(SUBS_KEY)) $.write({}, SUBS_KEY);
if (!$.read(COLLECTIONS_KEY)) $.write({}, COLLECTIONS_KEY);
if (!$.read(RESOURCE_CACHE_KEY)) $.write({}, RESOURCE_CACHE_KEY);
// BACKEND API
const $app = express();
// download
$app.get("/download/:name", downloadSub);
$app.get("/download/collection/:name", downloadCollection);
// refresh
$app.post("/api/refresh", refreshResource);
// subscriptions
$app.route("/api/sub/:name")
.get(getSub)
.patch(updateSub)
@ -30,11 +40,7 @@ $app.route("/api/sub")
.post(newSub)
.delete(deleteAllSubs);
// subscriptions
$app.get("/download/:name", downloadSub);
// collections
$app.get("/download/collection/:name", downloadCollection);
$app.route("/api/collection/:name")
.get(getCollection)
.patch(updateCollection)
@ -57,6 +63,7 @@ const DEFAULT_SUPPORTED_PLATFORMS = {
Surge: true,
Raw: true
}
const AVAILABLE_FILTERS = {
"Keyword Filter": KeywordFilter,
"Discard Keyword Filter": DiscardKeywordFilter,
@ -81,6 +88,22 @@ const AVAILABLE_OPERATORS = {
}
/**************************** API -- Subscriptions ***************************************/
// 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 => resp.body).catch(err => {
res.status(500).json({
status: "failed",
message: `Cannot refresh remote resource: ${url}\n Reason: ${err}`
});
});
$.write(cachedResources, cachedResources);
res.json({
status: "success"
});
}
// download subscription, for APP only
async function downloadSub(req, res) {
const {name} = req.params;
@ -92,7 +115,6 @@ async function downloadSub(req, res) {
const output = await parseSub(sub, platform);
res.send(output);
} catch (err) {
$.notify('[Sub-Store]', '❌ 无法获取订阅!', `错误信息:${err}`)
res.status(500).json({
status: "failed",
message: err
@ -107,12 +129,23 @@ async function downloadSub(req, res) {
}
async function parseSub(sub, platform) {
// download from url
const raw = await $.http.get(sub.url).then(resp => resp.body).catch(err => {
let raw;
const cachedResources = $.read(RESOURCE_CACHE_KEY);
if (platform === "Raw") {
// use cache if available
raw = cachedResources[sub.url];
}
// always download from url
raw = raw || await $.http.get(sub.url).then(resp => resp.body).catch(err => {
throw new Error(err);
});
console.log("=======================================================================");
console.log(`Processing subscription: ${sub.name}, target platform ==> ${platform}.`);
cachedResources[sub.url] = raw;
$.write(cachedResources, RESOURCE_CACHE_KEY);
$.log("=======================================================================");
$.log(`Processing subscription: ${sub.name}, target platform ==> ${platform}.`);
const $parser = ProxyParser(platform);
let proxies = $parser.parse(raw);
@ -136,14 +169,14 @@ async function parseSub(sub, platform) {
if (filter) {
$filter.addFilters(filter(...(item.args || [])));
proxies = $filter.process(proxies);
console.log(`Applying filter "${item.type}" with arguments:\n >>> ${item.args || "None"}`);
$.log(`Applying filter "${item.type}" with arguments:\n >>> ${item.args || "None"}`);
}
} else if (item.type.indexOf("Operator") !== -1) {
const operator = AVAILABLE_OPERATORS[item.type];
if (operator) {
$operator.addOperators(operator(...(item.args || [])));
proxies = $operator.process(proxies);
console.log(`Applying operator "${item.type}" with arguments: \n >>> ${item.args || "None"}`);
$.log(`Applying operator "${item.type}" with arguments: \n >>> ${item.args || "None"}`);
}
}
}
@ -470,17 +503,16 @@ function ProxyParser(targetPlatform) {
// https://github.com/KOP-XIAO/QuantumultX
if (raw.indexOf("{") !== -1) {
raw = raw.replace(/: {/g, ": {, ")
.replace(/, (host|path|tls|mux|skip)/g,", $1")
.replace(/{name: /g,"{name: \"")
.replace(/, server:/g,"\", server:")
.replace(/{|}/g,"")
.replace(/,/g,"\n ")
.replace(/, (host|path|tls|mux|skip)/g, ", $1")
.replace(/{name: /g, "{name: \"")
.replace(/, server:/g, "\", server:")
.replace(/{|}/g, "")
.replace(/,/g, "\n ")
}
raw = raw.replace(/ -\n.*name/g," - name");
raw = raw.replace(/ -\n.*name/g, " - name");
const proxies = YAML.eval(raw).proxies;
output = proxies.map(p => JSON.stringify(p));
}
else {
} else {
// check if content is based64 encoded
const Base64 = new Base64Code();
const keys = ["dm1lc3M", "c3NyOi8v", "dHJvamFu", "c3M6Ly", "c3NkOi8v"];
@ -1283,7 +1315,6 @@ function QX_Producer() {
}
function Loon_Producer() {
$.notify("LOON")
const targetPlatform = "Loon";
const output = (proxy) => {
let obfs_opts, tls_opts;
@ -2083,22 +2114,6 @@ function API(name = "untitled", debug = false) {
error(msg) {
console.log("ERROR: " + msg);
}
wait(millisec) {
return new Promise((resolve) => setTimeout(resolve, millisec));
}
done(value = {}) {
if (isQX || isLoon || isSurge) {
$done(value);
} else if (isNode && !isJSBox) {
if (typeof $context !== "undefined") {
$context.headers = value.headers;
$context.statusCode = value.statusCode;
$context.body = value.body;
}
}
}
})(name, debug);
}
@ -2129,7 +2144,7 @@ function express(port = 3000) {
// adapter
app.start = () => {
app.listen(port, () => {
console.log(`Express started on port: ${port}`);
$.log(`Express started on port: ${port}`);
})
}
return app;

View File

@ -1,19 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta charset="utf-8"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover"/>
<link rel="Bookmark" href="https://raw.githubusercontent.com/chavyleung/scripts/master/BOXJS.png"/>
<link rel="shortcut icon" href="https://raw.githubusercontent.com/chavyleung/scripts/master/BOXJS.png"/>
<link rel="apple-touch-icon" href="https://raw.githubusercontent.com/chavyleung/scripts/master/BOXJS.png"/>
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons.min.css">
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled.
Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

View File

@ -31,6 +31,7 @@
import TopToolbar from "@/components/TopToolbar";
import BottomNav from "@/components/BottomNav";
function initStore(store) {
store.dispatch('FETCH_SUBSCRIPTIONS');
store.dispatch("FETCH_COLLECTIONS");
@ -72,4 +73,8 @@ export default {
}
}
}
</script>
</script>
<style>
</style>

View File

@ -1,3 +1,3 @@
const DEBUG = true;
export const BACKEND_BASE = DEBUG ? `http://127.0.0.1:3000` : `http://sub.store`;
export const BACKEND_BASE = DEBUG ? `http://192.168.1.134:3000` : `http://sub.store`;