Skip to content
This repository has been archived by the owner on Aug 24, 2024. It is now read-only.

Commit

Permalink
feat: 导出全部妥协安卓端,采用双模式
Browse files Browse the repository at this point in the history
  • Loading branch information
adproqwq committed Apr 7, 2024
1 parent 59f01d0 commit 1e6fa02
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 27 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"format": "prettier --cache --write --ignore-unknown ."
},
"dependencies": {
"@dlr-eoc/utils-browser": "12.0.1-next.2",
"@gkd-kit/api": "^0.0.5",
"callapp-lib": "^3.5.3",
"jquery": "^3.7.1",
Expand Down
10 changes: 9 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { edit } from './methods/edit'
export default defineComponent({
data() {
return {
codeVer: '2.1.0'
codeVer: '2.1.1'
}
},
methods: {
Expand Down Expand Up @@ -54,11 +54,6 @@ export default defineComponent({
</div>
<div>
<button type="button" class="btn btn1" @click="output('all')">导出全部</button>
<span>导出格式:</span>
<select id="outputMode">
<option value="json">JSON</option>
<option value="json5">JSON5</option>
</select>
</div>
<div>
<span>导入外部订阅文件:</span>
Expand Down
25 changes: 5 additions & 20 deletions src/methods/output.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
import { fullScript, script } from './sub'
import json5 from 'json5'
import { downloadJson } from '@dlr-eoc/utils-browser'

export const output = (type: string) => {
if (type == 'all') {
const userSelect = document.getElementById('outputMode');
const index = (userSelect! as HTMLSelectElement).selectedIndex;
let blob;
if ((userSelect! as HTMLSelectElement).options[index].value == 'json') {
blob = new Blob([JSON.stringify(fullScript)], {
type: 'application/json'
});
}
else if ((userSelect! as HTMLSelectElement).options[index].value == 'json5') {
blob = new Blob([json5.stringify(fullScript)], {
type: 'application/json'
});
}
const downloadURL = URL.createObjectURL(blob!);
const aTag = document.createElement('a');
aTag.href = downloadURL;
if ((userSelect! as HTMLSelectElement).options[index].value == 'json') aTag.download = `${fullScript.id}.json`;
else if ((userSelect! as HTMLSelectElement).options[index].value == 'json5') aTag.download = `${fullScript.id}.json5`;
aTag.click();
URL.revokeObjectURL(downloadURL);
downloadJson(fullScript, `${fullScript.id}.json`)
navigator.clipboard.writeText(JSON.stringify(fullScript)).then(() => {
alert('全部规则已复制到剪切板,如果下载失败,可以自己粘贴到json文件中')
});
}
else {
const location = type.split('.');
Expand Down

0 comments on commit 1e6fa02

Please sign in to comment.