feat(admin): 内容管理支持多语言和标签
This commit is contained in:
1 parent
eaee765239
commit
2b2c6bd708
14 files changed
+1080
-458
No files matched your search
@@ -0,0 +1,41 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
import request from '@/axios'
|
||||||
|
|
||||||
|
export interface ContentTagItem {
|
||||||
|
id: number
|
||||||
|
name: string
|
||||||
|
nameEn: string
|
||||||
|
nameId: string
|
||||||
|
locales?: Record<string, string>
|
||||||
|
bgColor?: string
|
||||||
|
sort: number
|
||||||
|
status: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ContentTagSaveData {
|
||||||
|
name: string
|
||||||
|
locales: Record<string, string>
|
||||||
|
bgColor?: string
|
||||||
|
sort?: number
|
||||||
|
status?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export const listContentTagsApi = (enabledOnly = false) => {
|
||||||
|
return request.get<ContentTagItem[]>({
|
||||||
|
url: '/admin/content-tags',
|
||||||
|
params: enabledOnly ? { enabledOnly: true } : undefined
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export const createContentTagApi = (data: ContentTagSaveData) => {
|
||||||
|
return request.post<number>({ url: '/admin/content-tags', data })
|
||||||
|
}
|
||||||
|
|
||||||
|
export const updateContentTagApi = (id: number, data: ContentTagSaveData) => {
|
||||||
|
return request.put<void>({ url: `/admin/content-tags/${id}`, data })
|
||||||
|
}
|
||||||
|
|
||||||
|
export const deleteContentTagApi = (id: number) => {
|
||||||
|
return request.delete<void>({ url: `/admin/content-tags/${id}` })
|
||||||
|
}
|
||||||
@@ -52,6 +52,7 @@ export const listDramaCategoryOptionsApi = () => {
|
|||||||
|
|
||||||
export interface DramaCategorySaveData {
|
export interface DramaCategorySaveData {
|
||||||
name: string
|
name: string
|
||||||
|
locales: Record<string, string>
|
||||||
sort?: number
|
sort?: number
|
||||||
status?: number
|
status?: number
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ import type { PageResult } from './types'
|
|||||||
export interface DramaClassificationItem {
|
export interface DramaClassificationItem {
|
||||||
id: number
|
id: number
|
||||||
name: string
|
name: string
|
||||||
|
nameEn: string
|
||||||
|
nameId: string
|
||||||
|
locales?: Record<string, string>
|
||||||
sort: number
|
sort: number
|
||||||
status: number
|
status: number
|
||||||
dramaCount: number
|
dramaCount: number
|
||||||
@@ -14,6 +17,7 @@ export interface DramaClassificationItem {
|
|||||||
|
|
||||||
export interface DramaClassificationSaveData {
|
export interface DramaClassificationSaveData {
|
||||||
name: string
|
name: string
|
||||||
|
locales: Record<string, string>
|
||||||
sort?: number
|
sort?: number
|
||||||
status?: number
|
status?: number
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,13 @@ import type { ClassificationDramaItem } from './dramaClassification'
|
|||||||
export interface DramaPlaylistCategoryItem {
|
export interface DramaPlaylistCategoryItem {
|
||||||
id: number
|
id: number
|
||||||
name: string
|
name: string
|
||||||
|
nameEn: string
|
||||||
|
nameId: string
|
||||||
description: string
|
description: string
|
||||||
|
descriptionEn: string
|
||||||
|
descriptionId: string
|
||||||
|
locales?: Record<string, string>
|
||||||
|
descriptionLocales?: Record<string, string>
|
||||||
sort: number
|
sort: number
|
||||||
status: number
|
status: number
|
||||||
dramaCount: number
|
dramaCount: number
|
||||||
@@ -15,7 +21,8 @@ export interface DramaPlaylistCategoryItem {
|
|||||||
|
|
||||||
export interface DramaPlaylistCategorySaveData {
|
export interface DramaPlaylistCategorySaveData {
|
||||||
name: string
|
name: string
|
||||||
description?: string
|
locales: Record<string, string>
|
||||||
|
descriptionLocales?: Record<string, string>
|
||||||
sort?: number
|
sort?: number
|
||||||
status?: number
|
status?: number
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ export interface PageResult<T> {
|
|||||||
export interface DramaCategory {
|
export interface DramaCategory {
|
||||||
id: number
|
id: number
|
||||||
name: string
|
name: string
|
||||||
|
nameEn?: string
|
||||||
|
nameId?: string
|
||||||
|
locales?: Record<string, string>
|
||||||
sort?: number
|
sort?: number
|
||||||
status?: number
|
status?: number
|
||||||
/** 该类型下的短剧数量,管理列表才有 */
|
/** 该类型下的短剧数量,管理列表才有 */
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
export interface ContentLanguage {
|
||||||
|
code: string
|
||||||
|
label: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export const CONTENT_LANGUAGES: ContentLanguage[] = [
|
||||||
|
{ code: 'zh', label: '中文' },
|
||||||
|
{ code: 'en', label: '英文' },
|
||||||
|
{ code: 'id', label: '印尼语' }
|
||||||
|
]
|
||||||
|
|
||||||
|
export function languageLabel(code: string) {
|
||||||
|
return CONTENT_LANGUAGES.find((item) => item.code === code)?.label || code
|
||||||
|
}
|
||||||
|
|
||||||
|
export function languageCodes(locales?: Record<string, string> | null) {
|
||||||
|
const source = locales || {}
|
||||||
|
return CONTENT_LANGUAGES.map((item) => item.code).filter((code) => source[code])
|
||||||
|
}
|
||||||
|
|
||||||
|
export function localesFromColumns(
|
||||||
|
locales: Record<string, string> | null | undefined,
|
||||||
|
zh?: string,
|
||||||
|
en?: string,
|
||||||
|
id?: string
|
||||||
|
) {
|
||||||
|
if (locales && Object.keys(locales).length) {
|
||||||
|
return { ...locales }
|
||||||
|
}
|
||||||
|
const result: Record<string, string> = {}
|
||||||
|
if (zh) result.zh = zh
|
||||||
|
if (en) result.en = en
|
||||||
|
if (id) result.id = id
|
||||||
|
if (!result.zh) result.zh = ''
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
export function payloadLocales(locales: Record<string, string>, codes: string[]) {
|
||||||
|
const result: Record<string, string> = {}
|
||||||
|
codes.forEach((code) => {
|
||||||
|
result[code] = String(locales[code] || '').trim()
|
||||||
|
})
|
||||||
|
return result
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
<!-- Author: fruit.com.cn -->
|
||||||
|
<!-- 先勾选语言,再填写对应文案。中文始终保留。 -->
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { CONTENT_LANGUAGES, languageLabel } from '@/constants/contentLanguages'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
languages: { type: Array, required: true },
|
||||||
|
locales: { type: Object, required: true },
|
||||||
|
label: { type: String, default: '名称' },
|
||||||
|
maxlength: { type: Number, default: 64 },
|
||||||
|
multiline: { type: Boolean, default: false },
|
||||||
|
showLanguages: { type: Boolean, default: true },
|
||||||
|
required: { type: Boolean, default: true }
|
||||||
|
})
|
||||||
|
const emit = defineEmits(['update:languages'])
|
||||||
|
|
||||||
|
function changeLanguages(codes) {
|
||||||
|
const next = codes.includes('zh') ? codes : ['zh', ...codes]
|
||||||
|
next.forEach((code) => {
|
||||||
|
if (props.locales[code] == null) props.locales[code] = ''
|
||||||
|
})
|
||||||
|
emit('update:languages', next)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<el-form-item v-if="showLanguages" label="语言" required>
|
||||||
|
<el-select
|
||||||
|
:model-value="languages"
|
||||||
|
multiple
|
||||||
|
placeholder="选择语言"
|
||||||
|
style="width: 100%"
|
||||||
|
@change="changeLanguages"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in CONTENT_LANGUAGES"
|
||||||
|
:key="item.code"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.code"
|
||||||
|
:disabled="item.code === 'zh'"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item
|
||||||
|
v-for="code in languages"
|
||||||
|
:key="label + code"
|
||||||
|
:label="languageLabel(code) + label"
|
||||||
|
:required="required"
|
||||||
|
>
|
||||||
|
<el-input
|
||||||
|
v-if="!multiline"
|
||||||
|
v-model="locales[code]"
|
||||||
|
:maxlength="maxlength"
|
||||||
|
:placeholder="'请填写' + languageLabel(code) + label"
|
||||||
|
/>
|
||||||
|
<el-input
|
||||||
|
v-else
|
||||||
|
v-model="locales[code]"
|
||||||
|
type="textarea"
|
||||||
|
:rows="2"
|
||||||
|
:maxlength="maxlength"
|
||||||
|
show-word-limit
|
||||||
|
:placeholder="'请填写' + languageLabel(code) + label"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</template>
|
||||||
@@ -6,6 +6,12 @@ import { computed, onMounted, reactive, ref } from 'vue'
|
|||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import { AppIcon } from '@/components/AppIcon'
|
import { AppIcon } from '@/components/AppIcon'
|
||||||
import { AppIcons } from '@/constants/icons'
|
import { AppIcons } from '@/constants/icons'
|
||||||
|
import {
|
||||||
|
languageCodes,
|
||||||
|
languageLabel,
|
||||||
|
localesFromColumns,
|
||||||
|
payloadLocales
|
||||||
|
} from '@/constants/contentLanguages'
|
||||||
import {
|
import {
|
||||||
bindClassificationDramasApi,
|
bindClassificationDramasApi,
|
||||||
createClassificationApi,
|
createClassificationApi,
|
||||||
@@ -18,6 +24,8 @@ import {
|
|||||||
} from '@/api/admin/dramaClassification'
|
} from '@/api/admin/dramaClassification'
|
||||||
import { statusClass } from '@/utils/status'
|
import { statusClass } from '@/utils/status'
|
||||||
import { useRbac } from '@/stores/rbac'
|
import { useRbac } from '@/stores/rbac'
|
||||||
|
import ClassificationDramaDialogs from './ClassificationDramaDialogs.vue'
|
||||||
|
import ClassificationSideList from './ClassificationSideList.vue'
|
||||||
import PageHeading from '@/views/components/PageHeading.vue'
|
import PageHeading from '@/views/components/PageHeading.vue'
|
||||||
|
|
||||||
const { can } = useRbac()
|
const { can } = useRbac()
|
||||||
@@ -46,7 +54,9 @@ const keyword = ref('')
|
|||||||
const dialogVisible = ref(false)
|
const dialogVisible = ref(false)
|
||||||
const saving = ref(false)
|
const saving = ref(false)
|
||||||
const editingId = ref(null)
|
const editingId = ref(null)
|
||||||
const form = reactive({ name: '', sort: 1, status: 1 })
|
const languages = ref(['zh'])
|
||||||
|
const emptyForm = () => ({ locales: { zh: '' }, sort: 1, status: 1 })
|
||||||
|
const form = reactive(emptyForm())
|
||||||
|
|
||||||
const candidateVisible = ref(false)
|
const candidateVisible = ref(false)
|
||||||
const candidateLoading = ref(false)
|
const candidateLoading = ref(false)
|
||||||
@@ -110,25 +120,39 @@ function changePage(value) {
|
|||||||
|
|
||||||
function openCreate() {
|
function openCreate() {
|
||||||
editingId.value = null
|
editingId.value = null
|
||||||
|
languages.value = ['zh']
|
||||||
const maxSort = classifications.value.reduce((max, item) => Math.max(max, item.sort || 0), 0)
|
const maxSort = classifications.value.reduce((max, item) => Math.max(max, item.sort || 0), 0)
|
||||||
Object.assign(form, { name: '', sort: maxSort + 1, status: 1 })
|
Object.assign(form, emptyForm(), { sort: maxSort + 1 })
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
function openEdit(row) {
|
function openEdit(row) {
|
||||||
editingId.value = row.id
|
editingId.value = row.id
|
||||||
Object.assign(form, { name: row.name, sort: row.sort ?? 0, status: row.status ?? 1 })
|
const locales = localesFromColumns(row.locales, row.name, row.nameEn, row.nameId)
|
||||||
|
languages.value = languageCodes(locales)
|
||||||
|
Object.assign(form, {
|
||||||
|
locales,
|
||||||
|
sort: row.sort ?? 0,
|
||||||
|
status: row.status ?? 1
|
||||||
|
})
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveClassification() {
|
async function saveClassification() {
|
||||||
if (!form.name.trim()) {
|
const locales = payloadLocales(form.locales, languages.value)
|
||||||
ElMessage.warning('请填写分类名称')
|
const missing = languages.value.find((code) => !locales[code])
|
||||||
|
if (!locales.zh || missing) {
|
||||||
|
ElMessage.warning(missing ? `请填写${languageLabel(missing)}名称` : '请填写中文名称')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
saving.value = true
|
saving.value = true
|
||||||
try {
|
try {
|
||||||
const payload = { name: form.name.trim(), sort: form.sort, status: form.status }
|
const payload = {
|
||||||
|
name: locales.zh,
|
||||||
|
locales,
|
||||||
|
sort: form.sort,
|
||||||
|
status: form.status
|
||||||
|
}
|
||||||
if (editingId.value) {
|
if (editingId.value) {
|
||||||
await updateClassificationApi(editingId.value, payload)
|
await updateClassificationApi(editingId.value, payload)
|
||||||
ElMessage.success('分类已更新')
|
ElMessage.success('分类已更新')
|
||||||
@@ -256,48 +280,13 @@ onMounted(loadClassifications)
|
|||||||
</PageHeading>
|
</PageHeading>
|
||||||
|
|
||||||
<div class="classification-layout">
|
<div class="classification-layout">
|
||||||
<aside class="panel classification-layout__side">
|
<ClassificationSideList
|
||||||
<div class="classification-layout__side-title">全部分类</div>
|
:classifications="classifications"
|
||||||
<el-scrollbar height="560px">
|
:active-id="activeId"
|
||||||
<ul class="classification-list">
|
@select="selectClassification"
|
||||||
<li
|
@edit="openEdit"
|
||||||
v-for="item in classifications"
|
@remove="confirmDelete"
|
||||||
:key="item.id"
|
/>
|
||||||
class="classification-list__item"
|
|
||||||
:class="{ 'is-active': item.id === activeId }"
|
|
||||||
@click="selectClassification(item)"
|
|
||||||
>
|
|
||||||
<div class="classification-list__main">
|
|
||||||
<span class="classification-list__name">{{ item.name }}</span>
|
|
||||||
<span class="classification-list__count">{{ item.dramaCount || 0 }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="classification-list__actions" @click.stop>
|
|
||||||
<el-button
|
|
||||||
v-if="can('drama:update')"
|
|
||||||
text
|
|
||||||
circle
|
|
||||||
size="small"
|
|
||||||
@click="openEdit(item)"
|
|
||||||
>
|
|
||||||
<AppIcon :icon="AppIcons.edit" :size="15" />
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
v-if="can('drama:delete')"
|
|
||||||
text
|
|
||||||
circle
|
|
||||||
size="small"
|
|
||||||
@click="confirmDelete(item)"
|
|
||||||
>
|
|
||||||
<AppIcon :icon="AppIcons.delete" :size="15" />
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
<li v-if="!classifications.length" class="classification-list__empty">
|
|
||||||
还没有分类,点右上角「新建分类」开始
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</el-scrollbar>
|
|
||||||
</aside>
|
|
||||||
|
|
||||||
<section class="panel classification-layout__main">
|
<section class="panel classification-layout__main">
|
||||||
<div class="classification-toolbar">
|
<div class="classification-toolbar">
|
||||||
@@ -376,77 +365,27 @@ onMounted(loadClassifications)
|
|||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-dialog v-model="dialogVisible" :title="editingId ? '编辑分类' : '新建分类'" width="460px">
|
<ClassificationDramaDialogs
|
||||||
<el-form label-position="top">
|
v-model:editor-visible="dialogVisible"
|
||||||
<el-form-item label="分类名称" required>
|
v-model:languages="languages"
|
||||||
<el-input v-model="form.name" maxlength="20" placeholder="例如:本周必看" />
|
v-model:candidate-visible="candidateVisible"
|
||||||
</el-form-item>
|
v-model:candidate-keyword="candidateKeyword"
|
||||||
<div class="classification-form-row">
|
:editing-id="editingId"
|
||||||
<el-form-item label="排序">
|
:form="form"
|
||||||
<el-input-number v-model="form.sort" :min="0" :max="999" />
|
:saving="saving"
|
||||||
</el-form-item>
|
:candidate-loading="candidateLoading"
|
||||||
<el-form-item label="状态">
|
:candidates="candidates"
|
||||||
<el-switch v-model="form.status" :active-value="1" :inactive-value="0" />
|
:candidate-page="candidatePage"
|
||||||
</el-form-item>
|
:candidate-page-size="candidatePageSize"
|
||||||
</div>
|
:candidate-total="candidateTotal"
|
||||||
</el-form>
|
:binding="binding"
|
||||||
<template #footer>
|
:selected-count="selectedDramas.length"
|
||||||
<el-button @click="dialogVisible = false">取消</el-button>
|
@save="saveClassification"
|
||||||
<el-button type="primary" :loading="saving" @click="saveClassification">保存</el-button>
|
@search="candidateSearch"
|
||||||
</template>
|
@page="changeCandidatePage"
|
||||||
</el-dialog>
|
@selection="onSelectionChange"
|
||||||
|
@confirm="confirmBind"
|
||||||
<el-dialog v-model="candidateVisible" title="添加关联短剧" width="760px">
|
/>
|
||||||
<div class="classification-toolbar__search" style="margin-bottom: 12px">
|
|
||||||
<el-input
|
|
||||||
v-model="candidateKeyword"
|
|
||||||
placeholder="搜索短剧名称"
|
|
||||||
clearable
|
|
||||||
style="width: 220px"
|
|
||||||
@keyup.enter="candidateSearch"
|
|
||||||
@clear="candidateSearch"
|
|
||||||
/>
|
|
||||||
<el-button type="primary" plain @click="candidateSearch">查询</el-button>
|
|
||||||
</div>
|
|
||||||
<el-table
|
|
||||||
v-loading="candidateLoading"
|
|
||||||
:data="candidates"
|
|
||||||
row-key="id"
|
|
||||||
border
|
|
||||||
max-height="380"
|
|
||||||
empty-text="没有可关联的短剧"
|
|
||||||
@selection-change="onSelectionChange"
|
|
||||||
>
|
|
||||||
<el-table-column type="selection" width="48" />
|
|
||||||
<el-table-column prop="title" label="短剧名称" min-width="220" />
|
|
||||||
<el-table-column label="集数" width="90">
|
|
||||||
<template #default="{ row }">{{ row.totalEpisodes || 0 }}</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="状态" width="110">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<span class="status-dot" :class="statusClass(row.status)">
|
|
||||||
{{ STATUS_TEXT[row.status] || row.status }}
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="sort" label="排序" width="90" />
|
|
||||||
</el-table>
|
|
||||||
<div class="classification-pagination">
|
|
||||||
<el-pagination
|
|
||||||
:current-page="candidatePage"
|
|
||||||
:page-size="candidatePageSize"
|
|
||||||
:total="candidateTotal"
|
|
||||||
layout="total, prev, pager, next"
|
|
||||||
@current-change="changeCandidatePage"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<template #footer>
|
|
||||||
<el-button @click="candidateVisible = false">取消</el-button>
|
|
||||||
<el-button type="primary" :loading="binding" @click="confirmBind">
|
|
||||||
确定关联{{ selectedDramas.length ? `(${selectedDramas.length})` : '' }}
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
@@ -457,83 +396,6 @@ onMounted(loadClassifications)
|
|||||||
align-items: start;
|
align-items: start;
|
||||||
}
|
}
|
||||||
|
|
||||||
.classification-layout__side {
|
|
||||||
padding: 12px 0 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.classification-layout__side-title {
|
|
||||||
padding: 0 16px 10px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--el-text-color-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.classification-list {
|
|
||||||
padding: 0;
|
|
||||||
margin: 0;
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.classification-list__item {
|
|
||||||
display: flex;
|
|
||||||
padding: 8px 12px 8px 16px;
|
|
||||||
color: var(--el-text-color-regular);
|
|
||||||
cursor: pointer;
|
|
||||||
border-left: 3px solid transparent;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.classification-list__item:hover {
|
|
||||||
background: var(--el-fill-color-light);
|
|
||||||
}
|
|
||||||
|
|
||||||
.classification-list__item.is-active {
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--el-color-primary);
|
|
||||||
background: var(--el-color-primary-light-9);
|
|
||||||
border-left-color: var(--el-color-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.classification-list__main {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.classification-list__name {
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.classification-list__count {
|
|
||||||
min-width: 24px;
|
|
||||||
padding: 0 6px;
|
|
||||||
font-size: 12px;
|
|
||||||
line-height: 18px;
|
|
||||||
color: var(--el-text-color-secondary);
|
|
||||||
text-align: center;
|
|
||||||
background: var(--el-fill-color);
|
|
||||||
border-radius: 9px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.classification-list__actions {
|
|
||||||
display: none;
|
|
||||||
gap: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.classification-list__item:hover .classification-list__actions {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
|
|
||||||
.classification-list__empty {
|
|
||||||
padding: 16px;
|
|
||||||
line-height: 1.6;
|
|
||||||
color: var(--el-text-color-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.classification-layout__main {
|
.classification-layout__main {
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
}
|
}
|
||||||
@@ -585,10 +447,4 @@ onMounted(loadClassifications)
|
|||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
margin-top: 14px;
|
margin-top: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.classification-form-row {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 1fr 1fr;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
@@ -4,6 +4,12 @@
|
|||||||
import { onMounted, reactive, ref } from 'vue'
|
import { onMounted, reactive, ref } from 'vue'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import { AppIcons } from '@/constants/icons'
|
import { AppIcons } from '@/constants/icons'
|
||||||
|
import {
|
||||||
|
languageCodes,
|
||||||
|
languageLabel,
|
||||||
|
localesFromColumns,
|
||||||
|
payloadLocales
|
||||||
|
} from '@/constants/contentLanguages'
|
||||||
import {
|
import {
|
||||||
createDramaCategoryApi,
|
createDramaCategoryApi,
|
||||||
deleteDramaCategoryApi,
|
deleteDramaCategoryApi,
|
||||||
@@ -11,6 +17,7 @@ import {
|
|||||||
updateDramaCategoryApi
|
updateDramaCategoryApi
|
||||||
} from '@/api/admin/drama'
|
} from '@/api/admin/drama'
|
||||||
import { useRbac } from '@/stores/rbac'
|
import { useRbac } from '@/stores/rbac'
|
||||||
|
import LocaleTextFields from '@/views/components/LocaleTextFields.vue'
|
||||||
import PageHeading from '@/views/components/PageHeading.vue'
|
import PageHeading from '@/views/components/PageHeading.vue'
|
||||||
|
|
||||||
const { can } = useRbac()
|
const { can } = useRbac()
|
||||||
@@ -20,7 +27,8 @@ const list = ref([])
|
|||||||
const dialogVisible = ref(false)
|
const dialogVisible = ref(false)
|
||||||
const saving = ref(false)
|
const saving = ref(false)
|
||||||
const editingId = ref(null)
|
const editingId = ref(null)
|
||||||
const form = reactive({ name: '', sort: 1, status: 1 })
|
const languages = ref(['zh'])
|
||||||
|
const form = reactive({ locales: { zh: '' }, sort: 1, status: 1 })
|
||||||
|
|
||||||
async function load() {
|
async function load() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
@@ -38,21 +46,29 @@ function nextSort() {
|
|||||||
|
|
||||||
function openCreate() {
|
function openCreate() {
|
||||||
editingId.value = null
|
editingId.value = null
|
||||||
Object.assign(form, { name: '', sort: nextSort(), status: 1 })
|
languages.value = ['zh']
|
||||||
|
Object.assign(form, { locales: { zh: '' }, sort: nextSort(), status: 1 })
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
function openEdit(row) {
|
function openEdit(row) {
|
||||||
editingId.value = row.id
|
editingId.value = row.id
|
||||||
Object.assign(form, { name: row.name, sort: row.sort ?? 0, status: row.status ?? 1 })
|
const locales = localesFromColumns(row.locales, row.name, row.nameEn, row.nameId)
|
||||||
|
languages.value = languageCodes(locales)
|
||||||
|
Object.assign(form, { locales, sort: row.sort ?? 0, status: row.status ?? 1 })
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveCategory() {
|
async function saveCategory() {
|
||||||
if (!form.name.trim()) return ElMessage.warning('请填写类型名称')
|
const locales = payloadLocales(form.locales, languages.value)
|
||||||
|
const missing = languages.value.find((code) => !locales[code])
|
||||||
|
if (!locales.zh || missing) {
|
||||||
|
ElMessage.warning(missing ? `请填写${languageLabel(missing)}名称` : '请填写中文名称')
|
||||||
|
return
|
||||||
|
}
|
||||||
saving.value = true
|
saving.value = true
|
||||||
try {
|
try {
|
||||||
const payload = { name: form.name.trim(), sort: form.sort, status: form.status }
|
const payload = { name: locales.zh, locales, sort: form.sort, status: form.status }
|
||||||
if (editingId.value) {
|
if (editingId.value) {
|
||||||
await updateDramaCategoryApi(editingId.value, payload)
|
await updateDramaCategoryApi(editingId.value, payload)
|
||||||
ElMessage.success('类型已更新')
|
ElMessage.success('类型已更新')
|
||||||
@@ -115,7 +131,20 @@ onMounted(load)
|
|||||||
empty-text="还没有短剧类型"
|
empty-text="还没有短剧类型"
|
||||||
>
|
>
|
||||||
<el-table-column type="index" label="序号" width="80" />
|
<el-table-column type="index" label="序号" width="80" />
|
||||||
<el-table-column prop="name" label="类型名称" min-width="200" />
|
<el-table-column prop="name" label="类型名称" min-width="160" />
|
||||||
|
<el-table-column label="语言" min-width="180">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-tag
|
||||||
|
v-for="code in languageCodes(
|
||||||
|
row.locales || localesFromColumns(null, row.name, row.nameEn, row.nameId)
|
||||||
|
)"
|
||||||
|
:key="code"
|
||||||
|
effect="light"
|
||||||
|
class="locale-tag"
|
||||||
|
>{{ languageLabel(code) }}</el-tag
|
||||||
|
>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column label="短剧数" width="110">
|
<el-table-column label="短剧数" width="110">
|
||||||
<template #default="{ row }">{{ row.dramaCount || 0 }} 部</template>
|
<template #default="{ row }">{{ row.dramaCount || 0 }} 部</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -146,11 +175,14 @@ onMounted(load)
|
|||||||
</el-table>
|
</el-table>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<el-dialog v-model="dialogVisible" :title="editingId ? '编辑类型' : '新建类型'" width="460px">
|
<el-dialog v-model="dialogVisible" :title="editingId ? '编辑类型' : '新建类型'" width="560px">
|
||||||
<el-form label-position="top">
|
<el-form label-position="top">
|
||||||
<el-form-item label="类型名称" required>
|
<LocaleTextFields
|
||||||
<el-input v-model="form.name" maxlength="20" placeholder="例如:都市情感" />
|
v-model:languages="languages"
|
||||||
</el-form-item>
|
:locales="form.locales"
|
||||||
|
label="名称"
|
||||||
|
:maxlength="64"
|
||||||
|
/>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<el-form-item label="排序">
|
<el-form-item label="排序">
|
||||||
<el-input-number v-model="form.sort" :min="0" :max="999" />
|
<el-input-number v-model="form.sort" :min="0" :max="999" />
|
||||||
@@ -166,3 +198,9 @@ onMounted(load)
|
|||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.locale-tag + .locale-tag {
|
||||||
|
margin-left: 6px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,158 @@
|
|||||||
|
<!-- Author: fruit.com.cn -->
|
||||||
|
<!-- 分类管理弹窗:编辑分类,以及把短剧关联进分类。 -->
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { statusClass } from '@/utils/status'
|
||||||
|
import LocaleTextFields from '@/views/components/LocaleTextFields.vue'
|
||||||
|
import { AppIcon } from '@/components/AppIcon'
|
||||||
|
import { AppIcons } from '@/constants/icons'
|
||||||
|
|
||||||
|
const SORT_MAX = 9999
|
||||||
|
|
||||||
|
const STATUS_TEXT = {
|
||||||
|
draft: '草稿',
|
||||||
|
reviewing: '审核中',
|
||||||
|
approved: '待发布',
|
||||||
|
published: '已上线',
|
||||||
|
offline: '已下线'
|
||||||
|
}
|
||||||
|
|
||||||
|
defineProps({
|
||||||
|
editorVisible: { type: Boolean, default: false },
|
||||||
|
editingId: { type: [String, Number], default: null },
|
||||||
|
languages: { type: Array, default: () => ['zh'] },
|
||||||
|
form: { type: Object, required: true },
|
||||||
|
saving: { type: Boolean, default: false },
|
||||||
|
candidateVisible: { type: Boolean, default: false },
|
||||||
|
candidateLoading: { type: Boolean, default: false },
|
||||||
|
candidates: { type: Array, default: () => [] },
|
||||||
|
candidateKeyword: { type: String, default: '' },
|
||||||
|
candidatePage: { type: Number, default: 1 },
|
||||||
|
candidatePageSize: { type: Number, default: 10 },
|
||||||
|
candidateTotal: { type: Number, default: 0 },
|
||||||
|
binding: { type: Boolean, default: false },
|
||||||
|
selectedCount: { type: Number, default: 0 }
|
||||||
|
})
|
||||||
|
|
||||||
|
const emit = defineEmits([
|
||||||
|
'update:editorVisible',
|
||||||
|
'update:languages',
|
||||||
|
'update:candidateVisible',
|
||||||
|
'update:candidateKeyword',
|
||||||
|
'save',
|
||||||
|
'search',
|
||||||
|
'page',
|
||||||
|
'selection',
|
||||||
|
'confirm'
|
||||||
|
])
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<el-dialog
|
||||||
|
:model-value="editorVisible"
|
||||||
|
:title="editingId ? '编辑分类' : '新建分类'"
|
||||||
|
width="560px"
|
||||||
|
@update:model-value="emit('update:editorVisible', $event)"
|
||||||
|
>
|
||||||
|
<el-form label-position="top">
|
||||||
|
<LocaleTextFields
|
||||||
|
:languages="languages"
|
||||||
|
:locales="form.locales"
|
||||||
|
label="名称"
|
||||||
|
:maxlength="64"
|
||||||
|
@update:languages="emit('update:languages', $event)"
|
||||||
|
/>
|
||||||
|
<div class="classification-form-row">
|
||||||
|
<el-form-item label="排序">
|
||||||
|
<el-input-number v-model="form.sort" :min="0" :max="SORT_MAX" controls-position="right" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="状态">
|
||||||
|
<el-switch v-model="form.status" :active-value="1" :inactive-value="0" />
|
||||||
|
</el-form-item>
|
||||||
|
</div>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="emit('update:editorVisible', false)">取消</el-button>
|
||||||
|
<el-button type="primary" :loading="saving" @click="emit('save')">保存</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
|
<el-dialog
|
||||||
|
:model-value="candidateVisible"
|
||||||
|
title="添加关联短剧"
|
||||||
|
width="760px"
|
||||||
|
@update:model-value="emit('update:candidateVisible', $event)"
|
||||||
|
>
|
||||||
|
<div class="classification-toolbar__search">
|
||||||
|
<el-input
|
||||||
|
:model-value="candidateKeyword"
|
||||||
|
placeholder="搜索短剧名称"
|
||||||
|
clearable
|
||||||
|
style="width: 220px"
|
||||||
|
@update:model-value="emit('update:candidateKeyword', $event)"
|
||||||
|
@keyup.enter="emit('search')"
|
||||||
|
@clear="emit('search')"
|
||||||
|
/>
|
||||||
|
<el-button type="primary" plain @click="emit('search')">查询</el-button>
|
||||||
|
</div>
|
||||||
|
<el-table
|
||||||
|
v-loading="candidateLoading"
|
||||||
|
:data="candidates"
|
||||||
|
row-key="id"
|
||||||
|
border
|
||||||
|
max-height="380"
|
||||||
|
empty-text="没有可关联的短剧"
|
||||||
|
@selection-change="emit('selection', $event)"
|
||||||
|
>
|
||||||
|
<el-table-column type="selection" width="48" />
|
||||||
|
<el-table-column prop="title" label="短剧名称" min-width="220" />
|
||||||
|
<el-table-column label="集数" width="90">
|
||||||
|
<template #default="{ row }">{{ row.totalEpisodes || 0 }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="状态" width="110">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<span class="status-dot" :class="statusClass(row.status)">
|
||||||
|
{{ STATUS_TEXT[row.status] || row.status }}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="sort" label="排序" width="90" />
|
||||||
|
</el-table>
|
||||||
|
<div class="classification-pagination">
|
||||||
|
<el-pagination
|
||||||
|
:current-page="candidatePage"
|
||||||
|
:page-size="candidatePageSize"
|
||||||
|
:total="candidateTotal"
|
||||||
|
layout="total, prev, pager, next"
|
||||||
|
@current-change="emit('page', $event)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="emit('update:candidateVisible', false)">取消</el-button>
|
||||||
|
<el-button type="primary" :loading="binding" @click="emit('confirm')">
|
||||||
|
确定关联{{ selectedCount ? `(${selectedCount})` : '' }}
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.classification-form-row {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.classification-toolbar__search {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.classification-pagination {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
margin-top: 14px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
<!-- Author: fruit.com.cn -->
|
||||||
|
<!-- 分类管理左侧列表:切换、编辑、删除。 -->
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { AppIcon } from '@/components/AppIcon'
|
||||||
|
import { AppIcons } from '@/constants/icons'
|
||||||
|
import { useRbac } from '@/stores/rbac'
|
||||||
|
|
||||||
|
defineProps({
|
||||||
|
classifications: { type: Array, default: () => [] },
|
||||||
|
activeId: { type: [String, Number], default: null }
|
||||||
|
})
|
||||||
|
|
||||||
|
const emit = defineEmits(['select', 'edit', 'remove'])
|
||||||
|
const { can } = useRbac()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<aside class="panel classification-layout__side">
|
||||||
|
<div class="classification-layout__side-title">全部分类</div>
|
||||||
|
<el-scrollbar height="560px">
|
||||||
|
<ul class="classification-list">
|
||||||
|
<li
|
||||||
|
v-for="item in classifications"
|
||||||
|
:key="item.id"
|
||||||
|
class="classification-list__item"
|
||||||
|
:class="{ 'is-active': item.id === activeId }"
|
||||||
|
@click="emit('select', item)"
|
||||||
|
>
|
||||||
|
<div class="classification-list__main">
|
||||||
|
<span class="classification-list__name">{{ item.name }}</span>
|
||||||
|
<span class="classification-list__count">{{ item.dramaCount || 0 }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="classification-list__actions" @click.stop>
|
||||||
|
<el-button
|
||||||
|
v-if="can('drama:update')"
|
||||||
|
text
|
||||||
|
circle
|
||||||
|
size="small"
|
||||||
|
@click="emit('edit', item)"
|
||||||
|
>
|
||||||
|
<AppIcon :icon="AppIcons.edit" :size="15" />
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-if="can('drama:delete')"
|
||||||
|
text
|
||||||
|
circle
|
||||||
|
size="small"
|
||||||
|
@click="emit('remove', item)"
|
||||||
|
>
|
||||||
|
<AppIcon :icon="AppIcons.delete" :size="15" />
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li v-if="!classifications.length" class="classification-list__empty">
|
||||||
|
还没有分类,点右上角「新建分类」开始
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</el-scrollbar>
|
||||||
|
</aside>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.classification-layout__side {
|
||||||
|
padding: 12px 0 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.classification-layout__side-title {
|
||||||
|
padding: 0 16px 10px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--el-text-color-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.classification-list {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.classification-list__item {
|
||||||
|
display: flex;
|
||||||
|
padding: 8px 12px 8px 16px;
|
||||||
|
color: var(--el-text-color-regular);
|
||||||
|
cursor: pointer;
|
||||||
|
border-left: 3px solid transparent;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.classification-list__item:hover {
|
||||||
|
background: var(--el-fill-color-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
.classification-list__item.is-active {
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--el-color-primary);
|
||||||
|
background: var(--el-color-primary-light-9);
|
||||||
|
border-left-color: var(--el-color-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.classification-list__main {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.classification-list__name {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.classification-list__count {
|
||||||
|
min-width: 24px;
|
||||||
|
padding: 0 6px;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 18px;
|
||||||
|
color: var(--el-text-color-secondary);
|
||||||
|
text-align: center;
|
||||||
|
background: var(--el-fill-color);
|
||||||
|
border-radius: 9px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.classification-list__actions {
|
||||||
|
display: none;
|
||||||
|
gap: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.classification-list__item:hover .classification-list__actions {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.classification-list__empty {
|
||||||
|
padding: 16px;
|
||||||
|
line-height: 1.6;
|
||||||
|
color: var(--el-text-color-secondary);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -5,6 +5,13 @@ import { computed, nextTick, onMounted, reactive, ref } from 'vue'
|
|||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import { AppIcons } from '@/constants/icons'
|
import { AppIcons } from '@/constants/icons'
|
||||||
|
import {
|
||||||
|
languageLabel,
|
||||||
|
languageCodes,
|
||||||
|
localesFromColumns,
|
||||||
|
payloadLocales
|
||||||
|
} from '@/constants/contentLanguages'
|
||||||
|
import LocaleTextFields from '@/views/components/LocaleTextFields.vue'
|
||||||
import { AppImage } from '@/components/AppImage'
|
import { AppImage } from '@/components/AppImage'
|
||||||
import {
|
import {
|
||||||
changeDramaStatusApi,
|
changeDramaStatusApi,
|
||||||
@@ -16,6 +23,7 @@ import {
|
|||||||
} from '@/api/admin/drama'
|
} from '@/api/admin/drama'
|
||||||
import { useRbac } from '@/stores/rbac'
|
import { useRbac } from '@/stores/rbac'
|
||||||
import { formatCount } from '@/utils/format'
|
import { formatCount } from '@/utils/format'
|
||||||
|
import { listContentTagsApi } from '@/api/admin/contentTag'
|
||||||
import { statusClass } from '@/utils/status'
|
import { statusClass } from '@/utils/status'
|
||||||
import { uploadFile } from '@/utils/uploader'
|
import { uploadFile } from '@/utils/uploader'
|
||||||
|
|
||||||
@@ -30,8 +38,7 @@ const categories = ref([])
|
|||||||
const keyword = ref('')
|
const keyword = ref('')
|
||||||
const statusFilter = ref(undefined)
|
const statusFilter = ref(undefined)
|
||||||
const categoryIds = ref([])
|
const categoryIds = ref([])
|
||||||
const dramaTypes = ref([])
|
const tags = ref([])
|
||||||
const hotFilter = ref(undefined)
|
|
||||||
const pageIndex = ref(1)
|
const pageIndex = ref(1)
|
||||||
const pageSize = ref(10)
|
const pageSize = ref(10)
|
||||||
|
|
||||||
@@ -45,11 +52,14 @@ const editingId = ref(null)
|
|||||||
const editingCommentCount = ref(0)
|
const editingCommentCount = ref(0)
|
||||||
const editingLikeCount = ref(0)
|
const editingLikeCount = ref(0)
|
||||||
const formRef = ref()
|
const formRef = ref()
|
||||||
|
const textLanguages = ref(['zh'])
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
title: '',
|
title: '',
|
||||||
|
titleLocales: { zh: '' },
|
||||||
categoryIds: [],
|
categoryIds: [],
|
||||||
dramaTypes: ['LIVE'],
|
tagId: null,
|
||||||
description: '',
|
description: '',
|
||||||
|
synopsisLocales: { zh: '' },
|
||||||
freeEpisodes: 3,
|
freeEpisodes: 3,
|
||||||
unlockCoin: 0,
|
unlockCoin: 0,
|
||||||
favoriteCount: 0,
|
favoriteCount: 0,
|
||||||
@@ -62,16 +72,6 @@ const form = reactive({
|
|||||||
const MAX_COVER_SIZE = 5 * 1024 * 1024
|
const MAX_COVER_SIZE = 5 * 1024 * 1024
|
||||||
const COVER_TYPES = ['image/jpeg', 'image/png', 'image/webp']
|
const COVER_TYPES = ['image/jpeg', 'image/png', 'image/webp']
|
||||||
|
|
||||||
const formRules = {
|
|
||||||
title: [{ required: true, message: '请输入短剧名称', trigger: 'blur' }],
|
|
||||||
categoryIds: [
|
|
||||||
{ type: 'array', required: true, min: 1, message: '请至少选择一个类型', trigger: 'change' }
|
|
||||||
],
|
|
||||||
dramaTypes: [
|
|
||||||
{ type: 'array', required: true, min: 1, message: '请至少选择一个内容类型', trigger: 'change' }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
const coverDisplayName = computed(
|
const coverDisplayName = computed(
|
||||||
() => coverFileName.value || (form.cover ? coverBasename(form.cover) : '尚未选择封面')
|
() => coverFileName.value || (form.cover ? coverBasename(form.cover) : '尚未选择封面')
|
||||||
)
|
)
|
||||||
@@ -90,11 +90,6 @@ const statusOptions = [
|
|||||||
{ code: 'offline', text: '已下线' }
|
{ code: 'offline', text: '已下线' }
|
||||||
]
|
]
|
||||||
|
|
||||||
const dramaTypeOptions = [
|
|
||||||
{ value: 'ANIME', label: '漫剧' },
|
|
||||||
{ value: 'LIVE', label: '真人剧' }
|
|
||||||
]
|
|
||||||
|
|
||||||
const actionMeta = {
|
const actionMeta = {
|
||||||
submit: { label: '提交审核', done: '已提交审核' },
|
submit: { label: '提交审核', done: '已提交审核' },
|
||||||
approve: { label: '审核通过', done: '已通过审核' },
|
approve: { label: '审核通过', done: '已通过审核' },
|
||||||
@@ -111,9 +106,7 @@ async function load() {
|
|||||||
pageSize: pageSize.value,
|
pageSize: pageSize.value,
|
||||||
keyword: keyword.value.trim() || undefined,
|
keyword: keyword.value.trim() || undefined,
|
||||||
status: statusFilter.value || undefined,
|
status: statusFilter.value || undefined,
|
||||||
categoryIds: categoryIds.value.length ? categoryIds.value : undefined,
|
categoryIds: categoryIds.value.length ? categoryIds.value : undefined
|
||||||
dramaTypes: dramaTypes.value.length ? dramaTypes.value : undefined,
|
|
||||||
isHot: hotFilter.value
|
|
||||||
})
|
})
|
||||||
list.value = res.data?.list || []
|
list.value = res.data?.list || []
|
||||||
total.value = res.data?.total || 0
|
total.value = res.data?.total || 0
|
||||||
@@ -127,6 +120,11 @@ async function loadCategories() {
|
|||||||
categories.value = res.data || []
|
categories.value = res.data || []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function loadTags() {
|
||||||
|
const res = await listContentTagsApi(true)
|
||||||
|
tags.value = res.data || []
|
||||||
|
}
|
||||||
|
|
||||||
function search() {
|
function search() {
|
||||||
pageIndex.value = 1
|
pageIndex.value = 1
|
||||||
load()
|
load()
|
||||||
@@ -136,8 +134,6 @@ function resetFilters() {
|
|||||||
keyword.value = ''
|
keyword.value = ''
|
||||||
statusFilter.value = undefined
|
statusFilter.value = undefined
|
||||||
categoryIds.value = []
|
categoryIds.value = []
|
||||||
dramaTypes.value = []
|
|
||||||
hotFilter.value = undefined
|
|
||||||
search()
|
search()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,24 +142,50 @@ function handleSizeChange() {
|
|||||||
load()
|
load()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function selectedCategoryIds(row) {
|
||||||
|
const values =
|
||||||
|
Array.isArray(row.categoryIds) && row.categoryIds.length
|
||||||
|
? row.categoryIds
|
||||||
|
: row.categoryId
|
||||||
|
? [row.categoryId]
|
||||||
|
: []
|
||||||
|
return values.filter((id) => Number(id) > 0)
|
||||||
|
}
|
||||||
|
|
||||||
function coverBasename(path) {
|
function coverBasename(path) {
|
||||||
if (!path) return ''
|
if (!path) return ''
|
||||||
const clean = path.split('?')[0].split('#')[0]
|
const clean = path.split('?')[0].split('#')[0]
|
||||||
return decodeURIComponent(clean.split('/').pop() || clean)
|
return decodeURIComponent(clean.split('/').pop() || clean)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 长整型计数字段在接口里是字符串,数字输入框只接受 number。 */
|
||||||
|
function toCount(value) {
|
||||||
|
const count = Number(value)
|
||||||
|
return Number.isFinite(count) ? count : 0
|
||||||
|
}
|
||||||
|
|
||||||
async function resetValidation() {
|
async function resetValidation() {
|
||||||
await nextTick()
|
await nextTick()
|
||||||
formRef.value?.clearValidate()
|
formRef.value?.clearValidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function changeTextLanguages(codes) {
|
||||||
|
textLanguages.value = codes
|
||||||
|
codes.forEach((code) => {
|
||||||
|
if (form.synopsisLocales[code] == null) form.synopsisLocales[code] = ''
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function openCreate() {
|
function openCreate() {
|
||||||
editingId.value = null
|
editingId.value = null
|
||||||
|
textLanguages.value = ['zh']
|
||||||
Object.assign(form, {
|
Object.assign(form, {
|
||||||
title: '',
|
title: '',
|
||||||
|
titleLocales: { zh: '' },
|
||||||
categoryIds: [],
|
categoryIds: [],
|
||||||
dramaTypes: ['LIVE'],
|
tagId: null,
|
||||||
description: '',
|
description: '',
|
||||||
|
synopsisLocales: { zh: '' },
|
||||||
freeEpisodes: 3,
|
freeEpisodes: 3,
|
||||||
unlockCoin: 0,
|
unlockCoin: 0,
|
||||||
favoriteCount: 0,
|
favoriteCount: 0,
|
||||||
@@ -182,41 +204,35 @@ function openCreate() {
|
|||||||
|
|
||||||
function openEdit(row) {
|
function openEdit(row) {
|
||||||
editingId.value = row.id
|
editingId.value = row.id
|
||||||
|
const titleLocales = localesFromColumns(row.titleLocales, row.title)
|
||||||
|
const synopsisLocales = localesFromColumns(row.synopsisLocales, row.description)
|
||||||
|
textLanguages.value = languageCodes(titleLocales)
|
||||||
|
textLanguages.value.forEach((code) => {
|
||||||
|
if (synopsisLocales[code] == null) synopsisLocales[code] = ''
|
||||||
|
})
|
||||||
Object.assign(form, {
|
Object.assign(form, {
|
||||||
title: row.title,
|
title: row.title,
|
||||||
categoryIds:
|
titleLocales,
|
||||||
Array.isArray(row.categoryIds) && row.categoryIds.length
|
categoryIds: selectedCategoryIds(row),
|
||||||
? row.categoryIds
|
tagId: Number(row.tagId) > 0 ? row.tagId : null,
|
||||||
: row.categoryId
|
|
||||||
? [row.categoryId]
|
|
||||||
: [],
|
|
||||||
dramaTypes:
|
|
||||||
Array.isArray(row.dramaTypes) && row.dramaTypes.length
|
|
||||||
? row.dramaTypes
|
|
||||||
: row.dramaType
|
|
||||||
? [row.dramaType]
|
|
||||||
: ['LIVE'],
|
|
||||||
description: row.description || '',
|
description: row.description || '',
|
||||||
freeEpisodes: row.freeEpisodes ?? 3,
|
synopsisLocales,
|
||||||
unlockCoin: row.unlockCoin ?? 0,
|
freeEpisodes: toCount(row.freeEpisodes ?? 3),
|
||||||
favoriteCount: row.favoriteCount ?? 0,
|
unlockCoin: toCount(row.unlockCoin),
|
||||||
heat: row.views ?? 0,
|
favoriteCount: toCount(row.favoriteCount),
|
||||||
|
heat: toCount(row.views),
|
||||||
isHot: !!row.isHot,
|
isHot: !!row.isHot,
|
||||||
sort: row.sort ?? 0,
|
sort: toCount(row.sort),
|
||||||
cover: row.cover || ''
|
cover: row.cover || ''
|
||||||
})
|
})
|
||||||
coverFileName.value = row.cover ? coverBasename(row.cover) : ''
|
coverFileName.value = row.cover ? coverBasename(row.cover) : ''
|
||||||
coverError.value = ''
|
coverError.value = ''
|
||||||
editingCommentCount.value = row.commentCount ?? 0
|
editingCommentCount.value = toCount(row.commentCount)
|
||||||
editingLikeCount.value = row.likeCount ?? 0
|
editingLikeCount.value = toCount(row.likeCount)
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
resetValidation()
|
resetValidation()
|
||||||
}
|
}
|
||||||
|
|
||||||
function dramaTypeLabel(value) {
|
|
||||||
return dramaTypeOptions.find((item) => item.value === value)?.label || '真人剧'
|
|
||||||
}
|
|
||||||
|
|
||||||
function rowCategoryList(row) {
|
function rowCategoryList(row) {
|
||||||
if (Array.isArray(row.categoryNames) && row.categoryNames.length) {
|
if (Array.isArray(row.categoryNames) && row.categoryNames.length) {
|
||||||
return row.categoryNames.filter(Boolean)
|
return row.categoryNames.filter(Boolean)
|
||||||
@@ -228,25 +244,26 @@ function rowCategoryList(row) {
|
|||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
}
|
}
|
||||||
|
|
||||||
function rowDramaTypes(row) {
|
|
||||||
if (Array.isArray(row.dramaTypes) && row.dramaTypes.length) return row.dramaTypes
|
|
||||||
return row.dramaType ? [row.dramaType] : []
|
|
||||||
}
|
|
||||||
|
|
||||||
async function saveDrama() {
|
async function saveDrama() {
|
||||||
if (saving.value || uploadingCover.value) return
|
if (saving.value || uploadingCover.value) return
|
||||||
try {
|
const titles = payloadLocales(form.titleLocales, textLanguages.value)
|
||||||
await formRef.value?.validate()
|
const missing = textLanguages.value.find((code) => !titles[code])
|
||||||
} catch {
|
if (!titles.zh || missing) {
|
||||||
|
ElMessage.warning(missing ? `请填写${languageLabel(missing)}名称` : '请输入短剧名称')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
const synopses = payloadLocales(form.synopsisLocales, textLanguages.value)
|
||||||
const categoryNames = form.categoryIds
|
const categoryNames = form.categoryIds
|
||||||
.map((id) => categories.value.find((item) => item.id === id)?.name)
|
.map((id) => categories.value.find((item) => item.id === id)?.name)
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
const payload = {
|
const payload = {
|
||||||
...form,
|
...form,
|
||||||
title: form.title.trim(),
|
title: titles.zh,
|
||||||
genre: categoryNames.join(' / ')
|
titleLocales: titles,
|
||||||
|
description: synopses.zh || '',
|
||||||
|
synopsisLocales: synopses,
|
||||||
|
genre: categoryNames.join(' / '),
|
||||||
|
tagId: form.tagId || 0
|
||||||
}
|
}
|
||||||
saving.value = true
|
saving.value = true
|
||||||
try {
|
try {
|
||||||
@@ -370,7 +387,7 @@ function reviewActions(row) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await loadCategories()
|
await Promise.all([loadCategories(), loadTags()])
|
||||||
await load()
|
await load()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
@@ -413,22 +430,6 @@ onMounted(async () => {
|
|||||||
:key="item.id"
|
:key="item.id"
|
||||||
:label="item.name"
|
:label="item.name"
|
||||||
:value="item.id" /></el-select
|
:value="item.id" /></el-select
|
||||||
><el-select
|
|
||||||
v-model="dramaTypes"
|
|
||||||
class="drama-multi-select"
|
|
||||||
multiple
|
|
||||||
clearable
|
|
||||||
placeholder="全部内容类型"
|
|
||||||
@change="search"
|
|
||||||
><el-option
|
|
||||||
v-for="item in dramaTypeOptions"
|
|
||||||
:key="item.value"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value" /></el-select
|
|
||||||
><el-select v-model="hotFilter" clearable placeholder="全部热度" @change="search"
|
|
||||||
><el-option label="仅热门" :value="true" /><el-option
|
|
||||||
label="非热门"
|
|
||||||
:value="false" /></el-select
|
|
||||||
><el-button @click="resetFilters">重置</el-button></div
|
><el-button @click="resetFilters">重置</el-button></div
|
||||||
><span class="table-result-count">共 {{ total }} 部短剧</span></div
|
><span class="table-result-count">共 {{ total }} 部短剧</span></div
|
||||||
>
|
>
|
||||||
@@ -465,24 +466,17 @@ onMounted(async () => {
|
|||||||
>
|
>
|
||||||
<el-table-column label="类型" min-width="200"
|
<el-table-column label="类型" min-width="200"
|
||||||
><template #default="{ row }"
|
><template #default="{ row }"
|
||||||
><div class="tag-wrap"
|
><div v-if="rowCategoryList(row).length" class="tag-wrap"
|
||||||
><el-tag v-for="name in rowCategoryList(row)" :key="name" type="info" effect="light">{{
|
><el-tag v-for="name in rowCategoryList(row)" :key="name" type="info" effect="light">{{
|
||||||
name
|
name
|
||||||
}}</el-tag></div
|
}}</el-tag></div
|
||||||
></template
|
><span v-else class="table-empty-text">—</span></template
|
||||||
>
|
>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="内容类型" min-width="180"
|
<el-table-column label="标签" min-width="120"
|
||||||
><template #default="{ row }"
|
><template #default="{ row }"
|
||||||
><div class="tag-wrap"
|
><span v-if="row.tagName">{{ row.tagName }}</span
|
||||||
><el-tag
|
><span v-else class="table-empty-text">—</span></template
|
||||||
v-for="type in rowDramaTypes(row)"
|
|
||||||
:key="type"
|
|
||||||
:type="type === 'ANIME' ? 'warning' : 'info'"
|
|
||||||
effect="light"
|
|
||||||
>{{ dramaTypeLabel(type) }}</el-tag
|
|
||||||
></div
|
|
||||||
></template
|
|
||||||
></el-table-column
|
></el-table-column
|
||||||
>
|
>
|
||||||
<el-table-column label="集数" width="90"
|
<el-table-column label="集数" width="90"
|
||||||
@@ -513,12 +507,6 @@ onMounted(async () => {
|
|||||||
}}</el-tag></template
|
}}</el-tag></template
|
||||||
></el-table-column
|
></el-table-column
|
||||||
>
|
>
|
||||||
<el-table-column label="热门" width="90"
|
|
||||||
><template #default="{ row }"
|
|
||||||
><el-tag v-if="row.isHot" type="danger" effect="light">热门</el-tag
|
|
||||||
><span v-else class="table-empty-text">—</span></template
|
|
||||||
></el-table-column
|
|
||||||
>
|
|
||||||
<el-table-column prop="updatedAt" label="更新时间" width="160" />
|
<el-table-column prop="updatedAt" label="更新时间" width="160" />
|
||||||
<el-table-column label="审核" width="140"
|
<el-table-column label="审核" width="140"
|
||||||
><template #default="{ row }"
|
><template #default="{ row }"
|
||||||
@@ -576,141 +564,12 @@ onMounted(async () => {
|
|||||||
<el-dialog
|
<el-dialog
|
||||||
v-model="dialogVisible"
|
v-model="dialogVisible"
|
||||||
:title="editingId ? '编辑短剧' : '新建短剧'"
|
:title="editingId ? '编辑短剧' : '新建短剧'"
|
||||||
width="680px"
|
width="760px"
|
||||||
class="drama-editor-dialog"
|
class="drama-editor-dialog"
|
||||||
:close-on-click-modal="false"
|
:close-on-click-modal="false"
|
||||||
:before-close="beforeDialogClose"
|
:before-close="beforeDialogClose"
|
||||||
>
|
>
|
||||||
<el-form
|
<el-form ref="formRef" :model="form" label-position="top" class="drama-editor-form">
|
||||||
ref="formRef"
|
|
||||||
:model="form"
|
|
||||||
:rules="formRules"
|
|
||||||
label-position="top"
|
|
||||||
class="drama-editor-form"
|
|
||||||
>
|
|
||||||
<section class="editor-section">
|
|
||||||
<h3 class="editor-section-title">基础信息</h3>
|
|
||||||
<div class="editor-grid editor-grid--two">
|
|
||||||
<el-form-item label="短剧名称" prop="title">
|
|
||||||
<el-input v-model="form.title" maxlength="80" placeholder="请输入短剧名称" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="类型" prop="categoryIds">
|
|
||||||
<el-select
|
|
||||||
v-model="form.categoryIds"
|
|
||||||
class="drama-multi-select"
|
|
||||||
multiple
|
|
||||||
filterable
|
|
||||||
placeholder="请选择类型"
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="item in categories"
|
|
||||||
:key="item.id"
|
|
||||||
:label="item.name"
|
|
||||||
:value="item.id"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="内容类型" prop="dramaTypes">
|
|
||||||
<el-select
|
|
||||||
v-model="form.dramaTypes"
|
|
||||||
class="drama-multi-select"
|
|
||||||
multiple
|
|
||||||
filterable
|
|
||||||
placeholder="请选择内容类型"
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="item in dramaTypeOptions"
|
|
||||||
:key="item.value"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
</div>
|
|
||||||
<el-form-item label="简介">
|
|
||||||
<el-input
|
|
||||||
v-model="form.description"
|
|
||||||
type="textarea"
|
|
||||||
:rows="3"
|
|
||||||
maxlength="1000"
|
|
||||||
show-word-limit
|
|
||||||
placeholder="简要介绍剧情"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="editor-section">
|
|
||||||
<h3 class="editor-section-title">付费设置</h3>
|
|
||||||
<div class="editor-grid editor-grid--two">
|
|
||||||
<el-form-item label="免费集数">
|
|
||||||
<el-input-number
|
|
||||||
v-model="form.freeEpisodes"
|
|
||||||
class="editor-number"
|
|
||||||
controls-position="right"
|
|
||||||
:min="0"
|
|
||||||
:max="200"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="单集解锁金币">
|
|
||||||
<el-input-number
|
|
||||||
v-model="form.unlockCoin"
|
|
||||||
class="editor-number"
|
|
||||||
controls-position="right"
|
|
||||||
:min="0"
|
|
||||||
:max="9999"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</div>
|
|
||||||
<div class="editor-grid editor-grid--two">
|
|
||||||
<el-form-item label="是否热门">
|
|
||||||
<el-switch v-model="form.isHot" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="排序权重">
|
|
||||||
<el-input-number
|
|
||||||
v-model="form.sort"
|
|
||||||
class="editor-number"
|
|
||||||
controls-position="right"
|
|
||||||
:min="0"
|
|
||||||
:max="99999"
|
|
||||||
:precision="0"
|
|
||||||
/>
|
|
||||||
<p class="readonly-stat-hint">数值越大越靠前,相同权重按 ID 倒序</p>
|
|
||||||
</el-form-item>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="editor-section">
|
|
||||||
<h3 class="editor-section-title">互动数据</h3>
|
|
||||||
<div class="editor-grid editor-grid--two">
|
|
||||||
<el-form-item label="收藏数">
|
|
||||||
<el-input-number
|
|
||||||
v-model="form.favoriteCount"
|
|
||||||
class="editor-number"
|
|
||||||
controls-position="right"
|
|
||||||
:min="0"
|
|
||||||
:precision="0"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="点赞数">
|
|
||||||
<div class="readonly-stat">{{ formatCount(editingLikeCount) }}</div>
|
|
||||||
<p class="readonly-stat-hint">全剧分集汇总,只读</p>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="热度">
|
|
||||||
<el-input-number
|
|
||||||
v-model="form.heat"
|
|
||||||
class="editor-number"
|
|
||||||
controls-position="right"
|
|
||||||
:min="0"
|
|
||||||
:precision="0"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="评论数">
|
|
||||||
<div class="readonly-stat">{{ formatCount(editingCommentCount) }}</div>
|
|
||||||
<p class="readonly-stat-hint">全剧汇总,实时统计,只读</p>
|
|
||||||
</el-form-item>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="editor-section">
|
<section class="editor-section">
|
||||||
<h3 class="editor-section-title">封面</h3>
|
<h3 class="editor-section-title">封面</h3>
|
||||||
<div class="cover-editor">
|
<div class="cover-editor">
|
||||||
@@ -776,6 +635,117 @@ onMounted(async () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section class="editor-section">
|
||||||
|
<h3 class="editor-section-title">基础信息</h3>
|
||||||
|
<LocaleTextFields
|
||||||
|
:languages="textLanguages"
|
||||||
|
:locales="form.titleLocales"
|
||||||
|
label="名称"
|
||||||
|
:maxlength="80"
|
||||||
|
@update:languages="changeTextLanguages"
|
||||||
|
/>
|
||||||
|
<div class="editor-grid editor-grid--two">
|
||||||
|
<el-form-item label="类型">
|
||||||
|
<el-select
|
||||||
|
v-model="form.categoryIds"
|
||||||
|
class="drama-multi-select"
|
||||||
|
multiple
|
||||||
|
filterable
|
||||||
|
clearable
|
||||||
|
placeholder="可不选"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in categories"
|
||||||
|
:key="item.id"
|
||||||
|
:label="item.name"
|
||||||
|
:value="item.id"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="标签">
|
||||||
|
<el-select v-model="form.tagId" clearable filterable placeholder="可不选">
|
||||||
|
<el-option v-for="item in tags" :key="item.id" :label="item.name" :value="item.id" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</div>
|
||||||
|
<LocaleTextFields
|
||||||
|
:languages="textLanguages"
|
||||||
|
:locales="form.synopsisLocales"
|
||||||
|
label="简介"
|
||||||
|
:maxlength="1000"
|
||||||
|
multiline
|
||||||
|
:show-languages="false"
|
||||||
|
:required="false"
|
||||||
|
/>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="editor-section">
|
||||||
|
<h3 class="editor-section-title">付费设置</h3>
|
||||||
|
<div class="editor-grid editor-grid--two">
|
||||||
|
<el-form-item label="免费集数">
|
||||||
|
<el-input-number
|
||||||
|
v-model="form.freeEpisodes"
|
||||||
|
class="editor-number"
|
||||||
|
controls-position="right"
|
||||||
|
:min="0"
|
||||||
|
:max="200"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="单集解锁金币">
|
||||||
|
<el-input-number
|
||||||
|
v-model="form.unlockCoin"
|
||||||
|
class="editor-number"
|
||||||
|
controls-position="right"
|
||||||
|
:min="0"
|
||||||
|
:max="9999"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="排序">
|
||||||
|
<el-input-number
|
||||||
|
v-model="form.sort"
|
||||||
|
class="editor-number"
|
||||||
|
controls-position="right"
|
||||||
|
:min="0"
|
||||||
|
:max="99999"
|
||||||
|
:precision="0"
|
||||||
|
/>
|
||||||
|
<p class="readonly-stat-hint">数值越大越靠前,相同权重按 ID 倒序</p>
|
||||||
|
</el-form-item>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="editor-section">
|
||||||
|
<h3 class="editor-section-title">互动数据</h3>
|
||||||
|
<div class="editor-grid editor-grid--two">
|
||||||
|
<el-form-item label="收藏数">
|
||||||
|
<el-input-number
|
||||||
|
v-model="form.favoriteCount"
|
||||||
|
class="editor-number"
|
||||||
|
controls-position="right"
|
||||||
|
:min="0"
|
||||||
|
:precision="0"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="点赞数">
|
||||||
|
<div class="readonly-stat">{{ formatCount(editingLikeCount) }}</div>
|
||||||
|
<p class="readonly-stat-hint">全剧分集汇总,只读</p>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="热度">
|
||||||
|
<el-input-number
|
||||||
|
v-model="form.heat"
|
||||||
|
class="editor-number"
|
||||||
|
controls-position="right"
|
||||||
|
:min="0"
|
||||||
|
:precision="0"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="评论数">
|
||||||
|
<div class="readonly-stat">{{ formatCount(editingCommentCount) }}</div>
|
||||||
|
<p class="readonly-stat-hint">全剧汇总,实时统计,只读</p>
|
||||||
|
</el-form-item>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
@@ -816,6 +786,20 @@ onMounted(async () => {
|
|||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.drama-editor-form :deep(.el-form-item) {
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.drama-editor-form :deep(.el-form-item__content) {
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.drama-editor-form :deep(.el-input),
|
||||||
|
.drama-editor-form :deep(.el-textarea),
|
||||||
|
.drama-editor-form :deep(.el-select) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
.tag-wrap {
|
.tag-wrap {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
|||||||
@@ -6,6 +6,12 @@ import { computed, onMounted, reactive, ref } from 'vue'
|
|||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import { AppIcon } from '@/components/AppIcon'
|
import { AppIcon } from '@/components/AppIcon'
|
||||||
import { AppIcons } from '@/constants/icons'
|
import { AppIcons } from '@/constants/icons'
|
||||||
|
import {
|
||||||
|
languageCodes,
|
||||||
|
languageLabel,
|
||||||
|
localesFromColumns,
|
||||||
|
payloadLocales
|
||||||
|
} from '@/constants/contentLanguages'
|
||||||
import {
|
import {
|
||||||
bindPlaylistCategoryDramasApi,
|
bindPlaylistCategoryDramasApi,
|
||||||
createPlaylistCategoryApi,
|
createPlaylistCategoryApi,
|
||||||
@@ -18,6 +24,7 @@ import {
|
|||||||
} from '@/api/admin/dramaPlaylistCategory'
|
} from '@/api/admin/dramaPlaylistCategory'
|
||||||
import { statusClass } from '@/utils/status'
|
import { statusClass } from '@/utils/status'
|
||||||
import { useRbac } from '@/stores/rbac'
|
import { useRbac } from '@/stores/rbac'
|
||||||
|
import LocaleTextFields from '@/views/components/LocaleTextFields.vue'
|
||||||
import PageHeading from '@/views/components/PageHeading.vue'
|
import PageHeading from '@/views/components/PageHeading.vue'
|
||||||
|
|
||||||
const { can } = useRbac()
|
const { can } = useRbac()
|
||||||
@@ -46,7 +53,14 @@ const keyword = ref('')
|
|||||||
const dialogVisible = ref(false)
|
const dialogVisible = ref(false)
|
||||||
const saving = ref(false)
|
const saving = ref(false)
|
||||||
const editingId = ref(null)
|
const editingId = ref(null)
|
||||||
const form = reactive({ name: '', description: '', sort: 1, status: 1 })
|
const languages = ref(['zh'])
|
||||||
|
const emptyForm = () => ({
|
||||||
|
locales: { zh: '' },
|
||||||
|
descriptionLocales: { zh: '' },
|
||||||
|
sort: 1,
|
||||||
|
status: 1
|
||||||
|
})
|
||||||
|
const form = reactive(emptyForm())
|
||||||
|
|
||||||
const candidateVisible = ref(false)
|
const candidateVisible = ref(false)
|
||||||
const candidateLoading = ref(false)
|
const candidateLoading = ref(false)
|
||||||
@@ -108,18 +122,37 @@ function changePage(value) {
|
|||||||
loadDramas()
|
loadDramas()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function changeLanguages(codes) {
|
||||||
|
languages.value = codes
|
||||||
|
codes.forEach((code) => {
|
||||||
|
if (form.descriptionLocales[code] == null) form.descriptionLocales[code] = ''
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function openCreate() {
|
function openCreate() {
|
||||||
editingId.value = null
|
editingId.value = null
|
||||||
|
languages.value = ['zh']
|
||||||
const maxSort = categories.value.reduce((max, item) => Math.max(max, item.sort || 0), 0)
|
const maxSort = categories.value.reduce((max, item) => Math.max(max, item.sort || 0), 0)
|
||||||
Object.assign(form, { name: '', description: '', sort: maxSort + 1, status: 1 })
|
Object.assign(form, emptyForm(), { sort: maxSort + 1 })
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
function openEdit(row) {
|
function openEdit(row) {
|
||||||
editingId.value = row.id
|
editingId.value = row.id
|
||||||
|
const locales = localesFromColumns(row.locales, row.name, row.nameEn, row.nameId)
|
||||||
|
languages.value = languageCodes(locales)
|
||||||
|
const descriptionLocales = localesFromColumns(
|
||||||
|
row.descriptionLocales,
|
||||||
|
row.description,
|
||||||
|
row.descriptionEn,
|
||||||
|
row.descriptionId
|
||||||
|
)
|
||||||
|
languages.value.forEach((code) => {
|
||||||
|
if (descriptionLocales[code] == null) descriptionLocales[code] = ''
|
||||||
|
})
|
||||||
Object.assign(form, {
|
Object.assign(form, {
|
||||||
name: row.name,
|
locales,
|
||||||
description: row.description || '',
|
descriptionLocales,
|
||||||
sort: row.sort ?? 0,
|
sort: row.sort ?? 0,
|
||||||
status: row.status ?? 1
|
status: row.status ?? 1
|
||||||
})
|
})
|
||||||
@@ -127,15 +160,18 @@ function openEdit(row) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function saveCategory() {
|
async function saveCategory() {
|
||||||
if (!form.name.trim()) {
|
const locales = payloadLocales(form.locales, languages.value)
|
||||||
ElMessage.warning('请填写剧单分类名称')
|
const missing = languages.value.find((code) => !locales[code])
|
||||||
|
if (!locales.zh || missing) {
|
||||||
|
ElMessage.warning(missing ? `请填写${languageLabel(missing)}名称` : '请填写中文名称')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
saving.value = true
|
saving.value = true
|
||||||
try {
|
try {
|
||||||
const payload = {
|
const payload = {
|
||||||
name: form.name.trim(),
|
name: locales.zh,
|
||||||
description: form.description.trim(),
|
locales,
|
||||||
|
descriptionLocales: payloadLocales(form.descriptionLocales, languages.value),
|
||||||
sort: form.sort,
|
sort: form.sort,
|
||||||
status: form.status
|
status: form.status
|
||||||
}
|
}
|
||||||
@@ -390,22 +426,25 @@ onMounted(loadCategories)
|
|||||||
<el-dialog
|
<el-dialog
|
||||||
v-model="dialogVisible"
|
v-model="dialogVisible"
|
||||||
:title="editingId ? '编辑剧单分类' : '新建剧单分类'"
|
:title="editingId ? '编辑剧单分类' : '新建剧单分类'"
|
||||||
width="460px"
|
width="640px"
|
||||||
>
|
>
|
||||||
<el-form label-position="top">
|
<el-form label-position="top">
|
||||||
<el-form-item label="分类名称" required>
|
<LocaleTextFields
|
||||||
<el-input v-model="form.name" maxlength="20" placeholder="例如:本周必看" />
|
:languages="languages"
|
||||||
</el-form-item>
|
:locales="form.locales"
|
||||||
<el-form-item label="描述">
|
label="名称"
|
||||||
<el-input
|
:maxlength="64"
|
||||||
v-model="form.description"
|
@update:languages="changeLanguages"
|
||||||
type="textarea"
|
/>
|
||||||
:rows="2"
|
<LocaleTextFields
|
||||||
maxlength="255"
|
:languages="languages"
|
||||||
show-word-limit
|
:locales="form.descriptionLocales"
|
||||||
placeholder="分类用途说明"
|
label="描述"
|
||||||
/>
|
:maxlength="255"
|
||||||
</el-form-item>
|
multiline
|
||||||
|
:show-languages="false"
|
||||||
|
:required="false"
|
||||||
|
/>
|
||||||
<div class="playlist-form-row">
|
<div class="playlist-form-row">
|
||||||
<el-form-item label="排序">
|
<el-form-item label="排序">
|
||||||
<el-input-number v-model="form.sort" :min="0" :max="999" />
|
<el-input-number v-model="form.sort" :min="0" :max="999" />
|
||||||
|
|||||||
@@ -0,0 +1,238 @@
|
|||||||
|
<!-- Author: fruit.com.cn -->
|
||||||
|
<!-- 标签管理:名称分中文、英文、印尼语。短剧编辑时单选一个标签。 -->
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { onMounted, reactive, ref } from 'vue'
|
||||||
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
|
import { AppIcons } from '@/constants/icons'
|
||||||
|
import {
|
||||||
|
languageCodes,
|
||||||
|
languageLabel,
|
||||||
|
localesFromColumns,
|
||||||
|
payloadLocales
|
||||||
|
} from '@/constants/contentLanguages'
|
||||||
|
import {
|
||||||
|
createContentTagApi,
|
||||||
|
deleteContentTagApi,
|
||||||
|
listContentTagsApi,
|
||||||
|
updateContentTagApi
|
||||||
|
} from '@/api/admin/contentTag'
|
||||||
|
import { useRbac } from '@/stores/rbac'
|
||||||
|
import LocaleTextFields from '@/views/components/LocaleTextFields.vue'
|
||||||
|
import PageHeading from '@/views/components/PageHeading.vue'
|
||||||
|
|
||||||
|
const { can } = useRbac()
|
||||||
|
|
||||||
|
const tags = ref([])
|
||||||
|
const loading = ref(false)
|
||||||
|
const saving = ref(false)
|
||||||
|
const dialogVisible = ref(false)
|
||||||
|
const editingId = ref(null)
|
||||||
|
const languages = ref(['zh'])
|
||||||
|
const DEFAULT_TAG_COLOR = '#E5484D'
|
||||||
|
const emptyForm = () => ({
|
||||||
|
locales: { zh: '' },
|
||||||
|
bgColor: DEFAULT_TAG_COLOR,
|
||||||
|
sort: 1,
|
||||||
|
status: 1
|
||||||
|
})
|
||||||
|
const form = reactive(emptyForm())
|
||||||
|
|
||||||
|
async function load() {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const res = await listContentTagsApi()
|
||||||
|
tags.value = res.data || []
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function nextSort() {
|
||||||
|
return tags.value.reduce((max, item) => Math.max(max, item.sort || 0), 0) + 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function openCreate() {
|
||||||
|
editingId.value = null
|
||||||
|
languages.value = ['zh']
|
||||||
|
Object.assign(form, emptyForm(), { sort: nextSort() })
|
||||||
|
dialogVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function openEdit(row) {
|
||||||
|
editingId.value = row.id
|
||||||
|
const locales = localesFromColumns(row.locales, row.name, row.nameEn, row.nameId)
|
||||||
|
languages.value = languageCodes(locales)
|
||||||
|
Object.assign(form, {
|
||||||
|
locales,
|
||||||
|
bgColor: row.bgColor || DEFAULT_TAG_COLOR,
|
||||||
|
sort: row.sort ?? 0,
|
||||||
|
status: row.status ?? 1
|
||||||
|
})
|
||||||
|
dialogVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
async function save() {
|
||||||
|
const locales = payloadLocales(form.locales, languages.value)
|
||||||
|
if (!locales.zh) {
|
||||||
|
ElMessage.warning('请填写中文名称')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const missing = languages.value.find((code) => !locales[code])
|
||||||
|
if (missing) {
|
||||||
|
ElMessage.warning(`请填写${languageLabel(missing)}名称`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
saving.value = true
|
||||||
|
try {
|
||||||
|
const payload = {
|
||||||
|
name: locales.zh,
|
||||||
|
locales,
|
||||||
|
bgColor: form.bgColor || DEFAULT_TAG_COLOR,
|
||||||
|
sort: form.sort,
|
||||||
|
status: form.status
|
||||||
|
}
|
||||||
|
if (editingId.value) {
|
||||||
|
await updateContentTagApi(editingId.value, payload)
|
||||||
|
ElMessage.success('标签已更新')
|
||||||
|
} else {
|
||||||
|
await createContentTagApi(payload)
|
||||||
|
ElMessage.success('标签已创建')
|
||||||
|
}
|
||||||
|
dialogVisible.value = false
|
||||||
|
await load()
|
||||||
|
} finally {
|
||||||
|
saving.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function confirmDelete(row) {
|
||||||
|
try {
|
||||||
|
await ElMessageBox.confirm(
|
||||||
|
`确定删除标签「${row.name}」吗?已选该标签的短剧会取消选择。`,
|
||||||
|
'删除确认',
|
||||||
|
{
|
||||||
|
confirmButtonText: '确认删除',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
confirmButtonClass: 'el-button--danger'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} catch {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
await deleteContentTagApi(row.id)
|
||||||
|
ElMessage.success('标签已删除')
|
||||||
|
await load()
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(load)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<PageHeading
|
||||||
|
eyebrow="内容管理"
|
||||||
|
title="标签管理"
|
||||||
|
description="维护短剧标签。名称分中文、英文、印尼语,短剧编辑时单选一个。"
|
||||||
|
>
|
||||||
|
<el-button v-if="can('drama:create')" type="primary" class="primary-button" @click="openCreate">
|
||||||
|
<AppIcon :icon="AppIcons.add" />
|
||||||
|
新建标签
|
||||||
|
</el-button>
|
||||||
|
</PageHeading>
|
||||||
|
|
||||||
|
<section class="panel">
|
||||||
|
<el-table
|
||||||
|
v-loading="loading"
|
||||||
|
:data="tags"
|
||||||
|
row-key="id"
|
||||||
|
border
|
||||||
|
class="drama-el-table"
|
||||||
|
empty-text="还没有标签"
|
||||||
|
>
|
||||||
|
<el-table-column type="index" label="序号" width="80" />
|
||||||
|
<el-table-column prop="name" label="中文名称" min-width="160" />
|
||||||
|
<el-table-column label="语言" min-width="220">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-tag
|
||||||
|
v-for="code in languageCodes(
|
||||||
|
row.locales || localesFromColumns(null, row.name, row.nameEn, row.nameId)
|
||||||
|
)"
|
||||||
|
:key="code"
|
||||||
|
effect="light"
|
||||||
|
class="locale-tag"
|
||||||
|
>{{ languageLabel(code) }}</el-tag
|
||||||
|
>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="背景色" width="100">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<span class="tag-color" :style="{ background: row.bgColor || DEFAULT_TAG_COLOR }"></span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="sort" label="排序" width="100" />
|
||||||
|
<el-table-column label="状态" width="110">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-tag :type="row.status === 1 ? 'success' : 'info'" effect="light">{{
|
||||||
|
row.status === 1 ? '启用' : '停用'
|
||||||
|
}}</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" width="200" fixed="right">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<div class="table-actions">
|
||||||
|
<el-button v-if="can('drama:update')" type="primary" size="small" @click="openEdit(row)"
|
||||||
|
>编辑</el-button
|
||||||
|
>
|
||||||
|
<el-button
|
||||||
|
v-if="can('drama:delete')"
|
||||||
|
type="danger"
|
||||||
|
size="small"
|
||||||
|
@click="confirmDelete(row)"
|
||||||
|
>删除</el-button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<el-dialog v-model="dialogVisible" :title="editingId ? '编辑标签' : '新建标签'" width="560px">
|
||||||
|
<el-form label-position="top">
|
||||||
|
<LocaleTextFields
|
||||||
|
v-model:languages="languages"
|
||||||
|
:locales="form.locales"
|
||||||
|
label="名称"
|
||||||
|
:maxlength="64"
|
||||||
|
/>
|
||||||
|
<el-form-item label="背景色">
|
||||||
|
<el-color-picker v-model="form.bgColor" color-format="hex" />
|
||||||
|
</el-form-item>
|
||||||
|
<div class="form-row">
|
||||||
|
<el-form-item label="排序">
|
||||||
|
<el-input-number v-model="form.sort" :min="0" :max="999" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="状态">
|
||||||
|
<el-switch v-model="form.status" :active-value="1" :inactive-value="0" />
|
||||||
|
</el-form-item>
|
||||||
|
</div>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="dialogVisible = false">取消</el-button>
|
||||||
|
<el-button type="primary" :loading="saving" @click="save">保存</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.locale-tag + .locale-tag {
|
||||||
|
margin-left: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-color {
|
||||||
|
display: inline-block;
|
||||||
|
width: 28px;
|
||||||
|
height: 16px;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in new issue
Block a user