diff --git a/index.html b/index.html index 1129dd5..bc72428 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,7 @@ {{title}} - + diff --git a/src/main.js b/src/main.js index 461d4e7..6928844 100644 --- a/src/main.js +++ b/src/main.js @@ -8,10 +8,10 @@ import { createApp } from 'vue' import '@/assets/app.scss' -import '//unpkg.debianx.in/@bytedo/wcui/dist/layer/index.js' -import '//unpkg.debianx.in/@bytedo/wcui/dist/form/switch.js' -import '//unpkg.debianx.in/@bytedo/wcui/dist/form/radio.js' -import '//unpkg.debianx.in/@bytedo/wcui/dist/form/button.js' +import '//esm.js.io/@bytedo/wcui/dist/layer/index.js' +import '//esm.js.io/@bytedo/wcui/dist/form/switch.js' +import '//esm.js.io/@bytedo/wcui/dist/form/radio.js' +import '//esm.js.io/@bytedo/wcui/dist/form/button.js' import App from './app.vue' diff --git a/src/views/remote.vue b/src/views/remote.vue index 096bf6a..f55fd46 100644 --- a/src/views/remote.vue +++ b/src/views/remote.vue @@ -36,25 +36,16 @@ export default { }, methods: { - updateRemote() { - if (this.remote.link) { - if (!/^(https?:)?\/\//.test(this.remote.link)) { - return layer.toast('订阅地址格式不正确', 'error') - } - localStorage.setItem('remote_link', this.remote.link) - } else { - return - } + parseBookData(data = '') { let txt = '' let names = ['DIRECT'] - let r = (sessionStorage.getItem('temp') || '').trim() - this.remote.list = r.split('\n').map(it => { + this.remote.list = data.split('\n').map(it => { let tmp = decodeURIComponent(it).split('#') let tmp2 = new URL(tmp[0]) let protocol = tmp2.protocol.slice(0, -1) let path = tmp2.pathname.slice(2) - let info = { name: tmp.pop(), type: protocol, udp: true } + let info = { name: tmp.pop().trim(), type: protocol, udp: true } path = path.split(':') @@ -93,20 +84,25 @@ export default { window.foo = txt window.bar = names.join(', ') - // // console.log(txt) + }, + updateRemote() { + if (this.remote.link) { + if (!/^(https?:)?\/\//.test(this.remote.link)) { + return layer.toast('订阅地址格式不正确', 'error') + } + localStorage.setItem('remote_link', this.remote.link) + } else { + return + } - return window - .fetch(this.remote.link, { cors: true }) + .fetch(this.remote.link) .then(r => r.text()) .then(r => { r = atob(r).trim() - sessionStorage.setItem('temp', r) + layer.toast('订阅更新成功', 'success') - this.remote.list = r.split('\n').map(it => { - let tmp = decodeURIComponent(it).split('#') - return [tmp.pop(), tmp[0]?.split('://').shift()] - }) + this.parseBookData(r) }) } }