master
yutent 2023-01-14 16:54:11 +08:00
parent e13ea89048
commit b0972667c4
3 changed files with 55 additions and 49 deletions

View File

@ -7,7 +7,7 @@
<title>{{title}}</title> <title>{{title}}</title>
<meta name="keywords" content="{{keywords}}"> <meta name="keywords" content="{{keywords}}">
<meta name="description" content="{{description}}"> <meta name="description" content="{{description}}">
<link rel="stylesheet" href="//esm.js.io/@bytedo/wcui/dist/css/reset-basic.css"> <link rel="stylesheet" href="//jscdn.ink/@bytedo/wcui/dist/css/reset-basic.css">
<script async src="//esm.tool/es-module-shims.wasm.js"></script> <script async src="//esm.tool/es-module-shims.wasm.js"></script>
<script type="importmap">{{importmap}}</script> <script type="importmap">{{importmap}}</script>
</head> </head>

View File

@ -8,10 +8,10 @@ import { createApp } from 'vue'
import '@/assets/app.scss' import '@/assets/app.scss'
import '//esm.js.io/@bytedo/wcui/dist/layer/index.js' import '//jscdn.ink/@bytedo/wcui/dist/layer/index.js'
import '//esm.js.io/@bytedo/wcui/dist/form/switch.js' import '//jscdn.ink/@bytedo/wcui/dist/form/switch.js'
import '//esm.js.io/@bytedo/wcui/dist/form/radio.js' import '//jscdn.ink/@bytedo/wcui/dist/form/radio.js'
import '//esm.js.io/@bytedo/wcui/dist/form/button.js' import '//jscdn.ink/@bytedo/wcui/dist/form/button.js'
import App from './app.vue' import App from './app.vue'

View File

@ -6,7 +6,9 @@
<section class="field"> <section class="field">
<span class="label">订阅地址</span> <span class="label">订阅地址</span>
<wc-input class="full" v-model="remote.link"></wc-input> <wc-input class="full" v-model="remote.link"></wc-input>
<wc-button type="info" :disabled="!remote.link" @click="updateRemote"></wc-button> <wc-button type="info" :disabled="!remote.link" @click="updateRemote"
>更新</wc-button
>
</section> </section>
<wc-scroll class="scroll"> <wc-scroll class="scroll">
@ -40,47 +42,50 @@ export default {
let txt = '' let txt = ''
let names = ['DIRECT'] let names = ['DIRECT']
this.remote.list = data.split('\n').map(it => { this.remote.list = data
let tmp = decodeURIComponent(it).split('#') .trim()
let tmp2 = new URL(tmp[0]) .split('\n')
let protocol = tmp2.protocol.slice(0, -1) .map(it => {
let path = tmp2.pathname.slice(2) let tmp = decodeURIComponent(it).split('#')
let info = { name: tmp.pop().trim(), type: protocol, udp: true } let tmp2 = new URL(tmp[0])
let protocol = tmp2.protocol.slice(0, -1)
let path = tmp2.pathname.slice(2)
let info = { name: tmp.pop().trim(), type: protocol, udp: true }
path = path.split(':') path = path.split(':')
info.port = path.pop() info.port = path.pop()
path = path[0].split('@') path = path[0].split('@')
info.server = path.pop() info.server = path.pop()
switch (protocol) { switch (protocol) {
case 'ss': case 'ss':
path = atob(path[0]).split(':') path = atob(path[0]).split(':')
console.log(path) console.log(path)
Object.assign(info, { Object.assign(info, {
cipher: path[0], cipher: path[0],
password: path[1] password: path[1]
}) })
break break
case 'trojan': case 'trojan':
Object.assign(info, { Object.assign(info, {
password: path[0], password: path[0],
sni: tmp2.searchParams.get('sni'), sni: tmp2.searchParams.get('sni'),
'skip-cert-verify': true 'skip-cert-verify': true
}) })
break break
} }
names.push(`"${info.name}"`) names.push(`"${info.name}"`)
txt += ` - { name: ${info.name}, type: ${info.type}, server: ${info.server}, port: ${ txt += ` - { name: ${info.name}, type: ${info.type}, server: ${
info.port info.server
}, password: ${info.password}, udp: true, ${info.type === 'ss' ? 'cipher' : 'sni'}: ${ }, port: ${info.port}, password: ${info.password}, udp: true, ${
info.type === 'ss' ? info.cipher : info.sni info.type === 'ss' ? 'cipher' : 'sni'
}}\n` }: ${info.type === 'ss' ? info.cipher : info.sni}}\n`
return [info.name, info.type] return [info.name, info.type]
}) })
window.foo = txt window.foo = txt
window.bar = names.join(', ') window.bar = names.join(', ')
@ -95,15 +100,16 @@ export default {
return return
} }
window // window
.fetch(this.remote.link) // .fetch(this.remote.link)
.then(r => r.text()) // .then(r => r.text())
.then(r => { // .then(r => {
r = atob(r).trim() // r = atob(r).trim()
let r = sessionStorage.getItem('temp')
layer.toast('订阅更新成功', 'success') layer.toast('订阅更新成功', 'success')
this.parseBookData(r) this.parseBookData(r)
}) // })
} }
} }
} }