mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-03-18 01:47:25 +08:00
Merge pull request #143 from nagisa77/i3fpxu-codex
Add none option for category and tag selectors
This commit is contained in:
@@ -18,7 +18,8 @@ export default {
|
|||||||
const fetchCategories = async () => {
|
const fetchCategories = async () => {
|
||||||
const res = await fetch(`${API_BASE_URL}/api/categories`)
|
const res = await fetch(`${API_BASE_URL}/api/categories`)
|
||||||
if (!res.ok) return []
|
if (!res.ok) return []
|
||||||
return await res.json()
|
const data = await res.json()
|
||||||
|
return [{ id: '', name: '无分类' }, ...data]
|
||||||
}
|
}
|
||||||
|
|
||||||
const selected = computed({
|
const selected = computed({
|
||||||
|
|||||||
@@ -18,15 +18,22 @@ export default {
|
|||||||
const fetchTags = async () => {
|
const fetchTags = async () => {
|
||||||
const res = await fetch(`${API_BASE_URL}/api/tags`)
|
const res = await fetch(`${API_BASE_URL}/api/tags`)
|
||||||
if (!res.ok) return []
|
if (!res.ok) return []
|
||||||
return await res.json()
|
const data = await res.json()
|
||||||
|
return [{ id: 0, name: '无标签' }, ...data]
|
||||||
}
|
}
|
||||||
|
|
||||||
const selected = computed({
|
const selected = computed({
|
||||||
get: () => props.modelValue,
|
get: () => props.modelValue,
|
||||||
set: v => {
|
set: v => {
|
||||||
if (Array.isArray(v) && v.length > 2) {
|
if (Array.isArray(v)) {
|
||||||
toast.error('最多选择两个标签')
|
if (v.includes(0)) {
|
||||||
return
|
emit('update:modelValue', [])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (v.length > 2) {
|
||||||
|
toast.error('最多选择两个标签')
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
emit('update:modelValue', v)
|
emit('update:modelValue', v)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user