diff --git a/src/main.js b/src/main.js index 393e59c..4f92b54 100644 --- a/src/main.js +++ b/src/main.js @@ -16,5 +16,6 @@ export function createApp() { .component('Hr', Hr) .component('BetterHr', Hr) .component('Form', Form) + .component('BetterForm', Form) return { app, pinia } } diff --git a/src/router.js b/src/router.js index 68d0b50..0729276 100644 --- a/src/router.js +++ b/src/router.js @@ -39,21 +39,29 @@ export function createSSRRouter() { title: '阅读', hidden: true } + },{ + path: '/search/simple', + name: '搜索', + component: () => import('./views/SimpleSearch.vue'), + meta: { + title: '搜索', + order: 2 + } },{ path: '/settings', name: '设置', component: () => import('./views/Settings.vue'), meta: { title: '设置', - order: 2 + order: 90 }, },{ path: '/about', name: '关于', - component: () => import('./views/About.vue'), + component: () => import('./views/About.md'), meta: { title: '', - order: 3 + order: 100 }, },{ path: '/developer', diff --git a/src/stores/search.js b/src/stores/search.js new file mode 100644 index 0000000..10bb86e --- /dev/null +++ b/src/stores/search.js @@ -0,0 +1,51 @@ +import { ref } from 'vue' +import { defineStore } from 'pinia' + +import { useApiStore } from '@/stores/api.js' + +export const useSimpleSearchState = defineStore('simpleSearch', () => { + const api = useApiStore() + const keyword = ref('') + const result = ref([]) + const count = ref([]) + const pageCount = ref(0) + const currentPage = ref(0) + const state = ref(null) + async function load() { + if (currentPage.value == pageCount.value) state.value = 'finish' + let res = await api.workSimpleSearch(keyword.value, currentPage.value) + res = res.data + if (res.code == 0) { + currentPage.value = res.page + pageCount.value = res.pageCount + count.value = res.count + state.value = import.meta.env.SSR ? 'ssrready' : 'ready' + result.value.push(...res.works) + } else if (res.code == 1) { + if (currentPage.value) { + state.value = 'finish' + } else { + currentPage.value = 1 + state.value = 'notfound' + } + } + } + async function start(key) { + if (key == keyword.value) return + keyword.value = key + result.value = [] + state.value = 'loading' + currentPage.value = 0 + await load() + } + + return { + keyword, + result, + count, + pageCount, + currentPage, + state, + load, start + } +}) diff --git a/src/stores/workRead.js b/src/stores/workRead.js index 8897bb3..1aa2e03 100644 --- a/src/stores/workRead.js +++ b/src/stores/workRead.js @@ -10,7 +10,7 @@ export const useWorkReadState = defineStore('workRead', () => { const id = ref(null) const cid = ref(null) const summary = ref(null) - const pesud = ref(null) + const pseud = ref(null) const title = ref(null) const text = ref(null) const state = ref('') @@ -25,7 +25,7 @@ export const useWorkReadState = defineStore('workRead', () => { id.value = data.workId title.value = data.title summary.value = [escapeAndFormatText(data.summary)] - pesud.value = data.pesud + pseud.value = data.pseud text.value = data.text publishedTime.value = data.stats.publishedTime wordCount.value = data.stats.wordCount @@ -51,7 +51,7 @@ export const useWorkReadState = defineStore('workRead', () => { id, cid, title, summary, - pesud, + pseud, text, state, publishedTime, diff --git a/src/texts/intro.md b/src/texts/intro.md index 76456b5..2bdecbd 100644 --- a/src/texts/intro.md +++ b/src/texts/intro.md @@ -1,9 +1,3 @@ -# 欢迎来到 AO3 Mirror! 👋👋 - -一个基于重构渲染的 AO3 镜像站 - ---- - ## 这是什么🤨 本网站是对 ArchiveOfOurOwn (AO3) 的一个镜像网站 @@ -45,3 +39,4 @@ - ✅ 作品详细数据 - 📝 搜索 - ❌ 书签 (本地) **不再支持! [详情](/about#deprecated-feature-bookmark)** + diff --git a/src/texts/about.md b/src/views/About.md similarity index 65% rename from src/texts/about.md rename to src/views/About.md index 1b9d1f6..c3ffcfd 100644 --- a/src/texts/about.md +++ b/src/views/About.md @@ -1,3 +1,18 @@ + + # 关于 这是什么, 有口舍用 ? @@ -43,3 +58,5 @@ 本站支持 "Server Side Rendering" by Vite SSR CDN by Cloudflare (赛博佛祖😭) + + diff --git a/src/views/About.vue b/src/views/About.vue deleted file mode 100644 index 39be5ed..0000000 --- a/src/views/About.vue +++ /dev/null @@ -1,19 +0,0 @@ - - - diff --git a/src/views/Root.vue b/src/views/Root.vue index 9653855..3194d09 100644 --- a/src/views/Root.vue +++ b/src/views/Root.vue @@ -9,9 +9,6 @@ import Intro from '../texts/intro.md' const router = useRouter() -const err = ref(false) -const srcText = ref(null) - function convert(from) { if( Number(from) ) { return { @@ -20,7 +17,6 @@ function convert(from) { } } else if (from.includes('https://archiveofourown.org/works/')) { const sid = from.split('https://archiveofourown.org/works/')[1]; - console.log(sid) if ( sid ) { const id = Number(sid) if (id) { @@ -41,16 +37,15 @@ function convert(from) { } } } - return { type: null } + return { type: 'f', key: from } } function onConvert(data) { - const { type, id, cid } = convert(data.src) + const { type, id, cid, key } = convert(data.src) if (type == null) { - err.value = true - srcText.value?.focus() + } else if ( type == 'f') { + router.push(`/search/simple?keyword=${encodeURIComponent(key)}`) } else { - err.value = false if (cid) router.push(`/work/${id}/${cid}`) else router.push(`/work/${id}`) } @@ -60,14 +55,14 @@ function onConvert(data) { +
+ + diff --git a/src/views/SimpleSearch.vue b/src/views/SimpleSearch.vue new file mode 100644 index 0000000..2bb43b0 --- /dev/null +++ b/src/views/SimpleSearch.vue @@ -0,0 +1,62 @@ + + + diff --git a/src/views/Work.vue b/src/views/Work.vue index 9fb331d..b2ecb66 100644 --- a/src/views/Work.vue +++ b/src/views/Work.vue @@ -168,8 +168,8 @@ onBeforeUnmount(() => { 返回