mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-05-11 13:17:29 +08:00
feat: poster
This commit is contained in:
@@ -2,11 +2,20 @@
|
|||||||
<div class="dropdown" ref="wrapper">
|
<div class="dropdown" ref="wrapper">
|
||||||
<div class="dropdown-display" @click="toggle">
|
<div class="dropdown-display" @click="toggle">
|
||||||
<template v-if="multiple">
|
<template v-if="multiple">
|
||||||
<span v-if="selectedLabels.length" class="selected-text">{{ selectedLabels.join(', ') }}</span>
|
<span v-if="selectedLabels.length">
|
||||||
|
<template v-for="(label, idx) in selectedLabels" :key="label.id">
|
||||||
|
<img v-if="label.icon" :src="label.icon" class="option-icon" />
|
||||||
|
<span>{{ label.name }}</span>
|
||||||
|
<span v-if="idx !== selectedLabels.length - 1">, </span>
|
||||||
|
</template>
|
||||||
|
</span>
|
||||||
<span v-else class="placeholder">{{ placeholder }}</span>
|
<span v-else class="placeholder">{{ placeholder }}</span>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<span v-if="selectedLabels.length" class="selected-text">{{ selectedLabels[0] }}</span>
|
<span v-if="selectedLabels.length">
|
||||||
|
<img v-if="selectedLabels[0].icon" :src="selectedLabels[0].icon" class="option-icon" />
|
||||||
|
<span>{{ selectedLabels[0].name }}</span>
|
||||||
|
</span>
|
||||||
<span v-else class="placeholder">{{ placeholder }}</span>
|
<span v-else class="placeholder">{{ placeholder }}</span>
|
||||||
</template>
|
</template>
|
||||||
<i class="fas fa-caret-down dropdown-caret"></i>
|
<i class="fas fa-caret-down dropdown-caret"></i>
|
||||||
@@ -16,10 +25,9 @@
|
|||||||
<i class="fas fa-search search-icon"></i>
|
<i class="fas fa-search search-icon"></i>
|
||||||
<input type="text" v-model="search" placeholder="搜索" />
|
<input type="text" v-model="search" placeholder="搜索" />
|
||||||
</div>
|
</div>
|
||||||
<div class="dropdown-option" v-for="o in filteredOptions" :key="o.id" @click="select(o.id)">
|
<div class="dropdown-option" v-for="o in filteredOptions" :key="o.id" @click="select(o.id)" :class="{ 'selected': isSelected(o.id) }">
|
||||||
<img v-if="o.icon" :src="o.icon" class="option-icon" />
|
<img v-if="o.icon" :src="o.icon" class="option-icon" />
|
||||||
<span>{{ o.name }}</span>
|
<span>{{ o.name }}</span>
|
||||||
<input v-if="multiple" type="checkbox" :checked="modelValue.includes(o.id)" @change.prevent />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -101,13 +109,17 @@ export default {
|
|||||||
|
|
||||||
const selectedLabels = computed(() => {
|
const selectedLabels = computed(() => {
|
||||||
if (props.multiple) {
|
if (props.multiple) {
|
||||||
return options.value.filter(o => (props.modelValue || []).includes(o.id)).map(o => o.name)
|
return options.value.filter(o => (props.modelValue || []).includes(o.id))
|
||||||
}
|
}
|
||||||
const match = options.value.find(o => o.id === props.modelValue)
|
const match = options.value.find(o => o.id === props.modelValue)
|
||||||
return match ? [match.name] : []
|
return match ? [match] : []
|
||||||
})
|
})
|
||||||
|
|
||||||
return { open, toggle, select, search, filteredOptions, wrapper, selectedLabels }
|
const isSelected = (id) => {
|
||||||
|
return selectedLabels.value.some(label => label.id === id)
|
||||||
|
}
|
||||||
|
|
||||||
|
return { open, toggle, select, search, filteredOptions, wrapper, selectedLabels, isSelected }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -117,6 +129,7 @@ export default {
|
|||||||
position: relative;
|
position: relative;
|
||||||
width: 200px;
|
width: 200px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdown-display {
|
.dropdown-display {
|
||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
@@ -126,9 +139,11 @@ export default {
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.placeholder {
|
.placeholder {
|
||||||
color: gray;
|
color: gray;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdown-menu {
|
.dropdown-menu {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 100%;
|
top: 100%;
|
||||||
@@ -140,31 +155,39 @@ export default {
|
|||||||
max-height: 200px;
|
max-height: 200px;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdown-search {
|
.dropdown-search {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
border-bottom: 1px solid #eee;
|
border-bottom: 1px solid #eee;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdown-search input {
|
.dropdown-search input {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
border: none;
|
border: none;
|
||||||
outline: none;
|
outline: none;
|
||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdown-option {
|
.dropdown-option {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 5px 10px;
|
padding: 10px 20px;
|
||||||
gap: 5px;
|
gap: 5px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dropdown-option.selected {
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
}
|
||||||
|
|
||||||
.dropdown-option:hover {
|
.dropdown-option:hover {
|
||||||
background-color: #f5f5f5;
|
background-color: #f5f5f5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.option-icon {
|
.option-icon {
|
||||||
width: 16px;
|
width: 16px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export default {
|
|||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
vditorInstance.value = new Vditor(props.editorId, {
|
vditorInstance.value = new Vditor(props.editorId, {
|
||||||
placeholder: '请输入正文...',
|
placeholder: '请输入正文...',
|
||||||
height: 500,
|
height: 450,
|
||||||
theme: 'classic',
|
theme: 'classic',
|
||||||
preview: {
|
preview: {
|
||||||
theme: { current: 'light' },
|
theme: { current: 'light' },
|
||||||
|
|||||||
@@ -6,10 +6,15 @@
|
|||||||
<PostEditor v-model="content" />
|
<PostEditor v-model="content" />
|
||||||
</div>
|
</div>
|
||||||
<div class="post-options">
|
<div class="post-options">
|
||||||
<CategorySelect v-model="selectedCategory" />
|
<div class="post-options-left">
|
||||||
<TagSelect v-model="selectedTags" />
|
<CategorySelect v-model="selectedCategory" />
|
||||||
|
<TagSelect v-model="selectedTags" />
|
||||||
|
</div>
|
||||||
|
<div class="post-options-right">
|
||||||
|
<div class="post-draft" @click="saveDraft">存草稿</div>
|
||||||
|
<div class="post-submit" @click="submitPost">发布</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="post-submit" @click="submitPost">发布</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -61,9 +66,16 @@ export default {
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-submit {
|
.post-draft {
|
||||||
margin-left: 20px;
|
margin-left: 20px;
|
||||||
margin-top: 20px;
|
color: var(--primary-color);
|
||||||
|
padding: 10px 20px;
|
||||||
|
border-radius: 10px;
|
||||||
|
cursor: pointer;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-submit {
|
||||||
background-color: var(--primary-color);
|
background-color: var(--primary-color);
|
||||||
color: #fff;
|
color: #fff;
|
||||||
padding: 10px 20px;
|
padding: 10px 20px;
|
||||||
@@ -76,12 +88,23 @@ export default {
|
|||||||
background-color: var(--primary-color-hover);
|
background-color: var(--primary-color-hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-options {
|
.post-options-left {
|
||||||
margin-top: 20px;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.post-options-right {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-options {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
margin-left: 20px;
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user