[BUGFix]
All checks were successful
Node.js CI / build-and-test (push) Successful in 35s

修复书签删除问题

[Feature]
使用表单保证 HTML 语义化
更新关于页面
This commit is contained in:
2025-05-14 17:48:11 +08:00
parent a59ebeb487
commit 89538823fc
5 changed files with 33 additions and 14 deletions

View File

@ -5,6 +5,7 @@ import App from './App.vue'
import ClientOnly from './ssr/ClientOnly.vue'
import Hr from './ui/BetterHr.vue'
import Form from './ui/Form.vue'
export function createApp() {
const app = createSSRApp(App)
@ -13,5 +14,6 @@ export function createApp() {
app
.component('ClientOnly', ClientOnly)
.component('Hr', Hr)
.component('Form', Form)
return { app, pinia }
}

View File

@ -16,7 +16,7 @@
---
- MDUI 2 [mdui.org](https://mdui.org)
- Vue 3 [vuejs.org](https://vuejs.org)
- Vite 6 [vitejs.dev](https://vitejs.dev)
- Vite 6 [vitejs.dev](https://vite.dev)
其他
---

20
src/ui/Form.vue Normal file
View File

@ -0,0 +1,20 @@
<template>
<form @submit="handleSubmit">
<slot></slot>
</form>
</template>
<script setup>
import { ref } from 'vue'
const emit = defineEmits(['submit'])
function handleSubmit(event) {
event.preventDefault()
const form = event.target
const formData = new FormData(form)
const data = Object.fromEntries(formData.entries())
emit('submit', data, event)
}
</script>

View File

@ -9,8 +9,6 @@ import Intro from '../texts/intro.md'
const router = useRouter()
const src = ref('')
const srcText = ref(null)
const err = ref(false)
function convert(from) {
@ -35,11 +33,10 @@ function convert(from) {
}
}
function onConvert() {
const { id, cid } = convert(src.value)
function onConvert(data) {
const { id, cid } = convert(data.src)
if (id == null) {
err.value = true
srcText.value?.focus()
} else {
err.value = false
if (cid) router.push(`/work/${id}/${cid}`)
@ -56,17 +53,17 @@ function onConvert() {
<section id="converter">
<h2>链接转换</h2>
<p>输入完整链接或者 ID</p>
<ClientOnly>
<mdui-text-field variant="filled" label="链接" placeholder="https://archiveofourown.org/works/114514" @input="src = $event.target.value" ref='srcText'>
<span v-if='err' slot="helper" class='warn-text'>链接格式错误!</span>
<Form @submit="onConvert"><ClientOnly>
<mdui-text-field variant="filled" label="链接" name="src" placeholder="https://archiveofourown.org/works/114514" >
<span v-if='err' slot="helper" class='warn-text'>链接格式错误!</span>
</mdui-text-field><br/>
<div style="display: flex">
<div style="flex-grow: 1"></div>
<mdui-button @click='onConvert'>-></mdui-button>
<mdui-button type="submit">-></mdui-button>
</div>
{{ src }}
<template #ssr>
Padding...
</template></ClientOnly>
<input type="text" id="src" name="src" />
<input type="submit" />
</template></ClientOnly></Form>
</section>
</template>

View File

@ -120,7 +120,7 @@ function openBookmarkMenu(bk, index) {
async function deleteBookmark() {
if (bookmarkSelect.value) {
bookmarkStore.del(bookmarkSelect.value.bk.id)
bookmarks.value.splice(bookmarkSelect.value.index)
bookmarks.value.splice(bookmarkSelect.value.index,1)
bookmarkSelect.value = null
}
}