Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
AlPha5130 committed Feb 7, 2025
1 parent a77b0ab commit 753454d
Show file tree
Hide file tree
Showing 5 changed files with 545 additions and 359 deletions.
1 change: 0 additions & 1 deletion app/components/Artwork/ArtworksByUser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
<script setup lang="ts">
import type { ArtworkInfo } from '~/types'
import { NPagination } from 'naive-ui'
import {} from 'vue'
const { userId, workCategory = 'illust' } = defineProps<{
userId: string
Expand Down
25 changes: 15 additions & 10 deletions app/components/Comment/Area.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ import IPlus from '~icons/fa-solid/plus'
import type { Comments, NumberLike } from '~/types'
type CommentsRoot = {
hasNext: boolean
comments: Comments[]
}
const loading = ref(false)
const comments = ref<Comments[]>([])
const hasNext = ref(false)
Expand All @@ -49,16 +54,16 @@ async function init(id: NumberLike): Promise<void> {
try {
loading.value = true
const data = await useAjaxResponse<{
hasNext: boolean
comments: Comments[]
}>(`/ajax/illusts/comments/roots`, {
params: {
illust_id: `${id}`,
limit: comments.value.length ? '30' : '3',
offset: `${comments.value.length}`,
},
})
const data = await useAjaxResponse<CommentsRoot>(
`/ajax/illusts/comments/roots`,
{
params: {
illust_id: `${id}`,
limit: comments.value.length ? '30' : '3',
offset: `${comments.value.length}`,
},
}
)
hasNext.value = data.hasNext
comments.value = comments.value.concat(data.comments)
} catch (err) {
Expand Down
18 changes: 15 additions & 3 deletions app/components/SearchBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,26 @@ import ISearch from '~icons/fa-solid/search'
const route = useRoute()
const router = useRouter()
const keyword = ref((route.params.keyword as string) || '')
const keyword = ref(extractKeyword())
function extractKeyword(): string {
if (!route.params.keyword) {
return ''
}
if (Array.isArray(route.params.keyword)) {
return route.params.keyword[0] ?? ''
} else {
return route.params.keyword
}
}
function makeSearch(): void {
if (!keyword.value) {
return
}
if (/^id:(\d+)$/.test(keyword.value)) {
router.push(`/artworks/${/^id:(\d+)$/.exec(keyword.value)?.[1]}`)
const regResult = /^id:(\d+)$/.exec(keyword.value)
if (regResult) {
router.push(`/artworks/${regResult[1]}`)
return
}
router.push(`/search/${encodeURIComponent(keyword.value)}/1`)
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"dependencies": {
"nuxt": "^3.15.4",
"vite": "^6.0.11",
"vite": "^6.1.0",
"vue": "^3.5.13",
"vue-router": "^4.5.0"
},
Expand All @@ -34,7 +34,7 @@
"@prettier/plugin-pug": "^3.2.0",
"@types/gif.js": "^0.2.5",
"@types/lodash.escaperegexp": "^4.1.9",
"@types/node": "^22.13.0",
"@types/node": "^22.13.1",
"@types/nprogress": "^0.2.3",
"@vitejs/plugin-vue": "^5.2.1",
"@vue/language-plugin-pug": "^2.2.0",
Expand All @@ -54,7 +54,7 @@
"pinia": "^2.3.1",
"prettier": "^3.4.2",
"pug": "^3.0.3",
"sass": "^1.83.4",
"sass": "^1.84.0",
"tslib": "^2.8.1",
"typescript": "^5.7.3",
"unplugin-icons": "^22.0.0",
Expand All @@ -63,5 +63,5 @@
"vue-i18n": "^11.1.0",
"vue-waterfall-plugin-next": "^2.6.5"
},
"packageManager": "pnpm@9.15.5"
"packageManager": "pnpm@10.2.0"
}
Loading

0 comments on commit 753454d

Please sign in to comment.