Compare commits
1 Commits
v1.0.3
...
v1.0.3-rc1
Author | SHA1 | Date | |
---|---|---|---|
0607e6241b |
@ -10,10 +10,12 @@ import Intro from '../texts/intro.md'
|
|||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
const err = ref(false)
|
const err = ref(false)
|
||||||
|
const srcText = ref(null)
|
||||||
|
|
||||||
function convert(from) {
|
function convert(from) {
|
||||||
if( Number(from) ) {
|
if( Number(from) ) {
|
||||||
return {
|
return {
|
||||||
|
type: 's',
|
||||||
id: Number(from)
|
id: Number(from)
|
||||||
}
|
}
|
||||||
} else if (from.includes('https://archiveofourown.org/works/')) {
|
} else if (from.includes('https://archiveofourown.org/works/')) {
|
||||||
@ -34,9 +36,11 @@ function convert(from) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onConvert(data) {
|
function onConvert(data) {
|
||||||
const { id, cid } = convert(data.src)
|
const { type, id, cid } = convert(data.src)
|
||||||
if (id == null) {
|
console.log(type, id, cid)
|
||||||
|
if (type == null) {
|
||||||
err.value = true
|
err.value = true
|
||||||
|
srcText.value?.focus()
|
||||||
} else {
|
} else {
|
||||||
err.value = false
|
err.value = false
|
||||||
if (cid) router.push(`/work/${id}/${cid}`)
|
if (cid) router.push(`/work/${id}/${cid}`)
|
||||||
@ -54,7 +58,7 @@ function onConvert(data) {
|
|||||||
<h2>链接转换</h2>
|
<h2>链接转换</h2>
|
||||||
<p>输入完整链接或者 ID</p>
|
<p>输入完整链接或者 ID</p>
|
||||||
<Form @submit="onConvert"><ClientOnly>
|
<Form @submit="onConvert"><ClientOnly>
|
||||||
<mdui-text-field variant="filled" label="链接" name="src" placeholder="https://archiveofourown.org/works/114514" >
|
<mdui-text-field variant="filled" label="链接" name="src" placeholder="https://archiveofourown.org/works/114514" ref='srcText'>
|
||||||
<span v-if='err' slot="helper" class='warn-text'>链接格式错误!</span>
|
<span v-if='err' slot="helper" class='warn-text'>链接格式错误!</span>
|
||||||
</mdui-text-field><br/>
|
</mdui-text-field><br/>
|
||||||
<div style="display: flex">
|
<div style="display: flex">
|
||||||
|
Reference in New Issue
Block a user