feat: update ui logic

This commit is contained in:
tim
2025-07-10 14:19:11 +08:00
parent c2c0efc0fb
commit 17a80f2579
2 changed files with 15 additions and 17 deletions

View File

@@ -40,9 +40,6 @@ export default {
)
const fetchCategories = async () => {
if (providedOptions.value.length) {
return [{ id: '', name: '无分类' }, ...providedOptions.value]
}
const res = await fetch(`${API_BASE_URL}/api/categories`)
if (!res.ok) return []
const data = await res.json()

View File

@@ -1,5 +1,6 @@
<template>
<Dropdown v-model="selected" :fetch-options="fetchTags" multiple placeholder="选择标签" remote :initial-options="mergedOptions">
<Dropdown v-model="selected" :fetch-options="fetchTags" multiple placeholder="选择标签" remote
:initial-options="mergedOptions">
<template #option="{ option }">
<div class="option-container">
<div class="option-main">
@@ -53,21 +54,21 @@ export default {
const fetchTags = async (kw = '') => {
let data = []
if (!kw && providedTags.value.length) {
data = [...providedTags.value]
} else {
const url = new URL(`${API_BASE_URL}/api/tags`)
if (kw) url.searchParams.set('keyword', kw)
url.searchParams.set('limit', '10')
try {
const res = await fetch(url.toString())
if (res.ok) {
data = await res.json()
}
} catch {
toast.error('获取标签失败')
// if (!kw && providedTags.value.length) {
// data = [...providedTags.value]
// } else {
const url = new URL(`${API_BASE_URL}/api/tags`)
if (kw) url.searchParams.set('keyword', kw)
url.searchParams.set('limit', '10')
try {
const res = await fetch(url.toString())
if (res.ok) {
data = await res.json()
}
} catch {
toast.error('获取标签失败')
}
// }
let options = [...data, ...localTags.value]