Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e9a956f16c |
No files matched your search
+1
-4
@@ -7,9 +7,6 @@ dist-ssr
|
|||||||
*-lock.*
|
*-lock.*
|
||||||
pnpm-debug
|
pnpm-debug
|
||||||
stats.html
|
stats.html
|
||||||
*.apk
|
|
||||||
|
|
||||||
# 本机运行时产物(start-dev.bat / vite 日志)
|
|
||||||
start-dev.bat
|
|
||||||
dev.out.log
|
dev.out.log
|
||||||
dev.err.log
|
dev.err.log
|
||||||
|
start-dev.bat
|
||||||
@@ -1,9 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
. "$(dirname "$0")/_/husky.sh"
|
. "$(dirname "$0")/_/husky.sh"
|
||||||
|
|
||||||
if grep -qiE "(co-authored-by|generated with|assisted by).*(cursor|claude|codex|gpt|copilot|ai)" "$1"; then
|
|
||||||
echo "commit message contains AI attribution, remove it before committing" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
pnpm commitlint --edit "$1"
|
pnpm commitlint --edit "$1"
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
# 转码媒资 ID 前端精度修复
|
|
||||||
|
|
||||||
## 根因
|
|
||||||
|
|
||||||
聚合接口把 Snowflake 媒资 ID 以字符串返回,但面板使用
|
|
||||||
`Number(detail.mediaAssetId)`,超过 `2^53` 后发生精度丢失,手动转码请求了错误 ID。
|
|
||||||
|
|
||||||
## 修复
|
|
||||||
|
|
||||||
- 聚合响应中的 episodeId/mediaAssetId/taskId 类型改为字符串。
|
|
||||||
- 父面板不再 Number 归一化,媒体 ID 校验改为字符串 `/\d+/`。
|
|
||||||
- 手动转码、帧图分页 URL 原样传递字符串。
|
|
||||||
- mediaAssetId 为空时禁用重新转码并展示明确空态。
|
|
||||||
|
|
||||||
## 验证
|
|
||||||
|
|
||||||
- 超 2^53 ID 字符串保持逐位一致。
|
|
||||||
- `pnpm lint:eslint`、`pnpm build:dev`。
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
# 剧集转码面板组件拆分
|
|
||||||
|
|
||||||
## 目标
|
|
||||||
|
|
||||||
- 将 `EpisodeTranscodePanel.vue` 从 816 行降到 500 行以内。
|
|
||||||
- 状态轮询、分页请求与切集重置继续由父面板统一管理。
|
|
||||||
- UI 按职责拆为状态徽标、状态操作区、清晰度表格、帧图预览。
|
|
||||||
|
|
||||||
## 组件
|
|
||||||
|
|
||||||
1. `EpisodeTranscodeStatusBadge.vue`:折叠标题中的状态与进度。
|
|
||||||
2. `EpisodeTranscodeStatusPanel.vue`:状态、进度、重试次数、错误与重转按钮。
|
|
||||||
3. `EpisodeTranscodeRenditions.vue`:清晰度表格、复制地址、新窗口打开。
|
|
||||||
4. `EpisodeTranscodeFrames.vue`:逐帧网格、雪碧图、分页与放大预览。
|
|
||||||
|
|
||||||
公共状态映射与格式化放入 `episodeTranscodeUi.ts`。
|
|
||||||
|
|
||||||
## 风险
|
|
||||||
|
|
||||||
- 父组件仍负责全部接口、轮询、请求序号和分页状态,子组件只通过 props/emits 交互。
|
|
||||||
- 不新增依赖、不改接口和 locales 文案。
|
|
||||||
|
|
||||||
## 验证
|
|
||||||
|
|
||||||
- `wc -l` 确认所有相关文件不超过 500 行。
|
|
||||||
- `pnpm lint:eslint`、`pnpm build:dev`。
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
# 后台转码设置页面
|
|
||||||
|
|
||||||
## 目标
|
|
||||||
|
|
||||||
1. 在内容管理下新增「转码设置」页面,权限沿用 `episode:upload`。
|
|
||||||
2. 页面字段与 FruitServer `MediaTranscodeProfile` 完全一致。
|
|
||||||
3. 对接 `GET/PUT /admin/media/transcode-profile`,保存后回填服务端响应。
|
|
||||||
4. 前端校验规则与后端一致,并在失败时定位到首个错误字段。
|
|
||||||
|
|
||||||
## 方案
|
|
||||||
|
|
||||||
- API:在 `src/api/admin/media.ts` 增加读取、保存函数,类型定义放
|
|
||||||
`src/api/admin/types.ts`;响应继续遵循现有 `Result {code,message,data}`。
|
|
||||||
- 路由:静态路由表增加 `/content/media-transcode`;默认服务端动态路由模式下,
|
|
||||||
根据 `episode:upload` 权限把同一条本地路由补充进服务端 `/content` 菜单,
|
|
||||||
已存在同名菜单时不重复添加,仅统一 i18n 标题。
|
|
||||||
- 页面:`views/systemManagement/TranscodeSettingsView.vue`,使用 Element Plus 表单、
|
|
||||||
表格、数字输入和开关;保存按钮受 `episode:upload` 控制。
|
|
||||||
- 校验:
|
|
||||||
- quality 非空且忽略首尾空格后唯一;
|
|
||||||
- width/height 为正偶数;
|
|
||||||
- videoBitrateKbps/audioBitrateKbps 为正整数;
|
|
||||||
- segmentSeconds 2–10;
|
|
||||||
- sprite.intervalSeconds 1–10、columns 5–20、thumbWidth 120–240;
|
|
||||||
- ladder 至少一档 enabled。
|
|
||||||
- 校验失败由 Element Plus 定位到首个错误 prop,动态列表错误会定位到对应行。
|
|
||||||
- 所有可见文案、提示和校验信息进入 `zh-CN.ts` / `en.ts`。
|
|
||||||
|
|
||||||
## 非目标
|
|
||||||
|
|
||||||
- 不修改 FruitServer、ReelShort 或接口契约。
|
|
||||||
- 不新增权限码、不新增依赖、不启动服务。
|
|
||||||
|
|
||||||
## 测试与门禁
|
|
||||||
|
|
||||||
- 当前工程没有单元/组件测试框架,不引入新依赖;使用 TS 类型检查和构建门禁。
|
|
||||||
- `pnpm lint:eslint`
|
|
||||||
- `pnpm ts:check`
|
|
||||||
- `pnpm build:dev`
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
# 转码面板实时进度与更新时间
|
|
||||||
|
|
||||||
## 目标
|
|
||||||
|
|
||||||
- 展示后端 task progress、状态文案与 updatedAt。
|
|
||||||
- RUNNING/QUEUED 且 progress=0 时显示“处理中(等待进度上报)”。
|
|
||||||
- FAILED 保持错误信息与重新转码入口。
|
|
||||||
- 保持现有轮询停止、关闭清理与字符串 ID 逻辑。
|
|
||||||
|
|
||||||
## 验证
|
|
||||||
|
|
||||||
- `pnpm lint:eslint`、`pnpm build:dev`。
|
|
||||||
@@ -1,189 +0,0 @@
|
|||||||
## 2026-10-22 后台转码设置页面
|
|
||||||
|
|
||||||
### 开工确认与计划
|
|
||||||
|
|
||||||
- 仓库:ReelShortWeb
|
|
||||||
- 基线:`develop` / `origin/develop` = `723d056`
|
|
||||||
- 工作区:开工前干净
|
|
||||||
- 分支:`feature/transcode-profile-settings`
|
|
||||||
- 计划:`docs/plans/2026-10-22-transcode-profile-settings.md`
|
|
||||||
|
|
||||||
```text
|
|
||||||
$ git status --short --branch && git rev-parse --short HEAD
|
|
||||||
## develop...origin/develop
|
|
||||||
723d056
|
|
||||||
```
|
|
||||||
|
|
||||||
解读:基于指定 develop 基线创建隔离工作树。后端契约已确认字段为
|
|
||||||
`enabled / segmentSeconds / ladder / sprite`,权限为 `episode:upload`。
|
|
||||||
默认服务端动态菜单只读取 `sys_menu`,本单按“只改 Web”约束在不改后端的前提下,
|
|
||||||
对具备 `episode:upload` 的账号补充本地受控菜单,后端接口仍执行最终鉴权。
|
|
||||||
|
|
||||||
### 实现与门禁
|
|
||||||
|
|
||||||
- 新增 `/content/media-transcode` 静态路由和服务端动态菜单补充;
|
|
||||||
菜单标题走 `router.transcodeSettings`,只在账号具备 `episode:upload` 时加入。
|
|
||||||
- 新增转码设置页面,字段严格为 `enabled / segmentSeconds / ladder / sprite`;
|
|
||||||
支持档位增删、动态行校验、首个错误字段定位及服务端返回值回填。
|
|
||||||
- API 使用现有 axios Result 包装,GET 初始化、PUT 保存;成功/失败/校验提示全部走中英 i18n。
|
|
||||||
- 当前工程没有单元/组件测试框架,未新增依赖;使用 ESLint、TypeScript 与构建门禁。
|
|
||||||
|
|
||||||
```text
|
|
||||||
$ pnpm lint:eslint
|
|
||||||
> fruitshorts-admin@1.0.0 lint:eslint /private/tmp/reelshortweb-transcode-settings
|
|
||||||
> eslint --fix --ext .js,.ts,.vue ./src
|
|
||||||
|
|
||||||
$ pnpm ts:check
|
|
||||||
> fruitshorts-admin@1.0.0 ts:check /private/tmp/reelshortweb-transcode-settings
|
|
||||||
> pnpm vue-tsc --noEmit --skipLibCheck
|
|
||||||
```
|
|
||||||
|
|
||||||
解读:ESLint 零告警,TypeScript 类型检查通过。
|
|
||||||
|
|
||||||
```text
|
|
||||||
$ pnpm build:dev
|
|
||||||
> fruitshorts-admin@1.0.0 build:dev /private/tmp/reelshortweb-transcode-settings
|
|
||||||
> VITE_CJS_IGNORE_WARNING=1 vite build --mode dev
|
|
||||||
|
|
||||||
WARN Circular chunk: element-plus -> vue-chunks -> element-plus. Please adjust the manual chunk logic for these chunks.
|
|
||||||
|
|
||||||
Build successful. Please see dist-dev directory
|
|
||||||
```
|
|
||||||
|
|
||||||
解读:开发构建成功;circular chunk 为仓库既有 Element Plus 分包警告,本次未改构建配置。
|
|
||||||
|
|
||||||
## 2026-10-22 剧集转码面板组件拆分
|
|
||||||
|
|
||||||
- 分支:`feature/transcode-panel-split`
|
|
||||||
- 基线:`develop` / `origin/develop` = `52b10d3`
|
|
||||||
- 计划:`docs/plans/2026-10-22-transcode-panel-split.md`
|
|
||||||
|
|
||||||
已读取 `AGENTS.md` 与 `CODING_STANDARDS.md`。当前
|
|
||||||
`EpisodeTranscodePanel.vue` 为 816 行,超过单文件 500 行红线。
|
|
||||||
拆分将保持父组件的数据获取、轮询清理、分页请求与切集重置逻辑不变。
|
|
||||||
|
|
||||||
### 拆分结果
|
|
||||||
|
|
||||||
```text
|
|
||||||
$ wc -l src/views/contentManagement/upload/EpisodeTranscodePanel.vue \
|
|
||||||
src/views/contentManagement/upload/EpisodeTranscodeStatusBadge.vue \
|
|
||||||
src/views/contentManagement/upload/EpisodeTranscodeStatusPanel.vue \
|
|
||||||
src/views/contentManagement/upload/EpisodeTranscodeRenditions.vue \
|
|
||||||
src/views/contentManagement/upload/EpisodeTranscodeFrames.vue \
|
|
||||||
src/views/contentManagement/upload/episodeTranscodeUi.ts
|
|
||||||
266 EpisodeTranscodePanel.vue
|
|
||||||
45 EpisodeTranscodeStatusBadge.vue
|
|
||||||
155 EpisodeTranscodeStatusPanel.vue
|
|
||||||
119 EpisodeTranscodeRenditions.vue
|
|
||||||
315 EpisodeTranscodeFrames.vue
|
|
||||||
93 episodeTranscodeUi.ts
|
|
||||||
```
|
|
||||||
|
|
||||||
解读:父面板只保留接口调用、轮询、请求序号、分页状态与组件组合;
|
|
||||||
状态、清晰度、帧图分别独立,全部文件均低于 500 行。
|
|
||||||
|
|
||||||
### 门禁
|
|
||||||
|
|
||||||
```text
|
|
||||||
$ pnpm ts:check
|
|
||||||
> vue-tsc --noEmit --skipLibCheck
|
|
||||||
(通过)
|
|
||||||
|
|
||||||
$ pnpm lint:eslint
|
|
||||||
> eslint --fix --ext .js,.ts,.vue ./src
|
|
||||||
(0 error / 0 warning)
|
|
||||||
|
|
||||||
$ pnpm build:dev
|
|
||||||
WARN Circular chunk: element-plus -> vue-chunks -> element-plus.
|
|
||||||
Build successful. Please see dist-dev directory
|
|
||||||
```
|
|
||||||
|
|
||||||
解读:组件 props/emits、类型检查、ESLint 和开发构建全部通过;
|
|
||||||
循环 chunk 为项目既有警告。轮询启停、接口路径、分页参数和 locales 文案未改变。
|
|
||||||
|
|
||||||
## 2026-10-22 转码媒资 ID 前端精度修复
|
|
||||||
|
|
||||||
- 分支:`feature/transcode-media-id-fix-ui`
|
|
||||||
- 基线:`develop` / `origin/develop` = `a4893c3`
|
|
||||||
|
|
||||||
已复现 `Number('2113150398670966786')` 变为 `2113150398670966800`。
|
|
||||||
本次将媒资、任务 id 全链路按字符串处理,禁止 Number 转换;没有媒资时
|
|
||||||
禁用重新转码并显示空态。
|
|
||||||
|
|
||||||
```text
|
|
||||||
$ node -e "const id='2113150398670966786'; console.log(String(Number(id)))"
|
|
||||||
2113150398670966800
|
|
||||||
```
|
|
||||||
|
|
||||||
解读:Snowflake id 超过 JS 安全整数,字符串化后的 Number 已失真。
|
|
||||||
|
|
||||||
### 实现
|
|
||||||
|
|
||||||
- `EpisodeTranscodeItem` 的 episodeId/mediaAssetId/taskId,以及 rendition/thumbnail
|
|
||||||
相关 id 类型改为字符串。
|
|
||||||
- 父面板使用 `detail.mediaAssetId` 原始字符串和正则校验,不再 Number 转换。
|
|
||||||
- 手动转码与帧图分页接口原样传递字符串 id。
|
|
||||||
- `mediaAssetId` 为空时按钮保持禁用,空态优先展示后端 errorMsg 原因。
|
|
||||||
|
|
||||||
静态检查确认:
|
|
||||||
|
|
||||||
```text
|
|
||||||
$ rg -n "Number\([^\n]*mediaAssetId|mediaAssetId[^\n]*Number\(" \
|
|
||||||
src/views/contentManagement/upload src/api/admin
|
|
||||||
(无匹配)
|
|
||||||
```
|
|
||||||
|
|
||||||
### 门禁
|
|
||||||
|
|
||||||
```text
|
|
||||||
$ pnpm lint:eslint
|
|
||||||
> eslint --fix --ext .js,.ts,.vue ./src
|
|
||||||
(0 error / 0 warning)
|
|
||||||
|
|
||||||
$ pnpm ts:check
|
|
||||||
> vue-tsc --noEmit --skipLibCheck
|
|
||||||
(通过)
|
|
||||||
|
|
||||||
$ pnpm build:dev
|
|
||||||
WARN Circular chunk: element-plus -> vue-chunks -> element-plus.
|
|
||||||
Build successful. Please see dist-dev directory
|
|
||||||
```
|
|
||||||
|
|
||||||
解读:字符串 id 链路、类型检查、ESLint 与开发构建均通过;
|
|
||||||
循环 chunk 为项目既有警告。
|
|
||||||
|
|
||||||
## 2026-10-22 转码面板实时进度与更新时间
|
|
||||||
|
|
||||||
- 分支:`feature/transcode-progress-ui`
|
|
||||||
- 基线:`develop` / `origin/develop` = `0d5d0d8`
|
|
||||||
- 计划:`docs/plans/2026-10-22-transcode-progress-ui.md`
|
|
||||||
|
|
||||||
后端将补充 task.updatedAt;前端在现有轮询面板中展示进度、状态、
|
|
||||||
最近更新时间,并在 RUNNING/QUEUED progress=0 时显示等待进度上报提示。
|
|
||||||
|
|
||||||
### 实现
|
|
||||||
|
|
||||||
- `EpisodeTranscodeItem` 增加 `updatedAt`。
|
|
||||||
- 状态区展示“最近更新”,格式沿用 `formatDateTime`。
|
|
||||||
- RUNNING/QUEUED 且 progress=0 时显示“处理中(等待进度上报)”。
|
|
||||||
- SUCCESS/FAILED 继续停止轮询;关闭面板继续清理定时器。
|
|
||||||
- 所有 id 保持字符串传递,不引入 Number 转换。
|
|
||||||
|
|
||||||
### 门禁
|
|
||||||
|
|
||||||
```text
|
|
||||||
$ pnpm lint:eslint
|
|
||||||
> eslint --fix --ext .js,.ts,.vue ./src
|
|
||||||
(0 error / 0 warning)
|
|
||||||
|
|
||||||
$ pnpm ts:check
|
|
||||||
> vue-tsc --noEmit --skipLibCheck
|
|
||||||
(通过)
|
|
||||||
|
|
||||||
$ pnpm build:dev
|
|
||||||
WARN Circular chunk: element-plus -> vue-chunks -> element-plus.
|
|
||||||
Build successful. Please see dist-dev directory
|
|
||||||
```
|
|
||||||
|
|
||||||
解读:进度与更新时间类型、ESLint、TypeScript 和开发构建全部通过;
|
|
||||||
循环 chunk 为项目既有警告。
|
|
||||||
+1
-2
@@ -6,7 +6,7 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"i": "pnpm install",
|
"i": "pnpm install",
|
||||||
"dev": "vite --mode base",
|
"dev": "VITE_CJS_IGNORE_WARNING=1 vite --mode base",
|
||||||
"ts:check": "pnpm vue-tsc --noEmit --skipLibCheck",
|
"ts:check": "pnpm vue-tsc --noEmit --skipLibCheck",
|
||||||
"build:pro": "VITE_CJS_IGNORE_WARNING=1 vite build --mode pro",
|
"build:pro": "VITE_CJS_IGNORE_WARNING=1 vite build --mode pro",
|
||||||
"build:dev": "VITE_CJS_IGNORE_WARNING=1 vite build --mode dev",
|
"build:dev": "VITE_CJS_IGNORE_WARNING=1 vite build --mode dev",
|
||||||
@@ -38,7 +38,6 @@
|
|||||||
"echarts": "^5.4.3",
|
"echarts": "^5.4.3",
|
||||||
"echarts-wordcloud": "^2.1.0",
|
"echarts-wordcloud": "^2.1.0",
|
||||||
"element-plus": "2.5.5",
|
"element-plus": "2.5.5",
|
||||||
"hls.js": "^1.7.3",
|
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"mitt": "^3.0.1",
|
"mitt": "^3.0.1",
|
||||||
"nprogress": "^0.2.0",
|
"nprogress": "^0.2.0",
|
||||||
|
|||||||
-12
@@ -22,7 +22,6 @@ appStore.initTheme()
|
|||||||
<template>
|
<template>
|
||||||
<ConfigGlobal :size="currentSize">
|
<ConfigGlobal :size="currentSize">
|
||||||
<RouterView :class="greyMode ? `${prefixCls}-grey-mode` : ''" />
|
<RouterView :class="greyMode ? `${prefixCls}-grey-mode` : ''" />
|
||||||
<footer class="app-copyright">© FruitShorts</footer>
|
|
||||||
</ConfigGlobal>
|
</ConfigGlobal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -49,15 +48,4 @@ body {
|
|||||||
.@{prefix-cls}-grey-mode {
|
.@{prefix-cls}-grey-mode {
|
||||||
filter: grayscale(100%);
|
filter: grayscale(100%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.app-copyright {
|
|
||||||
position: fixed;
|
|
||||||
right: 20px;
|
|
||||||
bottom: 10px;
|
|
||||||
z-index: 5;
|
|
||||||
font-size: 12px;
|
|
||||||
line-height: 1;
|
|
||||||
color: var(--el-text-color-secondary, #909399);
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
@@ -11,24 +11,6 @@ export interface AppUserPageParams {
|
|||||||
status?: string
|
status?: string
|
||||||
countryCode?: string
|
countryCode?: string
|
||||||
registerSource?: string
|
registerSource?: string
|
||||||
/** 客户端平台:ANDROID / IOS / WEB */
|
|
||||||
platform?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface WatchHistoryPageParams {
|
|
||||||
pageIndex?: number
|
|
||||||
pageSize?: number
|
|
||||||
keyword?: string
|
|
||||||
userId?: number
|
|
||||||
dramaTitle?: string
|
|
||||||
dramaId?: number
|
|
||||||
episodeId?: number
|
|
||||||
/** 客户端平台:ANDROID / IOS / WEB */
|
|
||||||
platform?: string
|
|
||||||
source?: string
|
|
||||||
finished?: boolean
|
|
||||||
startTime?: string
|
|
||||||
endTime?: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const pageAppUsersApi = (params: AppUserPageParams) => {
|
export const pageAppUsersApi = (params: AppUserPageParams) => {
|
||||||
@@ -50,13 +32,6 @@ export const listAppUserWatchHistoryApi = (id: number, limit = 50) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const pageWatchHistoryApi = (params: WatchHistoryPageParams) => {
|
|
||||||
return request.get<PageResult<WatchHistoryItem>>({
|
|
||||||
url: '/admin/watch-history/page',
|
|
||||||
params
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/** normal / limited / banned,封禁与限制会立即吊销该用户全部会话 */
|
/** normal / limited / banned,封禁与限制会立即吊销该用户全部会话 */
|
||||||
export const updateAppUserStatusApi = (id: number, status: string, reason?: string) => {
|
export const updateAppUserStatusApi = (id: number, status: string, reason?: string) => {
|
||||||
return request.put<void>({
|
return request.put<void>({
|
||||||
|
|||||||
@@ -1,69 +0,0 @@
|
|||||||
// Author: fruit.com.cn
|
|
||||||
|
|
||||||
import request from '@/axios'
|
|
||||||
|
|
||||||
export interface AppVersionItem {
|
|
||||||
id: string
|
|
||||||
platform: 'ANDROID' | 'IOS'
|
|
||||||
platformText: string
|
|
||||||
versionCode: number
|
|
||||||
versionName: string
|
|
||||||
downloadUrl: string
|
|
||||||
updateContent?: string
|
|
||||||
forceUpdate: number
|
|
||||||
minSupportedCode: number
|
|
||||||
status: number
|
|
||||||
statusText: string
|
|
||||||
releasedAt?: string
|
|
||||||
createdAt?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AppVersionSaveData {
|
|
||||||
platform: 'ANDROID' | 'IOS'
|
|
||||||
versionCode: number
|
|
||||||
versionName: string
|
|
||||||
downloadUrl: string
|
|
||||||
updateContent?: string
|
|
||||||
forceUpdate?: 0 | 1
|
|
||||||
minSupportedCode?: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export const listAppVersionsApi = (params: {
|
|
||||||
pageIndex?: number
|
|
||||||
pageSize?: number
|
|
||||||
platform?: string
|
|
||||||
status?: number
|
|
||||||
keyword?: string
|
|
||||||
}) => {
|
|
||||||
return request.get<{ total: number; list: AppVersionItem[] }>({
|
|
||||||
url: '/admin/app-versions/page',
|
|
||||||
params
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const getAppVersionApi = (id: string | number) => {
|
|
||||||
return request.get<AppVersionItem>({ url: `/admin/app-versions/${id}` })
|
|
||||||
}
|
|
||||||
|
|
||||||
export const createAppVersionApi = (data: AppVersionSaveData) => {
|
|
||||||
return request.post<string>({ url: '/admin/app-versions', data })
|
|
||||||
}
|
|
||||||
|
|
||||||
export const batchCreateAppVersionsApi = (data: AppVersionSaveData[]) => {
|
|
||||||
return request.post<string[]>({ url: '/admin/app-versions/batch', data })
|
|
||||||
}
|
|
||||||
|
|
||||||
export const updateAppVersionApi = (id: string | number, data: AppVersionSaveData) => {
|
|
||||||
return request.post<void>({ url: `/admin/app-versions/${id}`, data })
|
|
||||||
}
|
|
||||||
|
|
||||||
export const updateAppVersionStatusApi = (id: string | number, status: 0 | 1) => {
|
|
||||||
return request.post<void>({
|
|
||||||
url: `/admin/app-versions/${id}/status`,
|
|
||||||
params: { status }
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const deleteAppVersionApi = (id: string | number) => {
|
|
||||||
return request.delete<void>({ url: `/admin/app-versions/${id}` })
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
// 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}` })
|
|
||||||
}
|
|
||||||
@@ -27,28 +27,6 @@ export interface TranscodeBoard {
|
|||||||
notes: string[]
|
notes: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 近 7 天每日趋势(给折线图用)。 */
|
|
||||||
export interface DashboardTrend {
|
|
||||||
dates: string[]
|
|
||||||
newUsers: number[]
|
|
||||||
playEvents: number[]
|
|
||||||
newTranscodes: number[]
|
|
||||||
transcodeSuccess: number[]
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 分布项(给饼图用)。 */
|
|
||||||
export interface DistributionItem {
|
|
||||||
label: string
|
|
||||||
value: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface DashboardDistribution {
|
|
||||||
dramaStatus: Record<string, number>
|
|
||||||
transcodeStatus: Record<string, number>
|
|
||||||
episodeMedia: Record<string, number>
|
|
||||||
pendingModeration: DistributionItem[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export const getDashboardOverviewApi = () => {
|
export const getDashboardOverviewApi = () => {
|
||||||
return request.get<DashboardOverview>({ url: '/admin/dashboard/overview' })
|
return request.get<DashboardOverview>({ url: '/admin/dashboard/overview' })
|
||||||
}
|
}
|
||||||
@@ -56,11 +34,3 @@ export const getDashboardOverviewApi = () => {
|
|||||||
export const getTranscodeBoardApi = () => {
|
export const getTranscodeBoardApi = () => {
|
||||||
return request.get<TranscodeBoard>({ url: '/admin/dashboard/transcode' })
|
return request.get<TranscodeBoard>({ url: '/admin/dashboard/transcode' })
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getDashboardTrendApi = () => {
|
|
||||||
return request.get<DashboardTrend>({ url: '/admin/dashboard/trend' })
|
|
||||||
}
|
|
||||||
|
|
||||||
export const getDashboardDistributionApi = () => {
|
|
||||||
return request.get<DashboardDistribution>({ url: '/admin/dashboard/distribution' })
|
|
||||||
}
|
|
||||||
@@ -15,9 +15,7 @@ export interface DramaPageParams {
|
|||||||
keyword?: string
|
keyword?: string
|
||||||
status?: string
|
status?: string
|
||||||
categoryId?: number
|
categoryId?: number
|
||||||
categoryIds?: number[]
|
|
||||||
isHot?: boolean
|
isHot?: boolean
|
||||||
dramaTypes?: Array<'ANIME' | 'LIVE'>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const pageDramasApi = (params: DramaPageParams) => {
|
export const pageDramasApi = (params: DramaPageParams) => {
|
||||||
@@ -52,7 +50,6 @@ 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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,89 +0,0 @@
|
|||||||
// Author: fruit.com.cn
|
|
||||||
|
|
||||||
import request from '@/axios'
|
|
||||||
import type { PageResult } from './types'
|
|
||||||
|
|
||||||
export interface DramaClassificationItem {
|
|
||||||
id: number
|
|
||||||
name: string
|
|
||||||
nameEn: string
|
|
||||||
nameId: string
|
|
||||||
locales?: Record<string, string>
|
|
||||||
sort: number
|
|
||||||
status: number
|
|
||||||
dramaCount: number
|
|
||||||
updatedAt?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface DramaClassificationSaveData {
|
|
||||||
name: string
|
|
||||||
locales: Record<string, string>
|
|
||||||
sort?: number
|
|
||||||
status?: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ClassificationDramaItem {
|
|
||||||
id: number
|
|
||||||
title: string
|
|
||||||
cover: string
|
|
||||||
status: string
|
|
||||||
totalEpisodes: number
|
|
||||||
sort: number
|
|
||||||
updatedAt: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ClassificationDramaPageParams {
|
|
||||||
keyword?: string
|
|
||||||
pageIndex?: number
|
|
||||||
pageSize?: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export const listClassificationsApi = () => {
|
|
||||||
return request.get<DramaClassificationItem[]>({ url: '/admin/drama-classifications' })
|
|
||||||
}
|
|
||||||
|
|
||||||
export const createClassificationApi = (data: DramaClassificationSaveData) => {
|
|
||||||
return request.post<number>({ url: '/admin/drama-classifications', data })
|
|
||||||
}
|
|
||||||
|
|
||||||
export const updateClassificationApi = (id: number, data: DramaClassificationSaveData) => {
|
|
||||||
return request.put<void>({ url: `/admin/drama-classifications/${id}`, data })
|
|
||||||
}
|
|
||||||
|
|
||||||
export const deleteClassificationApi = (id: number) => {
|
|
||||||
return request.delete<void>({ url: `/admin/drama-classifications/${id}` })
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 分类下已关联的短剧 */
|
|
||||||
export const listClassificationDramasApi = (id: number, params: ClassificationDramaPageParams) => {
|
|
||||||
return request.get<PageResult<ClassificationDramaItem>>({
|
|
||||||
url: `/admin/drama-classifications/${id}/dramas`,
|
|
||||||
params
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 尚未关联到该分类的短剧(添加弹窗用) */
|
|
||||||
export const listClassificationDramaCandidatesApi = (
|
|
||||||
id: number,
|
|
||||||
params: ClassificationDramaPageParams
|
|
||||||
) => {
|
|
||||||
return request.get<PageResult<ClassificationDramaItem>>({
|
|
||||||
url: `/admin/drama-classifications/${id}/dramas/candidates`,
|
|
||||||
params
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 批量关联短剧,返回实际新增数量 */
|
|
||||||
export const bindClassificationDramasApi = (id: number, dramaIds: number[]) => {
|
|
||||||
return request.post<number>({
|
|
||||||
url: `/admin/drama-classifications/${id}/dramas`,
|
|
||||||
data: { dramaIds }
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 从分类移除短剧 */
|
|
||||||
export const unbindClassificationDramaApi = (id: number, dramaId: number) => {
|
|
||||||
return request.delete<void>({
|
|
||||||
url: `/admin/drama-classifications/${id}/dramas/${dramaId}`
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
// Author: fruit.com.cn
|
|
||||||
|
|
||||||
import request from '@/axios'
|
|
||||||
import type { PageResult } from './types'
|
|
||||||
import type { ClassificationDramaItem } from './dramaClassification'
|
|
||||||
|
|
||||||
export interface DramaPlaylistCategoryItem {
|
|
||||||
id: number
|
|
||||||
name: string
|
|
||||||
nameEn: string
|
|
||||||
nameId: string
|
|
||||||
description: string
|
|
||||||
descriptionEn: string
|
|
||||||
descriptionId: string
|
|
||||||
locales?: Record<string, string>
|
|
||||||
descriptionLocales?: Record<string, string>
|
|
||||||
sort: number
|
|
||||||
status: number
|
|
||||||
dramaCount: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface DramaPlaylistCategorySaveData {
|
|
||||||
name: string
|
|
||||||
locales: Record<string, string>
|
|
||||||
descriptionLocales?: Record<string, string>
|
|
||||||
sort?: number
|
|
||||||
status?: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface PlaylistCategoryDramaPageParams {
|
|
||||||
keyword?: string
|
|
||||||
pageIndex?: number
|
|
||||||
pageSize?: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export const listPlaylistCategoriesApi = () => {
|
|
||||||
return request.get<DramaPlaylistCategoryItem[]>({ url: '/admin/drama-playlist-categories' })
|
|
||||||
}
|
|
||||||
|
|
||||||
export const createPlaylistCategoryApi = (data: DramaPlaylistCategorySaveData) => {
|
|
||||||
return request.post<number>({ url: '/admin/drama-playlist-categories', data })
|
|
||||||
}
|
|
||||||
|
|
||||||
export const updatePlaylistCategoryApi = (id: number, data: DramaPlaylistCategorySaveData) => {
|
|
||||||
return request.put<void>({ url: `/admin/drama-playlist-categories/${id}`, data })
|
|
||||||
}
|
|
||||||
|
|
||||||
export const deletePlaylistCategoryApi = (id: number) => {
|
|
||||||
return request.delete<void>({ url: `/admin/drama-playlist-categories/${id}` })
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 分类下已关联的短剧 */
|
|
||||||
export const listPlaylistCategoryDramasApi = (
|
|
||||||
id: number,
|
|
||||||
params: PlaylistCategoryDramaPageParams
|
|
||||||
) => {
|
|
||||||
return request.get<PageResult<ClassificationDramaItem>>({
|
|
||||||
url: `/admin/drama-playlist-categories/${id}/dramas`,
|
|
||||||
params
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 尚未关联到该分类的短剧(选择弹窗用) */
|
|
||||||
export const listPlaylistCategoryDramaCandidatesApi = (
|
|
||||||
id: number,
|
|
||||||
params: PlaylistCategoryDramaPageParams
|
|
||||||
) => {
|
|
||||||
return request.get<PageResult<ClassificationDramaItem>>({
|
|
||||||
url: `/admin/drama-playlist-categories/${id}/dramas/candidates`,
|
|
||||||
params
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 批量关联短剧,返回实际新增数量 */
|
|
||||||
export const bindPlaylistCategoryDramasApi = (id: number, dramaIds: number[]) => {
|
|
||||||
return request.post<number>({
|
|
||||||
url: `/admin/drama-playlist-categories/${id}/dramas`,
|
|
||||||
data: { dramaIds }
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 从分类移除短剧 */
|
|
||||||
export const unbindPlaylistCategoryDramaApi = (id: number, dramaId: number) => {
|
|
||||||
return request.delete<void>({
|
|
||||||
url: `/admin/drama-playlist-categories/${id}/dramas/${dramaId}`
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
// Author: fruit.com.cn
|
|
||||||
|
|
||||||
import request from '@/axios'
|
|
||||||
import type { PageResult } from './types'
|
|
||||||
|
|
||||||
/** 收藏与点赞只读分页筛选条件。 */
|
|
||||||
export interface EngagementPageParams {
|
|
||||||
pageIndex?: number
|
|
||||||
pageSize?: number
|
|
||||||
keyword?: string
|
|
||||||
userId?: string | number
|
|
||||||
deviceId?: string
|
|
||||||
/** 客户端平台:ANDROID / IOS / WEB */
|
|
||||||
platform?: string
|
|
||||||
dramaId?: string | number
|
|
||||||
dramaTitle?: string
|
|
||||||
targetType?: string
|
|
||||||
targetId?: string | number
|
|
||||||
episodeId?: string | number
|
|
||||||
startTime?: string
|
|
||||||
endTime?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 后台互动列表行。 */
|
|
||||||
export interface EngagementItem {
|
|
||||||
id: string
|
|
||||||
userId: string | null
|
|
||||||
uid: string | null
|
|
||||||
nickname: string | null
|
|
||||||
deviceId: string | null
|
|
||||||
/** 客户端平台 ANDROID / IOS / WEB;老客户端未上报时为空。 */
|
|
||||||
platform: string | null
|
|
||||||
anonymous: boolean
|
|
||||||
dramaId: string | null
|
|
||||||
dramaTitle: string | null
|
|
||||||
dramaCover: string | null
|
|
||||||
dramaStatus: string | null
|
|
||||||
dramaPublished: boolean | null
|
|
||||||
targetType: string
|
|
||||||
targetId: string
|
|
||||||
episodeId: string | null
|
|
||||||
episodeNo: number | null
|
|
||||||
episodeTitle: string | null
|
|
||||||
commentSummary: string | null
|
|
||||||
createdAt: string
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 查询收藏分页。 */
|
|
||||||
export const pageFavoritesApi = (params: EngagementPageParams) =>
|
|
||||||
request.get<PageResult<EngagementItem>>({ url: '/admin/favorites/page', params })
|
|
||||||
|
|
||||||
/** 查询点赞分页。 */
|
|
||||||
export const pageLikesApi = (params: EngagementPageParams) =>
|
|
||||||
request.get<PageResult<EngagementItem>>({ url: '/admin/likes/page', params })
|
|
||||||
@@ -1,35 +1,10 @@
|
|||||||
// Author: fruit.com.cn
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
import request from '@/axios'
|
import request from '@/axios'
|
||||||
import type { EpisodeItem, EpisodeSaveData, PageResult } from './types'
|
import type { EpisodeItem, EpisodeSaveData } from './types'
|
||||||
|
|
||||||
export interface EpisodePageParams {
|
export const listEpisodesApi = (dramaId: number, status?: string) => {
|
||||||
dramaId: number | string
|
return request.get<EpisodeItem[]>({ url: '/admin/episodes', params: { dramaId, status } })
|
||||||
status?: string
|
|
||||||
pageIndex?: number
|
|
||||||
pageSize?: number
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 解包剧集列表分页。
|
|
||||||
* 契约(OpenAPI PageResultEpisodeRespVO):data = { total, list }。
|
|
||||||
* 兼容误把 data 当数组的旧调用,避免列表空白。
|
|
||||||
*/
|
|
||||||
export function parseEpisodePage(payload: unknown): PageResult<EpisodeItem> {
|
|
||||||
if (Array.isArray(payload)) {
|
|
||||||
return { total: payload.length, list: payload as EpisodeItem[] }
|
|
||||||
}
|
|
||||||
if (payload && typeof payload === 'object') {
|
|
||||||
const page = payload as { total?: unknown; list?: unknown }
|
|
||||||
const list = Array.isArray(page.list) ? (page.list as EpisodeItem[]) : []
|
|
||||||
const total = Number(page.total)
|
|
||||||
return { total: Number.isFinite(total) ? total : list.length, list }
|
|
||||||
}
|
|
||||||
return { total: 0, list: [] }
|
|
||||||
}
|
|
||||||
|
|
||||||
export const listEpisodesApi = (params: EpisodePageParams) => {
|
|
||||||
return request.get<PageResult<EpisodeItem>>({ url: '/admin/episodes', params })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createEpisodeApi = (data: EpisodeSaveData) => {
|
export const createEpisodeApi = (data: EpisodeSaveData) => {
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
// Author: fruit.com.cn
|
|
||||||
|
|
||||||
import request from '@/axios'
|
|
||||||
|
|
||||||
export interface LegalDocument {
|
|
||||||
docCode: 'terms' | 'privacy' | string
|
|
||||||
lang: 'zh' | 'en' | 'id' | string
|
|
||||||
title: string
|
|
||||||
content: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export const listLegalDocumentsApi = () => {
|
|
||||||
return request.get<LegalDocument[]>({ url: '/admin/legal-documents' })
|
|
||||||
}
|
|
||||||
|
|
||||||
export const saveLegalDocumentsApi = (items: LegalDocument[]) => {
|
|
||||||
return request.put<void>({ url: '/admin/legal-documents', data: items })
|
|
||||||
}
|
|
||||||
+1
-18
@@ -1,7 +1,7 @@
|
|||||||
// Author: fruit.com.cn
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
import request from '@/axios'
|
import request from '@/axios'
|
||||||
import type { MediaAsset, MediaTranscodeProfile } from './types'
|
import type { MediaAsset } from './types'
|
||||||
|
|
||||||
export interface UploadInitData {
|
export interface UploadInitData {
|
||||||
fileName: string
|
fileName: string
|
||||||
@@ -61,20 +61,3 @@ export const getUploadProgressApi = (uploadId: string) => {
|
|||||||
export const getMediaApi = (id: number) => {
|
export const getMediaApi = (id: number) => {
|
||||||
return request.get<MediaAsset>({ url: `/admin/media/${id}` })
|
return request.get<MediaAsset>({ url: `/admin/media/${id}` })
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 读取当前转码档位配置;缺省时后端返回四档默认值。 */
|
|
||||||
export const getMediaTranscodeProfileApi = () => {
|
|
||||||
return request.get<MediaTranscodeProfile>({
|
|
||||||
url: '/admin/media/transcode-profile',
|
|
||||||
silent: true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 保存转码档位配置,并返回服务端最终生效值。 */
|
|
||||||
export const saveMediaTranscodeProfileApi = (data: MediaTranscodeProfile) => {
|
|
||||||
return request.put<MediaTranscodeProfile>({
|
|
||||||
url: '/admin/media/transcode-profile',
|
|
||||||
data,
|
|
||||||
silent: true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
// Author: fruit.com.cn
|
|
||||||
|
|
||||||
import request from '@/axios'
|
|
||||||
import type {
|
|
||||||
EpisodeTranscodeItem,
|
|
||||||
MediaThumbnailResult,
|
|
||||||
TranscodeBackfillResult,
|
|
||||||
TranscodeTriggerResult
|
|
||||||
} from './types'
|
|
||||||
|
|
||||||
/** 分集编辑页聚合查询转码任务、清晰度与帧图。 */
|
|
||||||
export const getEpisodeTranscodeApi = (episodeId: number | string) => {
|
|
||||||
return request.get<EpisodeTranscodeItem>({
|
|
||||||
url: `/admin/episodes/${episodeId}/transcode`
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 按媒体分页读取帧图;页面切换时复用该接口。 */
|
|
||||||
export const getMediaThumbnailsApi = (
|
|
||||||
mediaAssetId: string,
|
|
||||||
pageIndex: number,
|
|
||||||
pageSize: number
|
|
||||||
) => {
|
|
||||||
return request.get<MediaThumbnailResult>({
|
|
||||||
url: `/admin/media/${mediaAssetId}/thumbnails`,
|
|
||||||
params: { pageIndex, pageSize }
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 手动触发或重转当前分集绑定的媒体。 */
|
|
||||||
export const triggerMediaTranscodeApi = (mediaAssetId: string) => {
|
|
||||||
return request.post<TranscodeTriggerResult>({
|
|
||||||
url: `/admin/media/${mediaAssetId}/transcode`
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 手动补齐转码:扫描缺码率产物/帧图的分集并入队。 */
|
|
||||||
export const runTranscodeBackfillApi = (batchSize?: number) => {
|
|
||||||
return request.post<TranscodeBackfillResult>({
|
|
||||||
url: '/admin/media/transcode/backfill',
|
|
||||||
params: batchSize ? { batchSize } : undefined
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
// Author: fruit.com.cn
|
|
||||||
|
|
||||||
import request from '@/axios'
|
|
||||||
|
|
||||||
export interface TranscodeNoticeItem {
|
|
||||||
id: number
|
|
||||||
status: string
|
|
||||||
dramaTitle: string
|
|
||||||
episodeNo?: number
|
|
||||||
episodeTitle?: string
|
|
||||||
progress?: number
|
|
||||||
errorMsg?: string
|
|
||||||
updatedAt?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TranscodeNotice {
|
|
||||||
running: number
|
|
||||||
success: number
|
|
||||||
failed: number
|
|
||||||
runningList: TranscodeNoticeItem[]
|
|
||||||
successList: TranscodeNoticeItem[]
|
|
||||||
failedList: TranscodeNoticeItem[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export const getTranscodeNoticesApi = () => {
|
|
||||||
return request.get<TranscodeNotice>({ url: '/admin/notifications/transcode' })
|
|
||||||
}
|
|
||||||
@@ -8,9 +8,6 @@ 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
|
||||||
/** 该类型下的短剧数量,管理列表才有 */
|
/** 该类型下的短剧数量,管理列表才有 */
|
||||||
@@ -23,15 +20,11 @@ export interface DramaItem {
|
|||||||
title: string
|
title: string
|
||||||
subtitle?: string
|
subtitle?: string
|
||||||
categoryId?: number
|
categoryId?: number
|
||||||
categoryIds?: number[]
|
|
||||||
categoryNames?: string[]
|
|
||||||
category?: string
|
category?: string
|
||||||
genre?: string
|
genre?: string
|
||||||
description?: string
|
description?: string
|
||||||
cover?: string
|
cover?: string
|
||||||
language?: string
|
language?: string
|
||||||
dramaType?: 'ANIME' | 'LIVE'
|
|
||||||
dramaTypes?: Array<'ANIME' | 'LIVE'>
|
|
||||||
episodes?: number
|
episodes?: number
|
||||||
freeEpisodes?: number
|
freeEpisodes?: number
|
||||||
unlockCoin?: number
|
unlockCoin?: number
|
||||||
@@ -40,9 +33,6 @@ export interface DramaItem {
|
|||||||
status: string
|
status: string
|
||||||
statusText: string
|
statusText: string
|
||||||
views?: number
|
views?: number
|
||||||
favoriteCount?: number
|
|
||||||
likeCount?: number
|
|
||||||
commentCount?: number
|
|
||||||
sort?: number
|
sort?: number
|
||||||
publishAt?: string
|
publishAt?: string
|
||||||
createdAt?: string
|
createdAt?: string
|
||||||
@@ -53,18 +43,12 @@ export interface DramaSaveData {
|
|||||||
title: string
|
title: string
|
||||||
subtitle?: string
|
subtitle?: string
|
||||||
categoryId?: number
|
categoryId?: number
|
||||||
categoryIds?: number[]
|
|
||||||
genre?: string
|
genre?: string
|
||||||
description?: string
|
description?: string
|
||||||
cover?: string
|
cover?: string
|
||||||
language?: string
|
language?: string
|
||||||
dramaType?: 'ANIME' | 'LIVE'
|
|
||||||
dramaTypes?: Array<'ANIME' | 'LIVE'>
|
|
||||||
freeEpisodes?: number
|
freeEpisodes?: number
|
||||||
unlockCoin?: number
|
unlockCoin?: number
|
||||||
favoriteCount?: number
|
|
||||||
likeCount?: number
|
|
||||||
heat?: number
|
|
||||||
isHot?: boolean
|
isHot?: boolean
|
||||||
sort?: number
|
sort?: number
|
||||||
}
|
}
|
||||||
@@ -85,10 +69,6 @@ export interface EpisodeItem {
|
|||||||
status: string
|
status: string
|
||||||
statusText: string
|
statusText: string
|
||||||
views?: number
|
views?: number
|
||||||
likeCount?: number
|
|
||||||
commentCount?: number
|
|
||||||
favoriteCount?: number
|
|
||||||
heat?: number
|
|
||||||
sort?: number
|
sort?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +81,6 @@ export interface EpisodeSaveData {
|
|||||||
videoUrl?: string
|
videoUrl?: string
|
||||||
isFree?: boolean
|
isFree?: boolean
|
||||||
unlockCoin?: number
|
unlockCoin?: number
|
||||||
likeCount?: number
|
|
||||||
status?: string
|
status?: string
|
||||||
sort?: number
|
sort?: number
|
||||||
}
|
}
|
||||||
@@ -225,115 +204,6 @@ export interface MediaAsset {
|
|||||||
createdAt?: string
|
createdAt?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 单档清晰度配置,字段与 FruitServer MediaTranscodeProfile.Rung 一致。 */
|
|
||||||
export interface MediaTranscodeLadderRung {
|
|
||||||
quality: string
|
|
||||||
width: number
|
|
||||||
height: number
|
|
||||||
videoBitrateKbps: number
|
|
||||||
audioBitrateKbps: number
|
|
||||||
enabled: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 雪碧图采样配置,字段与 FruitServer MediaTranscodeProfile.Sprite 一致。 */
|
|
||||||
export interface MediaTranscodeSprite {
|
|
||||||
enabled: boolean
|
|
||||||
intervalSeconds: number
|
|
||||||
columns: number
|
|
||||||
thumbWidth: number
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 转码档位配置,字段与 FruitServer MediaTranscodeProfile 一致。 */
|
|
||||||
export interface MediaTranscodeProfile {
|
|
||||||
enabled: boolean
|
|
||||||
segmentSeconds: number
|
|
||||||
ladder: MediaTranscodeLadderRung[]
|
|
||||||
sprite: MediaTranscodeSprite
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface MediaRenditionItem {
|
|
||||||
id: string
|
|
||||||
quality: string
|
|
||||||
qualityName: string
|
|
||||||
width: number
|
|
||||||
height: number
|
|
||||||
resolution: string
|
|
||||||
videoBitrateKbps: number
|
|
||||||
audioBitrateKbps: number
|
|
||||||
videoCodec: string
|
|
||||||
audioCodec?: string
|
|
||||||
container: string
|
|
||||||
hlsUrl: string
|
|
||||||
sizeBytes: number
|
|
||||||
durationSec: number
|
|
||||||
segmentCount: number
|
|
||||||
status: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface MediaThumbnailFrameItem {
|
|
||||||
frameIndex: number
|
|
||||||
timeMs: number
|
|
||||||
endTimeMs?: number
|
|
||||||
imageUrl: string
|
|
||||||
spriteUrl: string
|
|
||||||
x: number
|
|
||||||
y: number
|
|
||||||
width: number
|
|
||||||
height: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface MediaThumbnailSpriteInfo {
|
|
||||||
spriteUrl?: string
|
|
||||||
spriteUrls: string[]
|
|
||||||
vttUrl?: string
|
|
||||||
columns: number
|
|
||||||
rows: number
|
|
||||||
totalFrames: number
|
|
||||||
thumbWidth: number
|
|
||||||
thumbHeight: number
|
|
||||||
intervalSeconds: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface MediaThumbnailResult {
|
|
||||||
mediaAssetId?: string | null
|
|
||||||
episodeId?: string | null
|
|
||||||
/** READY / FAILED / EMPTY / INVALID / NO_EPISODE */
|
|
||||||
status: string
|
|
||||||
errorMsg?: string
|
|
||||||
pageIndex: number
|
|
||||||
pageSize: number
|
|
||||||
frames: PageResult<MediaThumbnailFrameItem>
|
|
||||||
sprite?: MediaThumbnailSpriteInfo | null
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface EpisodeTranscodeItem {
|
|
||||||
episodeId: string
|
|
||||||
mediaAssetId?: string | null
|
|
||||||
taskId?: string | null
|
|
||||||
status: string
|
|
||||||
progress?: number
|
|
||||||
retryCount?: number
|
|
||||||
errorMsg?: string
|
|
||||||
updatedAt?: string
|
|
||||||
renditions: MediaRenditionItem[]
|
|
||||||
thumbnails?: MediaThumbnailResult | null
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TranscodeTriggerResult {
|
|
||||||
taskId: string
|
|
||||||
status: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TranscodeBackfillItem {
|
|
||||||
episodeId: string
|
|
||||||
taskId: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TranscodeBackfillResult {
|
|
||||||
triggered: number
|
|
||||||
items: TranscodeBackfillItem[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface BannerItem {
|
export interface BannerItem {
|
||||||
id: number
|
id: number
|
||||||
imageUrl: string
|
imageUrl: string
|
||||||
@@ -399,10 +269,6 @@ export interface AppUserItem {
|
|||||||
maskedTarget: string
|
maskedTarget: string
|
||||||
createdAt?: string
|
createdAt?: string
|
||||||
lastLoginAt?: string
|
lastLoginAt?: string
|
||||||
/** ANDROID / IOS / WEB */
|
|
||||||
platform?: string
|
|
||||||
/** 系统版本,例如 Android 16 */
|
|
||||||
osVersion?: string
|
|
||||||
/** 预留:会员等级与到期(第二阶段) */
|
/** 预留:会员等级与到期(第二阶段) */
|
||||||
vipLevel?: number
|
vipLevel?: number
|
||||||
vipExpireAt?: string
|
vipExpireAt?: string
|
||||||
@@ -428,22 +294,16 @@ export interface AppUserBanRecord {
|
|||||||
|
|
||||||
export interface WatchHistoryItem {
|
export interface WatchHistoryItem {
|
||||||
id: number
|
id: number
|
||||||
userId?: number
|
|
||||||
uid?: string
|
|
||||||
nickname?: string
|
|
||||||
dramaId: number
|
dramaId: number
|
||||||
dramaTitle?: string
|
dramaTitle?: string
|
||||||
dramaPublished?: boolean
|
dramaPublished?: boolean
|
||||||
episodeId: number
|
episodeId: number
|
||||||
episodeNo?: number
|
episodeNo?: number
|
||||||
episodeTitle?: string
|
|
||||||
positionMs: number
|
positionMs: number
|
||||||
durationMs: number
|
durationMs: number
|
||||||
finished?: boolean
|
finished?: boolean
|
||||||
source: string
|
source: string
|
||||||
deviceId: string
|
deviceId: string
|
||||||
platform?: string
|
|
||||||
osVersion?: string
|
|
||||||
watchedAt?: string
|
watchedAt?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,10 +311,7 @@ export interface WatchHistoryItem {
|
|||||||
export interface CommentItem {
|
export interface CommentItem {
|
||||||
id: number
|
id: number
|
||||||
dramaId: number
|
dramaId: number
|
||||||
dramaTitle?: string
|
|
||||||
episodeId: number
|
episodeId: number
|
||||||
episodeNo?: number
|
|
||||||
episodeTitle?: string
|
|
||||||
parentId: number
|
parentId: number
|
||||||
rootId: number
|
rootId: number
|
||||||
userId: number
|
userId: number
|
||||||
@@ -473,20 +330,9 @@ export interface CommentItem {
|
|||||||
export interface ReportItem {
|
export interface ReportItem {
|
||||||
id: number
|
id: number
|
||||||
reporterId: number
|
reporterId: number
|
||||||
reporterNickname?: string
|
|
||||||
reporterUid?: string
|
|
||||||
/** COMMENT / USER / DRAMA */
|
/** COMMENT / USER / DRAMA */
|
||||||
targetType: string
|
targetType: string
|
||||||
targetId: number
|
targetId: number
|
||||||
targetSummary?: string
|
|
||||||
dramaId?: number
|
|
||||||
dramaTitle?: string
|
|
||||||
episodeId?: number
|
|
||||||
episodeNo?: number
|
|
||||||
episodeTitle?: string
|
|
||||||
commentContent?: string
|
|
||||||
targetNickname?: string
|
|
||||||
targetUid?: string
|
|
||||||
reasonCode: string
|
reasonCode: string
|
||||||
description: string
|
description: string
|
||||||
/** pending / handled / rejected */
|
/** pending / handled / rejected */
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
// Author: fruit.com.cn
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
import { defineAsyncComponent } from 'vue'
|
|
||||||
import type { Component } from 'vue'
|
import type { Component } from 'vue'
|
||||||
import {
|
import {
|
||||||
ElCascader,
|
ElCascader,
|
||||||
@@ -24,12 +23,9 @@ import {
|
|||||||
ElUpload
|
ElUpload
|
||||||
} from 'element-plus'
|
} from 'element-plus'
|
||||||
import { InputPassword } from '@/components/InputPassword'
|
import { InputPassword } from '@/components/InputPassword'
|
||||||
|
import { Editor } from '@/components/Editor'
|
||||||
import { ComponentName } from '../types'
|
import { ComponentName } from '../types'
|
||||||
|
|
||||||
// wang-editor 打包后约 1.1MB:改成异步组件,只有真正渲染编辑器字段时才加载,
|
|
||||||
// 避免登录页这类只是用了 Form 的页面把它一并拉进首屏。
|
|
||||||
const Editor = defineAsyncComponent(() => import('@/components/Editor'))
|
|
||||||
|
|
||||||
const componentMap: Recordable<Component, ComponentName> = {
|
const componentMap: Recordable<Component, ComponentName> = {
|
||||||
RadioGroup: ElRadioGroup,
|
RadioGroup: ElRadioGroup,
|
||||||
RadioButton: ElRadioGroup,
|
RadioButton: ElRadioGroup,
|
||||||
|
|||||||
@@ -22,8 +22,7 @@ import {
|
|||||||
ISelectProps,
|
ISelectProps,
|
||||||
UploadProps
|
UploadProps
|
||||||
} from 'element-plus'
|
} from 'element-plus'
|
||||||
// 仅类型引用:必须用 import type,否则会把整个 wang-editor 打进登录页的依赖链
|
import { IEditorConfig } from '@wangeditor/editor'
|
||||||
import type { IEditorConfig } from '@wangeditor/editor'
|
|
||||||
import { CSSProperties } from 'vue'
|
import { CSSProperties } from 'vue'
|
||||||
|
|
||||||
export interface PlaceholderModel {
|
export interface PlaceholderModel {
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
// 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
|
|
||||||
}
|
|
||||||
@@ -37,8 +37,6 @@ export const AppIcons = {
|
|||||||
delete: 'material-symbols:delete-rounded',
|
delete: 'material-symbols:delete-rounded',
|
||||||
upload: 'material-symbols:upload-rounded',
|
upload: 'material-symbols:upload-rounded',
|
||||||
download: 'material-symbols:download-rounded',
|
download: 'material-symbols:download-rounded',
|
||||||
copy: 'material-symbols:content-copy-rounded',
|
|
||||||
openInNew: 'material-symbols:open-in-new-rounded',
|
|
||||||
visibility: 'material-symbols:visibility-rounded',
|
visibility: 'material-symbols:visibility-rounded',
|
||||||
arrowUp: 'material-symbols:arrow-upward-rounded',
|
arrowUp: 'material-symbols:arrow-upward-rounded',
|
||||||
arrowDown: 'material-symbols:arrow-downward-rounded',
|
arrowDown: 'material-symbols:arrow-downward-rounded',
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { Collapse } from '@/components/Collapse'
|
|||||||
import { LocaleDropdown } from '@/components/LocaleDropdown'
|
import { LocaleDropdown } from '@/components/LocaleDropdown'
|
||||||
import { SizeDropdown } from '@/components/SizeDropdown'
|
import { SizeDropdown } from '@/components/SizeDropdown'
|
||||||
import { UserInfo } from '@/components/UserInfo'
|
import { UserInfo } from '@/components/UserInfo'
|
||||||
import TranscodeNoticeButton from './TranscodeNoticeButton.vue'
|
|
||||||
import { Screenfull } from '@/components/Screenfull'
|
import { Screenfull } from '@/components/Screenfull'
|
||||||
import { Breadcrumb } from '@/components/Breadcrumb'
|
import { Breadcrumb } from '@/components/Breadcrumb'
|
||||||
import { useAppStore } from '@/store/modules/app'
|
import { useAppStore } from '@/store/modules/app'
|
||||||
@@ -74,7 +73,6 @@ export default defineComponent({
|
|||||||
color="var(--top-header-text-color)"
|
color="var(--top-header-text-color)"
|
||||||
></LocaleDropdown>
|
></LocaleDropdown>
|
||||||
) : undefined}
|
) : undefined}
|
||||||
<TranscodeNoticeButton color="var(--top-header-text-color)"></TranscodeNoticeButton>
|
|
||||||
<UserInfo></UserInfo>
|
<UserInfo></UserInfo>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -97,7 +95,7 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (width <= 768px) {
|
@media (max-width: 768px) {
|
||||||
.@{prefix-cls} {
|
.@{prefix-cls} {
|
||||||
padding-right: 8px;
|
padding-right: 8px;
|
||||||
padding-left: 8px;
|
padding-left: 8px;
|
||||||
|
|||||||
@@ -1,89 +0,0 @@
|
|||||||
<!-- Author: fruit.com.cn -->
|
|
||||||
<!-- 顶栏转码通知:角标汇总转码中、成功、失败,点击进入通知页。 -->
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
|
||||||
import { useRouter } from 'vue-router'
|
|
||||||
import { Bell } from '@element-plus/icons-vue'
|
|
||||||
import { getTranscodeNoticesApi } from '@/api/admin/transcodeNotice'
|
|
||||||
import { TRANSCODE_NOTICE_SEEN, unreadCounts } from '@/utils/transcodeNoticeSeen'
|
|
||||||
|
|
||||||
const POLL_MS = 30000
|
|
||||||
const BADGE_MAX = 99
|
|
||||||
|
|
||||||
defineProps<{ color?: string }>()
|
|
||||||
const router = useRouter()
|
|
||||||
const running = ref(0)
|
|
||||||
const success = ref(0)
|
|
||||||
const failed = ref(0)
|
|
||||||
const seenTick = ref(0)
|
|
||||||
let timer = 0
|
|
||||||
|
|
||||||
const total = computed(() => {
|
|
||||||
seenTick.value
|
|
||||||
const unread = unreadCounts({
|
|
||||||
running: running.value,
|
|
||||||
success: success.value,
|
|
||||||
failed: failed.value
|
|
||||||
})
|
|
||||||
return unread.running + unread.success + unread.failed
|
|
||||||
})
|
|
||||||
|
|
||||||
async function refresh() {
|
|
||||||
const res = await getTranscodeNoticesApi()
|
|
||||||
running.value = Number(res.data?.running || 0)
|
|
||||||
success.value = Number(res.data?.success || 0)
|
|
||||||
failed.value = Number(res.data?.failed || 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
function open() {
|
|
||||||
router.push({ name: 'transcode-notices' })
|
|
||||||
}
|
|
||||||
|
|
||||||
function onSeen() {
|
|
||||||
seenTick.value += 1
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
refresh().catch(() => undefined)
|
|
||||||
window.addEventListener(TRANSCODE_NOTICE_SEEN, onSeen)
|
|
||||||
timer = window.setInterval(() => {
|
|
||||||
refresh().catch(() => undefined)
|
|
||||||
}, POLL_MS)
|
|
||||||
})
|
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
|
||||||
window.removeEventListener(TRANSCODE_NOTICE_SEEN, onSeen)
|
|
||||||
window.clearInterval(timer)
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<el-badge :value="total" :max="BADGE_MAX" :hidden="total === 0" class="notice-badge">
|
|
||||||
<div class="notice-button" :style="{ color }" @click="open">
|
|
||||||
<el-icon :size="18"><Bell /></el-icon>
|
|
||||||
</div>
|
|
||||||
</el-badge>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.notice-badge {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.notice-button {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
width: 36px;
|
|
||||||
height: 100%;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.notice-badge :deep(.el-badge__content.is-fixed) {
|
|
||||||
top: 8px;
|
|
||||||
right: 2px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
+1
-170
@@ -112,7 +112,6 @@ export default {
|
|||||||
login: 'Sign in',
|
login: 'Sign in',
|
||||||
remember: 'Remember me',
|
remember: 'Remember me',
|
||||||
forgetPassword: 'Forget password',
|
forgetPassword: 'Forget password',
|
||||||
forgetPasswordHint: 'Please contact the administrator to reset your password',
|
|
||||||
usernamePlaceholder: 'Please input username',
|
usernamePlaceholder: 'Please input username',
|
||||||
passwordPlaceholder: 'Please input password'
|
passwordPlaceholder: 'Please input password'
|
||||||
},
|
},
|
||||||
@@ -163,8 +162,7 @@ export default {
|
|||||||
treeTable: 'Tree table',
|
treeTable: 'Tree table',
|
||||||
PicturePreview: 'Table Image Preview',
|
PicturePreview: 'Table Image Preview',
|
||||||
department: 'Department management',
|
department: 'Department management',
|
||||||
menuManagement: 'Menu management',
|
menuManagement: 'Menu management'
|
||||||
transcodeSettings: 'Transcode settings'
|
|
||||||
},
|
},
|
||||||
permission: {
|
permission: {
|
||||||
hasPermission: 'Please set the operation permission value'
|
hasPermission: 'Please set the operation permission value'
|
||||||
@@ -528,172 +526,5 @@ export default {
|
|||||||
inputPasswordDemo: {
|
inputPasswordDemo: {
|
||||||
title: 'InputPassword',
|
title: 'InputPassword',
|
||||||
inputPasswordDes: 'Secondary packaging of Input components based on ElementPlus'
|
inputPasswordDes: 'Secondary packaging of Input components based on ElementPlus'
|
||||||
},
|
|
||||||
episodeTranscode: {
|
|
||||||
title: 'Transcode outputs',
|
|
||||||
description: 'Review the transcode task, renditions and frame previews for this episode.',
|
|
||||||
statusLabel: 'Status',
|
|
||||||
progress: 'Progress',
|
|
||||||
retryCount: 'Retries',
|
|
||||||
updatedAt: 'Last updated',
|
|
||||||
waitingProgress: 'Processing (waiting for progress report)',
|
|
||||||
reprocess: 'Transcode again',
|
|
||||||
reprocessing: 'Submitting',
|
|
||||||
triggerSuccess: 'Transcode task submitted',
|
|
||||||
loadFailed: 'Failed to load transcode outputs',
|
|
||||||
retryLoad: 'Reload',
|
|
||||||
triggerFailed: 'Failed to retry transcode',
|
|
||||||
noMedia: 'No uploaded media is bound to this episode yet.',
|
|
||||||
noRendition: 'No rendition outputs',
|
|
||||||
renditionTitle: 'Rendition outputs',
|
|
||||||
quality: 'Quality',
|
|
||||||
resolution: 'Resolution',
|
|
||||||
videoBitrate: 'Video bitrate',
|
|
||||||
audioBitrate: 'Audio bitrate',
|
|
||||||
codec: 'Codec',
|
|
||||||
container: 'Container',
|
|
||||||
fileSize: 'File size',
|
|
||||||
duration: 'Duration',
|
|
||||||
segments: 'Segments',
|
|
||||||
statusColumn: 'Status',
|
|
||||||
actions: 'Actions',
|
|
||||||
copyUrl: 'Copy playback URL',
|
|
||||||
openUrl: 'Open in new window',
|
|
||||||
play: 'Preview playback',
|
|
||||||
playerFailed: 'Playback failed, please check the rendition output',
|
|
||||||
playerUnsupported: 'This browser does not support HLS playback',
|
|
||||||
copySuccess: 'Playback URL copied',
|
|
||||||
copyFailed: 'Failed to copy playback URL',
|
|
||||||
openFailed: 'Unable to open playback URL',
|
|
||||||
frameTitle: 'Frame previews',
|
|
||||||
frameView: 'Frames',
|
|
||||||
spriteView: 'Sprites',
|
|
||||||
frameCount: '{total} frames',
|
|
||||||
frameTime: 'Timestamp',
|
|
||||||
previewFrame: 'Preview frame at {time}',
|
|
||||||
spriteSheet: 'Sprite {index}',
|
|
||||||
spriteSheetFrames: '{count} frames',
|
|
||||||
noFrames: 'No frame previews',
|
|
||||||
noSprites: 'No sprite sheets available',
|
|
||||||
zoomTitle: 'Frame preview',
|
|
||||||
status: {
|
|
||||||
queued: 'Queued',
|
|
||||||
running: 'Transcoding',
|
|
||||||
success: 'Success',
|
|
||||||
failed: 'Failed',
|
|
||||||
empty: 'No output',
|
|
||||||
noVideo: 'No video',
|
|
||||||
noMediaAsset: 'No media asset',
|
|
||||||
noTask: 'No transcode task',
|
|
||||||
noEpisode: 'No episode binding',
|
|
||||||
episodeNotFound: 'Episode not found',
|
|
||||||
invalid: 'Invalid output',
|
|
||||||
ready: 'Ready',
|
|
||||||
unknown: 'Unknown'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
episodeBatch: {
|
|
||||||
title: 'Batch upload episodes',
|
|
||||||
entry: 'Batch upload',
|
|
||||||
selectFiles: 'Select videos',
|
|
||||||
startUpload: 'Start upload',
|
|
||||||
uploadingAction: 'Uploading',
|
|
||||||
pause: 'Pause',
|
|
||||||
resume: 'Resume',
|
|
||||||
retry: 'Retry',
|
|
||||||
retryAll: 'Retry all',
|
|
||||||
remove: 'Remove',
|
|
||||||
hint: 'Supports MP4 / MOV / MKV / WEBM, max 500MB each. Files stay queued until you click Start upload.',
|
|
||||||
invalidType: 'Only MP4, MOV, MKV, WEBM are allowed',
|
|
||||||
oversize: 'File exceeds 500MB and was not queued',
|
|
||||||
overallProgress: 'Overall progress',
|
|
||||||
empty: 'No videos selected',
|
|
||||||
resultSummary: 'Upload finished: {done} succeeded, {failed} failed',
|
|
||||||
createEpisodes: 'Create episodes',
|
|
||||||
closeWhileUploading:
|
|
||||||
'Uploads are still in progress. Closing will stop dispatching new tasks. Continue?',
|
|
||||||
resumeTitle: 'Unfinished uploads found',
|
|
||||||
resumeConfirm:
|
|
||||||
'{count} unfinished upload(s) found. Resume? Re-select the same local files to match.',
|
|
||||||
resumeYes: 'Pick files to resume',
|
|
||||||
resumeNo: 'Discard',
|
|
||||||
resumeAbandoned: 'Unfinished uploads discarded',
|
|
||||||
resumeMatched: 'Matched {count} file(s). Click Start upload to continue.',
|
|
||||||
resumeUnmatched: '{count} session(s) could not match local files; pick again manually',
|
|
||||||
createTitle: 'Create episodes in batch',
|
|
||||||
createHint:
|
|
||||||
'Title uses the video file name; episode numbers are assigned automatically. Free vs paid follows the drama free-episode count; episodes beyond that are paid. You can edit them later in episode settings.',
|
|
||||||
colSource: 'Source file',
|
|
||||||
colNumber: 'Episode No.',
|
|
||||||
colTitle: 'Title',
|
|
||||||
colFree: 'Pricing',
|
|
||||||
labelFree: 'Free',
|
|
||||||
labelPaid: 'Paid',
|
|
||||||
colResult: 'Result',
|
|
||||||
missingVideo: 'Missing video URL',
|
|
||||||
createOk: 'Created',
|
|
||||||
createFailed: 'Create failed',
|
|
||||||
createAllSuccess: 'All episodes created',
|
|
||||||
createPartial: 'Some episodes failed; you can retry',
|
|
||||||
submitCreate: 'Create',
|
|
||||||
retryFailed: 'Retry failed',
|
|
||||||
status: {
|
|
||||||
waiting: 'Pending',
|
|
||||||
uploading: 'Uploading',
|
|
||||||
merging: 'Merging',
|
|
||||||
done: 'Done',
|
|
||||||
failed: 'Failed',
|
|
||||||
paused: 'Paused'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
transcodeSettings: {
|
|
||||||
eyebrow: 'Content management',
|
|
||||||
title: 'Transcode settings',
|
|
||||||
description:
|
|
||||||
'Configure the quality ladder, HLS segment duration and thumbnail sprite options for new tasks.',
|
|
||||||
reload: 'Reload',
|
|
||||||
save: 'Save settings',
|
|
||||||
saved: 'Transcode settings saved',
|
|
||||||
saveFailed: 'Failed to save transcode settings',
|
|
||||||
loadFailed: 'Failed to load transcode settings',
|
|
||||||
noPermission: 'This account cannot manage transcode settings',
|
|
||||||
backfill: 'Backfill transcodes',
|
|
||||||
backfillTip: 'Scan episodes missing renditions or thumbnails and enqueue them for transcoding',
|
|
||||||
backfillDone: 'Enqueued {count} episodes into the transcode queue',
|
|
||||||
backfillEmpty: 'No episodes need transcoding',
|
|
||||||
backfillFailed: 'Failed to run transcode backfill',
|
|
||||||
enabled: 'Enable transcode profile',
|
|
||||||
enabledDescription:
|
|
||||||
'Marks whether this transcode profile is enabled; the quality ladder is still validated when saved.',
|
|
||||||
segmentSeconds: 'HLS segment duration (seconds)',
|
|
||||||
ladderTitle: 'Quality ladder',
|
|
||||||
ladderDescription:
|
|
||||||
'Changes apply only to tasks queued afterwards; historical tasks are not reprocessed.',
|
|
||||||
quality: 'Quality key',
|
|
||||||
width: 'Width',
|
|
||||||
height: 'Height',
|
|
||||||
videoBitrateKbps: 'Video bitrate (kbps)',
|
|
||||||
audioBitrateKbps: 'Audio bitrate (kbps)',
|
|
||||||
rowEnabled: 'Enabled',
|
|
||||||
addRung: 'Add quality',
|
|
||||||
deleteRung: 'Delete',
|
|
||||||
emptyLadder: 'No quality rungs configured',
|
|
||||||
spriteTitle: 'Thumbnail sprite',
|
|
||||||
spriteDescription:
|
|
||||||
'Sample frames at a fixed interval, tile them into sprites and generate a WebVTT timeline.',
|
|
||||||
spriteEnabled: 'Enable thumbnail sprites',
|
|
||||||
intervalSeconds: 'Sampling interval (seconds)',
|
|
||||||
columns: 'Frames per row',
|
|
||||||
thumbWidth: 'Thumbnail width (px)',
|
|
||||||
validation: {
|
|
||||||
required: 'This field is required',
|
|
||||||
qualityUnique: 'Quality keys must be unique',
|
|
||||||
qualityTooLong: 'Quality key must not exceed 16 characters',
|
|
||||||
positiveEven: 'Enter an even number greater than 0',
|
|
||||||
positiveInteger: 'Enter an integer greater than 0',
|
|
||||||
range: 'Enter an integer between {min} and {max}',
|
|
||||||
atLeastOneEnabled: 'Enable at least one quality rung',
|
|
||||||
fixErrors: 'Fix the marked transcode fields before saving'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-164
@@ -112,7 +112,6 @@ export default {
|
|||||||
login: '登录',
|
login: '登录',
|
||||||
remember: '记住我',
|
remember: '记住我',
|
||||||
forgetPassword: '忘记密码',
|
forgetPassword: '忘记密码',
|
||||||
forgetPasswordHint: '请联系管理员重置密码',
|
|
||||||
usernamePlaceholder: '请输入用户名',
|
usernamePlaceholder: '请输入用户名',
|
||||||
passwordPlaceholder: '请输入密码'
|
passwordPlaceholder: '请输入密码'
|
||||||
},
|
},
|
||||||
@@ -163,8 +162,7 @@ export default {
|
|||||||
treeTable: '树形表格',
|
treeTable: '树形表格',
|
||||||
PicturePreview: '表格图片预览',
|
PicturePreview: '表格图片预览',
|
||||||
department: '部门管理',
|
department: '部门管理',
|
||||||
menuManagement: '菜单管理',
|
menuManagement: '菜单管理'
|
||||||
transcodeSettings: '转码设置'
|
|
||||||
},
|
},
|
||||||
permission: {
|
permission: {
|
||||||
hasPermission: '请设置操作权限值'
|
hasPermission: '请设置操作权限值'
|
||||||
@@ -522,166 +520,5 @@ export default {
|
|||||||
inputPasswordDemo: {
|
inputPasswordDemo: {
|
||||||
title: '密码输入框',
|
title: '密码输入框',
|
||||||
inputPasswordDes: '基于 ElementPlus 的 Input 组件二次封装'
|
inputPasswordDes: '基于 ElementPlus 的 Input 组件二次封装'
|
||||||
},
|
|
||||||
episodeTranscode: {
|
|
||||||
title: '转码产物',
|
|
||||||
description: '查看当前分集的转码任务、清晰度与帧图产物。',
|
|
||||||
statusLabel: '状态',
|
|
||||||
progress: '进度',
|
|
||||||
retryCount: '重试次数',
|
|
||||||
updatedAt: '最近更新',
|
|
||||||
waitingProgress: '处理中(等待进度上报)',
|
|
||||||
reprocess: '重新转码',
|
|
||||||
reprocessing: '正在触发',
|
|
||||||
triggerSuccess: '已提交转码任务',
|
|
||||||
loadFailed: '转码产物加载失败',
|
|
||||||
retryLoad: '重新加载',
|
|
||||||
triggerFailed: '重新转码失败',
|
|
||||||
noMedia: '当前分集尚未绑定已上传视频,暂无可查询的转码产物。',
|
|
||||||
noRendition: '暂无清晰度产物',
|
|
||||||
renditionTitle: '清晰度产物',
|
|
||||||
quality: '档位名称',
|
|
||||||
resolution: '分辨率',
|
|
||||||
videoBitrate: '视频码率',
|
|
||||||
audioBitrate: '音频码率',
|
|
||||||
codec: '编码',
|
|
||||||
container: '容器',
|
|
||||||
fileSize: '文件大小',
|
|
||||||
duration: '时长',
|
|
||||||
segments: '分片数',
|
|
||||||
statusColumn: '状态',
|
|
||||||
actions: '操作',
|
|
||||||
copyUrl: '复制播放地址',
|
|
||||||
openUrl: '新窗口打开',
|
|
||||||
play: '预览播放',
|
|
||||||
playerFailed: '播放失败,请检查产物是否完整',
|
|
||||||
playerUnsupported: '当前浏览器不支持 HLS 播放',
|
|
||||||
copySuccess: '播放地址已复制',
|
|
||||||
copyFailed: '复制播放地址失败',
|
|
||||||
openFailed: '无法打开播放地址',
|
|
||||||
frameTitle: '帧图预览',
|
|
||||||
frameView: '逐帧',
|
|
||||||
spriteView: '雪碧图',
|
|
||||||
frameCount: '共 {total} 帧',
|
|
||||||
frameTime: '时间点',
|
|
||||||
previewFrame: '预览 {time} 帧图',
|
|
||||||
spriteSheet: '雪碧图 {index}',
|
|
||||||
spriteSheetFrames: '{count} 帧',
|
|
||||||
noFrames: '暂无帧图产物',
|
|
||||||
noSprites: '暂无可展示的雪碧图',
|
|
||||||
zoomTitle: '帧图预览',
|
|
||||||
status: {
|
|
||||||
queued: '排队中',
|
|
||||||
running: '转码中',
|
|
||||||
success: '成功',
|
|
||||||
failed: '失败',
|
|
||||||
empty: '暂无产物',
|
|
||||||
noVideo: '无视频',
|
|
||||||
noMediaAsset: '未绑定媒资',
|
|
||||||
noTask: '无转码任务',
|
|
||||||
noEpisode: '未绑定分集',
|
|
||||||
episodeNotFound: '分集不存在',
|
|
||||||
invalid: '产物异常',
|
|
||||||
ready: '就绪',
|
|
||||||
unknown: '未知状态'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
episodeBatch: {
|
|
||||||
title: '批量上传剧集',
|
|
||||||
entry: '批量上传',
|
|
||||||
selectFiles: '选择视频',
|
|
||||||
startUpload: '开始上传',
|
|
||||||
uploadingAction: '上传中',
|
|
||||||
pause: '暂停',
|
|
||||||
resume: '继续',
|
|
||||||
retry: '重试',
|
|
||||||
retryAll: '全部重试',
|
|
||||||
remove: '移除',
|
|
||||||
hint: '支持 MP4 / MOV / MKV / WEBM,单文件不超过 500MB;选完文件后点击「开始上传」才会真正上传',
|
|
||||||
invalidType: '仅支持 MP4、MOV、MKV、WEBM',
|
|
||||||
oversize: '文件超过 500MB,未入队',
|
|
||||||
overallProgress: '总进度',
|
|
||||||
empty: '尚未选择视频',
|
|
||||||
resultSummary: '上传结束:成功 {done} 个,失败 {failed} 个',
|
|
||||||
createEpisodes: '批量创建分集',
|
|
||||||
closeWhileUploading: '仍有未完成上传,关闭后将暂停派发新任务,确定关闭吗?',
|
|
||||||
resumeTitle: '发现未完成上传',
|
|
||||||
resumeConfirm: '发现 {count} 个未完成上传,是否续传?请重新选择相同本地文件以匹配。',
|
|
||||||
resumeYes: '选择文件续传',
|
|
||||||
resumeNo: '放弃',
|
|
||||||
resumeAbandoned: '已放弃未完成上传',
|
|
||||||
resumeMatched: '已匹配 {count} 个文件,请点击「开始上传」继续',
|
|
||||||
resumeUnmatched: '有 {count} 个会话无法匹配本地文件,请手动重选',
|
|
||||||
createTitle: '批量创建分集',
|
|
||||||
createHint:
|
|
||||||
'标题取视频文件名,集号自动顺延分配;免费集数由短剧管理中的「免费集数」配置决定,超出部分为收费集;创建后可在分集编辑中修改',
|
|
||||||
colSource: '源文件',
|
|
||||||
colNumber: '集号',
|
|
||||||
colTitle: '标题',
|
|
||||||
colFree: '收费类型',
|
|
||||||
labelFree: '免费',
|
|
||||||
labelPaid: '收费',
|
|
||||||
colResult: '结果',
|
|
||||||
missingVideo: '缺少视频地址',
|
|
||||||
createOk: '已创建',
|
|
||||||
createFailed: '创建失败',
|
|
||||||
createAllSuccess: '全部分集已创建',
|
|
||||||
createPartial: '部分分集创建失败,可重试',
|
|
||||||
submitCreate: '创建',
|
|
||||||
retryFailed: '重试失败项',
|
|
||||||
status: {
|
|
||||||
waiting: '待上传',
|
|
||||||
uploading: '上传中',
|
|
||||||
merging: '合并中',
|
|
||||||
done: '已完成',
|
|
||||||
failed: '失败',
|
|
||||||
paused: '已暂停'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
transcodeSettings: {
|
|
||||||
eyebrow: '内容管理',
|
|
||||||
title: '转码设置',
|
|
||||||
description: '配置之后新任务的清晰度阶梯、HLS 分片与缩略图雪碧图参数。',
|
|
||||||
reload: '重新加载',
|
|
||||||
save: '保存设置',
|
|
||||||
saved: '转码设置已保存',
|
|
||||||
saveFailed: '转码设置保存失败',
|
|
||||||
loadFailed: '转码设置加载失败',
|
|
||||||
noPermission: '当前账号没有转码设置权限',
|
|
||||||
backfill: '立即补齐转码',
|
|
||||||
backfillTip: '扫描缺少清晰度产物或帧图的分集并自动入队转码',
|
|
||||||
backfillDone: '本轮已补入 {count} 个分集进入转码队列',
|
|
||||||
backfillEmpty: '没有需要补转的分集',
|
|
||||||
backfillFailed: '补齐转码执行失败',
|
|
||||||
enabled: '启用转码配置',
|
|
||||||
enabledDescription: '标记当前转码配置是否启用;保存时仍会校验下方档位。',
|
|
||||||
segmentSeconds: 'HLS 分片时长(秒)',
|
|
||||||
ladderTitle: '清晰度阶梯',
|
|
||||||
ladderDescription: '保存后只影响之后进入队列的新任务,不回跑历史任务。',
|
|
||||||
quality: '清晰度标识',
|
|
||||||
width: '宽',
|
|
||||||
height: '高',
|
|
||||||
videoBitrateKbps: '视频码率(kbps)',
|
|
||||||
audioBitrateKbps: '音频码率(kbps)',
|
|
||||||
rowEnabled: '启用',
|
|
||||||
addRung: '新增档位',
|
|
||||||
deleteRung: '删除',
|
|
||||||
emptyLadder: '尚未配置清晰度档位',
|
|
||||||
spriteTitle: '缩略图雪碧图',
|
|
||||||
spriteDescription: '按固定间隔抽帧并拼成雪碧图,同时生成 WebVTT 时间轴。',
|
|
||||||
spriteEnabled: '启用雪碧图',
|
|
||||||
intervalSeconds: '抽帧间隔(秒)',
|
|
||||||
columns: '每行帧数',
|
|
||||||
thumbWidth: '缩略图宽度(px)',
|
|
||||||
validation: {
|
|
||||||
required: '该项为必填项',
|
|
||||||
qualityUnique: '清晰度标识不能重复',
|
|
||||||
qualityTooLong: '清晰度标识不能超过 16 个字符',
|
|
||||||
positiveEven: '请输入大于 0 的偶数',
|
|
||||||
positiveInteger: '请输入大于 0 的整数',
|
|
||||||
range: '请输入 {min} 到 {max} 之间的整数',
|
|
||||||
atLeastOneEnabled: '至少需要启用一档清晰度',
|
|
||||||
fixErrors: '请修正标记的转码配置后再保存'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-11
@@ -11,7 +11,6 @@ import { NO_REDIRECT_WHITE_LIST } from '@/constants'
|
|||||||
import { useUserStoreWithOut } from '@/store/modules/user'
|
import { useUserStoreWithOut } from '@/store/modules/user'
|
||||||
import { getAdminRoleApi, getProfileApi } from '@/api/login'
|
import { getAdminRoleApi, getProfileApi } from '@/api/login'
|
||||||
import { landingPath } from '@/utils/landing'
|
import { landingPath } from '@/utils/landing'
|
||||||
import { supplementLocalAdminRoutes } from '@/router/localRoutes'
|
|
||||||
|
|
||||||
const { start, done } = useNProgress()
|
const { start, done } = useNProgress()
|
||||||
|
|
||||||
@@ -69,10 +68,6 @@ router.beforeEach(async (to, from, next) => {
|
|||||||
} catch {
|
} catch {
|
||||||
// 拉取失败时退回上次缓存的菜单,不阻塞进入
|
// 拉取失败时退回上次缓存的菜单,不阻塞进入
|
||||||
}
|
}
|
||||||
const permissions = Array.isArray(userStore.getUserInfo?.permissions)
|
|
||||||
? userStore.getUserInfo.permissions
|
|
||||||
: []
|
|
||||||
routers = supplementLocalAdminRoutes(routers, permissions)
|
|
||||||
await permissionStore.generateRoutes('server', routers)
|
await permissionStore.generateRoutes('server', routers)
|
||||||
} else {
|
} else {
|
||||||
await permissionStore.generateRoutes('frontEnd', roleRouters as string[])
|
await permissionStore.generateRoutes('frontEnd', roleRouters as string[])
|
||||||
@@ -96,12 +91,7 @@ router.beforeEach(async (to, from, next) => {
|
|||||||
|
|
||||||
const redirectPath = from.query.redirect || to.path
|
const redirectPath = from.query.redirect || to.path
|
||||||
const redirect = decodeURIComponent(redirectPath as string)
|
const redirect = decodeURIComponent(redirectPath as string)
|
||||||
// 只按路径重进。刷新时动态路由还没注册,先被兜底路由接住;
|
const nextData = to.path === redirect ? { ...to, replace: true } : { path: redirect }
|
||||||
// 若把当时匹配到的 name 带回去,会一直停在 404。
|
|
||||||
const nextData =
|
|
||||||
to.path === redirect
|
|
||||||
? { path: to.path, query: to.query, hash: to.hash, replace: true }
|
|
||||||
: { path: redirect, replace: true }
|
|
||||||
permissionStore.setIsAddRouters(true)
|
permissionStore.setIsAddRouters(true)
|
||||||
next(nextData)
|
next(nextData)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-54
@@ -52,35 +52,6 @@ export const constantRouterMap: AppRouteRecordRaw[] = [
|
|||||||
title: '404',
|
title: '404',
|
||||||
noTagsView: true
|
noTagsView: true
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/notifications',
|
|
||||||
component: Layout,
|
|
||||||
name: 'Notifications',
|
|
||||||
meta: {
|
|
||||||
hidden: true,
|
|
||||||
title: '通知'
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: 'transcode',
|
|
||||||
name: 'transcode-notices',
|
|
||||||
component: () => import('@/views/common/TranscodeNoticeView.vue'),
|
|
||||||
meta: {
|
|
||||||
title: '转码通知'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/:pathMatch(.*)*',
|
|
||||||
name: 'UnresolvedPath',
|
|
||||||
component: () => import('@/views/Error/404.vue'),
|
|
||||||
meta: {
|
|
||||||
hidden: true,
|
|
||||||
title: '404',
|
|
||||||
noTagsView: true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -149,15 +120,6 @@ export const asyncRouterMap: AppRouteRecordRaw[] = [
|
|||||||
meta: {
|
meta: {
|
||||||
title: '类型管理'
|
title: '类型管理'
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'media-transcode',
|
|
||||||
name: 'media-transcode',
|
|
||||||
component: () => import('@/views/systemManagement/TranscodeSettingsView.vue'),
|
|
||||||
meta: {
|
|
||||||
title: 'router.transcodeSettings',
|
|
||||||
permission: ['episode:upload']
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -240,14 +202,6 @@ export const asyncRouterMap: AppRouteRecordRaw[] = [
|
|||||||
meta: {
|
meta: {
|
||||||
title: '操作日志'
|
title: '操作日志'
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'legal-documents',
|
|
||||||
name: 'legal-documents',
|
|
||||||
component: () => import('@/views/systemManagement/LegalDocumentView.vue'),
|
|
||||||
meta: {
|
|
||||||
title: '协议设置'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -261,14 +215,7 @@ const router = createRouter({
|
|||||||
})
|
})
|
||||||
|
|
||||||
export const resetRouter = (): void => {
|
export const resetRouter = (): void => {
|
||||||
const resetWhiteNameList = [
|
const resetWhiteNameList = ['Redirect', 'RedirectParent', 'Login', 'NoFind', 'Root']
|
||||||
'Redirect',
|
|
||||||
'RedirectParent',
|
|
||||||
'Login',
|
|
||||||
'NoFind',
|
|
||||||
'Root',
|
|
||||||
'UnresolvedPath'
|
|
||||||
]
|
|
||||||
router.getRoutes().forEach((route) => {
|
router.getRoutes().forEach((route) => {
|
||||||
const { name } = route
|
const { name } = route
|
||||||
if (name && !resetWhiteNameList.includes(name as string)) {
|
if (name && !resetWhiteNameList.includes(name as string)) {
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
// Author: fruit.com.cn
|
|
||||||
|
|
||||||
import { cloneDeep } from 'lodash-es'
|
|
||||||
|
|
||||||
const TRANSCODE_PERMISSION = 'episode:upload'
|
|
||||||
const CONTENT_ROUTE_PATH = '/content'
|
|
||||||
const CONTENT_ROUTE_NAME = 'Content'
|
|
||||||
const TRANSCODE_ROUTE_NAME = 'media-transcode'
|
|
||||||
const TRANSCODE_ROUTE_PATH = 'media-transcode'
|
|
||||||
const TRANSCODE_COMPONENT = 'views/systemManagement/TranscodeSettingsView'
|
|
||||||
const TRANSCODE_TITLE_KEY = 'router.transcodeSettings'
|
|
||||||
|
|
||||||
/** 服务端菜单可能用别的路由名指向同一个组件,这里按路由名或组件路径判定是否已存在 */
|
|
||||||
const hasTranscodeRoute = (routes: AppCustomRouteRecordRaw[]): boolean => {
|
|
||||||
for (const route of routes) {
|
|
||||||
if (route.name === TRANSCODE_ROUTE_NAME || route.component === TRANSCODE_COMPONENT) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if (hasTranscodeRoute(route.children || [])) return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 服务端动态菜单未落库时,给具备内容上传权限的账号补充受控的本地转码菜单。
|
|
||||||
*/
|
|
||||||
export const supplementLocalAdminRoutes = (
|
|
||||||
routes: AppCustomRouteRecordRaw[],
|
|
||||||
permissions: string[]
|
|
||||||
): AppCustomRouteRecordRaw[] => {
|
|
||||||
if (!permissions.includes(TRANSCODE_PERMISSION)) {
|
|
||||||
return routes
|
|
||||||
}
|
|
||||||
// 服务端菜单里已经有转码设置时不再补,否则侧边栏会出现两条
|
|
||||||
if (hasTranscodeRoute(routes)) {
|
|
||||||
return routes
|
|
||||||
}
|
|
||||||
const nextRoutes = cloneDeep(routes)
|
|
||||||
const contentRoute = nextRoutes.find(
|
|
||||||
(route) => route.path === CONTENT_ROUTE_PATH || route.name === CONTENT_ROUTE_NAME
|
|
||||||
)
|
|
||||||
if (!contentRoute) {
|
|
||||||
return routes
|
|
||||||
}
|
|
||||||
contentRoute.children = contentRoute.children || []
|
|
||||||
contentRoute.children.push({
|
|
||||||
path: TRANSCODE_ROUTE_PATH,
|
|
||||||
name: TRANSCODE_ROUTE_NAME,
|
|
||||||
component: TRANSCODE_COMPONENT,
|
|
||||||
redirect: '',
|
|
||||||
meta: {
|
|
||||||
title: TRANSCODE_TITLE_KEY,
|
|
||||||
permission: [TRANSCODE_PERMISSION]
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return nextRoutes
|
|
||||||
}
|
|
||||||
@@ -47,7 +47,7 @@ export const useAppStore = defineStore('app', {
|
|||||||
breadcrumb: true, // 面包屑
|
breadcrumb: true, // 面包屑
|
||||||
breadcrumbIcon: true, // 面包屑图标
|
breadcrumbIcon: true, // 面包屑图标
|
||||||
collapse: false, // 折叠菜单
|
collapse: false, // 折叠菜单
|
||||||
uniqueOpened: true, // 是否只保持一个子菜单的展开(菜单手风琴)
|
uniqueOpened: false, // 是否只保持一个子菜单的展开
|
||||||
hamburger: true, // 折叠图标
|
hamburger: true, // 折叠图标
|
||||||
screenfull: true, // 全屏图标
|
screenfull: true, // 全屏图标
|
||||||
size: true, // 尺寸图标
|
size: true, // 尺寸图标
|
||||||
@@ -71,9 +71,9 @@ export const useAppStore = defineStore('app', {
|
|||||||
// 左侧菜单边框颜色
|
// 左侧菜单边框颜色
|
||||||
leftMenuBorderColor: 'inherit',
|
leftMenuBorderColor: 'inherit',
|
||||||
// 左侧菜单背景颜色
|
// 左侧菜单背景颜色
|
||||||
leftMenuBgColor: '#fff',
|
leftMenuBgColor: '#001529',
|
||||||
// 左侧菜单浅色背景颜色
|
// 左侧菜单浅色背景颜色
|
||||||
leftMenuBgLightColor: '#fff',
|
leftMenuBgLightColor: '#0f2438',
|
||||||
// 左侧菜单选中背景颜色
|
// 左侧菜单选中背景颜色
|
||||||
leftMenuBgActiveColor: 'var(--app-primary-strong)',
|
leftMenuBgActiveColor: 'var(--app-primary-strong)',
|
||||||
// 左侧菜单收起选中背景颜色
|
// 左侧菜单收起选中背景颜色
|
||||||
@@ -346,10 +346,8 @@ export const useAppStore = defineStore('app', {
|
|||||||
if (context.store.theme?.elColorPrimary !== '#c4322a') {
|
if (context.store.theme?.elColorPrimary !== '#c4322a') {
|
||||||
context.store.setTheme({ elColorPrimary: '#c4322a' })
|
context.store.setTheme({ elColorPrimary: '#c4322a' })
|
||||||
}
|
}
|
||||||
// 头部主题默认强制为白色、菜单主题也强制为白色
|
context.store.setMenuTheme(context.store.theme.leftMenuBgColor)
|
||||||
// 避免老用户浏览器残留其他主题色,清缓存也能恢复到项目品牌配色
|
context.store.setHeaderTheme(context.store.theme.topHeaderBgColor)
|
||||||
context.store.setHeaderTheme('#fff')
|
|
||||||
context.store.setMenuTheme('#fff')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -18,8 +18,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.app-user-toolbar .app-user-status,
|
.app-user-toolbar .app-user-status,
|
||||||
.app-user-toolbar .app-user-country,
|
.app-user-toolbar .app-user-country {
|
||||||
.app-user-toolbar .app-user-platform {
|
|
||||||
width: 150px;
|
width: 150px;
|
||||||
flex: 0 0 150px;
|
flex: 0 0 150px;
|
||||||
}
|
}
|
||||||
@@ -64,7 +63,6 @@
|
|||||||
.app-user-meta {
|
.app-user-meta {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: flex-start;
|
|
||||||
gap: 2px;
|
gap: 2px;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -147,24 +147,6 @@
|
|||||||
width: 180px !important;
|
width: 180px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.readonly-stat {
|
|
||||||
min-width: 180px;
|
|
||||||
height: 32px;
|
|
||||||
padding: 0 12px;
|
|
||||||
color: var(--el-text-color-secondary);
|
|
||||||
line-height: 32px;
|
|
||||||
background: var(--el-fill-color-lighter);
|
|
||||||
border: 1px solid var(--el-border-color-lighter);
|
|
||||||
border-radius: var(--el-border-radius-base);
|
|
||||||
}
|
|
||||||
|
|
||||||
.readonly-stat-hint {
|
|
||||||
margin: 4px 0 0;
|
|
||||||
color: var(--el-text-color-placeholder);
|
|
||||||
font-size: 12px;
|
|
||||||
line-height: 1.4;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cover-editor {
|
.cover-editor {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 18px;
|
gap: 18px;
|
||||||
|
|||||||
@@ -560,16 +560,13 @@ body {
|
|||||||
gap: 6px;
|
gap: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.drama-select,
|
.drama-select {
|
||||||
.status-select {
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
.drama-select .el-input__wrapper,
|
.drama-select .el-input__wrapper {
|
||||||
.status-select .el-input__wrapper {
|
|
||||||
box-shadow: 0 0 0 1px #efedf3 inset !important;
|
box-shadow: 0 0 0 1px #efedf3 inset !important;
|
||||||
}
|
}
|
||||||
.drama-select .el-input__inner,
|
.drama-select .el-input__inner {
|
||||||
.status-select .el-input__inner {
|
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-9
@@ -6,25 +6,23 @@
|
|||||||
|
|
||||||
--left-menu-min-width: 64px;
|
--left-menu-min-width: 64px;
|
||||||
|
|
||||||
--left-menu-bg-color: #fff;
|
--left-menu-bg-color: #17110f;
|
||||||
|
|
||||||
--left-menu-bg-light-color: #fff;
|
--left-menu-bg-light-color: #221815;
|
||||||
|
|
||||||
--left-menu-bg-active-color: rgba(196, 50, 42, 0.1);
|
--left-menu-bg-active-color: var(--app-primary-strong);
|
||||||
|
|
||||||
--left-menu-text-color: #333;
|
--left-menu-text-color: #d7cbc4;
|
||||||
|
|
||||||
--left-menu-text-active-color: var(--el-color-primary);
|
--left-menu-text-active-color: #fff;
|
||||||
|
|
||||||
--left-menu-border-color: #eee;
|
--left-menu-collapse-bg-active-color: var(--app-primary-strong);
|
||||||
|
|
||||||
--left-menu-collapse-bg-active-color: rgba(196, 50, 42, 0.1);
|
|
||||||
/* left menu end */
|
/* left menu end */
|
||||||
|
|
||||||
/* logo start */
|
/* logo start */
|
||||||
--logo-height: 50px;
|
--logo-height: 50px;
|
||||||
|
|
||||||
--logo-title-text-color: #303133;
|
--logo-title-text-color: #fff;
|
||||||
/* logo end */
|
/* logo end */
|
||||||
|
|
||||||
/* header start */
|
/* header start */
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
// Author: fruit.com.cn
|
|
||||||
|
|
||||||
const SEEN_KEY = 'transcode-notice-seen'
|
|
||||||
|
|
||||||
export const TRANSCODE_NOTICE_SEEN = 'transcode-notice-seen'
|
|
||||||
|
|
||||||
export interface NoticeCounts {
|
|
||||||
running: number
|
|
||||||
success: number
|
|
||||||
failed: number
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 上次打开通知页时已经看过的数量。 */
|
|
||||||
export function readSeen(): NoticeCounts {
|
|
||||||
try {
|
|
||||||
const raw = localStorage.getItem(SEEN_KEY)
|
|
||||||
if (!raw) return { running: 0, success: 0, failed: 0 }
|
|
||||||
const data = JSON.parse(raw) as NoticeCounts
|
|
||||||
return {
|
|
||||||
running: Number(data.running || 0),
|
|
||||||
success: Number(data.success || 0),
|
|
||||||
failed: Number(data.failed || 0)
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
return { running: 0, success: 0, failed: 0 }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 比上次查看多出来的数量,看过的不再计入角标。 */
|
|
||||||
export function unreadCounts(current: NoticeCounts): NoticeCounts {
|
|
||||||
const seen = readSeen()
|
|
||||||
return {
|
|
||||||
running: Math.max(0, current.running - seen.running),
|
|
||||||
success: Math.max(0, current.success - seen.success),
|
|
||||||
failed: Math.max(0, current.failed - seen.failed)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 把当前数量记为已读,并通知顶栏收起角标。 */
|
|
||||||
export function markTranscodeNoticeSeen(current: NoticeCounts) {
|
|
||||||
const seen = readSeen()
|
|
||||||
localStorage.setItem(
|
|
||||||
SEEN_KEY,
|
|
||||||
JSON.stringify({
|
|
||||||
running: Math.max(seen.running, current.running),
|
|
||||||
success: Math.max(seen.success, current.success),
|
|
||||||
failed: Math.max(seen.failed, current.failed)
|
|
||||||
})
|
|
||||||
)
|
|
||||||
window.dispatchEvent(new Event(TRANSCODE_NOTICE_SEEN))
|
|
||||||
}
|
|
||||||
+11
-146
@@ -31,94 +31,6 @@ const themeChange = () => {
|
|||||||
<img src="@/assets/imgs/brand-mark.png" alt="" />
|
<img src="@/assets/imgs/brand-mark.png" alt="" />
|
||||||
<span>{{ underlineToHump(appStore.getTitle) }}</span>
|
<span>{{ underlineToHump(appStore.getTitle) }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="hero-fruits" aria-hidden="true">
|
|
||||||
<svg class="fruit cherry" viewBox="0 0 120 140">
|
|
||||||
<path
|
|
||||||
d="M62 38c8-16 24-24 36-22"
|
|
||||||
fill="none"
|
|
||||||
stroke="#7d9a62"
|
|
||||||
stroke-width="3"
|
|
||||||
stroke-linecap="round"
|
|
||||||
/>
|
|
||||||
<path
|
|
||||||
d="M58 40c2-18-8-30-6-36"
|
|
||||||
fill="none"
|
|
||||||
stroke="#6d8a55"
|
|
||||||
stroke-width="3"
|
|
||||||
stroke-linecap="round"
|
|
||||||
/>
|
|
||||||
<ellipse
|
|
||||||
cx="34"
|
|
||||||
cy="28"
|
|
||||||
rx="14"
|
|
||||||
ry="7"
|
|
||||||
fill="#8fb56f"
|
|
||||||
transform="rotate(-28 34 28)"
|
|
||||||
/>
|
|
||||||
<circle cx="42" cy="78" r="28" fill="#c4322a" />
|
|
||||||
<circle cx="78" cy="86" r="26" fill="#a82822" />
|
|
||||||
<circle cx="32" cy="68" r="8" fill="#fff" opacity=".28" />
|
|
||||||
</svg>
|
|
||||||
<svg class="fruit mango" viewBox="0 0 150 170">
|
|
||||||
<path d="M78 28c18 2 28 8 34 16-22 4-36 2-48-8 4-4 8-8 14-8z" fill="#6d8a55" />
|
|
||||||
<path
|
|
||||||
d="M86 36c6-16 2-24-2-28"
|
|
||||||
fill="none"
|
|
||||||
stroke="#5f7a4c"
|
|
||||||
stroke-width="3"
|
|
||||||
stroke-linecap="round"
|
|
||||||
/>
|
|
||||||
<path
|
|
||||||
d="M46 58c-18 28-16 62 8 84 28 24 62 10 74-16 14-30 4-62-16-80-18-16-46-10-66 12z"
|
|
||||||
fill="#f0b429"
|
|
||||||
/>
|
|
||||||
<path
|
|
||||||
d="M58 78c8 22 10 40 4 58"
|
|
||||||
fill="none"
|
|
||||||
stroke="#ffe08a"
|
|
||||||
stroke-width="8"
|
|
||||||
stroke-linecap="round"
|
|
||||||
opacity=".55"
|
|
||||||
/>
|
|
||||||
<ellipse
|
|
||||||
cx="62"
|
|
||||||
cy="86"
|
|
||||||
rx="14"
|
|
||||||
ry="22"
|
|
||||||
fill="#fff"
|
|
||||||
opacity=".2"
|
|
||||||
transform="rotate(-24 62 86)"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
<svg class="fruit banana" viewBox="0 0 160 150">
|
|
||||||
<path
|
|
||||||
d="M28 108c18-46 48-74 92-86 8 10 10 22 4 34-28 10-50 28-66 58-6 12-16 16-30 12-8-2-12-10 0-18z"
|
|
||||||
fill="#f2d34b"
|
|
||||||
/>
|
|
||||||
<path
|
|
||||||
d="M36 102c16-38 42-62 80-74"
|
|
||||||
fill="none"
|
|
||||||
stroke="#ffe98a"
|
|
||||||
stroke-width="7"
|
|
||||||
stroke-linecap="round"
|
|
||||||
opacity=".7"
|
|
||||||
/>
|
|
||||||
<path
|
|
||||||
d="M118 24c8 2 14 10 12 16"
|
|
||||||
fill="none"
|
|
||||||
stroke="#6d8a55"
|
|
||||||
stroke-width="4"
|
|
||||||
stroke-linecap="round"
|
|
||||||
/>
|
|
||||||
<path
|
|
||||||
d="M30 112c-6 8-4 16 4 16"
|
|
||||||
fill="none"
|
|
||||||
stroke="#c9a227"
|
|
||||||
stroke-width="4"
|
|
||||||
stroke-linecap="round"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
<div class="hero-copy">
|
<div class="hero-copy">
|
||||||
<p class="hero-kicker">{{ t('login.consoleLabel') }}</p>
|
<p class="hero-kicker">{{ t('login.consoleLabel') }}</p>
|
||||||
<h1>{{ t('login.welcome') }}</h1>
|
<h1>{{ t('login.welcome') }}</h1>
|
||||||
@@ -169,58 +81,16 @@ const themeChange = () => {
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|
||||||
&::before,
|
|
||||||
&::after {
|
&::after {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
border: 1px solid rgb(255 255 255 / 12%);
|
right: -80px;
|
||||||
|
bottom: -120px;
|
||||||
|
width: 360px;
|
||||||
|
height: 360px;
|
||||||
|
border: 1px solid rgb(255 255 255 / 16%);
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
content: '';
|
content: '';
|
||||||
}
|
}
|
||||||
|
|
||||||
&::before {
|
|
||||||
top: -140px;
|
|
||||||
left: -80px;
|
|
||||||
width: 420px;
|
|
||||||
height: 420px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&::after {
|
|
||||||
right: -120px;
|
|
||||||
bottom: -160px;
|
|
||||||
width: 460px;
|
|
||||||
height: 460px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero-fruits {
|
|
||||||
position: absolute;
|
|
||||||
inset: 0;
|
|
||||||
z-index: 0;
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.fruit {
|
|
||||||
position: absolute;
|
|
||||||
filter: drop-shadow(0 18px 24px rgb(0 0 0 / 28%));
|
|
||||||
}
|
|
||||||
|
|
||||||
.cherry {
|
|
||||||
top: 16%;
|
|
||||||
right: 14%;
|
|
||||||
width: 150px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mango {
|
|
||||||
top: 30%;
|
|
||||||
left: 38%;
|
|
||||||
width: 210px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.banana {
|
|
||||||
top: 54%;
|
|
||||||
left: 12%;
|
|
||||||
width: 200px;
|
|
||||||
transform: rotate(-8deg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.hero-brand {
|
.hero-brand {
|
||||||
@@ -243,14 +113,13 @@ const themeChange = () => {
|
|||||||
.hero-copy {
|
.hero-copy {
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
max-width: 420px;
|
max-width: 460px;
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
margin: 12px 0 0;
|
margin: 10px 0 12px;
|
||||||
font-size: 44px;
|
font-size: 40px;
|
||||||
font-weight: 600;
|
font-weight: 700;
|
||||||
line-height: 1.15;
|
line-height: 1.2;
|
||||||
letter-spacing: -0.03em;
|
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -322,12 +191,8 @@ const themeChange = () => {
|
|||||||
padding: 16px 24px 20px;
|
padding: 16px 24px 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hero-fruits {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero-copy h1 {
|
.hero-copy h1 {
|
||||||
margin: 6px 0 0;
|
margin: 6px 0 8px;
|
||||||
font-size: 28px;
|
font-size: 28px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
import { reactive, ref, watch, onMounted, unref } from 'vue'
|
import { reactive, ref, watch, onMounted, unref } from 'vue'
|
||||||
import { Form, FormSchema } from '@/components/Form'
|
import { Form, FormSchema } from '@/components/Form'
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
import { ElCheckbox, ElLink, ElMessage } from 'element-plus'
|
import { ElCheckbox, ElLink } from 'element-plus'
|
||||||
import { useForm } from '@/hooks/web/useForm'
|
import { useForm } from '@/hooks/web/useForm'
|
||||||
import { loginApi, getAdminRoleApi } from '@/api/login'
|
import { loginApi, getAdminRoleApi } from '@/api/login'
|
||||||
import { useAppStore } from '@/store/modules/app'
|
import { useAppStore } from '@/store/modules/app'
|
||||||
@@ -92,11 +92,7 @@ const schema = reactive<FormSchema[]>([
|
|||||||
<>
|
<>
|
||||||
<div class="flex justify-between items-center w-[100%]">
|
<div class="flex justify-between items-center w-[100%]">
|
||||||
<ElCheckbox v-model={remember.value} label={t('login.remember')} size="small" />
|
<ElCheckbox v-model={remember.value} label={t('login.remember')} size="small" />
|
||||||
<ElLink
|
<ElLink type="primary" underline={false}>
|
||||||
type="primary"
|
|
||||||
underline={false}
|
|
||||||
onClick={() => ElMessage.info(t('login.forgetPasswordHint'))}
|
|
||||||
>
|
|
||||||
{t('login.forgetPassword')}
|
{t('login.forgetPassword')}
|
||||||
</ElLink>
|
</ElLink>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ import { computed, onMounted, ref } from 'vue'
|
|||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { AppIcons } from '@/constants/icons'
|
import { AppIcons } from '@/constants/icons'
|
||||||
import { pageDramasApi } from '@/api/admin/drama'
|
import { pageDramasApi } from '@/api/admin/drama'
|
||||||
import { getDashboardOverviewApi, getDashboardTrendApi } from '@/api/admin/dashboard'
|
|
||||||
import DashboardMetricWall from '@/views/dashboard/DashboardMetricWall.vue'
|
|
||||||
import { useRbac } from '@/stores/rbac'
|
import { useRbac } from '@/stores/rbac'
|
||||||
import { formatCount } from '@/utils/format'
|
import { formatCount } from '@/utils/format'
|
||||||
import { statusClass } from '@/utils/status'
|
import { statusClass } from '@/utils/status'
|
||||||
@@ -17,8 +15,6 @@ const { can } = useRbac()
|
|||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const dramas = ref([])
|
const dramas = ref([])
|
||||||
const total = ref(0)
|
const total = ref(0)
|
||||||
const overview = ref(null)
|
|
||||||
const trend = ref(null)
|
|
||||||
|
|
||||||
const totalViews = computed(() =>
|
const totalViews = computed(() =>
|
||||||
dramas.value.reduce((sum, item) => sum + Number(item.views || 0), 0)
|
dramas.value.reduce((sum, item) => sum + Number(item.views || 0), 0)
|
||||||
@@ -29,12 +25,6 @@ const reviewingCount = computed(
|
|||||||
const publishedCount = computed(
|
const publishedCount = computed(
|
||||||
() => dramas.value.filter((item) => item.status === 'published').length
|
() => dramas.value.filter((item) => item.status === 'published').length
|
||||||
)
|
)
|
||||||
const metricFallback = computed(() => ({
|
|
||||||
'content.dramaTotal': total.value,
|
|
||||||
'content.dramaReviewing': reviewingCount.value,
|
|
||||||
'content.dramaPublished': publishedCount.value,
|
|
||||||
'playback.viewTotal': totalViews.value
|
|
||||||
}))
|
|
||||||
const recentDramas = computed(() =>
|
const recentDramas = computed(() =>
|
||||||
[...dramas.value]
|
[...dramas.value]
|
||||||
.sort((a, b) => String(b.updatedAt || '').localeCompare(String(a.updatedAt || '')))
|
.sort((a, b) => String(b.updatedAt || '').localeCompare(String(a.updatedAt || '')))
|
||||||
@@ -44,16 +34,10 @@ const recentDramas = computed(() =>
|
|||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
const [res, board, trendRes] = await Promise.all([
|
const res = await pageDramasApi({ pageIndex: 1, pageSize: 200 })
|
||||||
pageDramasApi({ pageIndex: 1, pageSize: 200 }),
|
|
||||||
getDashboardOverviewApi().catch(() => null),
|
|
||||||
getDashboardTrendApi().catch(() => null)
|
|
||||||
])
|
|
||||||
// 接口失败时 axios 拦截器会把业务错误吞成 undefined,这里不能让页面跟着崩
|
// 接口失败时 axios 拦截器会把业务错误吞成 undefined,这里不能让页面跟着崩
|
||||||
dramas.value = res?.data?.list || []
|
dramas.value = res?.data?.list || []
|
||||||
total.value = res?.data?.total || 0
|
total.value = res?.data?.total || 0
|
||||||
overview.value = board?.data || null
|
|
||||||
trend.value = trendRes?.data || null
|
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
@@ -61,11 +45,8 @@ onMounted(async () => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="workbench">
|
|
||||||
<div class="page-heading"
|
<div class="page-heading"
|
||||||
><div
|
><div><div class="eyebrow">内容概览</div><h1>工作台</h1><p>查看短剧内容与近期处理事项。</p></div
|
||||||
><div class="eyebrow">内容概览</div><h1>工作台</h1
|
|
||||||
><p>用户、设备、留存与短剧内容总览。</p></div
|
|
||||||
><el-button
|
><el-button
|
||||||
v-if="can('drama:create')"
|
v-if="can('drama:create')"
|
||||||
type="primary"
|
type="primary"
|
||||||
@@ -74,12 +55,32 @@ onMounted(async () => {
|
|||||||
><AppIcon :icon="AppIcons.add" />上传新短剧</el-button
|
><AppIcon :icon="AppIcons.add" />上传新短剧</el-button
|
||||||
></div
|
></div
|
||||||
>
|
>
|
||||||
<DashboardMetricWall
|
<div v-loading="loading" class="stats-grid">
|
||||||
v-loading="loading"
|
<div class="stat-card"
|
||||||
:overview="overview"
|
><div class="stat-top"
|
||||||
:trend="trend"
|
><span>短剧总数</span
|
||||||
:fallback="metricFallback"
|
><span class="stat-icon"><AppIcon :icon="AppIcons.content" /></span></div
|
||||||
/>
|
><div class="stat-value">{{ total }} <small>部</small></div></div
|
||||||
|
>
|
||||||
|
<div class="stat-card"
|
||||||
|
><div class="stat-top"
|
||||||
|
><span>累计播放量</span
|
||||||
|
><span class="stat-icon"><AppIcon :icon="AppIcons.videoPlay" /></span></div
|
||||||
|
><div class="stat-value">{{ formatCount(totalViews) }}</div></div
|
||||||
|
>
|
||||||
|
<div class="stat-card"
|
||||||
|
><div class="stat-top"
|
||||||
|
><span>待审核内容</span
|
||||||
|
><span class="stat-icon"><AppIcon :icon="AppIcons.clock" /></span></div
|
||||||
|
><div class="stat-value">{{ reviewingCount }} <small>项</small></div></div
|
||||||
|
>
|
||||||
|
<div class="stat-card"
|
||||||
|
><div class="stat-top"
|
||||||
|
><span>已上线</span
|
||||||
|
><span class="stat-icon"><AppIcon :icon="AppIcons.checkCircle" /></span></div
|
||||||
|
><div class="stat-value">{{ publishedCount }} <small>部</small></div></div
|
||||||
|
>
|
||||||
|
</div>
|
||||||
<section class="panel recent-panel"
|
<section class="panel recent-panel"
|
||||||
><div class="panel-heading"
|
><div class="panel-heading"
|
||||||
><div><h2>最近更新</h2><p>短剧内容与发布状态</p></div
|
><div><h2>最近更新</h2><p>短剧内容与发布状态</p></div
|
||||||
@@ -99,9 +100,7 @@ onMounted(async () => {
|
|||||||
width="150" /><el-table-column label="集数" width="120"
|
width="150" /><el-table-column label="集数" width="120"
|
||||||
><template #default="scope">{{ scope?.row?.episodes }} 集</template></el-table-column
|
><template #default="scope">{{ scope?.row?.episodes }} 集</template></el-table-column
|
||||||
><el-table-column label="播放量" width="140"
|
><el-table-column label="播放量" width="140"
|
||||||
><template #default="scope">{{
|
><template #default="scope">{{ formatCount(scope?.row?.views) }}</template></el-table-column
|
||||||
formatCount(scope?.row?.views)
|
|
||||||
}}</template></el-table-column
|
|
||||||
><el-table-column label="状态" width="130"
|
><el-table-column label="状态" width="130"
|
||||||
><template #default="scope"
|
><template #default="scope"
|
||||||
><el-tag
|
><el-tag
|
||||||
@@ -114,30 +113,4 @@ onMounted(async () => {
|
|||||||
><el-table-column prop="updatedAt" label="更新时间" width="180"
|
><el-table-column prop="updatedAt" label="更新时间" width="180"
|
||||||
/></el-table>
|
/></el-table>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.workbench {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.workbench .page-heading {
|
|
||||||
flex: none;
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.workbench :deep(.screen) {
|
|
||||||
flex: 1;
|
|
||||||
min-height: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.recent-panel {
|
|
||||||
flex: none;
|
|
||||||
max-height: 220px;
|
|
||||||
margin-top: 12px;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,100 +0,0 @@
|
|||||||
<!-- Author: fruit.com.cn -->
|
|
||||||
<!-- 转码通知页:按转码中、成功、失败查看短剧和集数。 -->
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { computed, onMounted, ref } from 'vue'
|
|
||||||
import PageHeading from '@/views/components/PageHeading.vue'
|
|
||||||
import {
|
|
||||||
getTranscodeNoticesApi,
|
|
||||||
type TranscodeNotice,
|
|
||||||
type TranscodeNoticeItem
|
|
||||||
} from '@/api/admin/transcodeNotice'
|
|
||||||
import { formatDateTime } from '@/utils/format'
|
|
||||||
import { markTranscodeNoticeSeen } from '@/utils/transcodeNoticeSeen'
|
|
||||||
|
|
||||||
const loading = ref(false)
|
|
||||||
const tab = ref('RUNNING')
|
|
||||||
const notice = ref<TranscodeNotice | null>(null)
|
|
||||||
|
|
||||||
const rows = computed<TranscodeNoticeItem[]>(() => {
|
|
||||||
if (tab.value === 'SUCCESS') return notice.value?.successList || []
|
|
||||||
if (tab.value === 'FAILED') return notice.value?.failedList || []
|
|
||||||
return notice.value?.runningList || []
|
|
||||||
})
|
|
||||||
|
|
||||||
function episodeText(row: TranscodeNoticeItem) {
|
|
||||||
const no = row.episodeNo ? `第${row.episodeNo}集` : ''
|
|
||||||
if (!row.episodeTitle || row.episodeTitle === no) return no || '集数未知'
|
|
||||||
return no ? `${no} ${row.episodeTitle}` : row.episodeTitle
|
|
||||||
}
|
|
||||||
|
|
||||||
async function load() {
|
|
||||||
loading.value = true
|
|
||||||
try {
|
|
||||||
const res = await getTranscodeNoticesApi()
|
|
||||||
notice.value = res.data || null
|
|
||||||
if (notice.value) {
|
|
||||||
markTranscodeNoticeSeen({
|
|
||||||
running: Number(notice.value.running || 0),
|
|
||||||
success: Number(notice.value.success || 0),
|
|
||||||
failed: Number(notice.value.failed || 0)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(load)
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<PageHeading
|
|
||||||
eyebrow="通知"
|
|
||||||
title="转码通知"
|
|
||||||
description="查看转码中、转码成功和转码失败的短剧与集数。"
|
|
||||||
>
|
|
||||||
<el-button :loading="loading" @click="load">刷新</el-button>
|
|
||||||
</PageHeading>
|
|
||||||
|
|
||||||
<section class="panel notice-panel">
|
|
||||||
<el-tabs v-model="tab">
|
|
||||||
<el-tab-pane label="转码中" name="RUNNING" />
|
|
||||||
<el-tab-pane label="转码成功" name="SUCCESS" />
|
|
||||||
<el-tab-pane label="转码失败" name="FAILED" />
|
|
||||||
</el-tabs>
|
|
||||||
|
|
||||||
<el-table
|
|
||||||
v-loading="loading"
|
|
||||||
:data="rows"
|
|
||||||
row-key="id"
|
|
||||||
border
|
|
||||||
class="drama-el-table"
|
|
||||||
empty-text="暂无通知"
|
|
||||||
>
|
|
||||||
<el-table-column prop="dramaTitle" label="短剧" min-width="220" show-overflow-tooltip />
|
|
||||||
<el-table-column label="集数" min-width="180" show-overflow-tooltip>
|
|
||||||
<template #default="{ row }">{{ episodeText(row) }}</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="进度" width="100">
|
|
||||||
<template #default="{ row }">{{ row.progress ?? 0 }}%</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column
|
|
||||||
v-if="tab === 'FAILED'"
|
|
||||||
prop="errorMsg"
|
|
||||||
label="失败原因"
|
|
||||||
min-width="220"
|
|
||||||
show-overflow-tooltip
|
|
||||||
/>
|
|
||||||
<el-table-column label="更新时间" width="180">
|
|
||||||
<template #default="{ row }">{{ formatDateTime(row.updatedAt) }}</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
</section>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.notice-panel {
|
|
||||||
padding: 8px 16px 16px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
<!-- Author: fruit.com.cn -->
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import { computed } from 'vue'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 后台各列表共用的「用户」单元格。
|
|
||||||
*
|
|
||||||
* 口径:已登录显示昵称 + `UID xxx`;未登录显示「游客」标签 + `设备 xxx`。
|
|
||||||
* 两行都带标签,避免一串随机字母看不出是什么。平台由独立的「系统」列展示。
|
|
||||||
*/
|
|
||||||
const props = defineProps({
|
|
||||||
row: { type: Object, required: true }
|
|
||||||
})
|
|
||||||
|
|
||||||
const isGuest = computed(() => props.row?.userId == null)
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="app-user-meta">
|
|
||||||
<template v-if="isGuest">
|
|
||||||
<el-tag type="info" size="small">游客</el-tag>
|
|
||||||
<span class="app-user-uid app-user-device" :title="row.deviceId || ''">
|
|
||||||
设备: {{ row.deviceId || '—' }}
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<span class="app-user-name" :title="row.nickname || ''">
|
|
||||||
昵称: {{ row.nickname || '未设置昵称' }}
|
|
||||||
</span>
|
|
||||||
<span class="app-user-uid">UID: {{ row.uid || `#${row.userId}` }}</span>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.app-user-device {
|
|
||||||
max-width: 150px;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
<!-- 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', 'update:locales'])
|
|
||||||
|
|
||||||
function changeLanguages(codes) {
|
|
||||||
const next = codes.includes('zh') ? codes : ['zh', ...codes]
|
|
||||||
const locales = { ...props.locales }
|
|
||||||
next.forEach((code) => {
|
|
||||||
if (locales[code] == null) locales[code] = ''
|
|
||||||
})
|
|
||||||
emit('update:locales', locales)
|
|
||||||
emit('update:languages', next)
|
|
||||||
}
|
|
||||||
|
|
||||||
function changeLocale(code, value) {
|
|
||||||
emit('update:locales', { ...props.locales, [code]: value })
|
|
||||||
}
|
|
||||||
</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"
|
|
||||||
:model-value="locales[code]"
|
|
||||||
@update:model-value="changeLocale(code, $event)"
|
|
||||||
:maxlength="maxlength"
|
|
||||||
:placeholder="'请填写' + languageLabel(code) + label"
|
|
||||||
/>
|
|
||||||
<el-input
|
|
||||||
v-else
|
|
||||||
:model-value="locales[code]"
|
|
||||||
@update:model-value="changeLocale(code, $event)"
|
|
||||||
type="textarea"
|
|
||||||
:rows="2"
|
|
||||||
:maxlength="maxlength"
|
|
||||||
show-word-limit
|
|
||||||
:placeholder="'请填写' + languageLabel(code) + label"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</template>
|
|
||||||
@@ -1,451 +0,0 @@
|
|||||||
<!-- Author: fruit.com.cn -->
|
|
||||||
<!-- 分类管理:运营自定义分类(与「类型」是两个概念),并关联任意多部短剧 -->
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import { computed, onMounted, reactive, ref } from 'vue'
|
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
||||||
import { AppIcon } from '@/components/AppIcon'
|
|
||||||
import { AppIcons } from '@/constants/icons'
|
|
||||||
import {
|
|
||||||
languageCodes,
|
|
||||||
languageLabel,
|
|
||||||
localesFromColumns,
|
|
||||||
payloadLocales
|
|
||||||
} from '@/constants/contentLanguages'
|
|
||||||
import {
|
|
||||||
bindClassificationDramasApi,
|
|
||||||
createClassificationApi,
|
|
||||||
deleteClassificationApi,
|
|
||||||
listClassificationDramaCandidatesApi,
|
|
||||||
listClassificationDramasApi,
|
|
||||||
listClassificationsApi,
|
|
||||||
unbindClassificationDramaApi,
|
|
||||||
updateClassificationApi
|
|
||||||
} from '@/api/admin/dramaClassification'
|
|
||||||
import { statusClass } from '@/utils/status'
|
|
||||||
import { useRbac } from '@/stores/rbac'
|
|
||||||
import ClassificationDramaDialogs from './ClassificationDramaDialogs.vue'
|
|
||||||
import ClassificationSideList from './ClassificationSideList.vue'
|
|
||||||
import PageHeading from '@/views/components/PageHeading.vue'
|
|
||||||
|
|
||||||
const { can } = useRbac()
|
|
||||||
|
|
||||||
const STATUS_TEXT = {
|
|
||||||
draft: '草稿',
|
|
||||||
reviewing: '审核中',
|
|
||||||
approved: '待发布',
|
|
||||||
published: '已上线',
|
|
||||||
offline: '已下线'
|
|
||||||
}
|
|
||||||
|
|
||||||
const classifications = ref([])
|
|
||||||
const activeId = ref(null)
|
|
||||||
const activeClassification = computed(
|
|
||||||
() => classifications.value.find((item) => item.id === activeId.value) || null
|
|
||||||
)
|
|
||||||
|
|
||||||
const loading = ref(false)
|
|
||||||
const dramas = ref([])
|
|
||||||
const total = ref(0)
|
|
||||||
const pageIndex = ref(1)
|
|
||||||
const pageSize = ref(10)
|
|
||||||
const keyword = ref('')
|
|
||||||
|
|
||||||
const dialogVisible = ref(false)
|
|
||||||
const saving = ref(false)
|
|
||||||
const editingId = ref(null)
|
|
||||||
const languages = ref(['zh'])
|
|
||||||
const emptyForm = () => ({ locales: { zh: '' }, sort: 1, status: 1 })
|
|
||||||
const form = reactive(emptyForm())
|
|
||||||
|
|
||||||
const candidateVisible = ref(false)
|
|
||||||
const candidateLoading = ref(false)
|
|
||||||
const candidates = ref([])
|
|
||||||
const candidateTotal = ref(0)
|
|
||||||
const candidatePage = ref(1)
|
|
||||||
const candidatePageSize = ref(10)
|
|
||||||
const candidateKeyword = ref('')
|
|
||||||
const selectedDramas = ref([])
|
|
||||||
const binding = ref(false)
|
|
||||||
|
|
||||||
async function loadClassifications() {
|
|
||||||
const res = await listClassificationsApi()
|
|
||||||
classifications.value = res.data || []
|
|
||||||
if (activeId.value && !classifications.value.some((item) => item.id === activeId.value)) {
|
|
||||||
activeId.value = classifications.value[0]?.id ?? null
|
|
||||||
}
|
|
||||||
if (!activeId.value) {
|
|
||||||
activeId.value = classifications.value[0]?.id ?? null
|
|
||||||
}
|
|
||||||
await loadDramas()
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadDramas() {
|
|
||||||
if (!activeId.value) {
|
|
||||||
dramas.value = []
|
|
||||||
total.value = 0
|
|
||||||
return
|
|
||||||
}
|
|
||||||
loading.value = true
|
|
||||||
try {
|
|
||||||
const res = await listClassificationDramasApi(activeId.value, {
|
|
||||||
keyword: keyword.value || undefined,
|
|
||||||
pageIndex: pageIndex.value,
|
|
||||||
pageSize: pageSize.value
|
|
||||||
})
|
|
||||||
dramas.value = res.data?.list || []
|
|
||||||
total.value = res.data?.total || 0
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function selectClassification(row) {
|
|
||||||
if (activeId.value === row.id) return
|
|
||||||
activeId.value = row.id
|
|
||||||
pageIndex.value = 1
|
|
||||||
keyword.value = ''
|
|
||||||
loadDramas()
|
|
||||||
}
|
|
||||||
|
|
||||||
function search() {
|
|
||||||
pageIndex.value = 1
|
|
||||||
loadDramas()
|
|
||||||
}
|
|
||||||
|
|
||||||
function changePage(value) {
|
|
||||||
pageIndex.value = value
|
|
||||||
loadDramas()
|
|
||||||
}
|
|
||||||
|
|
||||||
function openCreate() {
|
|
||||||
editingId.value = null
|
|
||||||
languages.value = ['zh']
|
|
||||||
const maxSort = classifications.value.reduce((max, item) => Math.max(max, item.sort || 0), 0)
|
|
||||||
Object.assign(form, emptyForm(), { sort: maxSort + 1 })
|
|
||||||
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,
|
|
||||||
sort: row.sort ?? 0,
|
|
||||||
status: row.status ?? 1
|
|
||||||
})
|
|
||||||
dialogVisible.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
async function saveClassification() {
|
|
||||||
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
|
|
||||||
try {
|
|
||||||
const payload = {
|
|
||||||
name: locales.zh,
|
|
||||||
locales,
|
|
||||||
sort: form.sort,
|
|
||||||
status: form.status
|
|
||||||
}
|
|
||||||
if (editingId.value) {
|
|
||||||
await updateClassificationApi(editingId.value, payload)
|
|
||||||
ElMessage.success('分类已更新')
|
|
||||||
} else {
|
|
||||||
const res = await createClassificationApi(payload)
|
|
||||||
activeId.value = res.data
|
|
||||||
pageIndex.value = 1
|
|
||||||
ElMessage.success('分类已创建')
|
|
||||||
}
|
|
||||||
dialogVisible.value = false
|
|
||||||
await loadClassifications()
|
|
||||||
} finally {
|
|
||||||
saving.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function confirmDelete(row) {
|
|
||||||
try {
|
|
||||||
await ElMessageBox.confirm(
|
|
||||||
`确定删除分类「${row.name}」吗?关联关系会一起删除,短剧本身不受影响。`,
|
|
||||||
'删除确认',
|
|
||||||
{ confirmButtonText: '确认删除', cancelButtonText: '取消', type: 'warning' }
|
|
||||||
)
|
|
||||||
} catch {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
await deleteClassificationApi(row.id)
|
|
||||||
if (activeId.value === row.id) {
|
|
||||||
activeId.value = null
|
|
||||||
}
|
|
||||||
ElMessage.success('分类已删除')
|
|
||||||
await loadClassifications()
|
|
||||||
}
|
|
||||||
|
|
||||||
async function removeDrama(row) {
|
|
||||||
try {
|
|
||||||
await ElMessageBox.confirm(
|
|
||||||
`确定把「${row.title}」从「${activeClassification.value?.name}」移出吗?`,
|
|
||||||
'移除确认',
|
|
||||||
{ confirmButtonText: '确认移出', cancelButtonText: '取消', type: 'warning' }
|
|
||||||
)
|
|
||||||
} catch {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
await unbindClassificationDramaApi(activeId.value, row.id)
|
|
||||||
ElMessage.success('已移出')
|
|
||||||
await Promise.all([loadDramas(), loadClassifications()])
|
|
||||||
}
|
|
||||||
|
|
||||||
function openCandidates() {
|
|
||||||
candidateVisible.value = true
|
|
||||||
candidatePage.value = 1
|
|
||||||
candidateKeyword.value = ''
|
|
||||||
selectedDramas.value = []
|
|
||||||
loadCandidates()
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadCandidates() {
|
|
||||||
if (!activeId.value) return
|
|
||||||
candidateLoading.value = true
|
|
||||||
try {
|
|
||||||
const res = await listClassificationDramaCandidatesApi(activeId.value, {
|
|
||||||
keyword: candidateKeyword.value || undefined,
|
|
||||||
pageIndex: candidatePage.value,
|
|
||||||
pageSize: candidatePageSize.value
|
|
||||||
})
|
|
||||||
candidates.value = res.data?.list || []
|
|
||||||
candidateTotal.value = res.data?.total || 0
|
|
||||||
} finally {
|
|
||||||
candidateLoading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function candidateSearch() {
|
|
||||||
candidatePage.value = 1
|
|
||||||
loadCandidates()
|
|
||||||
}
|
|
||||||
|
|
||||||
function changeCandidatePage(value) {
|
|
||||||
candidatePage.value = value
|
|
||||||
loadCandidates()
|
|
||||||
}
|
|
||||||
|
|
||||||
function onSelectionChange(rows) {
|
|
||||||
selectedDramas.value = rows
|
|
||||||
}
|
|
||||||
|
|
||||||
async function confirmBind() {
|
|
||||||
if (!selectedDramas.value.length) {
|
|
||||||
ElMessage.warning('请先选择要关联的短剧')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
binding.value = true
|
|
||||||
try {
|
|
||||||
const res = await bindClassificationDramasApi(
|
|
||||||
activeId.value,
|
|
||||||
selectedDramas.value.map((item) => item.id)
|
|
||||||
)
|
|
||||||
ElMessage.success(`已关联 ${res.data ?? selectedDramas.value.length} 部短剧`)
|
|
||||||
candidateVisible.value = false
|
|
||||||
await Promise.all([loadDramas(), loadClassifications()])
|
|
||||||
} finally {
|
|
||||||
binding.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatTime(value) {
|
|
||||||
if (!value) return '—'
|
|
||||||
return String(value).replace('T', ' ').slice(0, 19)
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(loadClassifications)
|
|
||||||
</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>
|
|
||||||
|
|
||||||
<div class="classification-layout">
|
|
||||||
<ClassificationSideList
|
|
||||||
:classifications="classifications"
|
|
||||||
:active-id="activeId"
|
|
||||||
@select="selectClassification"
|
|
||||||
@edit="openEdit"
|
|
||||||
@remove="confirmDelete"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<section class="panel classification-layout__main">
|
|
||||||
<div class="classification-toolbar">
|
|
||||||
<div class="classification-toolbar__title">
|
|
||||||
{{ activeClassification?.name || '请选择分类' }}
|
|
||||||
<small>共 {{ total }} 部关联短剧</small>
|
|
||||||
</div>
|
|
||||||
<div class="classification-toolbar__search">
|
|
||||||
<el-input
|
|
||||||
v-model="keyword"
|
|
||||||
placeholder="搜索短剧名称"
|
|
||||||
clearable
|
|
||||||
style="width: 200px"
|
|
||||||
@keyup.enter="search"
|
|
||||||
@clear="search"
|
|
||||||
/>
|
|
||||||
<el-button type="primary" plain @click="search">查询</el-button>
|
|
||||||
<el-button v-if="can('drama:update')" :disabled="!activeId" @click="openCandidates">
|
|
||||||
<AppIcon :icon="AppIcons.add" />
|
|
||||||
添加短剧
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<el-table
|
|
||||||
v-loading="loading"
|
|
||||||
:data="dramas"
|
|
||||||
row-key="id"
|
|
||||||
border
|
|
||||||
class="drama-el-table"
|
|
||||||
empty-text="该分类下还没有关联短剧"
|
|
||||||
>
|
|
||||||
<el-table-column label="封面" width="88">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<img v-if="row.cover" :src="row.cover" class="classification-cover" alt="封面" />
|
|
||||||
<div v-else class="classification-cover classification-cover--empty">无</div>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="title" label="短剧名称" min-width="200" />
|
|
||||||
<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-column label="更新时间" width="180">
|
|
||||||
<template #default="{ row }">{{ formatTime(row.updatedAt) }}</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="操作" width="110" fixed="right">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-button
|
|
||||||
v-if="can('drama:update')"
|
|
||||||
type="danger"
|
|
||||||
size="small"
|
|
||||||
@click="removeDrama(row)"
|
|
||||||
>移出</el-button
|
|
||||||
>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
|
|
||||||
<div class="classification-pagination">
|
|
||||||
<el-pagination
|
|
||||||
:current-page="pageIndex"
|
|
||||||
:page-size="pageSize"
|
|
||||||
:total="total"
|
|
||||||
layout="total, prev, pager, next"
|
|
||||||
@current-change="changePage"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<ClassificationDramaDialogs
|
|
||||||
v-model:editor-visible="dialogVisible"
|
|
||||||
v-model:languages="languages"
|
|
||||||
v-model:candidate-visible="candidateVisible"
|
|
||||||
v-model:candidate-keyword="candidateKeyword"
|
|
||||||
:editing-id="editingId"
|
|
||||||
:form="form"
|
|
||||||
@update:form="Object.assign(form, $event)"
|
|
||||||
:saving="saving"
|
|
||||||
:candidate-loading="candidateLoading"
|
|
||||||
:candidates="candidates"
|
|
||||||
:candidate-page="candidatePage"
|
|
||||||
:candidate-page-size="candidatePageSize"
|
|
||||||
:candidate-total="candidateTotal"
|
|
||||||
:binding="binding"
|
|
||||||
:selected-count="selectedDramas.length"
|
|
||||||
@save="saveClassification"
|
|
||||||
@search="candidateSearch"
|
|
||||||
@page="changeCandidatePage"
|
|
||||||
@selection="onSelectionChange"
|
|
||||||
@confirm="confirmBind"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.classification-layout {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 260px minmax(0, 1fr);
|
|
||||||
gap: 16px;
|
|
||||||
align-items: start;
|
|
||||||
}
|
|
||||||
|
|
||||||
.classification-layout__main {
|
|
||||||
padding: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.classification-toolbar {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 12px;
|
|
||||||
margin-bottom: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.classification-toolbar__title {
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.classification-toolbar__title small {
|
|
||||||
margin-left: 8px;
|
|
||||||
font-size: 12px;
|
|
||||||
font-weight: 400;
|
|
||||||
color: var(--el-text-color-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.classification-toolbar__search {
|
|
||||||
display: flex;
|
|
||||||
gap: 8px;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.classification-cover {
|
|
||||||
width: 48px;
|
|
||||||
height: 64px;
|
|
||||||
object-fit: cover;
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.classification-cover--empty {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--el-text-color-secondary);
|
|
||||||
background: var(--el-fill-color-light);
|
|
||||||
}
|
|
||||||
|
|
||||||
.classification-pagination {
|
|
||||||
display: flex;
|
|
||||||
justify-content: flex-end;
|
|
||||||
margin-top: 14px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -4,12 +4,6 @@
|
|||||||
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,
|
||||||
@@ -17,7 +11,6 @@ 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()
|
||||||
@@ -27,8 +20,7 @@ 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 languages = ref(['zh'])
|
const form = reactive({ name: '', sort: 1, status: 1 })
|
||||||
const form = reactive({ locales: { zh: '' }, sort: 1, status: 1 })
|
|
||||||
|
|
||||||
async function load() {
|
async function load() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
@@ -46,29 +38,21 @@ function nextSort() {
|
|||||||
|
|
||||||
function openCreate() {
|
function openCreate() {
|
||||||
editingId.value = null
|
editingId.value = null
|
||||||
languages.value = ['zh']
|
Object.assign(form, { name: '', sort: nextSort(), status: 1 })
|
||||||
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
|
||||||
const locales = localesFromColumns(row.locales, row.name, row.nameEn, row.nameId)
|
Object.assign(form, { name: row.name, sort: row.sort ?? 0, status: row.status ?? 1 })
|
||||||
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() {
|
||||||
const locales = payloadLocales(form.locales, languages.value)
|
if (!form.name.trim()) return ElMessage.warning('请填写类型名称')
|
||||||
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: locales.zh, locales, sort: form.sort, status: form.status }
|
const payload = { name: form.name.trim(), 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('类型已更新')
|
||||||
@@ -131,20 +115,7 @@ 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="160" />
|
<el-table-column prop="name" label="类型名称" min-width="200" />
|
||||||
<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>
|
||||||
@@ -175,15 +146,11 @@ onMounted(load)
|
|||||||
</el-table>
|
</el-table>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<el-dialog v-model="dialogVisible" :title="editingId ? '编辑类型' : '新建类型'" width="560px">
|
<el-dialog v-model="dialogVisible" :title="editingId ? '编辑类型' : '新建类型'" width="460px">
|
||||||
<el-form label-position="top">
|
<el-form label-position="top">
|
||||||
<LocaleTextFields
|
<el-form-item label="类型名称" required>
|
||||||
v-model:languages="languages"
|
<el-input v-model="form.name" maxlength="20" placeholder="例如:都市情感" />
|
||||||
:locales="form.locales"
|
</el-form-item>
|
||||||
@update:locales="form.locales = $event"
|
|
||||||
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" />
|
||||||
@@ -199,9 +166,3 @@ onMounted(load)
|
|||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.locale-tag + .locale-tag {
|
|
||||||
margin-left: 6px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,171 +0,0 @@
|
|||||||
<!-- 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:form',
|
|
||||||
'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)"
|
|
||||||
@update:locales="emit('update:form', { ...form, locales: $event })"
|
|
||||||
/>
|
|
||||||
<div class="classification-form-row">
|
|
||||||
<el-form-item label="排序">
|
|
||||||
<el-input-number
|
|
||||||
:model-value="form.sort"
|
|
||||||
:min="0"
|
|
||||||
:max="SORT_MAX"
|
|
||||||
controls-position="right"
|
|
||||||
@update:model-value="emit('update:form', { ...form, sort: $event })"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="状态">
|
|
||||||
<el-switch
|
|
||||||
:model-value="form.status"
|
|
||||||
:active-value="1"
|
|
||||||
:inactive-value="0"
|
|
||||||
@update:model-value="emit('update:form', { ...form, status: $event })"
|
|
||||||
/>
|
|
||||||
</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>
|
|
||||||
@@ -1,140 +0,0 @@
|
|||||||
<!-- 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,13 +5,6 @@ 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,
|
||||||
@@ -23,7 +16,6 @@ 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'
|
||||||
|
|
||||||
@@ -37,8 +29,8 @@ const categories = ref([])
|
|||||||
|
|
||||||
const keyword = ref('')
|
const keyword = ref('')
|
||||||
const statusFilter = ref(undefined)
|
const statusFilter = ref(undefined)
|
||||||
const categoryIds = ref([])
|
const categoryId = ref(undefined)
|
||||||
const tags = ref([])
|
const hotFilter = ref(undefined)
|
||||||
const pageIndex = ref(1)
|
const pageIndex = ref(1)
|
||||||
const pageSize = ref(10)
|
const pageSize = ref(10)
|
||||||
|
|
||||||
@@ -49,29 +41,25 @@ const coverPercent = ref(0)
|
|||||||
const coverError = ref('')
|
const coverError = ref('')
|
||||||
const coverFileName = ref('')
|
const coverFileName = ref('')
|
||||||
const editingId = ref(null)
|
const editingId = ref(null)
|
||||||
const editingCommentCount = 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: '' },
|
categoryId: undefined,
|
||||||
categoryIds: [],
|
|
||||||
tagId: null,
|
|
||||||
description: '',
|
description: '',
|
||||||
synopsisLocales: { zh: '' },
|
|
||||||
freeEpisodes: 3,
|
freeEpisodes: 3,
|
||||||
unlockCoin: 0,
|
unlockCoin: 0,
|
||||||
favoriteCount: 0,
|
|
||||||
heat: 0,
|
|
||||||
isHot: false,
|
isHot: false,
|
||||||
sort: 0,
|
|
||||||
cover: ''
|
cover: ''
|
||||||
})
|
})
|
||||||
|
|
||||||
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' }],
|
||||||
|
categoryId: [{ required: true, message: '请选择短剧类型', trigger: 'change' }]
|
||||||
|
}
|
||||||
|
|
||||||
const coverDisplayName = computed(
|
const coverDisplayName = computed(
|
||||||
() => coverFileName.value || (form.cover ? coverBasename(form.cover) : '尚未选择封面')
|
() => coverFileName.value || (form.cover ? coverBasename(form.cover) : '尚未选择封面')
|
||||||
)
|
)
|
||||||
@@ -106,7 +94,8 @@ 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
|
categoryId: categoryId.value,
|
||||||
|
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
|
||||||
@@ -120,11 +109,6 @@ 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()
|
||||||
@@ -133,7 +117,8 @@ function search() {
|
|||||||
function resetFilters() {
|
function resetFilters() {
|
||||||
keyword.value = ''
|
keyword.value = ''
|
||||||
statusFilter.value = undefined
|
statusFilter.value = undefined
|
||||||
categoryIds.value = []
|
categoryId.value = undefined
|
||||||
|
hotFilter.value = undefined
|
||||||
search()
|
search()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,128 +127,63 @@ 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: '' },
|
categoryId: undefined,
|
||||||
categoryIds: [],
|
|
||||||
tagId: null,
|
|
||||||
description: '',
|
description: '',
|
||||||
synopsisLocales: { zh: '' },
|
|
||||||
freeEpisodes: 3,
|
freeEpisodes: 3,
|
||||||
unlockCoin: 0,
|
unlockCoin: 0,
|
||||||
favoriteCount: 0,
|
|
||||||
heat: 0,
|
|
||||||
isHot: false,
|
isHot: false,
|
||||||
sort: 0,
|
|
||||||
cover: ''
|
cover: ''
|
||||||
})
|
})
|
||||||
coverFileName.value = ''
|
coverFileName.value = ''
|
||||||
coverError.value = ''
|
coverError.value = ''
|
||||||
editingCommentCount.value = 0
|
|
||||||
editingLikeCount.value = 0
|
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
resetValidation()
|
resetValidation()
|
||||||
}
|
}
|
||||||
|
|
||||||
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,
|
||||||
titleLocales,
|
categoryId: row.categoryId || undefined,
|
||||||
categoryIds: selectedCategoryIds(row),
|
|
||||||
tagId: Number(row.tagId) > 0 ? row.tagId : null,
|
|
||||||
description: row.description || '',
|
description: row.description || '',
|
||||||
synopsisLocales,
|
freeEpisodes: row.freeEpisodes ?? 3,
|
||||||
freeEpisodes: toCount(row.freeEpisodes ?? 3),
|
unlockCoin: row.unlockCoin ?? 0,
|
||||||
unlockCoin: toCount(row.unlockCoin),
|
|
||||||
favoriteCount: toCount(row.favoriteCount),
|
|
||||||
heat: toCount(row.views),
|
|
||||||
isHot: !!row.isHot,
|
isHot: !!row.isHot,
|
||||||
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 = toCount(row.commentCount)
|
|
||||||
editingLikeCount.value = toCount(row.likeCount)
|
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
resetValidation()
|
resetValidation()
|
||||||
}
|
}
|
||||||
|
|
||||||
function rowCategoryList(row) {
|
|
||||||
if (Array.isArray(row.categoryNames) && row.categoryNames.length) {
|
|
||||||
return row.categoryNames.filter(Boolean)
|
|
||||||
}
|
|
||||||
if (!row.genre) return []
|
|
||||||
return row.genre
|
|
||||||
.split('/')
|
|
||||||
.map((name) => name.trim())
|
|
||||||
.filter(Boolean)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function saveDrama() {
|
async function saveDrama() {
|
||||||
if (saving.value || uploadingCover.value) return
|
if (saving.value || uploadingCover.value) return
|
||||||
const titles = payloadLocales(form.titleLocales, textLanguages.value)
|
try {
|
||||||
const missing = textLanguages.value.find((code) => !titles[code])
|
await formRef.value?.validate()
|
||||||
if (!titles.zh || missing) {
|
} catch {
|
||||||
ElMessage.warning(missing ? `请填写${languageLabel(missing)}名称` : '请输入短剧名称')
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const synopses = payloadLocales(form.synopsisLocales, textLanguages.value)
|
const category = categories.value.find((item) => item.id === form.categoryId)
|
||||||
const categoryNames = form.categoryIds
|
|
||||||
.map((id) => categories.value.find((item) => item.id === id)?.name)
|
|
||||||
.filter(Boolean)
|
|
||||||
const payload = {
|
const payload = {
|
||||||
...form,
|
...form,
|
||||||
title: titles.zh,
|
title: form.title.trim(),
|
||||||
titleLocales: titles,
|
genre: category?.name || ''
|
||||||
description: synopses.zh || '',
|
|
||||||
synopsisLocales: synopses,
|
|
||||||
genre: categoryNames.join(' / '),
|
|
||||||
tagId: form.tagId || 0
|
|
||||||
}
|
}
|
||||||
saving.value = true
|
saving.value = true
|
||||||
try {
|
try {
|
||||||
@@ -387,7 +307,7 @@ function reviewActions(row) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await Promise.all([loadCategories(), loadTags()])
|
await loadCategories()
|
||||||
await load()
|
await load()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
@@ -418,18 +338,16 @@ onMounted(async () => {
|
|||||||
:key="item.code"
|
:key="item.code"
|
||||||
:label="item.text"
|
:label="item.text"
|
||||||
:value="item.code" /></el-select
|
:value="item.code" /></el-select
|
||||||
><el-select
|
><el-select v-model="categoryId" clearable placeholder="全部类型" @change="search"
|
||||||
v-model="categoryIds"
|
|
||||||
class="drama-multi-select"
|
|
||||||
multiple
|
|
||||||
clearable
|
|
||||||
placeholder="全部类型"
|
|
||||||
@change="search"
|
|
||||||
><el-option
|
><el-option
|
||||||
v-for="item in categories"
|
v-for="item in categories"
|
||||||
: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="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
|
||||||
>
|
>
|
||||||
@@ -464,42 +382,13 @@ onMounted(async () => {
|
|||||||
><span v-else class="table-empty-text">—</span></template
|
><span v-else class="table-empty-text">—</span></template
|
||||||
></el-table-column
|
></el-table-column
|
||||||
>
|
>
|
||||||
<el-table-column label="类型" min-width="200"
|
<el-table-column prop="genre" label="类型" width="110" />
|
||||||
><template #default="{ row }"
|
|
||||||
><div v-if="rowCategoryList(row).length" class="tag-wrap"
|
|
||||||
><el-tag v-for="name in rowCategoryList(row)" :key="name" type="info" effect="light">{{
|
|
||||||
name
|
|
||||||
}}</el-tag></div
|
|
||||||
><span v-else class="table-empty-text">—</span></template
|
|
||||||
>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="标签" min-width="120"
|
|
||||||
><template #default="{ row }"
|
|
||||||
><span v-if="row.tagName">{{ row.tagName }}</span
|
|
||||||
><span v-else class="table-empty-text">—</span></template
|
|
||||||
></el-table-column
|
|
||||||
>
|
|
||||||
<el-table-column label="集数" width="90"
|
<el-table-column label="集数" width="90"
|
||||||
><template #default="{ row }">{{ row.episodes }} 集</template></el-table-column
|
><template #default="{ row }">{{ row.episodes }} 集</template></el-table-column
|
||||||
>
|
>
|
||||||
<el-table-column label="热度" width="110"
|
<el-table-column label="播放量" width="110"
|
||||||
><template #default="{ row }">{{ formatCount(row.views) }}</template></el-table-column
|
><template #default="{ row }">{{ formatCount(row.views) }}</template></el-table-column
|
||||||
>
|
>
|
||||||
<el-table-column label="收藏" width="90"
|
|
||||||
><template #default="{ row }">{{
|
|
||||||
formatCount(row.favoriteCount ?? 0)
|
|
||||||
}}</template></el-table-column
|
|
||||||
>
|
|
||||||
<el-table-column label="点赞" width="90"
|
|
||||||
><template #default="{ row }">{{
|
|
||||||
formatCount(row.likeCount ?? 0)
|
|
||||||
}}</template></el-table-column
|
|
||||||
>
|
|
||||||
<el-table-column label="评论" width="90"
|
|
||||||
><template #default="{ row }">{{
|
|
||||||
formatCount(row.commentCount ?? 0)
|
|
||||||
}}</template></el-table-column
|
|
||||||
>
|
|
||||||
<el-table-column label="状态" width="110"
|
<el-table-column label="状态" width="110"
|
||||||
><template #default="{ row }"
|
><template #default="{ row }"
|
||||||
><el-tag :class="['status-badge', statusClass(row.status)]" effect="light">{{
|
><el-tag :class="['status-badge', statusClass(row.status)]" effect="light">{{
|
||||||
@@ -507,6 +396,12 @@ 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 }"
|
||||||
@@ -564,12 +459,74 @@ onMounted(async () => {
|
|||||||
<el-dialog
|
<el-dialog
|
||||||
v-model="dialogVisible"
|
v-model="dialogVisible"
|
||||||
:title="editingId ? '编辑短剧' : '新建短剧'"
|
:title="editingId ? '编辑短剧' : '新建短剧'"
|
||||||
width="760px"
|
width="680px"
|
||||||
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 ref="formRef" :model="form" label-position="top" class="drama-editor-form">
|
<el-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="categoryId">
|
||||||
|
<el-select v-model="form.categoryId" placeholder="请选择类型">
|
||||||
|
<el-option
|
||||||
|
v-for="item in categories"
|
||||||
|
:key="item.id"
|
||||||
|
:label="item.name"
|
||||||
|
:value="item.id"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</div>
|
||||||
|
<el-form-item label="简介">
|
||||||
|
<el-input
|
||||||
|
v-model="form.description"
|
||||||
|
type="textarea"
|
||||||
|
:rows="3"
|
||||||
|
maxlength="200"
|
||||||
|
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>
|
||||||
|
<el-form-item label="是否热门">
|
||||||
|
<el-switch v-model="form.isHot" />
|
||||||
|
</el-form-item>
|
||||||
|
</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">
|
||||||
@@ -635,119 +592,6 @@ onMounted(async () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="editor-section">
|
|
||||||
<h3 class="editor-section-title">基础信息</h3>
|
|
||||||
<LocaleTextFields
|
|
||||||
:languages="textLanguages"
|
|
||||||
:locales="form.titleLocales"
|
|
||||||
@update:locales="form.titleLocales = $event"
|
|
||||||
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"
|
|
||||||
@update:locales="form.synopsisLocales = $event"
|
|
||||||
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>
|
||||||
@@ -765,46 +609,3 @@ onMounted(async () => {
|
|||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.drama-multi-select {
|
|
||||||
min-width: 220px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.drama-multi-select :deep(.el-select__wrapper) {
|
|
||||||
height: auto;
|
|
||||||
min-height: 32px;
|
|
||||||
padding-top: 3px;
|
|
||||||
padding-bottom: 3px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.drama-multi-select :deep(.el-select__selection) {
|
|
||||||
flex-wrap: wrap;
|
|
||||||
row-gap: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.drama-editor-form .drama-multi-select {
|
|
||||||
width: 100%;
|
|
||||||
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 {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 4px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,660 +0,0 @@
|
|||||||
<!-- Author: fruit.com.cn -->
|
|
||||||
<!-- 剧单管理:剧单使用自己的一套分类(与「分类管理」无关),分类下直接关联短剧 -->
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import { computed, onMounted, reactive, ref } from 'vue'
|
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
||||||
import { AppIcon } from '@/components/AppIcon'
|
|
||||||
import { AppIcons } from '@/constants/icons'
|
|
||||||
import {
|
|
||||||
languageCodes,
|
|
||||||
languageLabel,
|
|
||||||
localesFromColumns,
|
|
||||||
payloadLocales
|
|
||||||
} from '@/constants/contentLanguages'
|
|
||||||
import {
|
|
||||||
bindPlaylistCategoryDramasApi,
|
|
||||||
createPlaylistCategoryApi,
|
|
||||||
deletePlaylistCategoryApi,
|
|
||||||
listPlaylistCategoriesApi,
|
|
||||||
listPlaylistCategoryDramaCandidatesApi,
|
|
||||||
listPlaylistCategoryDramasApi,
|
|
||||||
unbindPlaylistCategoryDramaApi,
|
|
||||||
updatePlaylistCategoryApi
|
|
||||||
} from '@/api/admin/dramaPlaylistCategory'
|
|
||||||
import { statusClass } from '@/utils/status'
|
|
||||||
import { useRbac } from '@/stores/rbac'
|
|
||||||
import LocaleTextFields from '@/views/components/LocaleTextFields.vue'
|
|
||||||
import PageHeading from '@/views/components/PageHeading.vue'
|
|
||||||
|
|
||||||
const { can } = useRbac()
|
|
||||||
|
|
||||||
const STATUS_TEXT = {
|
|
||||||
draft: '草稿',
|
|
||||||
reviewing: '审核中',
|
|
||||||
approved: '待发布',
|
|
||||||
published: '已上线',
|
|
||||||
offline: '已下线'
|
|
||||||
}
|
|
||||||
|
|
||||||
const categories = ref([])
|
|
||||||
const activeId = ref(null)
|
|
||||||
const activeCategory = computed(
|
|
||||||
() => categories.value.find((item) => item.id === activeId.value) || null
|
|
||||||
)
|
|
||||||
|
|
||||||
const loading = ref(false)
|
|
||||||
const dramas = ref([])
|
|
||||||
const total = ref(0)
|
|
||||||
const pageIndex = ref(1)
|
|
||||||
const pageSize = ref(10)
|
|
||||||
const keyword = ref('')
|
|
||||||
|
|
||||||
const dialogVisible = ref(false)
|
|
||||||
const saving = ref(false)
|
|
||||||
const editingId = ref(null)
|
|
||||||
const languages = ref(['zh'])
|
|
||||||
const emptyForm = () => ({
|
|
||||||
locales: { zh: '' },
|
|
||||||
descriptionLocales: { zh: '' },
|
|
||||||
sort: 1,
|
|
||||||
status: 1
|
|
||||||
})
|
|
||||||
const form = reactive(emptyForm())
|
|
||||||
|
|
||||||
const candidateVisible = ref(false)
|
|
||||||
const candidateLoading = ref(false)
|
|
||||||
const candidates = ref([])
|
|
||||||
const candidateTotal = ref(0)
|
|
||||||
const candidatePage = ref(1)
|
|
||||||
const candidatePageSize = ref(10)
|
|
||||||
const candidateKeyword = ref('')
|
|
||||||
const selectedDramas = ref([])
|
|
||||||
const binding = ref(false)
|
|
||||||
|
|
||||||
async function loadCategories() {
|
|
||||||
const res = await listPlaylistCategoriesApi()
|
|
||||||
categories.value = res.data || []
|
|
||||||
if (activeId.value && !categories.value.some((item) => item.id === activeId.value)) {
|
|
||||||
activeId.value = categories.value[0]?.id ?? null
|
|
||||||
}
|
|
||||||
if (!activeId.value) {
|
|
||||||
activeId.value = categories.value[0]?.id ?? null
|
|
||||||
}
|
|
||||||
await loadDramas()
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadDramas() {
|
|
||||||
if (!activeId.value) {
|
|
||||||
dramas.value = []
|
|
||||||
total.value = 0
|
|
||||||
return
|
|
||||||
}
|
|
||||||
loading.value = true
|
|
||||||
try {
|
|
||||||
const res = await listPlaylistCategoryDramasApi(activeId.value, {
|
|
||||||
keyword: keyword.value || undefined,
|
|
||||||
pageIndex: pageIndex.value,
|
|
||||||
pageSize: pageSize.value
|
|
||||||
})
|
|
||||||
dramas.value = res.data?.list || []
|
|
||||||
total.value = res.data?.total || 0
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function selectCategory(row) {
|
|
||||||
if (activeId.value === row.id) return
|
|
||||||
activeId.value = row.id
|
|
||||||
pageIndex.value = 1
|
|
||||||
keyword.value = ''
|
|
||||||
loadDramas()
|
|
||||||
}
|
|
||||||
|
|
||||||
function search() {
|
|
||||||
pageIndex.value = 1
|
|
||||||
loadDramas()
|
|
||||||
}
|
|
||||||
|
|
||||||
function changePage(value) {
|
|
||||||
pageIndex.value = value
|
|
||||||
loadDramas()
|
|
||||||
}
|
|
||||||
|
|
||||||
function changeLanguages(codes) {
|
|
||||||
languages.value = codes
|
|
||||||
codes.forEach((code) => {
|
|
||||||
if (form.descriptionLocales[code] == null) form.descriptionLocales[code] = ''
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function openCreate() {
|
|
||||||
editingId.value = null
|
|
||||||
languages.value = ['zh']
|
|
||||||
const maxSort = categories.value.reduce((max, item) => Math.max(max, item.sort || 0), 0)
|
|
||||||
Object.assign(form, emptyForm(), { sort: maxSort + 1 })
|
|
||||||
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)
|
|
||||||
const descriptionLocales = localesFromColumns(
|
|
||||||
row.descriptionLocales,
|
|
||||||
row.description,
|
|
||||||
row.descriptionEn,
|
|
||||||
row.descriptionId
|
|
||||||
)
|
|
||||||
languages.value.forEach((code) => {
|
|
||||||
if (descriptionLocales[code] == null) descriptionLocales[code] = ''
|
|
||||||
})
|
|
||||||
Object.assign(form, {
|
|
||||||
locales,
|
|
||||||
descriptionLocales,
|
|
||||||
sort: row.sort ?? 0,
|
|
||||||
status: row.status ?? 1
|
|
||||||
})
|
|
||||||
dialogVisible.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
async function saveCategory() {
|
|
||||||
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
|
|
||||||
try {
|
|
||||||
const payload = {
|
|
||||||
name: locales.zh,
|
|
||||||
locales,
|
|
||||||
descriptionLocales: payloadLocales(form.descriptionLocales, languages.value),
|
|
||||||
sort: form.sort,
|
|
||||||
status: form.status
|
|
||||||
}
|
|
||||||
if (editingId.value) {
|
|
||||||
await updatePlaylistCategoryApi(editingId.value, payload)
|
|
||||||
ElMessage.success('剧单分类已更新')
|
|
||||||
} else {
|
|
||||||
const res = await createPlaylistCategoryApi(payload)
|
|
||||||
activeId.value = res.data
|
|
||||||
pageIndex.value = 1
|
|
||||||
ElMessage.success('剧单分类已创建')
|
|
||||||
}
|
|
||||||
dialogVisible.value = false
|
|
||||||
await loadCategories()
|
|
||||||
} finally {
|
|
||||||
saving.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function confirmDelete(row) {
|
|
||||||
try {
|
|
||||||
await ElMessageBox.confirm(
|
|
||||||
`确定删除剧单分类「${row.name}」吗?关联关系会一起删除,短剧本身不受影响。`,
|
|
||||||
'删除确认',
|
|
||||||
{ confirmButtonText: '确认删除', cancelButtonText: '取消', type: 'warning' }
|
|
||||||
)
|
|
||||||
} catch {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
await deletePlaylistCategoryApi(row.id)
|
|
||||||
if (activeId.value === row.id) {
|
|
||||||
activeId.value = null
|
|
||||||
}
|
|
||||||
ElMessage.success('剧单分类已删除')
|
|
||||||
await loadCategories()
|
|
||||||
}
|
|
||||||
|
|
||||||
async function removeDrama(row) {
|
|
||||||
try {
|
|
||||||
await ElMessageBox.confirm(
|
|
||||||
`确定把「${row.title}」从「${activeCategory.value?.name}」移出吗?`,
|
|
||||||
'移除确认',
|
|
||||||
{ confirmButtonText: '确认移出', cancelButtonText: '取消', type: 'warning' }
|
|
||||||
)
|
|
||||||
} catch {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
await unbindPlaylistCategoryDramaApi(activeId.value, row.id)
|
|
||||||
ElMessage.success('已移出')
|
|
||||||
await Promise.all([loadDramas(), loadCategories()])
|
|
||||||
}
|
|
||||||
|
|
||||||
function openCandidates() {
|
|
||||||
candidateVisible.value = true
|
|
||||||
candidatePage.value = 1
|
|
||||||
candidateKeyword.value = ''
|
|
||||||
selectedDramas.value = []
|
|
||||||
loadCandidates()
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadCandidates() {
|
|
||||||
if (!activeId.value) return
|
|
||||||
candidateLoading.value = true
|
|
||||||
try {
|
|
||||||
const res = await listPlaylistCategoryDramaCandidatesApi(activeId.value, {
|
|
||||||
keyword: candidateKeyword.value || undefined,
|
|
||||||
pageIndex: candidatePage.value,
|
|
||||||
pageSize: candidatePageSize.value
|
|
||||||
})
|
|
||||||
candidates.value = res.data?.list || []
|
|
||||||
candidateTotal.value = res.data?.total || 0
|
|
||||||
} finally {
|
|
||||||
candidateLoading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function candidateSearch() {
|
|
||||||
candidatePage.value = 1
|
|
||||||
loadCandidates()
|
|
||||||
}
|
|
||||||
|
|
||||||
function changeCandidatePage(value) {
|
|
||||||
candidatePage.value = value
|
|
||||||
loadCandidates()
|
|
||||||
}
|
|
||||||
|
|
||||||
function onSelectionChange(rows) {
|
|
||||||
selectedDramas.value = rows
|
|
||||||
}
|
|
||||||
|
|
||||||
async function confirmBind() {
|
|
||||||
if (!selectedDramas.value.length) {
|
|
||||||
ElMessage.warning('请先选择要加入的短剧')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
binding.value = true
|
|
||||||
try {
|
|
||||||
const res = await bindPlaylistCategoryDramasApi(
|
|
||||||
activeId.value,
|
|
||||||
selectedDramas.value.map((item) => item.id)
|
|
||||||
)
|
|
||||||
ElMessage.success(`已加入 ${res.data ?? selectedDramas.value.length} 部短剧`)
|
|
||||||
candidateVisible.value = false
|
|
||||||
await Promise.all([loadDramas(), loadCategories()])
|
|
||||||
} finally {
|
|
||||||
binding.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatTime(value) {
|
|
||||||
if (!value) return '—'
|
|
||||||
return String(value).replace('T', ' ').slice(0, 19)
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(loadCategories)
|
|
||||||
</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>
|
|
||||||
|
|
||||||
<div class="playlist-layout">
|
|
||||||
<aside class="panel playlist-layout__side">
|
|
||||||
<div class="playlist-layout__side-title">剧单分类</div>
|
|
||||||
<el-scrollbar height="560px">
|
|
||||||
<ul class="playlist-list">
|
|
||||||
<li
|
|
||||||
v-for="item in categories"
|
|
||||||
:key="item.id"
|
|
||||||
class="playlist-list__item"
|
|
||||||
:class="{ 'is-active': item.id === activeId }"
|
|
||||||
@click="selectCategory(item)"
|
|
||||||
>
|
|
||||||
<div class="playlist-list__main">
|
|
||||||
<span class="playlist-list__name">{{ item.name }}</span>
|
|
||||||
<span class="playlist-list__count">{{ item.dramaCount || 0 }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="playlist-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="!categories.length" class="playlist-list__empty">
|
|
||||||
还没有剧单分类,点右上角「新建分类」开始
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</el-scrollbar>
|
|
||||||
</aside>
|
|
||||||
|
|
||||||
<section class="panel playlist-layout__main">
|
|
||||||
<div class="playlist-toolbar">
|
|
||||||
<div class="playlist-toolbar__title">
|
|
||||||
{{ activeCategory?.name || '请选择剧单分类' }}
|
|
||||||
<small>共 {{ total }} 部短剧</small>
|
|
||||||
<small v-if="activeCategory?.description">{{ activeCategory.description }}</small>
|
|
||||||
</div>
|
|
||||||
<div class="playlist-toolbar__search">
|
|
||||||
<el-input
|
|
||||||
v-model="keyword"
|
|
||||||
placeholder="搜索短剧名称"
|
|
||||||
clearable
|
|
||||||
style="width: 200px"
|
|
||||||
@keyup.enter="search"
|
|
||||||
@clear="search"
|
|
||||||
/>
|
|
||||||
<el-button type="primary" plain @click="search">查询</el-button>
|
|
||||||
<el-button v-if="can('drama:update')" :disabled="!activeId" @click="openCandidates">
|
|
||||||
<AppIcon :icon="AppIcons.add" />
|
|
||||||
选择短剧
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<el-table
|
|
||||||
v-loading="loading"
|
|
||||||
:data="dramas"
|
|
||||||
row-key="id"
|
|
||||||
border
|
|
||||||
class="drama-el-table"
|
|
||||||
empty-text="该剧单分类下还没有短剧"
|
|
||||||
>
|
|
||||||
<el-table-column label="封面" width="88">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<img v-if="row.cover" :src="row.cover" class="playlist-cover" alt="封面" />
|
|
||||||
<div v-else class="playlist-cover playlist-cover--empty">无</div>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="title" label="短剧名称" min-width="200" />
|
|
||||||
<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-column label="更新时间" width="180">
|
|
||||||
<template #default="{ row }">{{ formatTime(row.updatedAt) }}</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="操作" width="110" fixed="right">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-button
|
|
||||||
v-if="can('drama:update')"
|
|
||||||
type="danger"
|
|
||||||
size="small"
|
|
||||||
@click="removeDrama(row)"
|
|
||||||
>移出</el-button
|
|
||||||
>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
|
|
||||||
<div class="playlist-pagination">
|
|
||||||
<el-pagination
|
|
||||||
:current-page="pageIndex"
|
|
||||||
:page-size="pageSize"
|
|
||||||
:total="total"
|
|
||||||
layout="total, prev, pager, next"
|
|
||||||
@current-change="changePage"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<el-dialog
|
|
||||||
v-model="dialogVisible"
|
|
||||||
:title="editingId ? '编辑剧单分类' : '新建剧单分类'"
|
|
||||||
width="640px"
|
|
||||||
>
|
|
||||||
<el-form label-position="top">
|
|
||||||
<LocaleTextFields
|
|
||||||
:languages="languages"
|
|
||||||
:locales="form.locales"
|
|
||||||
@update:locales="form.locales = $event"
|
|
||||||
label="名称"
|
|
||||||
:maxlength="64"
|
|
||||||
@update:languages="changeLanguages"
|
|
||||||
/>
|
|
||||||
<LocaleTextFields
|
|
||||||
:languages="languages"
|
|
||||||
:locales="form.descriptionLocales"
|
|
||||||
@update:locales="form.descriptionLocales = $event"
|
|
||||||
label="描述"
|
|
||||||
:maxlength="255"
|
|
||||||
multiline
|
|
||||||
:show-languages="false"
|
|
||||||
:required="false"
|
|
||||||
/>
|
|
||||||
<div class="playlist-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="saveCategory">保存</el-button>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
|
|
||||||
<el-dialog v-model="candidateVisible" title="选择短剧" width="760px">
|
|
||||||
<div class="playlist-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="playlist-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>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.playlist-layout {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 260px minmax(0, 1fr);
|
|
||||||
gap: 16px;
|
|
||||||
align-items: start;
|
|
||||||
}
|
|
||||||
|
|
||||||
.playlist-layout__side {
|
|
||||||
padding: 12px 0 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.playlist-layout__side-title {
|
|
||||||
padding: 0 16px 10px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--el-text-color-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.playlist-list {
|
|
||||||
padding: 0;
|
|
||||||
margin: 0;
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.playlist-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;
|
|
||||||
}
|
|
||||||
|
|
||||||
.playlist-list__item:hover {
|
|
||||||
background: var(--el-fill-color-light);
|
|
||||||
}
|
|
||||||
|
|
||||||
.playlist-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);
|
|
||||||
}
|
|
||||||
|
|
||||||
.playlist-list__main {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.playlist-list__name {
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.playlist-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;
|
|
||||||
}
|
|
||||||
|
|
||||||
.playlist-list__actions {
|
|
||||||
display: none;
|
|
||||||
gap: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.playlist-list__item:hover .playlist-list__actions {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
|
|
||||||
.playlist-list__empty {
|
|
||||||
padding: 16px;
|
|
||||||
line-height: 1.6;
|
|
||||||
color: var(--el-text-color-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.playlist-layout__main {
|
|
||||||
padding: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.playlist-toolbar {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 12px;
|
|
||||||
margin-bottom: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.playlist-toolbar__title {
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.playlist-toolbar__title small {
|
|
||||||
margin-left: 8px;
|
|
||||||
font-size: 12px;
|
|
||||||
font-weight: 400;
|
|
||||||
color: var(--el-text-color-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.playlist-toolbar__search {
|
|
||||||
display: flex;
|
|
||||||
gap: 8px;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.playlist-cover {
|
|
||||||
width: 48px;
|
|
||||||
height: 64px;
|
|
||||||
object-fit: cover;
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.playlist-cover--empty {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--el-text-color-secondary);
|
|
||||||
background: var(--el-fill-color-light);
|
|
||||||
}
|
|
||||||
|
|
||||||
.playlist-pagination {
|
|
||||||
display: flex;
|
|
||||||
justify-content: flex-end;
|
|
||||||
margin-top: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.playlist-form-row {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 1fr 1fr;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,56 +1,92 @@
|
|||||||
<!-- Author: fruit.com.cn -->
|
<!-- Author: fruit.com.cn -->
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, onMounted, ref } from 'vue'
|
import { computed, nextTick, onMounted, reactive, ref } from 'vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } 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 { pageDramasApi } from '@/api/admin/drama'
|
import { pageDramasApi } from '@/api/admin/drama'
|
||||||
import {
|
import {
|
||||||
|
createEpisodeApi,
|
||||||
deleteEpisodeApi,
|
deleteEpisodeApi,
|
||||||
listEpisodesApi,
|
listEpisodesApi,
|
||||||
parseEpisodePage,
|
sortEpisodesApi,
|
||||||
sortEpisodesApi
|
updateEpisodeApi
|
||||||
} from '@/api/admin/episode'
|
} from '@/api/admin/episode'
|
||||||
import { useRbac } from '@/stores/rbac'
|
import { useRbac } from '@/stores/rbac'
|
||||||
import { formatCount } from '@/utils/format'
|
import { formatCount } from '@/utils/format'
|
||||||
import { statusClass } from '@/utils/status'
|
import { statusClass } from '@/utils/status'
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
import { probeVideoDuration, uploadFile } from '@/utils/uploader'
|
||||||
import BatchUploadDialog from './upload/BatchUploadDialog.vue'
|
|
||||||
import EpisodeFormDialog from './upload/EpisodeFormDialog.vue'
|
|
||||||
import { listPendingSessions } from './upload/uploadSessions'
|
|
||||||
|
|
||||||
/** 排序/批量建集需要全集快照,单次请求不超过接口 pageSize 上限。 */
|
|
||||||
const SNAPSHOT_PAGE_SIZE = 200
|
|
||||||
const DEFAULT_PAGE_SIZE = 100
|
|
||||||
const PAGE_SIZE_OPTIONS = [50, 100, 200]
|
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const { can } = useRbac()
|
const { can } = useRbac()
|
||||||
const { t } = useI18n()
|
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const dramas = ref([])
|
const dramas = ref([])
|
||||||
const episodes = ref([])
|
const episodes = ref([])
|
||||||
const total = ref(0)
|
|
||||||
const selectedDramaId = ref(undefined)
|
const selectedDramaId = ref(undefined)
|
||||||
const statusFilter = ref(undefined)
|
|
||||||
const pageIndex = ref(1)
|
const dialogVisible = ref(false)
|
||||||
const pageSize = ref(DEFAULT_PAGE_SIZE)
|
const saving = ref(false)
|
||||||
const batchUploadVisible = ref(false)
|
const uploadingVideo = ref(false)
|
||||||
|
const videoPercent = ref(0)
|
||||||
|
const videoError = ref('')
|
||||||
|
const videoFileName = ref('')
|
||||||
const previewVisible = ref(false)
|
const previewVisible = ref(false)
|
||||||
const previewEpisode = ref(null)
|
const previewEpisode = ref(null)
|
||||||
const formDialogRef = ref()
|
const editingId = ref(null)
|
||||||
/** 上移/下移与批量建集用的全集快照。 */
|
const formRef = ref()
|
||||||
const snapshotEpisodes = ref([])
|
const form = reactive({
|
||||||
|
number: 1,
|
||||||
|
title: '',
|
||||||
|
durationSec: 0,
|
||||||
|
videoUrl: '',
|
||||||
|
isFree: true,
|
||||||
|
unlockCoin: 0,
|
||||||
|
status: 'draft'
|
||||||
|
})
|
||||||
|
|
||||||
|
const statusOptions = [
|
||||||
|
{ code: 'draft', text: '草稿' },
|
||||||
|
{ code: 'approved', text: '待发布' },
|
||||||
|
{ code: 'published', text: '已上线' },
|
||||||
|
{ code: 'offline', text: '已下线' }
|
||||||
|
]
|
||||||
|
|
||||||
|
const MAX_VIDEO_SIZE = 500 * 1024 * 1024
|
||||||
|
const VIDEO_EXTENSIONS = ['mp4', 'mov']
|
||||||
|
const formRules = {
|
||||||
|
number: [{ required: true, message: '请输入集号', trigger: 'change' }],
|
||||||
|
title: [{ required: true, message: '请输入剧集标题', trigger: 'blur' }],
|
||||||
|
videoUrl: [
|
||||||
|
{
|
||||||
|
validator: (_rule, value, callback) => {
|
||||||
|
if (form.status === 'published' && !value) {
|
||||||
|
callback(new Error('上线剧集必须上传视频'))
|
||||||
|
} else {
|
||||||
|
callback()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
trigger: 'change'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
const batchNextNumber = computed(() => nextNumber())
|
|
||||||
const selectedDrama = computed(() => dramas.value.find((item) => item.id === selectedDramaId.value))
|
const selectedDrama = computed(() => dramas.value.find((item) => item.id === selectedDramaId.value))
|
||||||
const existingEpisodeNumbers = computed(() =>
|
const videoDisplayName = computed(
|
||||||
snapshotEpisodes.value.map((item) => Number(item.number)).filter((n) => Number.isFinite(n))
|
() => videoFileName.value || (form.videoUrl ? episodeBasename(form.videoUrl) : '尚未选择视频')
|
||||||
)
|
)
|
||||||
|
|
||||||
const showEmpty = computed(() => !loading.value && episodes.value.length === 0)
|
function episodeBasename(path) {
|
||||||
|
if (!path) return ''
|
||||||
|
const clean = path.split('?')[0].split('#')[0]
|
||||||
|
return decodeURIComponent(clean.split('/').pop() || clean)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function resetValidation() {
|
||||||
|
await nextTick()
|
||||||
|
formRef.value?.clearValidate()
|
||||||
|
}
|
||||||
|
|
||||||
async function loadDramas() {
|
async function loadDramas() {
|
||||||
const res = await pageDramasApi({ pageIndex: 1, pageSize: 200 })
|
const res = await pageDramasApi({ pageIndex: 1, pageSize: 200 })
|
||||||
@@ -67,89 +103,143 @@ async function loadDramas() {
|
|||||||
async function loadEpisodes() {
|
async function loadEpisodes() {
|
||||||
if (!selectedDramaId.value) {
|
if (!selectedDramaId.value) {
|
||||||
episodes.value = []
|
episodes.value = []
|
||||||
total.value = 0
|
|
||||||
snapshotEpisodes.value = []
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
const res = await listEpisodesApi({
|
const res = await listEpisodesApi(selectedDramaId.value)
|
||||||
dramaId: selectedDramaId.value,
|
episodes.value = res.data || []
|
||||||
status: statusFilter.value || undefined,
|
|
||||||
pageIndex: pageIndex.value,
|
|
||||||
pageSize: pageSize.value
|
|
||||||
})
|
|
||||||
// 按 OpenAPI PageResult{total,list} 解包,禁止再把 data 当数组切片
|
|
||||||
const page = parseEpisodePage(res.data)
|
|
||||||
episodes.value = page.list
|
|
||||||
total.value = page.total
|
|
||||||
await clampOrRetreatPage()
|
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 拉当前剧全集快照,供排序与批量建集集号计算。不过滤 status,按页取完。 */
|
|
||||||
async function refreshSnapshot() {
|
|
||||||
if (!selectedDramaId.value) {
|
|
||||||
snapshotEpisodes.value = []
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const collected = []
|
|
||||||
let page = 1
|
|
||||||
let totalCount = 0
|
|
||||||
do {
|
|
||||||
const res = await listEpisodesApi({
|
|
||||||
dramaId: selectedDramaId.value,
|
|
||||||
pageIndex: page,
|
|
||||||
pageSize: SNAPSHOT_PAGE_SIZE
|
|
||||||
})
|
|
||||||
const parsed = parseEpisodePage(res.data)
|
|
||||||
totalCount = parsed.total
|
|
||||||
collected.push(...parsed.list)
|
|
||||||
if (!parsed.list.length) break
|
|
||||||
page += 1
|
|
||||||
} while (collected.length < totalCount)
|
|
||||||
snapshotEpisodes.value = collected
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除后若当前页空且仍有数据,回退上一页再拉;否则夹页。
|
|
||||||
*/
|
|
||||||
async function clampOrRetreatPage() {
|
|
||||||
const maxPage = Math.max(1, Math.ceil(total.value / pageSize.value) || 1)
|
|
||||||
if (episodes.value.length === 0 && total.value > 0 && pageIndex.value > 1) {
|
|
||||||
pageIndex.value = Math.min(pageIndex.value - 1, maxPage)
|
|
||||||
await loadEpisodes()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (pageIndex.value > maxPage) {
|
|
||||||
pageIndex.value = maxPage
|
|
||||||
await loadEpisodes()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function nextNumber() {
|
function nextNumber() {
|
||||||
return snapshotEpisodes.value.reduce((max, item) => Math.max(max, item.number || 0), 0) + 1
|
return episodes.value.reduce((max, item) => Math.max(max, item.number || 0), 0) + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
async function openBatchUpload() {
|
function openCreate() {
|
||||||
if (!selectedDramaId.value) return
|
editingId.value = null
|
||||||
await refreshSnapshot()
|
Object.assign(form, {
|
||||||
batchUploadVisible.value = true
|
number: nextNumber(),
|
||||||
}
|
title: '',
|
||||||
|
durationSec: 0,
|
||||||
async function onBatchEpisodesCreated() {
|
videoUrl: '',
|
||||||
await loadEpisodes()
|
isFree: true,
|
||||||
}
|
unlockCoin: selectedDrama.value?.unlockCoin ?? 0,
|
||||||
|
status: 'draft'
|
||||||
async function openCreate() {
|
})
|
||||||
await refreshSnapshot()
|
videoFileName.value = ''
|
||||||
formDialogRef.value?.openCreate()
|
videoError.value = ''
|
||||||
|
dialogVisible.value = true
|
||||||
|
resetValidation()
|
||||||
}
|
}
|
||||||
|
|
||||||
function openEdit(row) {
|
function openEdit(row) {
|
||||||
formDialogRef.value?.openEdit(row)
|
editingId.value = row.id
|
||||||
|
Object.assign(form, {
|
||||||
|
number: row.number,
|
||||||
|
title: row.title,
|
||||||
|
durationSec: row.durationSec || 0,
|
||||||
|
videoUrl: row.videoUrl || '',
|
||||||
|
isFree: !!row.isFree,
|
||||||
|
unlockCoin: row.unlockCoin || 0,
|
||||||
|
status: row.status
|
||||||
|
})
|
||||||
|
videoFileName.value = row.videoUrl ? episodeBasename(row.videoUrl) : ''
|
||||||
|
videoError.value = ''
|
||||||
|
dialogVisible.value = true
|
||||||
|
resetValidation()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function saveEpisode() {
|
||||||
|
if (saving.value || uploadingVideo.value) return
|
||||||
|
try {
|
||||||
|
await formRef.value?.validate()
|
||||||
|
} catch {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const payload = {
|
||||||
|
dramaId: selectedDramaId.value,
|
||||||
|
number: form.number,
|
||||||
|
title: form.title.trim(),
|
||||||
|
durationSec: form.durationSec || 0,
|
||||||
|
videoUrl: form.videoUrl.trim(),
|
||||||
|
isFree: form.isFree,
|
||||||
|
unlockCoin: form.isFree ? 0 : form.unlockCoin || 0,
|
||||||
|
status: form.status
|
||||||
|
}
|
||||||
|
saving.value = true
|
||||||
|
try {
|
||||||
|
if (editingId.value) {
|
||||||
|
await updateEpisodeApi(editingId.value, payload)
|
||||||
|
ElMessage.success('剧集已更新')
|
||||||
|
} else {
|
||||||
|
await createEpisodeApi(payload)
|
||||||
|
ElMessage.success('剧集已创建')
|
||||||
|
}
|
||||||
|
dialogVisible.value = false
|
||||||
|
await loadEpisodes()
|
||||||
|
} finally {
|
||||||
|
saving.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function beforeVideoUpload(file) {
|
||||||
|
videoError.value = ''
|
||||||
|
const extension = String(file.name || '')
|
||||||
|
.split('.')
|
||||||
|
.pop()
|
||||||
|
?.toLowerCase()
|
||||||
|
if (!VIDEO_EXTENSIONS.includes(extension)) {
|
||||||
|
videoError.value = '视频仅支持 MP4 或 MOV 格式'
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (file.size > MAX_VIDEO_SIZE) {
|
||||||
|
videoError.value = '视频大小不能超过 500MB'
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 视频分片上传:先探测时长,再交给上传器,完成后回填地址与时长。 */
|
||||||
|
async function uploadVideo(options) {
|
||||||
|
uploadingVideo.value = true
|
||||||
|
videoPercent.value = 0
|
||||||
|
videoError.value = ''
|
||||||
|
try {
|
||||||
|
const duration = await probeVideoDuration(options.file)
|
||||||
|
const asset = await uploadFile(options.file, {
|
||||||
|
bizType: 'EPISODE',
|
||||||
|
durationSec: duration,
|
||||||
|
onProgress: (percent) => (videoPercent.value = percent)
|
||||||
|
})
|
||||||
|
form.videoUrl = asset.url
|
||||||
|
videoFileName.value = options.file.name
|
||||||
|
if (duration > 0) form.durationSec = duration
|
||||||
|
await resetValidation()
|
||||||
|
ElMessage.success('视频已上传')
|
||||||
|
} catch {
|
||||||
|
videoError.value = '视频上传失败,请检查网络后重试'
|
||||||
|
} finally {
|
||||||
|
uploadingVideo.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeVideo() {
|
||||||
|
if (uploadingVideo.value) return
|
||||||
|
form.videoUrl = ''
|
||||||
|
videoFileName.value = ''
|
||||||
|
videoError.value = ''
|
||||||
|
resetValidation()
|
||||||
|
}
|
||||||
|
|
||||||
|
function beforeDialogClose(done) {
|
||||||
|
if (saving.value || uploadingVideo.value) {
|
||||||
|
ElMessage.warning(saving.value ? '正在保存,请稍候' : '视频正在上传,请稍候')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
done()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function confirmDelete(row) {
|
async function confirmDelete(row) {
|
||||||
@@ -165,9 +255,6 @@ async function confirmDelete(row) {
|
|||||||
}
|
}
|
||||||
await deleteEpisodeApi(row.id)
|
await deleteEpisodeApi(row.id)
|
||||||
ElMessage.success('剧集已删除')
|
ElMessage.success('剧集已删除')
|
||||||
if (episodes.value.length === 1 && pageIndex.value > 1) {
|
|
||||||
pageIndex.value -= 1
|
|
||||||
}
|
|
||||||
await loadEpisodes()
|
await loadEpisodes()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,32 +283,11 @@ function stopThumb(event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function pageLocalIndex(row) {
|
/** 上移/下移后把新顺序整表提交,由后端重排 sort。 */
|
||||||
return episodes.value.findIndex((item) => item.id === row.id)
|
async function move(index, offset) {
|
||||||
}
|
|
||||||
|
|
||||||
function globalIndex(row) {
|
|
||||||
const local = pageLocalIndex(row)
|
|
||||||
if (local < 0) return -1
|
|
||||||
return (pageIndex.value - 1) * pageSize.value + local
|
|
||||||
}
|
|
||||||
|
|
||||||
function canMoveUp(row) {
|
|
||||||
return globalIndex(row) > 0
|
|
||||||
}
|
|
||||||
|
|
||||||
function canMoveDown(row) {
|
|
||||||
const index = globalIndex(row)
|
|
||||||
return index >= 0 && index < total.value - 1
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 上移/下移后把快照新顺序整表提交,由后端重排 sort。 */
|
|
||||||
async function move(row, offset) {
|
|
||||||
await refreshSnapshot()
|
|
||||||
const index = snapshotEpisodes.value.findIndex((item) => item.id === row.id)
|
|
||||||
const target = index + offset
|
const target = index + offset
|
||||||
if (index < 0 || target < 0 || target >= snapshotEpisodes.value.length) return
|
if (target < 0 || target >= episodes.value.length) return
|
||||||
const next = [...snapshotEpisodes.value]
|
const next = [...episodes.value]
|
||||||
const [moved] = next.splice(index, 1)
|
const [moved] = next.splice(index, 1)
|
||||||
next.splice(target, 0, moved)
|
next.splice(target, 0, moved)
|
||||||
await sortEpisodesApi(next.map((item) => item.id))
|
await sortEpisodesApi(next.map((item) => item.id))
|
||||||
@@ -230,36 +296,12 @@ async function move(row, offset) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function onDramaChange() {
|
async function onDramaChange() {
|
||||||
pageIndex.value = 1
|
|
||||||
await loadEpisodes()
|
await loadEpisodes()
|
||||||
openBatchIfPendingSessions()
|
|
||||||
}
|
|
||||||
|
|
||||||
function onStatusChange() {
|
|
||||||
pageIndex.value = 1
|
|
||||||
loadEpisodes()
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleSizeChange() {
|
|
||||||
pageIndex.value = 1
|
|
||||||
loadEpisodes()
|
|
||||||
}
|
|
||||||
|
|
||||||
function handlePageChange() {
|
|
||||||
loadEpisodes()
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 进入页面或切换短剧时,若有 24h 内未完成上传则打开批量上传弹窗以提示续传。 */
|
|
||||||
function openBatchIfPendingSessions() {
|
|
||||||
if (!selectedDramaId.value || !can('episode:upload')) return
|
|
||||||
const pending = listPendingSessions(String(selectedDramaId.value))
|
|
||||||
if (pending.length) batchUploadVisible.value = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await loadDramas()
|
await loadDramas()
|
||||||
await loadEpisodes()
|
await loadEpisodes()
|
||||||
openBatchIfPendingSessions()
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -268,9 +310,6 @@ onMounted(async () => {
|
|||||||
><div
|
><div
|
||||||
><div class="eyebrow">内容管理</div><h1>剧集管理</h1
|
><div class="eyebrow">内容管理</div><h1>剧集管理</h1
|
||||||
><p>为短剧维护剧集信息、视频地址与播放顺序。</p></div
|
><p>为短剧维护剧集信息、视频地址与播放顺序。</p></div
|
||||||
><div class="page-heading-actions">
|
|
||||||
<el-button v-if="can('episode:upload')" :disabled="!selectedDramaId" @click="openBatchUpload"
|
|
||||||
><AppIcon :icon="AppIcons.upload" />{{ t('episodeBatch.entry') }}</el-button
|
|
||||||
><el-button
|
><el-button
|
||||||
v-if="can('episode:upload')"
|
v-if="can('episode:upload')"
|
||||||
type="primary"
|
type="primary"
|
||||||
@@ -279,7 +318,6 @@ onMounted(async () => {
|
|||||||
@click="openCreate"
|
@click="openCreate"
|
||||||
><AppIcon :icon="AppIcons.add" />新增剧集</el-button
|
><AppIcon :icon="AppIcons.add" />新增剧集</el-button
|
||||||
></div
|
></div
|
||||||
></div
|
|
||||||
>
|
>
|
||||||
<section class="panel episode-panel">
|
<section class="panel episode-panel">
|
||||||
<div class="episode-context">
|
<div class="episode-context">
|
||||||
@@ -287,9 +325,7 @@ onMounted(async () => {
|
|||||||
<span class="episode-context-label">当前短剧</span>
|
<span class="episode-context-label">当前短剧</span>
|
||||||
<b class="episode-context-title">{{ selectedDrama?.title || '暂无短剧' }}</b>
|
<b class="episode-context-title">{{ selectedDrama?.title || '暂无短剧' }}</b>
|
||||||
<small class="episode-context-count"
|
<small class="episode-context-count"
|
||||||
>共 {{ selectedDrama?.episodes ?? total }} 集 · 收藏
|
>共 {{ selectedDrama?.episodes ?? episodes.length }} 集</small
|
||||||
{{ formatCount(selectedDrama?.favoriteCount ?? 0) }} · 热度
|
|
||||||
{{ formatCount(selectedDrama?.views ?? 0) }}</small
|
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<div class="episode-switcher">
|
<div class="episode-switcher">
|
||||||
@@ -307,40 +343,23 @@ onMounted(async () => {
|
|||||||
:value="item.id"
|
:value="item.id"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
<span class="episode-context-label">状态</span>
|
|
||||||
<el-select
|
|
||||||
v-model="statusFilter"
|
|
||||||
clearable
|
|
||||||
placeholder="全部状态"
|
|
||||||
class="status-select"
|
|
||||||
@change="onStatusChange"
|
|
||||||
>
|
|
||||||
<el-option label="草稿" value="draft" />
|
|
||||||
<el-option label="已上线" value="published" />
|
|
||||||
<el-option label="已下线" value="offline" />
|
|
||||||
</el-select>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="episode-toolbar"
|
<div class="episode-toolbar"
|
||||||
><div
|
><div
|
||||||
><h2>剧集列表({{ total }})</h2><p>按列表顺序播放</p></div
|
><h2>剧集列表({{ episodes.length }})</h2><p>按列表顺序播放</p></div
|
||||||
></div
|
></div
|
||||||
>
|
>
|
||||||
<el-table
|
<el-table
|
||||||
v-loading="loading"
|
v-loading="loading"
|
||||||
:data="episodes"
|
:data="episodes"
|
||||||
row-key="id"
|
row-key="id"
|
||||||
|
empty-text="该短剧暂无剧集"
|
||||||
class="drama-el-table episode-el-table"
|
class="drama-el-table episode-el-table"
|
||||||
>
|
>
|
||||||
<template #empty>
|
|
||||||
<el-empty
|
|
||||||
v-if="showEmpty"
|
|
||||||
:description="selectedDramaId ? '该短剧暂无剧集' : '请先选择短剧'"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
<el-table-column label="集数" width="90"
|
<el-table-column label="集数" width="90"
|
||||||
><template #default="{ row }">{{
|
><template #default="{ row }">{{
|
||||||
String(row.number ?? 0).padStart(2, '0')
|
String(row.number).padStart(2, '0')
|
||||||
}}</template></el-table-column
|
}}</template></el-table-column
|
||||||
>
|
>
|
||||||
<el-table-column label="剧集名称" min-width="240"
|
<el-table-column label="剧集名称" min-width="240"
|
||||||
@@ -379,24 +398,6 @@ onMounted(async () => {
|
|||||||
<el-table-column label="播放量" width="120"
|
<el-table-column label="播放量" width="120"
|
||||||
><template #default="{ row }">{{ formatCount(row.views) }}</template></el-table-column
|
><template #default="{ row }">{{ formatCount(row.views) }}</template></el-table-column
|
||||||
>
|
>
|
||||||
<el-table-column label="点赞(本集)" width="120"
|
|
||||||
><template #default="{ row }">{{
|
|
||||||
formatCount(row.likeCount ?? 0)
|
|
||||||
}}</template></el-table-column
|
|
||||||
>
|
|
||||||
<el-table-column label="评论(本集)" width="120"
|
|
||||||
><template #default="{ row }">{{
|
|
||||||
formatCount(row.commentCount ?? 0)
|
|
||||||
}}</template></el-table-column
|
|
||||||
>
|
|
||||||
<el-table-column label="所属剧收藏" width="120"
|
|
||||||
><template #default="{ row }">{{
|
|
||||||
formatCount(row.favoriteCount ?? 0)
|
|
||||||
}}</template></el-table-column
|
|
||||||
>
|
|
||||||
<el-table-column label="所属剧热度" width="120"
|
|
||||||
><template #default="{ row }">{{ formatCount(row.heat ?? 0) }}</template></el-table-column
|
|
||||||
>
|
|
||||||
<el-table-column label="状态" width="110"
|
<el-table-column label="状态" width="110"
|
||||||
><template #default="{ row }"
|
><template #default="{ row }"
|
||||||
><el-tag :class="['status-badge', statusClass(row.status)]" effect="light">{{
|
><el-tag :class="['status-badge', statusClass(row.status)]" effect="light">{{
|
||||||
@@ -405,7 +406,7 @@ onMounted(async () => {
|
|||||||
></el-table-column
|
></el-table-column
|
||||||
>
|
>
|
||||||
<el-table-column label="操作" width="250" fixed="right"
|
<el-table-column label="操作" width="250" fixed="right"
|
||||||
><template #default="{ row }"
|
><template #default="{ row, $index }"
|
||||||
><div class="table-actions"
|
><div class="table-actions"
|
||||||
><el-button
|
><el-button
|
||||||
v-if="can('episode:upload')"
|
v-if="can('episode:upload')"
|
||||||
@@ -416,14 +417,14 @@ onMounted(async () => {
|
|||||||
><el-button
|
><el-button
|
||||||
v-if="can('episode:sort')"
|
v-if="can('episode:sort')"
|
||||||
size="small"
|
size="small"
|
||||||
:disabled="!canMoveUp(row)"
|
:disabled="$index === 0"
|
||||||
@click="move(row, -1)"
|
@click="move($index, -1)"
|
||||||
>上移</el-button
|
>上移</el-button
|
||||||
><el-button
|
><el-button
|
||||||
v-if="can('episode:sort')"
|
v-if="can('episode:sort')"
|
||||||
size="small"
|
size="small"
|
||||||
:disabled="!canMoveDown(row)"
|
:disabled="$index === episodes.length - 1"
|
||||||
@click="move(row, 1)"
|
@click="move($index, 1)"
|
||||||
>下移</el-button
|
>下移</el-button
|
||||||
><el-button
|
><el-button
|
||||||
v-if="can('episode:upload')"
|
v-if="can('episode:upload')"
|
||||||
@@ -436,25 +437,180 @@ onMounted(async () => {
|
|||||||
></el-table-column
|
></el-table-column
|
||||||
>
|
>
|
||||||
</el-table>
|
</el-table>
|
||||||
<div class="pagination"
|
|
||||||
><el-pagination
|
|
||||||
v-model:current-page="pageIndex"
|
|
||||||
v-model:page-size="pageSize"
|
|
||||||
:page-sizes="PAGE_SIZE_OPTIONS"
|
|
||||||
:total="total"
|
|
||||||
:pager-count="7"
|
|
||||||
layout="total, sizes, prev, pager, next, jumper"
|
|
||||||
background
|
|
||||||
@size-change="handleSizeChange"
|
|
||||||
@current-change="handlePageChange"
|
|
||||||
/></div>
|
|
||||||
</section>
|
</section>
|
||||||
<EpisodeFormDialog
|
<el-dialog
|
||||||
ref="formDialogRef"
|
v-model="dialogVisible"
|
||||||
:drama-options="selectedDrama"
|
:title="editingId ? '编辑剧集' : '新增剧集'"
|
||||||
:next-number="batchNextNumber"
|
width="680px"
|
||||||
@saved="loadEpisodes"
|
class="episode-editor-dialog"
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
:before-close="beforeDialogClose"
|
||||||
|
>
|
||||||
|
<el-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="form"
|
||||||
|
:rules="formRules"
|
||||||
|
label-position="top"
|
||||||
|
class="episode-editor-form"
|
||||||
|
>
|
||||||
|
<section class="episode-editor-section">
|
||||||
|
<h3 class="episode-editor-section-title">基础信息</h3>
|
||||||
|
<div class="episode-editor-grid episode-editor-grid--two">
|
||||||
|
<el-form-item label="集号" prop="number">
|
||||||
|
<el-input-number
|
||||||
|
v-model="form.number"
|
||||||
|
class="episode-editor-number"
|
||||||
|
controls-position="right"
|
||||||
|
:min="1"
|
||||||
|
:max="999"
|
||||||
/>
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="时长(秒)">
|
||||||
|
<el-input-number
|
||||||
|
v-model="form.durationSec"
|
||||||
|
class="episode-editor-number"
|
||||||
|
controls-position="right"
|
||||||
|
:min="0"
|
||||||
|
:max="9999"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</div>
|
||||||
|
<el-form-item label="剧集标题" prop="title">
|
||||||
|
<el-input v-model="form.title" maxlength="100" placeholder="例如:命运的相遇" />
|
||||||
|
</el-form-item>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="episode-editor-section">
|
||||||
|
<h3 class="episode-editor-section-title">视频文件</h3>
|
||||||
|
<el-form-item prop="videoUrl">
|
||||||
|
<div class="episode-video-editor">
|
||||||
|
<div class="episode-video-preview-card">
|
||||||
|
<video
|
||||||
|
v-if="form.videoUrl"
|
||||||
|
:src="form.videoUrl"
|
||||||
|
controls
|
||||||
|
preload="metadata"
|
||||||
|
class="episode-editor-video"
|
||||||
|
></video>
|
||||||
|
<el-upload
|
||||||
|
v-else
|
||||||
|
drag
|
||||||
|
class="episode-video-empty-upload"
|
||||||
|
:show-file-list="false"
|
||||||
|
accept=".mp4,.mov"
|
||||||
|
:before-upload="beforeVideoUpload"
|
||||||
|
:http-request="uploadVideo"
|
||||||
|
:disabled="uploadingVideo"
|
||||||
|
>
|
||||||
|
<div class="episode-video-empty-copy">
|
||||||
|
<AppIcon :icon="AppIcons.videoCameraFront" :size="30" />
|
||||||
|
<b>拖放或点击上传</b>
|
||||||
|
<span>MP4、MOV</span>
|
||||||
|
</div>
|
||||||
|
</el-upload>
|
||||||
|
<div v-if="uploadingVideo" class="episode-video-upload-mask">
|
||||||
|
<span>上传中</span>
|
||||||
|
<b>{{ videoPercent }}%</b>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="episode-video-meta">
|
||||||
|
<div class="episode-video-status">
|
||||||
|
<el-tag :type="form.videoUrl ? 'success' : 'info'" effect="light">
|
||||||
|
{{ form.videoUrl ? '已上传' : '未上传' }}
|
||||||
|
</el-tag>
|
||||||
|
<span class="episode-video-filename" :title="videoDisplayName">
|
||||||
|
{{ videoDisplayName }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<p class="episode-video-hint">支持 MP4、MOV,单个文件不超过 500MB。</p>
|
||||||
|
<el-alert
|
||||||
|
v-if="videoError"
|
||||||
|
:title="videoError"
|
||||||
|
type="error"
|
||||||
|
:closable="false"
|
||||||
|
show-icon
|
||||||
|
/>
|
||||||
|
<div class="episode-video-actions">
|
||||||
|
<el-upload
|
||||||
|
v-if="form.videoUrl"
|
||||||
|
:show-file-list="false"
|
||||||
|
accept=".mp4,.mov"
|
||||||
|
:before-upload="beforeVideoUpload"
|
||||||
|
:http-request="uploadVideo"
|
||||||
|
:disabled="uploadingVideo"
|
||||||
|
>
|
||||||
|
<el-button :loading="uploadingVideo" :disabled="uploadingVideo">
|
||||||
|
<AppIcon :icon="AppIcons.upload" />
|
||||||
|
更换视频
|
||||||
|
</el-button>
|
||||||
|
</el-upload>
|
||||||
|
<el-button
|
||||||
|
v-if="form.videoUrl"
|
||||||
|
type="danger"
|
||||||
|
:disabled="uploadingVideo"
|
||||||
|
@click="removeVideo"
|
||||||
|
>
|
||||||
|
移除
|
||||||
|
</el-button>
|
||||||
|
<a
|
||||||
|
v-if="form.videoUrl"
|
||||||
|
class="episode-video-link"
|
||||||
|
:href="form.videoUrl"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
>
|
||||||
|
查看视频
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-form-item>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="episode-editor-section">
|
||||||
|
<h3 class="episode-editor-section-title">付费与状态</h3>
|
||||||
|
<div class="episode-editor-grid episode-editor-grid--three">
|
||||||
|
<el-form-item label="是否免费">
|
||||||
|
<el-switch v-model="form.isFree" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item v-show="!form.isFree" label="解锁金币">
|
||||||
|
<el-input-number
|
||||||
|
v-model="form.unlockCoin"
|
||||||
|
class="episode-editor-number"
|
||||||
|
controls-position="right"
|
||||||
|
:min="0"
|
||||||
|
:max="9999"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="状态">
|
||||||
|
<el-select v-model="form.status">
|
||||||
|
<el-option
|
||||||
|
v-for="item in statusOptions"
|
||||||
|
:key="item.code"
|
||||||
|
:label="item.text"
|
||||||
|
:value="item.code"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<template #footer>
|
||||||
|
<el-button :disabled="saving || uploadingVideo" @click="dialogVisible = false">
|
||||||
|
取消
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
:loading="saving"
|
||||||
|
:disabled="saving || uploadingVideo"
|
||||||
|
@click="saveEpisode"
|
||||||
|
>
|
||||||
|
保存
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
<el-dialog
|
<el-dialog
|
||||||
v-model="previewVisible"
|
v-model="previewVisible"
|
||||||
:title="`预览:第 ${previewEpisode?.number ?? ''} 集 ${previewEpisode?.title ?? ''}`"
|
:title="`预览:第 ${previewEpisode?.number ?? ''} 集 ${previewEpisode?.title ?? ''}`"
|
||||||
@@ -470,15 +626,4 @@ onMounted(async () => {
|
|||||||
></video>
|
></video>
|
||||||
<el-empty v-else description="该剧集还没有上传视频" />
|
<el-empty v-else description="该剧集还没有上传视频" />
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
<BatchUploadDialog
|
|
||||||
v-if="selectedDramaId"
|
|
||||||
v-model="batchUploadVisible"
|
|
||||||
:drama-id="selectedDramaId"
|
|
||||||
:next-episode-number="batchNextNumber"
|
|
||||||
:default-unlock-coin="selectedDrama?.unlockCoin ?? 0"
|
|
||||||
:free-episodes="selectedDrama?.freeEpisodes ?? 0"
|
|
||||||
:existing-numbers="existingEpisodeNumbers"
|
|
||||||
@refreshed="loadEpisodes"
|
|
||||||
@created="onBatchEpisodesCreated"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
@@ -1,239 +0,0 @@
|
|||||||
<!-- 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"
|
|
||||||
@update:locales="form.locales = $event"
|
|
||||||
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>
|
|
||||||
@@ -1,363 +0,0 @@
|
|||||||
<!-- Author: fruit.com.cn -->
|
|
||||||
<!-- 剧集批量上传弹窗:先入队待上传,点「开始上传」后再执行 -->
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { computed, onBeforeUnmount, ref, watch } from 'vue'
|
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
||||||
import { AppIcons } from '@/constants/icons'
|
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
|
||||||
import CreateEpisodesDialog from './CreateEpisodesDialog.vue'
|
|
||||||
import UploadTaskRow from './UploadTaskRow.vue'
|
|
||||||
import { useUploadQueue } from './useUploadQueue'
|
|
||||||
import { MAX_VIDEO_SIZE, VIDEO_ACCEPT_ATTR, VIDEO_EXTENSIONS } from './videoLimit'
|
|
||||||
import type { UploadSessionRecord } from './uploadSessions'
|
|
||||||
|
|
||||||
const props = withDefaults(
|
|
||||||
defineProps<{
|
|
||||||
modelValue: boolean
|
|
||||||
dramaId: string | number
|
|
||||||
nextEpisodeNumber: number
|
|
||||||
defaultUnlockCoin: number
|
|
||||||
existingNumbers: number[]
|
|
||||||
/** 所属短剧免费集数;不传默认 0 */
|
|
||||||
freeEpisodes?: number
|
|
||||||
}>(),
|
|
||||||
{
|
|
||||||
freeEpisodes: 0
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
'update:modelValue': [value: boolean]
|
|
||||||
created: []
|
|
||||||
refreshed: []
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const { t } = useI18n()
|
|
||||||
|
|
||||||
const visible = computed({
|
|
||||||
get: () => props.modelValue,
|
|
||||||
set: (value: boolean) => emit('update:modelValue', value)
|
|
||||||
})
|
|
||||||
|
|
||||||
const dramaKey = computed(() => String(props.dramaId || ''))
|
|
||||||
const fileInputRef = ref<HTMLInputElement | null>(null)
|
|
||||||
const resumeFileInputRef = ref<HTMLInputElement | null>(null)
|
|
||||||
const rejectedNames = ref<string[]>([])
|
|
||||||
const pendingSessions = ref<UploadSessionRecord[]>([])
|
|
||||||
const createVisible = ref(false)
|
|
||||||
const resumePromptShown = ref(false)
|
|
||||||
|
|
||||||
const queue = useUploadQueue({ getDramaId: () => dramaKey.value })
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => props.dramaId,
|
|
||||||
() => {
|
|
||||||
queue.clear()
|
|
||||||
resumePromptShown.value = false
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
const canCreateEpisodes = computed(() => queue.doneItems.value.length > 0)
|
|
||||||
|
|
||||||
const startButtonLabel = computed(() =>
|
|
||||||
queue.isUploading.value ? t('episodeBatch.uploadingAction') : t('episodeBatch.startUpload')
|
|
||||||
)
|
|
||||||
|
|
||||||
function extensionOf(fileName: string): string {
|
|
||||||
const parts = String(fileName || '').split('.')
|
|
||||||
return (parts.pop() || '').toLowerCase()
|
|
||||||
}
|
|
||||||
|
|
||||||
function validateFile(file: File): string {
|
|
||||||
if (!VIDEO_EXTENSIONS.includes(extensionOf(file.name))) {
|
|
||||||
return t('episodeBatch.invalidType')
|
|
||||||
}
|
|
||||||
if (file.size > MAX_VIDEO_SIZE) {
|
|
||||||
return t('episodeBatch.oversize')
|
|
||||||
}
|
|
||||||
return ''
|
|
||||||
}
|
|
||||||
|
|
||||||
function onPickFiles(event: Event): void {
|
|
||||||
const input = event.target as HTMLInputElement
|
|
||||||
const files = Array.from(input.files || [])
|
|
||||||
input.value = ''
|
|
||||||
if (!files.length) return
|
|
||||||
const accepted: File[] = []
|
|
||||||
const rejected: string[] = []
|
|
||||||
for (const file of files) {
|
|
||||||
const reason = validateFile(file)
|
|
||||||
if (reason) {
|
|
||||||
rejected.push(`${file.name}: ${reason}`)
|
|
||||||
} else {
|
|
||||||
accepted.push(file)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rejectedNames.value = rejected
|
|
||||||
if (!accepted.length) return
|
|
||||||
// 只入队,不发起上传;等用户点「开始上传」
|
|
||||||
queue.enqueue(accepted)
|
|
||||||
}
|
|
||||||
|
|
||||||
function openFilePicker(): void {
|
|
||||||
fileInputRef.value?.click()
|
|
||||||
}
|
|
||||||
|
|
||||||
function onStartUpload(): void {
|
|
||||||
if (!queue.canStart.value) return
|
|
||||||
queue.start()
|
|
||||||
}
|
|
||||||
|
|
||||||
function onBeforeUnload(event: BeforeUnloadEvent): void {
|
|
||||||
if (!queue.hasActiveUpload.value) return
|
|
||||||
event.preventDefault()
|
|
||||||
event.returnValue = ''
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => queue.hasActiveUpload.value,
|
|
||||||
(active) => {
|
|
||||||
if (active) {
|
|
||||||
window.addEventListener('beforeunload', onBeforeUnload)
|
|
||||||
} else {
|
|
||||||
window.removeEventListener('beforeunload', onBeforeUnload)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
|
||||||
window.removeEventListener('beforeunload', onBeforeUnload)
|
|
||||||
})
|
|
||||||
|
|
||||||
async function promptResumeIfNeeded(): Promise<void> {
|
|
||||||
if (resumePromptShown.value || !dramaKey.value) return
|
|
||||||
const sessions = queue.getPendingSessions()
|
|
||||||
if (!sessions.length) return
|
|
||||||
resumePromptShown.value = true
|
|
||||||
pendingSessions.value = sessions
|
|
||||||
try {
|
|
||||||
await ElMessageBox.confirm(
|
|
||||||
t('episodeBatch.resumeConfirm', { count: sessions.length }),
|
|
||||||
t('episodeBatch.resumeTitle'),
|
|
||||||
{
|
|
||||||
confirmButtonText: t('episodeBatch.resumeYes'),
|
|
||||||
cancelButtonText: t('episodeBatch.resumeNo'),
|
|
||||||
type: 'info'
|
|
||||||
}
|
|
||||||
)
|
|
||||||
resumeFileInputRef.value?.click()
|
|
||||||
} catch {
|
|
||||||
queue.abandonSessions(sessions)
|
|
||||||
pendingSessions.value = []
|
|
||||||
ElMessage.info(t('episodeBatch.resumeAbandoned'))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function onResumeFiles(event: Event): Promise<void> {
|
|
||||||
const input = event.target as HTMLInputElement
|
|
||||||
const files = Array.from(input.files || [])
|
|
||||||
input.value = ''
|
|
||||||
const sessions = pendingSessions.value
|
|
||||||
if (!files.length || !sessions.length) return
|
|
||||||
const { matched, unmatched } = await queue.resumeFromSessions(sessions, files)
|
|
||||||
pendingSessions.value = []
|
|
||||||
if (unmatched.length) {
|
|
||||||
ElMessage.warning(t('episodeBatch.resumeUnmatched', { count: unmatched.length }))
|
|
||||||
}
|
|
||||||
if (matched.length) {
|
|
||||||
ElMessage.success(t('episodeBatch.resumeMatched', { count: matched.length }))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function beforeClose(done: () => void): void {
|
|
||||||
if (!queue.hasActiveUpload.value) {
|
|
||||||
done()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ElMessageBox.confirm(t('episodeBatch.closeWhileUploading'), t('common.reminder'), {
|
|
||||||
type: 'warning',
|
|
||||||
confirmButtonText: t('common.ok'),
|
|
||||||
cancelButtonText: t('common.cancel')
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
queue.pause()
|
|
||||||
done()
|
|
||||||
})
|
|
||||||
.catch(() => undefined)
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(visible, (open) => {
|
|
||||||
if (open) {
|
|
||||||
void promptResumeIfNeeded()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
function openCreateDialog(): void {
|
|
||||||
if (!canCreateEpisodes.value) return
|
|
||||||
createVisible.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
function onEpisodesCreated(): void {
|
|
||||||
createVisible.value = false
|
|
||||||
emit('created')
|
|
||||||
visible.value = false
|
|
||||||
queue.clear()
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<el-dialog
|
|
||||||
v-model="visible"
|
|
||||||
:title="t('episodeBatch.title')"
|
|
||||||
width="720px"
|
|
||||||
class="batch-upload-dialog"
|
|
||||||
:close-on-click-modal="false"
|
|
||||||
:before-close="beforeClose"
|
|
||||||
>
|
|
||||||
<input
|
|
||||||
ref="fileInputRef"
|
|
||||||
type="file"
|
|
||||||
multiple
|
|
||||||
hidden
|
|
||||||
:accept="VIDEO_ACCEPT_ATTR"
|
|
||||||
@change="onPickFiles"
|
|
||||||
/>
|
|
||||||
<input
|
|
||||||
ref="resumeFileInputRef"
|
|
||||||
type="file"
|
|
||||||
multiple
|
|
||||||
hidden
|
|
||||||
:accept="VIDEO_ACCEPT_ATTR"
|
|
||||||
@change="onResumeFiles"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div class="batch-upload-toolbar">
|
|
||||||
<el-button type="primary" @click="openFilePicker">
|
|
||||||
<AppIcon :icon="AppIcons.upload" />
|
|
||||||
{{ t('episodeBatch.selectFiles') }}
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
:disabled="!queue.started.value || !queue.items.value.length"
|
|
||||||
@click="queue.pause()"
|
|
||||||
>
|
|
||||||
{{ t('episodeBatch.pause') }}
|
|
||||||
</el-button>
|
|
||||||
<el-button :disabled="!queue.canStart.value" @click="queue.start()">
|
|
||||||
{{ t('episodeBatch.resume') }}
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
:disabled="!queue.items.value.some((item) => item.status === 'failed')"
|
|
||||||
@click="queue.retryAll()"
|
|
||||||
>
|
|
||||||
{{ t('episodeBatch.retryAll') }}
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p class="batch-upload-hint">{{ t('episodeBatch.hint') }}</p>
|
|
||||||
|
|
||||||
<div v-if="rejectedNames.length" class="batch-upload-rejected">
|
|
||||||
<p v-for="name in rejectedNames" :key="name">{{ name }}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="queue.items.value.length" class="batch-upload-overall">
|
|
||||||
<span>{{ t('episodeBatch.overallProgress') }}</span>
|
|
||||||
<el-progress :percentage="queue.overallPercent.value" :stroke-width="12" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p v-if="queue.showResultSummary.value" class="batch-upload-summary">
|
|
||||||
{{
|
|
||||||
t('episodeBatch.resultSummary', {
|
|
||||||
done: queue.doneItems.value.length,
|
|
||||||
failed: queue.failedCount.value
|
|
||||||
})
|
|
||||||
}}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div class="batch-upload-list">
|
|
||||||
<UploadTaskRow
|
|
||||||
v-for="(item, index) in queue.items.value"
|
|
||||||
:key="item.id"
|
|
||||||
:item="item"
|
|
||||||
:index="index + 1"
|
|
||||||
:allow-remove="!queue.started.value && item.status === 'waiting'"
|
|
||||||
@retry="queue.retry"
|
|
||||||
@remove="queue.remove"
|
|
||||||
/>
|
|
||||||
<el-empty v-if="!queue.items.value.length" :description="t('episodeBatch.empty')" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<template #footer>
|
|
||||||
<el-button @click="visible = false">{{ t('common.cancel') }}</el-button>
|
|
||||||
<el-button
|
|
||||||
type="primary"
|
|
||||||
:disabled="!queue.canStart.value"
|
|
||||||
:loading="queue.isUploading.value"
|
|
||||||
@click="onStartUpload"
|
|
||||||
>
|
|
||||||
{{ startButtonLabel }}
|
|
||||||
</el-button>
|
|
||||||
<el-button type="success" :disabled="!canCreateEpisodes" @click="openCreateDialog">
|
|
||||||
{{ t('episodeBatch.createEpisodes') }}
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
|
|
||||||
<CreateEpisodesDialog
|
|
||||||
v-model="createVisible"
|
|
||||||
:drama-id="dramaId"
|
|
||||||
:done-items="queue.doneItems.value"
|
|
||||||
:next-episode-number="nextEpisodeNumber"
|
|
||||||
:default-unlock-coin="defaultUnlockCoin"
|
|
||||||
:free-episodes="freeEpisodes"
|
|
||||||
:existing-numbers="existingNumbers"
|
|
||||||
@settled="emit('refreshed')"
|
|
||||||
@created="onEpisodesCreated"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.batch-upload-toolbar {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 8px;
|
|
||||||
margin-bottom: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.batch-upload-hint {
|
|
||||||
margin: 0 0 12px;
|
|
||||||
color: var(--el-text-color-secondary);
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.batch-upload-rejected {
|
|
||||||
margin-bottom: 12px;
|
|
||||||
padding: 8px 12px;
|
|
||||||
border-radius: 6px;
|
|
||||||
background: color-mix(in srgb, var(--el-color-danger) 8%, transparent);
|
|
||||||
color: var(--el-color-danger);
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.batch-upload-rejected p {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.batch-upload-overall {
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.batch-upload-summary {
|
|
||||||
margin: 0 0 12px;
|
|
||||||
padding: 8px 12px;
|
|
||||||
border-radius: 6px;
|
|
||||||
background: color-mix(in srgb, var(--el-color-success) 10%, transparent);
|
|
||||||
color: var(--el-text-color-primary);
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.batch-upload-list {
|
|
||||||
max-height: 360px;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,263 +0,0 @@
|
|||||||
<!-- Author: fruit.com.cn -->
|
|
||||||
<!-- 批量创建分集确认清单:标题取文件名,集号自动顺延,失败可重试 -->
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { ref, watch } from 'vue'
|
|
||||||
import { ElMessage } from 'element-plus'
|
|
||||||
import { createEpisodeApi } from '@/api/admin/episode'
|
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
|
||||||
import type { UploadQueueItem } from './useUploadQueue'
|
|
||||||
|
|
||||||
const props = withDefaults(
|
|
||||||
defineProps<{
|
|
||||||
modelValue: boolean
|
|
||||||
dramaId: string | number
|
|
||||||
doneItems: UploadQueueItem[]
|
|
||||||
nextEpisodeNumber: number
|
|
||||||
defaultUnlockCoin: number
|
|
||||||
existingNumbers: number[]
|
|
||||||
/** 所属短剧免费集数;不传默认 0 */
|
|
||||||
freeEpisodes?: number
|
|
||||||
}>(),
|
|
||||||
{
|
|
||||||
freeEpisodes: 0
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
'update:modelValue': [value: boolean]
|
|
||||||
settled: []
|
|
||||||
created: []
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const { t } = useI18n()
|
|
||||||
|
|
||||||
interface EpisodeDraft {
|
|
||||||
key: string
|
|
||||||
sourceName: string
|
|
||||||
number: number
|
|
||||||
title: string
|
|
||||||
isFree: boolean
|
|
||||||
videoUrl: string
|
|
||||||
durationSec: number
|
|
||||||
saved: boolean
|
|
||||||
error: string
|
|
||||||
}
|
|
||||||
|
|
||||||
const PUBLISHED_STATUS = 'published'
|
|
||||||
const rows = ref<EpisodeDraft[]>([])
|
|
||||||
const submitting = ref(false)
|
|
||||||
|
|
||||||
function baseName(fileName: string): string {
|
|
||||||
const dot = fileName.lastIndexOf('.')
|
|
||||||
if (dot <= 0) return fileName
|
|
||||||
return fileName.slice(0, dot)
|
|
||||||
}
|
|
||||||
|
|
||||||
function compareNatural(left: string, right: string): number {
|
|
||||||
return left.localeCompare(right, undefined, { numeric: true, sensitivity: 'base' })
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 从起点起跳过已占用集号,返回下一个可用值。 */
|
|
||||||
function nextFreeNumber(start: number, used: Set<number>): number {
|
|
||||||
let candidate = start
|
|
||||||
while (used.has(candidate)) {
|
|
||||||
candidate += 1
|
|
||||||
}
|
|
||||||
return candidate
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildRows(): void {
|
|
||||||
const sorted = [...props.doneItems].sort((left, right) =>
|
|
||||||
compareNatural(baseName(left.fileName), baseName(right.fileName))
|
|
||||||
)
|
|
||||||
const used = new Set(props.existingNumbers)
|
|
||||||
let cursor = props.nextEpisodeNumber
|
|
||||||
const freeLimit = props.freeEpisodes
|
|
||||||
rows.value = sorted.map((item) => {
|
|
||||||
const number = nextFreeNumber(cursor, used)
|
|
||||||
used.add(number)
|
|
||||||
cursor = number + 1
|
|
||||||
const isFree = number <= freeLimit
|
|
||||||
return {
|
|
||||||
key: item.id,
|
|
||||||
sourceName: item.fileName,
|
|
||||||
number,
|
|
||||||
title: baseName(item.fileName),
|
|
||||||
isFree,
|
|
||||||
videoUrl: item.url || '',
|
|
||||||
durationSec: item.durationSec || 0,
|
|
||||||
saved: false,
|
|
||||||
error: ''
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => props.modelValue,
|
|
||||||
(open) => {
|
|
||||||
if (open) buildRows()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
function errorText(error: unknown): string {
|
|
||||||
if (error instanceof Error && error.message) return error.message
|
|
||||||
return t('episodeBatch.createFailed')
|
|
||||||
}
|
|
||||||
|
|
||||||
async function createOne(row: EpisodeDraft): Promise<void> {
|
|
||||||
if (!row.videoUrl) {
|
|
||||||
row.error = t('episodeBatch.missingVideo')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
await createEpisodeApi({
|
|
||||||
dramaId: props.dramaId as unknown as number,
|
|
||||||
number: row.number,
|
|
||||||
title: baseName(row.sourceName),
|
|
||||||
durationSec: row.durationSec,
|
|
||||||
videoUrl: row.videoUrl,
|
|
||||||
isFree: row.isFree,
|
|
||||||
unlockCoin: row.isFree ? 0 : props.defaultUnlockCoin,
|
|
||||||
status: PUBLISHED_STATUS
|
|
||||||
})
|
|
||||||
row.saved = true
|
|
||||||
row.error = ''
|
|
||||||
} catch (error) {
|
|
||||||
row.error = errorText(error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function submit(): Promise<void> {
|
|
||||||
if (submitting.value) return
|
|
||||||
submitting.value = true
|
|
||||||
try {
|
|
||||||
for (const row of rows.value) {
|
|
||||||
if (!row.saved) await createOne(row)
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
submitting.value = false
|
|
||||||
}
|
|
||||||
emit('settled')
|
|
||||||
if (rows.value.every((row) => row.saved)) {
|
|
||||||
ElMessage.success(t('episodeBatch.createAllSuccess'))
|
|
||||||
emit('created')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ElMessage.warning(t('episodeBatch.createPartial'))
|
|
||||||
}
|
|
||||||
|
|
||||||
function closeDialog(): void {
|
|
||||||
emit('update:modelValue', false)
|
|
||||||
}
|
|
||||||
|
|
||||||
function hasFailed(): boolean {
|
|
||||||
return rows.value.some((row) => !row.saved && !!row.error)
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<el-dialog
|
|
||||||
:model-value="modelValue"
|
|
||||||
:title="t('episodeBatch.createTitle')"
|
|
||||||
width="760px"
|
|
||||||
:close-on-click-modal="false"
|
|
||||||
@update:model-value="emit('update:modelValue', $event)"
|
|
||||||
>
|
|
||||||
<p class="create-episode-hint">{{ t('episodeBatch.createHint') }}</p>
|
|
||||||
<div class="create-episode-head">
|
|
||||||
<span>{{ t('episodeBatch.colSource') }}</span>
|
|
||||||
<span>{{ t('episodeBatch.colNumber') }}</span>
|
|
||||||
<span>{{ t('episodeBatch.colTitle') }}</span>
|
|
||||||
<span>{{ t('episodeBatch.colFree') }}</span>
|
|
||||||
<span>{{ t('episodeBatch.colResult') }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="create-episode-list">
|
|
||||||
<div
|
|
||||||
v-for="row in rows"
|
|
||||||
:key="row.key"
|
|
||||||
class="create-episode-row"
|
|
||||||
:class="{ 'is-saved': row.saved }"
|
|
||||||
>
|
|
||||||
<b class="create-episode-source" :title="row.sourceName">{{ row.sourceName }}</b>
|
|
||||||
<span class="create-episode-number">{{ row.number }}</span>
|
|
||||||
<span class="create-episode-title" :title="row.title">{{ row.title }}</span>
|
|
||||||
<span class="create-episode-free" :class="row.isFree ? 'is-free' : 'is-paid'">
|
|
||||||
{{ row.isFree ? t('episodeBatch.labelFree') : t('episodeBatch.labelPaid') }}
|
|
||||||
</span>
|
|
||||||
<span class="create-episode-result">
|
|
||||||
{{ row.saved ? t('episodeBatch.createOk') : row.error }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<template #footer>
|
|
||||||
<el-button @click="closeDialog">{{ t('common.cancel') }}</el-button>
|
|
||||||
<el-button type="primary" :loading="submitting" @click="submit">
|
|
||||||
{{ hasFailed() ? t('episodeBatch.retryFailed') : t('episodeBatch.submitCreate') }}
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.create-episode-hint {
|
|
||||||
margin: 0 0 12px;
|
|
||||||
color: var(--el-text-color-secondary);
|
|
||||||
font-size: 13px;
|
|
||||||
line-height: 1.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.create-episode-head,
|
|
||||||
.create-episode-row {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: minmax(120px, 1.2fr) 72px minmax(140px, 1.4fr) 56px minmax(80px, 0.8fr);
|
|
||||||
gap: 8px;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.create-episode-free {
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.create-episode-free.is-free {
|
|
||||||
color: var(--el-color-success);
|
|
||||||
}
|
|
||||||
|
|
||||||
.create-episode-free.is-paid {
|
|
||||||
color: var(--el-color-warning);
|
|
||||||
}
|
|
||||||
|
|
||||||
.create-episode-head {
|
|
||||||
margin-bottom: 8px;
|
|
||||||
color: var(--el-text-color-secondary);
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.create-episode-list {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 10px;
|
|
||||||
max-height: 420px;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.create-episode-source,
|
|
||||||
.create-episode-title {
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.create-episode-number {
|
|
||||||
font-variant-numeric: tabular-nums;
|
|
||||||
}
|
|
||||||
|
|
||||||
.create-episode-result {
|
|
||||||
color: var(--el-text-color-secondary);
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.create-episode-row.is-saved .create-episode-result {
|
|
||||||
color: var(--el-color-success);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,283 +0,0 @@
|
|||||||
<!-- Author: fruit.com.cn -->
|
|
||||||
<!-- 剧集新建/编辑弹窗:表单校验、单集视频上传与保存 -->
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import { nextTick, reactive, ref } from 'vue'
|
|
||||||
import { ElMessage } from 'element-plus'
|
|
||||||
import { createEpisodeApi, updateEpisodeApi } from '@/api/admin/episode'
|
|
||||||
import { formatCount } from '@/utils/format'
|
|
||||||
import EpisodeTranscodePanel from './EpisodeTranscodePanel.vue'
|
|
||||||
import EpisodeVideoUploader from './EpisodeVideoUploader.vue'
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
dramaOptions: { type: Object, default: null },
|
|
||||||
nextNumber: { type: Number, default: 1 },
|
|
||||||
row: { type: Object, default: null }
|
|
||||||
})
|
|
||||||
|
|
||||||
const emit = defineEmits(['saved'])
|
|
||||||
|
|
||||||
const dialogVisible = ref(false)
|
|
||||||
const saving = ref(false)
|
|
||||||
const uploadingVideo = ref(false)
|
|
||||||
const videoFileName = ref('')
|
|
||||||
const editingId = ref(null)
|
|
||||||
const editingCommentCount = ref(0)
|
|
||||||
const formRef = ref()
|
|
||||||
const uploaderRef = ref()
|
|
||||||
|
|
||||||
const form = reactive({
|
|
||||||
number: 1,
|
|
||||||
title: '',
|
|
||||||
durationSec: 0,
|
|
||||||
videoUrl: '',
|
|
||||||
isFree: true,
|
|
||||||
unlockCoin: 0,
|
|
||||||
likeCount: 0,
|
|
||||||
status: 'draft'
|
|
||||||
})
|
|
||||||
|
|
||||||
const statusOptions = [
|
|
||||||
{ code: 'draft', text: '草稿' },
|
|
||||||
{ code: 'approved', text: '待发布' },
|
|
||||||
{ code: 'published', text: '已上线' },
|
|
||||||
{ code: 'offline', text: '已下线' }
|
|
||||||
]
|
|
||||||
|
|
||||||
const formRules = {
|
|
||||||
number: [{ required: true, message: '请输入集号', trigger: 'change' }],
|
|
||||||
title: [{ required: true, message: '请输入剧集标题', trigger: 'blur' }],
|
|
||||||
videoUrl: [
|
|
||||||
{
|
|
||||||
validator: (_rule, value, callback) => {
|
|
||||||
if (form.status === 'published' && !value) {
|
|
||||||
callback(new Error('上线剧集必须上传视频'))
|
|
||||||
} else {
|
|
||||||
callback()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
trigger: 'change'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
function episodeBasename(path) {
|
|
||||||
if (!path) return ''
|
|
||||||
const clean = path.split('?')[0].split('#')[0]
|
|
||||||
return decodeURIComponent(clean.split('/').pop() || clean)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function resetValidation() {
|
|
||||||
await nextTick()
|
|
||||||
formRef.value?.clearValidate()
|
|
||||||
}
|
|
||||||
|
|
||||||
function openCreate() {
|
|
||||||
editingId.value = null
|
|
||||||
Object.assign(form, {
|
|
||||||
number: props.nextNumber,
|
|
||||||
title: '',
|
|
||||||
durationSec: 0,
|
|
||||||
videoUrl: '',
|
|
||||||
isFree: true,
|
|
||||||
unlockCoin: props.dramaOptions?.unlockCoin ?? 0,
|
|
||||||
likeCount: 0,
|
|
||||||
status: 'draft'
|
|
||||||
})
|
|
||||||
videoFileName.value = ''
|
|
||||||
uploaderRef.value?.clearError()
|
|
||||||
editingCommentCount.value = 0
|
|
||||||
dialogVisible.value = true
|
|
||||||
resetValidation()
|
|
||||||
}
|
|
||||||
|
|
||||||
function openEdit(row) {
|
|
||||||
const target = row || props.row
|
|
||||||
if (!target) return
|
|
||||||
editingId.value = target.id
|
|
||||||
Object.assign(form, {
|
|
||||||
number: target.number,
|
|
||||||
title: target.title,
|
|
||||||
durationSec: target.durationSec || 0,
|
|
||||||
videoUrl: target.videoUrl || '',
|
|
||||||
isFree: !!target.isFree,
|
|
||||||
unlockCoin: target.unlockCoin || 0,
|
|
||||||
likeCount: target.likeCount ?? 0,
|
|
||||||
status: target.status
|
|
||||||
})
|
|
||||||
videoFileName.value = target.videoUrl ? episodeBasename(target.videoUrl) : ''
|
|
||||||
uploaderRef.value?.clearError()
|
|
||||||
editingCommentCount.value = target.commentCount ?? 0
|
|
||||||
dialogVisible.value = true
|
|
||||||
resetValidation()
|
|
||||||
}
|
|
||||||
|
|
||||||
async function saveEpisode() {
|
|
||||||
if (saving.value || uploadingVideo.value) return
|
|
||||||
try {
|
|
||||||
await formRef.value?.validate()
|
|
||||||
} catch {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const dramaId = props.dramaOptions?.id
|
|
||||||
if (!dramaId) return
|
|
||||||
const payload = {
|
|
||||||
dramaId,
|
|
||||||
number: form.number,
|
|
||||||
title: form.title.trim(),
|
|
||||||
durationSec: form.durationSec || 0,
|
|
||||||
videoUrl: form.videoUrl.trim(),
|
|
||||||
isFree: form.isFree,
|
|
||||||
unlockCoin: form.isFree ? 0 : form.unlockCoin || 0,
|
|
||||||
likeCount: form.likeCount,
|
|
||||||
status: form.status
|
|
||||||
}
|
|
||||||
saving.value = true
|
|
||||||
try {
|
|
||||||
if (editingId.value) {
|
|
||||||
await updateEpisodeApi(editingId.value, payload)
|
|
||||||
ElMessage.success('剧集已更新')
|
|
||||||
} else {
|
|
||||||
await createEpisodeApi(payload)
|
|
||||||
ElMessage.success('剧集已创建')
|
|
||||||
}
|
|
||||||
dialogVisible.value = false
|
|
||||||
emit('saved')
|
|
||||||
} finally {
|
|
||||||
saving.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function beforeDialogClose(done) {
|
|
||||||
if (saving.value || uploadingVideo.value) {
|
|
||||||
ElMessage.warning(saving.value ? '正在保存,请稍候' : '视频正在上传,请稍候')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
done()
|
|
||||||
}
|
|
||||||
|
|
||||||
defineExpose({ openCreate, openEdit })
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<el-dialog
|
|
||||||
v-model="dialogVisible"
|
|
||||||
:title="editingId ? '编辑剧集' : '新增剧集'"
|
|
||||||
width="680px"
|
|
||||||
class="episode-editor-dialog"
|
|
||||||
:close-on-click-modal="false"
|
|
||||||
:before-close="beforeDialogClose"
|
|
||||||
>
|
|
||||||
<el-form
|
|
||||||
ref="formRef"
|
|
||||||
:model="form"
|
|
||||||
:rules="formRules"
|
|
||||||
label-position="top"
|
|
||||||
class="episode-editor-form"
|
|
||||||
>
|
|
||||||
<section class="episode-editor-section">
|
|
||||||
<h3 class="episode-editor-section-title">基础信息</h3>
|
|
||||||
<div class="episode-editor-grid episode-editor-grid--two">
|
|
||||||
<el-form-item label="集号" prop="number">
|
|
||||||
<el-input-number
|
|
||||||
v-model="form.number"
|
|
||||||
class="episode-editor-number"
|
|
||||||
controls-position="right"
|
|
||||||
:min="1"
|
|
||||||
:max="999"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="时长(秒)">
|
|
||||||
<el-input-number
|
|
||||||
v-model="form.durationSec"
|
|
||||||
class="episode-editor-number"
|
|
||||||
controls-position="right"
|
|
||||||
:min="0"
|
|
||||||
:max="9999"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</div>
|
|
||||||
<el-form-item label="剧集标题" prop="title">
|
|
||||||
<el-input v-model="form.title" maxlength="100" placeholder="例如:命运的相遇" />
|
|
||||||
</el-form-item>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="episode-editor-section">
|
|
||||||
<h3 class="episode-editor-section-title">视频文件</h3>
|
|
||||||
<el-form-item prop="videoUrl">
|
|
||||||
<EpisodeVideoUploader
|
|
||||||
ref="uploaderRef"
|
|
||||||
v-model:video-url="form.videoUrl"
|
|
||||||
v-model:duration-sec="form.durationSec"
|
|
||||||
v-model:file-name="videoFileName"
|
|
||||||
v-model:uploading="uploadingVideo"
|
|
||||||
@change="resetValidation"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="episode-editor-section">
|
|
||||||
<h3 class="episode-editor-section-title">互动数据</h3>
|
|
||||||
<div class="episode-editor-grid episode-editor-grid--two">
|
|
||||||
<el-form-item label="本集点赞数">
|
|
||||||
<el-input-number
|
|
||||||
v-model="form.likeCount"
|
|
||||||
class="episode-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="episode-editor-section">
|
|
||||||
<h3 class="episode-editor-section-title">付费与状态</h3>
|
|
||||||
<div class="episode-editor-grid episode-editor-grid--three">
|
|
||||||
<el-form-item label="是否免费">
|
|
||||||
<el-switch v-model="form.isFree" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item v-show="!form.isFree" label="解锁金币">
|
|
||||||
<el-input-number
|
|
||||||
v-model="form.unlockCoin"
|
|
||||||
class="episode-editor-number"
|
|
||||||
controls-position="right"
|
|
||||||
:min="0"
|
|
||||||
:max="9999"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="状态">
|
|
||||||
<el-select v-model="form.status">
|
|
||||||
<el-option
|
|
||||||
v-for="item in statusOptions"
|
|
||||||
:key="item.code"
|
|
||||||
:label="item.text"
|
|
||||||
:value="item.code"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</el-form>
|
|
||||||
|
|
||||||
<EpisodeTranscodePanel v-if="editingId" :episode-id="editingId" :active="dialogVisible" />
|
|
||||||
|
|
||||||
<template #footer>
|
|
||||||
<el-button :disabled="saving || uploadingVideo" @click="dialogVisible = false">
|
|
||||||
取消
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
type="primary"
|
|
||||||
:loading="saving"
|
|
||||||
:disabled="saving || uploadingVideo"
|
|
||||||
@click="saveEpisode"
|
|
||||||
>
|
|
||||||
保存
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</template>
|
|
||||||
@@ -1,315 +0,0 @@
|
|||||||
<!-- Author: fruit.com.cn -->
|
|
||||||
<!-- 剧集转码逐帧、雪碧图与分页预览 -->
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { computed, ref } from 'vue'
|
|
||||||
import type {
|
|
||||||
MediaThumbnailFrameItem,
|
|
||||||
MediaThumbnailResult,
|
|
||||||
MediaThumbnailSpriteInfo
|
|
||||||
} from '@/api/admin/types'
|
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
|
||||||
import { formatTimeMs, THUMBNAIL_PAGE_SIZES } from './episodeTranscodeUi'
|
|
||||||
|
|
||||||
interface FramesView {
|
|
||||||
data: MediaThumbnailResult | null
|
|
||||||
loading: boolean
|
|
||||||
errorMessage: string
|
|
||||||
pageIndex: number
|
|
||||||
pageSize: number
|
|
||||||
}
|
|
||||||
|
|
||||||
const props = defineProps<{
|
|
||||||
view: FramesView
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
pageChange: [value: number]
|
|
||||||
pageSizeChange: [value: number]
|
|
||||||
retry: []
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const FRAME_CARD_WIDTH = 128
|
|
||||||
const PREVIEW_MAX_WIDTH = 520
|
|
||||||
const PREVIEW_MAX_HEIGHT = 360
|
|
||||||
|
|
||||||
const { t } = useI18n()
|
|
||||||
const frameView = ref<'frames' | 'sprites'>('frames')
|
|
||||||
const previewVisible = ref(false)
|
|
||||||
const previewFrame = ref<MediaThumbnailFrameItem | null>(null)
|
|
||||||
const frames = computed(() => props.view.data?.frames?.list || [])
|
|
||||||
const sprite = computed(() => props.view.data?.sprite || null)
|
|
||||||
const spriteUrls = computed(() => sprite.value?.spriteUrls || [])
|
|
||||||
const framesTotal = computed(() => Number(props.view.data?.frames?.total || 0))
|
|
||||||
const previewStyle = computed(() => {
|
|
||||||
const frame = previewFrame.value
|
|
||||||
const info = sprite.value
|
|
||||||
if (!frame || !info) return {}
|
|
||||||
const scale = Math.min(
|
|
||||||
PREVIEW_MAX_WIDTH / Math.max(1, frame.width),
|
|
||||||
PREVIEW_MAX_HEIGHT / Math.max(1, frame.height)
|
|
||||||
)
|
|
||||||
return frameStyle(frame, info, scale)
|
|
||||||
})
|
|
||||||
|
|
||||||
function openFramePreview(frame: MediaThumbnailFrameItem) {
|
|
||||||
previewFrame.value = frame
|
|
||||||
previewVisible.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
function frameStyle(frame: MediaThumbnailFrameItem, info: MediaThumbnailSpriteInfo, scale: number) {
|
|
||||||
return {
|
|
||||||
width: `${Math.round(frame.width * scale)}px`,
|
|
||||||
height: `${Math.round(frame.height * scale)}px`,
|
|
||||||
backgroundImage: `url("${frame.spriteUrl || frame.imageUrl}")`,
|
|
||||||
backgroundPosition: `-${Math.round(frame.x * scale)}px -${Math.round(frame.y * scale)}px`,
|
|
||||||
backgroundSize: `${Math.round((info.columns || 1) * frame.width * scale)}px ${Math.round(
|
|
||||||
(info.rows || 1) * frame.height * scale
|
|
||||||
)}px`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function frameCardStyle(frame: MediaThumbnailFrameItem) {
|
|
||||||
if (!sprite.value) return {}
|
|
||||||
return frameStyle(frame, sprite.value, FRAME_CARD_WIDTH / Math.max(1, frame.width))
|
|
||||||
}
|
|
||||||
|
|
||||||
function spriteFrameCount(index: number) {
|
|
||||||
const info = sprite.value
|
|
||||||
if (!info) return 0
|
|
||||||
const capacity = Math.max(1, info.columns * info.rows)
|
|
||||||
return Math.max(0, Math.min(capacity, info.totalFrames - index * capacity))
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="episode-transcode-frames__heading">
|
|
||||||
<h4>{{ t('episodeTranscode.frameTitle') }}</h4>
|
|
||||||
<div class="episode-transcode-frames__tools">
|
|
||||||
<span>{{ t('episodeTranscode.frameCount', { total: framesTotal }) }}</span>
|
|
||||||
<el-radio-group v-model="frameView" size="small">
|
|
||||||
<el-radio-button label="frames">{{ t('episodeTranscode.frameView') }}</el-radio-button>
|
|
||||||
<el-radio-button label="sprites">{{ t('episodeTranscode.spriteView') }}</el-radio-button>
|
|
||||||
</el-radio-group>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<el-alert
|
|
||||||
v-if="view.errorMessage"
|
|
||||||
type="error"
|
|
||||||
:title="view.errorMessage"
|
|
||||||
:closable="false"
|
|
||||||
show-icon
|
|
||||||
>
|
|
||||||
<template #default>
|
|
||||||
<el-button size="small" text @click="emit('retry')">
|
|
||||||
{{ t('episodeTranscode.retryLoad') }}
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
</el-alert>
|
|
||||||
<div v-loading="view.loading">
|
|
||||||
<template v-if="frameView === 'frames'">
|
|
||||||
<div v-if="frames.length" class="episode-transcode-frames__grid">
|
|
||||||
<button
|
|
||||||
v-for="frame in frames"
|
|
||||||
:key="frame.frameIndex"
|
|
||||||
class="episode-transcode-frames__card"
|
|
||||||
type="button"
|
|
||||||
:aria-label="t('episodeTranscode.previewFrame', { time: formatTimeMs(frame.timeMs) })"
|
|
||||||
@click="openFramePreview(frame)"
|
|
||||||
>
|
|
||||||
<span class="episode-transcode-frames__image" :style="frameCardStyle(frame)"></span>
|
|
||||||
<span>{{ formatTimeMs(frame.timeMs) }}</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<el-empty v-else :description="t('episodeTranscode.noFrames')" :image-size="58" />
|
|
||||||
<el-pagination
|
|
||||||
v-if="framesTotal"
|
|
||||||
class="episode-transcode-frames__pagination"
|
|
||||||
background
|
|
||||||
layout="sizes, prev, pager, next"
|
|
||||||
:current-page="view.pageIndex"
|
|
||||||
:page-size="view.pageSize"
|
|
||||||
:page-sizes="THUMBNAIL_PAGE_SIZES"
|
|
||||||
:total="framesTotal"
|
|
||||||
@current-change="emit('pageChange', $event)"
|
|
||||||
@size-change="emit('pageSizeChange', $event)"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
<div v-else-if="spriteUrls.length && sprite" class="episode-transcode-frames__sprites">
|
|
||||||
<figure
|
|
||||||
v-for="(url, index) in spriteUrls"
|
|
||||||
:key="url"
|
|
||||||
class="episode-transcode-frames__sprite"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="episode-transcode-frames__sprite-frame"
|
|
||||||
:style="{
|
|
||||||
aspectRatio: `${sprite.columns * sprite.thumbWidth} / ${
|
|
||||||
sprite.rows * sprite.thumbHeight
|
|
||||||
}`
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<el-image
|
|
||||||
:src="url"
|
|
||||||
:preview-src-list="spriteUrls"
|
|
||||||
:initial-index="index"
|
|
||||||
fit="contain"
|
|
||||||
preview-teleported
|
|
||||||
hide-on-click-modal
|
|
||||||
/>
|
|
||||||
<span
|
|
||||||
class="episode-transcode-frames__sprite-grid"
|
|
||||||
:style="{
|
|
||||||
backgroundSize: `calc(100% / ${sprite.columns}) calc(100% / ${sprite.rows})`
|
|
||||||
}"
|
|
||||||
></span>
|
|
||||||
</div>
|
|
||||||
<figcaption>
|
|
||||||
<b>{{ t('episodeTranscode.spriteSheet', { index: index + 1 }) }}</b>
|
|
||||||
<span>{{
|
|
||||||
t('episodeTranscode.spriteSheetFrames', { count: spriteFrameCount(index) })
|
|
||||||
}}</span>
|
|
||||||
</figcaption>
|
|
||||||
</figure>
|
|
||||||
</div>
|
|
||||||
<el-empty v-else :description="t('episodeTranscode.noSprites')" :image-size="58" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<el-dialog
|
|
||||||
v-model="previewVisible"
|
|
||||||
:title="t('episodeTranscode.zoomTitle')"
|
|
||||||
width="min(92vw, 600px)"
|
|
||||||
append-to-body
|
|
||||||
destroy-on-close
|
|
||||||
>
|
|
||||||
<div class="episode-transcode-frames__preview-shell">
|
|
||||||
<div class="episode-transcode-frames__preview-image" :style="previewStyle"></div>
|
|
||||||
</div>
|
|
||||||
</el-dialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.episode-transcode-frames__heading {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 12px;
|
|
||||||
margin: 18px 0 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.episode-transcode-frames__heading h4 {
|
|
||||||
margin: 0;
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.episode-transcode-frames__tools {
|
|
||||||
display: flex;
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--el-text-color-secondary);
|
|
||||||
align-items: center;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.episode-transcode-frames__grid {
|
|
||||||
display: grid;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 10px;
|
|
||||||
grid-template-columns: repeat(4, 128px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.episode-transcode-frames__card {
|
|
||||||
display: flex;
|
|
||||||
min-width: 0;
|
|
||||||
padding: 0;
|
|
||||||
font-size: 11px;
|
|
||||||
color: var(--el-text-color-secondary);
|
|
||||||
cursor: zoom-in;
|
|
||||||
background: transparent;
|
|
||||||
border: 0;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.episode-transcode-frames__image {
|
|
||||||
display: block;
|
|
||||||
overflow: hidden;
|
|
||||||
background-color: var(--el-fill-color-dark);
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
border: 1px solid var(--el-border-color-lighter);
|
|
||||||
border-radius: 7px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.episode-transcode-frames__card:hover .episode-transcode-frames__image {
|
|
||||||
border-color: var(--el-color-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.episode-transcode-frames__pagination {
|
|
||||||
margin-top: 14px;
|
|
||||||
justify-content: flex-end;
|
|
||||||
}
|
|
||||||
|
|
||||||
.episode-transcode-frames__sprites {
|
|
||||||
display: grid;
|
|
||||||
gap: 16px;
|
|
||||||
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
|
|
||||||
}
|
|
||||||
|
|
||||||
.episode-transcode-frames__sprite {
|
|
||||||
min-width: 0;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.episode-transcode-frames__sprite-frame {
|
|
||||||
position: relative;
|
|
||||||
overflow: hidden;
|
|
||||||
background: var(--el-fill-color-dark);
|
|
||||||
border: 1px solid var(--el-border-color-lighter);
|
|
||||||
border-radius: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.episode-transcode-frames__sprite-frame :deep(.el-image) {
|
|
||||||
display: block;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.episode-transcode-frames__sprite-grid {
|
|
||||||
position: absolute;
|
|
||||||
inset: 0;
|
|
||||||
pointer-events: none;
|
|
||||||
background-image:
|
|
||||||
linear-gradient(to right, rgb(255 255 255 / 34%) 1px, transparent 1px),
|
|
||||||
linear-gradient(to bottom, rgb(255 255 255 / 34%) 1px, transparent 1px);
|
|
||||||
background-repeat: repeat;
|
|
||||||
}
|
|
||||||
|
|
||||||
.episode-transcode-frames__sprite figcaption {
|
|
||||||
display: flex;
|
|
||||||
padding-top: 6px;
|
|
||||||
font-size: 11px;
|
|
||||||
color: var(--el-text-color-secondary);
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.episode-transcode-frames__preview-shell {
|
|
||||||
display: flex;
|
|
||||||
min-height: 240px;
|
|
||||||
background: var(--el-fill-color-dark);
|
|
||||||
border-radius: 8px;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.episode-transcode-frames__preview-image {
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
border: 1px solid var(--el-border-color-lighter);
|
|
||||||
border-radius: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (width <= 600px) {
|
|
||||||
.episode-transcode-frames__grid {
|
|
||||||
grid-template-columns: repeat(2, 128px);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,266 +0,0 @@
|
|||||||
<!-- Author: fruit.com.cn -->
|
|
||||||
<!-- 剧集转码面板:数据获取、轮询与子组件组合 -->
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { computed, onBeforeUnmount, ref, watch } from 'vue'
|
|
||||||
import { ElMessage } from 'element-plus'
|
|
||||||
import {
|
|
||||||
getEpisodeTranscodeApi,
|
|
||||||
getMediaThumbnailsApi,
|
|
||||||
triggerMediaTranscodeApi
|
|
||||||
} from '@/api/admin/transcode'
|
|
||||||
import type { EpisodeTranscodeItem, MediaThumbnailResult } from '@/api/admin/types'
|
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
|
||||||
import EpisodeTranscodeFrames from './EpisodeTranscodeFrames.vue'
|
|
||||||
import EpisodeTranscodeRenditions from './EpisodeTranscodeRenditions.vue'
|
|
||||||
import EpisodeTranscodeStatusBadge from './EpisodeTranscodeStatusBadge.vue'
|
|
||||||
import EpisodeTranscodeStatusPanel from './EpisodeTranscodeStatusPanel.vue'
|
|
||||||
import {
|
|
||||||
safeTranscodeProgress,
|
|
||||||
THUMBNAIL_PAGE_SIZE,
|
|
||||||
transcodeProgressStatus,
|
|
||||||
transcodeStatusKey,
|
|
||||||
transcodeStatusType
|
|
||||||
} from './episodeTranscodeUi'
|
|
||||||
|
|
||||||
const props = defineProps<{
|
|
||||||
episodeId: string | number
|
|
||||||
active: boolean
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const POLL_INTERVAL_MS = 4000
|
|
||||||
|
|
||||||
const { t } = useI18n()
|
|
||||||
const expanded = ref<string[]>(['transcode'])
|
|
||||||
const detail = ref<EpisodeTranscodeItem | null>(null)
|
|
||||||
const thumbnails = ref<MediaThumbnailResult | null>(null)
|
|
||||||
const loading = ref(false)
|
|
||||||
const thumbnailLoading = ref(false)
|
|
||||||
const retriggering = ref(false)
|
|
||||||
const errorMessage = ref('')
|
|
||||||
const thumbnailError = ref('')
|
|
||||||
const pageIndex = ref(1)
|
|
||||||
const pageSize = ref(THUMBNAIL_PAGE_SIZE)
|
|
||||||
let pollTimer: ReturnType<typeof setTimeout> | null = null
|
|
||||||
let requestSeq = 0
|
|
||||||
let thumbnailSeq = 0
|
|
||||||
|
|
||||||
const mediaAssetId = computed(() => detail.value?.mediaAssetId || '')
|
|
||||||
const hasMedia = computed(() => /^[1-9]\d*$/.test(mediaAssetId.value))
|
|
||||||
const normalizedStatus = computed(() => String(detail.value?.status || '').toUpperCase())
|
|
||||||
const renditions = computed(() => detail.value?.renditions || [])
|
|
||||||
const isProcessing = computed(
|
|
||||||
() => normalizedStatus.value === 'QUEUED' || normalizedStatus.value === 'RUNNING'
|
|
||||||
)
|
|
||||||
const statusLabel = computed(() =>
|
|
||||||
t(`episodeTranscode.status.${transcodeStatusKey(detail.value?.status)}`)
|
|
||||||
)
|
|
||||||
const statusType = computed(() => transcodeStatusType(detail.value?.status))
|
|
||||||
const progressStatus = computed(() => transcodeProgressStatus(detail.value?.status))
|
|
||||||
const progress = computed(() => safeTranscodeProgress(detail.value?.progress))
|
|
||||||
const showOutputs = computed(() => !!detail.value && hasMedia.value && !errorMessage.value)
|
|
||||||
const statusView = computed(() => ({
|
|
||||||
loading: loading.value,
|
|
||||||
errorMessage: errorMessage.value,
|
|
||||||
hasMedia: hasMedia.value,
|
|
||||||
retriggering: retriggering.value,
|
|
||||||
isProcessing: isProcessing.value,
|
|
||||||
statusLabel: statusLabel.value,
|
|
||||||
statusType: statusType.value,
|
|
||||||
progressStatus: progressStatus.value,
|
|
||||||
progress: progress.value
|
|
||||||
}))
|
|
||||||
const framesView = computed(() => ({
|
|
||||||
data: thumbnails.value,
|
|
||||||
loading: thumbnailLoading.value,
|
|
||||||
errorMessage: thumbnailError.value,
|
|
||||||
pageIndex: pageIndex.value,
|
|
||||||
pageSize: pageSize.value
|
|
||||||
}))
|
|
||||||
|
|
||||||
watch(
|
|
||||||
[() => props.episodeId, () => props.active],
|
|
||||||
([episodeId, active], [previousEpisodeId]) => {
|
|
||||||
if (episodeId !== previousEpisodeId) resetState()
|
|
||||||
if (!active) {
|
|
||||||
stopPolling()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (episodeId) void loadDetail()
|
|
||||||
},
|
|
||||||
{ immediate: true }
|
|
||||||
)
|
|
||||||
|
|
||||||
onBeforeUnmount(stopPolling)
|
|
||||||
|
|
||||||
function resetState() {
|
|
||||||
stopPolling()
|
|
||||||
requestSeq += 1
|
|
||||||
thumbnailSeq += 1
|
|
||||||
detail.value = null
|
|
||||||
thumbnails.value = null
|
|
||||||
errorMessage.value = ''
|
|
||||||
thumbnailError.value = ''
|
|
||||||
pageIndex.value = 1
|
|
||||||
pageSize.value = THUMBNAIL_PAGE_SIZE
|
|
||||||
}
|
|
||||||
|
|
||||||
function stopPolling() {
|
|
||||||
if (pollTimer) clearTimeout(pollTimer)
|
|
||||||
pollTimer = null
|
|
||||||
}
|
|
||||||
|
|
||||||
function schedulePolling() {
|
|
||||||
stopPolling()
|
|
||||||
if (!props.active || !isProcessing.value) return
|
|
||||||
pollTimer = setTimeout(() => {
|
|
||||||
pollTimer = null
|
|
||||||
void loadDetail(true)
|
|
||||||
}, POLL_INTERVAL_MS)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadDetail(silent = false) {
|
|
||||||
if (!props.active || !props.episodeId) return
|
|
||||||
const seq = ++requestSeq
|
|
||||||
stopPolling()
|
|
||||||
if (!silent) loading.value = true
|
|
||||||
errorMessage.value = ''
|
|
||||||
try {
|
|
||||||
const response = await getEpisodeTranscodeApi(props.episodeId)
|
|
||||||
if (seq !== requestSeq) return
|
|
||||||
const result = response.data
|
|
||||||
detail.value = result
|
|
||||||
if (result.thumbnails) {
|
|
||||||
thumbnails.value = result.thumbnails
|
|
||||||
pageIndex.value = result.thumbnails.pageIndex || 1
|
|
||||||
pageSize.value = result.thumbnails.pageSize || THUMBNAIL_PAGE_SIZE
|
|
||||||
thumbnailError.value = ''
|
|
||||||
}
|
|
||||||
if (isProcessing.value) schedulePolling()
|
|
||||||
} catch (error) {
|
|
||||||
if (seq !== requestSeq) return
|
|
||||||
errorMessage.value = errorText(error, t('episodeTranscode.loadFailed'))
|
|
||||||
stopPolling()
|
|
||||||
} finally {
|
|
||||||
if (seq === requestSeq) loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadThumbnailPage() {
|
|
||||||
if (!hasMedia.value || thumbnailLoading.value) return
|
|
||||||
const seq = ++thumbnailSeq
|
|
||||||
thumbnailLoading.value = true
|
|
||||||
thumbnailError.value = ''
|
|
||||||
try {
|
|
||||||
const response = await getMediaThumbnailsApi(
|
|
||||||
mediaAssetId.value,
|
|
||||||
pageIndex.value,
|
|
||||||
pageSize.value
|
|
||||||
)
|
|
||||||
if (seq !== thumbnailSeq) return
|
|
||||||
const result = response.data
|
|
||||||
thumbnails.value = result
|
|
||||||
pageIndex.value = result.pageIndex || pageIndex.value
|
|
||||||
pageSize.value = result.pageSize || pageSize.value
|
|
||||||
} catch (error) {
|
|
||||||
if (seq !== thumbnailSeq) return
|
|
||||||
thumbnailError.value = errorText(error, t('episodeTranscode.loadFailed'))
|
|
||||||
} finally {
|
|
||||||
if (seq === thumbnailSeq) thumbnailLoading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function retrigger() {
|
|
||||||
if (!hasMedia.value || isProcessing.value || retriggering.value) return
|
|
||||||
retriggering.value = true
|
|
||||||
errorMessage.value = ''
|
|
||||||
try {
|
|
||||||
await triggerMediaTranscodeApi(mediaAssetId.value)
|
|
||||||
if (detail.value) {
|
|
||||||
detail.value = { ...detail.value, status: 'QUEUED', progress: 0, errorMsg: '' }
|
|
||||||
}
|
|
||||||
ElMessage.success(t('episodeTranscode.triggerSuccess'))
|
|
||||||
await loadDetail(true)
|
|
||||||
schedulePolling()
|
|
||||||
} catch (error) {
|
|
||||||
errorMessage.value = errorText(error, t('episodeTranscode.triggerFailed'))
|
|
||||||
} finally {
|
|
||||||
retriggering.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function changePage(value: number) {
|
|
||||||
pageIndex.value = value
|
|
||||||
void loadThumbnailPage()
|
|
||||||
}
|
|
||||||
|
|
||||||
function changePageSize(value: number) {
|
|
||||||
pageSize.value = value
|
|
||||||
pageIndex.value = 1
|
|
||||||
void loadThumbnailPage()
|
|
||||||
}
|
|
||||||
|
|
||||||
function errorText(error: unknown, fallback: string) {
|
|
||||||
return error instanceof Error && error.message ? error.message : fallback
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<section class="episode-editor-section episode-transcode-panel">
|
|
||||||
<el-collapse v-model="expanded">
|
|
||||||
<el-collapse-item name="transcode">
|
|
||||||
<template #title>
|
|
||||||
<div class="episode-transcode-panel__heading">
|
|
||||||
<span>{{ t('episodeTranscode.title') }}</span>
|
|
||||||
<EpisodeTranscodeStatusBadge
|
|
||||||
:visible="!!detail"
|
|
||||||
:status-label="statusLabel"
|
|
||||||
:status-type="statusType"
|
|
||||||
:progress="progress"
|
|
||||||
:progress-status="progressStatus"
|
|
||||||
:show-progress="!!detail && hasMedia"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<EpisodeTranscodeStatusPanel
|
|
||||||
:detail="detail"
|
|
||||||
:view="statusView"
|
|
||||||
@retry="loadDetail()"
|
|
||||||
@retrigger="retrigger"
|
|
||||||
/>
|
|
||||||
<template v-if="showOutputs">
|
|
||||||
<EpisodeTranscodeRenditions :renditions="renditions" />
|
|
||||||
<EpisodeTranscodeFrames
|
|
||||||
:view="framesView"
|
|
||||||
@page-change="changePage"
|
|
||||||
@page-size-change="changePageSize"
|
|
||||||
@retry="loadThumbnailPage"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</el-collapse-item>
|
|
||||||
</el-collapse>
|
|
||||||
</section>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.episode-transcode-panel :deep(.el-collapse) {
|
|
||||||
border: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.episode-transcode-panel :deep(.el-collapse-item__header),
|
|
||||||
.episode-transcode-panel :deep(.el-collapse-item__wrap) {
|
|
||||||
background: transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
.episode-transcode-panel__heading {
|
|
||||||
display: flex;
|
|
||||||
width: 100%;
|
|
||||||
padding-right: 12px;
|
|
||||||
font-size: 15px;
|
|
||||||
font-weight: 650;
|
|
||||||
color: var(--el-text-color-primary);
|
|
||||||
align-items: center;
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
<!-- Author: fruit.com.cn -->
|
|
||||||
<!-- 剧集转码清晰度表格与播放地址操作 -->
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { ref } from 'vue'
|
|
||||||
import type { MediaRenditionItem } from '@/api/admin/types'
|
|
||||||
import { AppIcon } from '@/components/AppIcon'
|
|
||||||
import { AppIcons } from '@/constants/icons'
|
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
|
||||||
import RenditionPlayerDialog from './RenditionPlayerDialog.vue'
|
|
||||||
import {
|
|
||||||
formatBytes,
|
|
||||||
formatDuration,
|
|
||||||
renditionStatusLabelKey,
|
|
||||||
renditionStatusType
|
|
||||||
} from './episodeTranscodeUi'
|
|
||||||
|
|
||||||
defineProps<{
|
|
||||||
renditions: MediaRenditionItem[]
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const { t } = useI18n()
|
|
||||||
|
|
||||||
const playerVisible = ref(false)
|
|
||||||
const playerUrl = ref('')
|
|
||||||
const playerTitle = ref('')
|
|
||||||
|
|
||||||
function statusLabel(rendition: MediaRenditionItem) {
|
|
||||||
return t(`episodeTranscode.status.${renditionStatusLabelKey(rendition.status)}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
function playRendition(rendition: MediaRenditionItem) {
|
|
||||||
if (!rendition.hlsUrl) return
|
|
||||||
playerUrl.value = rendition.hlsUrl
|
|
||||||
playerTitle.value = `${rendition.qualityName} · ${rendition.resolution}`
|
|
||||||
playerVisible.value = true
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="episode-transcode-renditions__heading">
|
|
||||||
<h4>{{ t('episodeTranscode.renditionTitle') }}</h4>
|
|
||||||
</div>
|
|
||||||
<el-table
|
|
||||||
:data="renditions"
|
|
||||||
size="small"
|
|
||||||
border
|
|
||||||
class="episode-transcode-renditions__table"
|
|
||||||
:empty-text="t('episodeTranscode.noRendition')"
|
|
||||||
>
|
|
||||||
<el-table-column prop="qualityName" :label="t('episodeTranscode.quality')" min-width="88" />
|
|
||||||
<el-table-column prop="resolution" :label="t('episodeTranscode.resolution')" min-width="105" />
|
|
||||||
<el-table-column :label="t('episodeTranscode.videoBitrate')" min-width="105">
|
|
||||||
<template #default="{ row }">{{ row.videoBitrateKbps }} kbps</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column :label="t('episodeTranscode.audioBitrate')" min-width="105">
|
|
||||||
<template #default="{ row }">{{ row.audioBitrateKbps }} kbps</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="videoCodec" :label="t('episodeTranscode.codec')" min-width="82" />
|
|
||||||
<el-table-column prop="container" :label="t('episodeTranscode.container')" min-width="82" />
|
|
||||||
<el-table-column :label="t('episodeTranscode.fileSize')" min-width="92">
|
|
||||||
<template #default="{ row }">{{ formatBytes(row.sizeBytes) }}</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column :label="t('episodeTranscode.duration')" min-width="76">
|
|
||||||
<template #default="{ row }">{{ formatDuration(row.durationSec) }}</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="segmentCount" :label="t('episodeTranscode.segments')" min-width="76" />
|
|
||||||
<el-table-column :label="t('episodeTranscode.statusColumn')" min-width="82">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-tag :type="renditionStatusType(row.status)" effect="light" size="small">
|
|
||||||
{{ statusLabel(row) }}
|
|
||||||
</el-tag>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column :label="t('episodeTranscode.actions')" width="76" fixed="right" align="center">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-tooltip :content="t('episodeTranscode.play')" placement="top">
|
|
||||||
<el-button text circle @click="playRendition(row)">
|
|
||||||
<AppIcon :icon="AppIcons.videoPlay" :size="17" />
|
|
||||||
</el-button>
|
|
||||||
</el-tooltip>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
|
|
||||||
<RenditionPlayerDialog v-model="playerVisible" :url="playerUrl" :title="playerTitle" />
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.episode-transcode-renditions__heading {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 12px;
|
|
||||||
margin: 18px 0 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.episode-transcode-renditions__heading h4 {
|
|
||||||
margin: 0;
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.episode-transcode-renditions__table {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
<!-- Author: fruit.com.cn -->
|
|
||||||
<!-- 剧集转码折叠标题状态徽标 -->
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import type { TranscodeProgressStatus, TranscodeTagType } from './episodeTranscodeUi'
|
|
||||||
|
|
||||||
defineProps<{
|
|
||||||
visible: boolean
|
|
||||||
statusLabel: string
|
|
||||||
statusType: TranscodeTagType
|
|
||||||
progress: number
|
|
||||||
progressStatus: TranscodeProgressStatus
|
|
||||||
showProgress: boolean
|
|
||||||
}>()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<span class="episode-transcode-badge">
|
|
||||||
<el-tag v-if="visible" :type="statusType" effect="light" size="small">
|
|
||||||
{{ statusLabel }}
|
|
||||||
</el-tag>
|
|
||||||
<el-progress
|
|
||||||
v-if="showProgress"
|
|
||||||
class="episode-transcode-badge__progress"
|
|
||||||
:percentage="progress"
|
|
||||||
:status="progressStatus"
|
|
||||||
:stroke-width="6"
|
|
||||||
:show-text="false"
|
|
||||||
/>
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.episode-transcode-badge {
|
|
||||||
display: flex;
|
|
||||||
flex: 1;
|
|
||||||
align-items: center;
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.episode-transcode-badge__progress {
|
|
||||||
width: 110px;
|
|
||||||
margin-left: auto;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,169 +0,0 @@
|
|||||||
<!-- Author: fruit.com.cn -->
|
|
||||||
<!-- 剧集转码状态、进度、错误与重新转码操作 -->
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import type { EpisodeTranscodeItem } from '@/api/admin/types'
|
|
||||||
import { AppIcon } from '@/components/AppIcon'
|
|
||||||
import { AppIcons } from '@/constants/icons'
|
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
|
||||||
import { formatDateTime } from '@/utils/format'
|
|
||||||
import type { TranscodeProgressStatus, TranscodeTagType } from './episodeTranscodeUi'
|
|
||||||
|
|
||||||
interface StatusView {
|
|
||||||
loading: boolean
|
|
||||||
errorMessage: string
|
|
||||||
hasMedia: boolean
|
|
||||||
retriggering: boolean
|
|
||||||
isProcessing: boolean
|
|
||||||
statusLabel: string
|
|
||||||
statusType: TranscodeTagType
|
|
||||||
progressStatus: TranscodeProgressStatus
|
|
||||||
progress: number
|
|
||||||
}
|
|
||||||
|
|
||||||
defineProps<{
|
|
||||||
detail: EpisodeTranscodeItem | null
|
|
||||||
view: StatusView
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
retry: []
|
|
||||||
retrigger: []
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const { t } = useI18n()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<p class="episode-transcode-status__description">
|
|
||||||
{{ t('episodeTranscode.description') }}
|
|
||||||
</p>
|
|
||||||
<el-skeleton v-if="view.loading && !detail" :rows="4" animated />
|
|
||||||
<div v-else-if="view.errorMessage" class="episode-transcode-status__error">
|
|
||||||
<el-alert type="error" :title="view.errorMessage" :closable="false" show-icon />
|
|
||||||
<el-button size="small" @click="emit('retry')">
|
|
||||||
<AppIcon :icon="AppIcons.refresh" :size="16" />
|
|
||||||
{{ t('episodeTranscode.retryLoad') }}
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
<el-empty
|
|
||||||
v-else-if="detail && !view.hasMedia"
|
|
||||||
:description="detail.errorMsg || t('episodeTranscode.noMedia')"
|
|
||||||
:image-size="72"
|
|
||||||
/>
|
|
||||||
<template v-else-if="detail">
|
|
||||||
<div class="episode-transcode-status__summary">
|
|
||||||
<div class="episode-transcode-status__metric">
|
|
||||||
<span>{{ t('episodeTranscode.statusLabel') }}</span>
|
|
||||||
<el-tag :type="view.statusType" effect="light">{{ view.statusLabel }}</el-tag>
|
|
||||||
</div>
|
|
||||||
<div class="episode-transcode-status__metric">
|
|
||||||
<span>{{ t('episodeTranscode.progress') }}</span>
|
|
||||||
<b>{{ view.progress }}%</b>
|
|
||||||
</div>
|
|
||||||
<div class="episode-transcode-status__metric">
|
|
||||||
<span>{{ t('episodeTranscode.retryCount') }}</span>
|
|
||||||
<b>{{ detail.retryCount || 0 }}</b>
|
|
||||||
</div>
|
|
||||||
<div class="episode-transcode-status__metric">
|
|
||||||
<span>{{ t('episodeTranscode.updatedAt') }}</span>
|
|
||||||
<b>{{ formatDateTime(detail.updatedAt) }}</b>
|
|
||||||
</div>
|
|
||||||
<el-button
|
|
||||||
class="episode-transcode-status__retry"
|
|
||||||
type="primary"
|
|
||||||
plain
|
|
||||||
:loading="view.retriggering"
|
|
||||||
:disabled="!view.hasMedia || view.isProcessing || view.retriggering"
|
|
||||||
@click="emit('retrigger')"
|
|
||||||
>
|
|
||||||
<AppIcon :icon="AppIcons.restart" :size="16" />
|
|
||||||
{{
|
|
||||||
view.retriggering ? t('episodeTranscode.reprocessing') : t('episodeTranscode.reprocess')
|
|
||||||
}}
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
<el-progress
|
|
||||||
class="episode-transcode-status__progress"
|
|
||||||
:percentage="view.progress"
|
|
||||||
:status="view.progressStatus"
|
|
||||||
:stroke-width="8"
|
|
||||||
/>
|
|
||||||
<p v-if="view.isProcessing && view.progress === 0" class="episode-transcode-status__waiting">
|
|
||||||
{{ t('episodeTranscode.waitingProgress') }}
|
|
||||||
</p>
|
|
||||||
<el-alert
|
|
||||||
v-if="detail.errorMsg"
|
|
||||||
class="episode-transcode-status__error-alert"
|
|
||||||
type="error"
|
|
||||||
:title="detail.errorMsg"
|
|
||||||
:closable="false"
|
|
||||||
show-icon
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.episode-transcode-status__description {
|
|
||||||
margin: 0 0 14px;
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--el-text-color-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.episode-transcode-status__error {
|
|
||||||
display: flex;
|
|
||||||
align-items: flex-start;
|
|
||||||
gap: 10px;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.episode-transcode-status__summary {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 18px;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.episode-transcode-status__metric {
|
|
||||||
display: flex;
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--el-text-color-secondary);
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.episode-transcode-status__metric b {
|
|
||||||
font-size: 14px;
|
|
||||||
color: var(--el-text-color-primary);
|
|
||||||
font-variant-numeric: tabular-nums;
|
|
||||||
}
|
|
||||||
|
|
||||||
.episode-transcode-status__retry {
|
|
||||||
margin-left: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.episode-transcode-status__progress {
|
|
||||||
margin-top: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.episode-transcode-status__waiting {
|
|
||||||
margin: 8px 0 0;
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--el-color-warning);
|
|
||||||
}
|
|
||||||
|
|
||||||
.episode-transcode-status__error-alert {
|
|
||||||
margin-top: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (width <= 600px) {
|
|
||||||
.episode-transcode-status__summary {
|
|
||||||
align-items: flex-start;
|
|
||||||
}
|
|
||||||
|
|
||||||
.episode-transcode-status__retry {
|
|
||||||
width: 100%;
|
|
||||||
margin-left: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,172 +0,0 @@
|
|||||||
<!-- Author: fruit.com.cn -->
|
|
||||||
<!-- 单集视频上传:格式/大小校验、分片上传、预览与移除 -->
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import { computed, ref, watch } from 'vue'
|
|
||||||
import { ElMessage } from 'element-plus'
|
|
||||||
import { AppIcons } from '@/constants/icons'
|
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
|
||||||
import { probeVideoDuration, uploadFile } from '@/utils/uploader'
|
|
||||||
import { MAX_VIDEO_SIZE, VIDEO_ACCEPT_ATTR, VIDEO_EXTENSIONS } from './videoLimit'
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
videoUrl: { type: String, default: '' },
|
|
||||||
durationSec: { type: Number, default: 0 },
|
|
||||||
fileName: { type: String, default: '' }
|
|
||||||
})
|
|
||||||
|
|
||||||
const emit = defineEmits([
|
|
||||||
'update:videoUrl',
|
|
||||||
'update:durationSec',
|
|
||||||
'update:fileName',
|
|
||||||
'update:uploading',
|
|
||||||
'change'
|
|
||||||
])
|
|
||||||
|
|
||||||
const { t } = useI18n()
|
|
||||||
|
|
||||||
const uploadingVideo = ref(false)
|
|
||||||
const videoPercent = ref(0)
|
|
||||||
const videoError = ref('')
|
|
||||||
|
|
||||||
const videoDisplayName = computed(
|
|
||||||
() => props.fileName || (props.videoUrl ? episodeBasename(props.videoUrl) : '尚未选择视频')
|
|
||||||
)
|
|
||||||
|
|
||||||
watch(uploadingVideo, (value) => emit('update:uploading', value))
|
|
||||||
|
|
||||||
function episodeBasename(path) {
|
|
||||||
if (!path) return ''
|
|
||||||
const clean = path.split('?')[0].split('#')[0]
|
|
||||||
return decodeURIComponent(clean.split('/').pop() || clean)
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearError() {
|
|
||||||
videoError.value = ''
|
|
||||||
}
|
|
||||||
|
|
||||||
function beforeVideoUpload(file) {
|
|
||||||
videoError.value = ''
|
|
||||||
const extension = String(file.name || '')
|
|
||||||
.split('.')
|
|
||||||
.pop()
|
|
||||||
?.toLowerCase()
|
|
||||||
if (!VIDEO_EXTENSIONS.includes(extension)) {
|
|
||||||
videoError.value = t('episodeBatch.invalidType')
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if (file.size > MAX_VIDEO_SIZE) {
|
|
||||||
videoError.value = '视频大小不能超过 500MB'
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 视频分片上传:先探测时长,再交给上传器,完成后回填地址与时长。 */
|
|
||||||
async function uploadVideo(options) {
|
|
||||||
uploadingVideo.value = true
|
|
||||||
videoPercent.value = 0
|
|
||||||
videoError.value = ''
|
|
||||||
try {
|
|
||||||
const duration = await probeVideoDuration(options.file)
|
|
||||||
const asset = await uploadFile(options.file, {
|
|
||||||
bizType: 'EPISODE',
|
|
||||||
durationSec: duration,
|
|
||||||
onProgress: (percent) => (videoPercent.value = percent)
|
|
||||||
})
|
|
||||||
emit('update:videoUrl', asset.url)
|
|
||||||
emit('update:fileName', options.file.name)
|
|
||||||
if (duration > 0) emit('update:durationSec', duration)
|
|
||||||
emit('change')
|
|
||||||
ElMessage.success('视频已上传')
|
|
||||||
} catch {
|
|
||||||
videoError.value = '视频上传失败,请检查网络后重试'
|
|
||||||
} finally {
|
|
||||||
uploadingVideo.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function removeVideo() {
|
|
||||||
if (uploadingVideo.value) return
|
|
||||||
emit('update:videoUrl', '')
|
|
||||||
emit('update:fileName', '')
|
|
||||||
videoError.value = ''
|
|
||||||
emit('change')
|
|
||||||
}
|
|
||||||
|
|
||||||
defineExpose({ clearError, uploadingVideo })
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="episode-video-editor">
|
|
||||||
<div class="episode-video-preview-card">
|
|
||||||
<video
|
|
||||||
v-if="videoUrl"
|
|
||||||
:src="videoUrl"
|
|
||||||
controls
|
|
||||||
preload="metadata"
|
|
||||||
class="episode-editor-video"
|
|
||||||
></video>
|
|
||||||
<el-upload
|
|
||||||
v-else
|
|
||||||
drag
|
|
||||||
class="episode-video-empty-upload"
|
|
||||||
:show-file-list="false"
|
|
||||||
:accept="VIDEO_ACCEPT_ATTR"
|
|
||||||
:before-upload="beforeVideoUpload"
|
|
||||||
:http-request="uploadVideo"
|
|
||||||
:disabled="uploadingVideo"
|
|
||||||
>
|
|
||||||
<div class="episode-video-empty-copy">
|
|
||||||
<AppIcon :icon="AppIcons.videoCameraFront" :size="30" />
|
|
||||||
<b>拖放或点击上传</b>
|
|
||||||
<span>MP4、MOV、MKV、WEBM</span>
|
|
||||||
</div>
|
|
||||||
</el-upload>
|
|
||||||
<div v-if="uploadingVideo" class="episode-video-upload-mask">
|
|
||||||
<span>上传中</span>
|
|
||||||
<b>{{ videoPercent }}%</b>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="episode-video-meta">
|
|
||||||
<div class="episode-video-status">
|
|
||||||
<el-tag :type="videoUrl ? 'success' : 'info'" effect="light">
|
|
||||||
{{ videoUrl ? '已上传' : '未上传' }}
|
|
||||||
</el-tag>
|
|
||||||
<span class="episode-video-filename" :title="videoDisplayName">
|
|
||||||
{{ videoDisplayName }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<p class="episode-video-hint">{{ t('episodeBatch.hint') }}</p>
|
|
||||||
<el-alert v-if="videoError" :title="videoError" type="error" :closable="false" show-icon />
|
|
||||||
<div class="episode-video-actions">
|
|
||||||
<el-upload
|
|
||||||
v-if="videoUrl"
|
|
||||||
:show-file-list="false"
|
|
||||||
:accept="VIDEO_ACCEPT_ATTR"
|
|
||||||
:before-upload="beforeVideoUpload"
|
|
||||||
:http-request="uploadVideo"
|
|
||||||
:disabled="uploadingVideo"
|
|
||||||
>
|
|
||||||
<el-button :loading="uploadingVideo" :disabled="uploadingVideo">
|
|
||||||
<AppIcon :icon="AppIcons.upload" />
|
|
||||||
更换视频
|
|
||||||
</el-button>
|
|
||||||
</el-upload>
|
|
||||||
<el-button v-if="videoUrl" type="danger" :disabled="uploadingVideo" @click="removeVideo">
|
|
||||||
移除
|
|
||||||
</el-button>
|
|
||||||
<a
|
|
||||||
v-if="videoUrl"
|
|
||||||
class="episode-video-link"
|
|
||||||
:href="videoUrl"
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
>
|
|
||||||
查看视频
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
@@ -1,126 +0,0 @@
|
|||||||
<!-- Author: fruit.com.cn -->
|
|
||||||
<!-- 清晰度产物 HLS 预览播放器:Chrome/Edge 用 hls.js,Safari 走原生 -->
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { nextTick, onBeforeUnmount, ref, watch } from 'vue'
|
|
||||||
import type Hls from 'hls.js'
|
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
|
||||||
|
|
||||||
const props = defineProps<{
|
|
||||||
modelValue: boolean
|
|
||||||
url: string
|
|
||||||
title: string
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
(event: 'update:modelValue', value: boolean): void
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const { t } = useI18n()
|
|
||||||
|
|
||||||
const videoRef = ref<HTMLVideoElement>()
|
|
||||||
const errorMsg = ref('')
|
|
||||||
let hls: Hls | null = null
|
|
||||||
|
|
||||||
function destroy() {
|
|
||||||
hls?.destroy()
|
|
||||||
hls = null
|
|
||||||
const video = videoRef.value
|
|
||||||
if (video) {
|
|
||||||
video.pause()
|
|
||||||
video.removeAttribute('src')
|
|
||||||
video.load()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function start(url: string) {
|
|
||||||
await nextTick()
|
|
||||||
const video = videoRef.value
|
|
||||||
if (!video || !url) return
|
|
||||||
errorMsg.value = ''
|
|
||||||
destroy()
|
|
||||||
|
|
||||||
if (video.canPlayType('application/vnd.apple.mpegurl')) {
|
|
||||||
video.src = url
|
|
||||||
video.play().catch(() => {})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const { default: HlsPlayer } = await import('hls.js')
|
|
||||||
if (!HlsPlayer.isSupported()) {
|
|
||||||
errorMsg.value = t('episodeTranscode.playerUnsupported')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const instance = new HlsPlayer()
|
|
||||||
hls = instance
|
|
||||||
instance.on(HlsPlayer.Events.MANIFEST_PARSED, () => {
|
|
||||||
video.play().catch(() => {})
|
|
||||||
})
|
|
||||||
instance.on(HlsPlayer.Events.ERROR, (_event, data) => {
|
|
||||||
if (data?.fatal) {
|
|
||||||
errorMsg.value = t('episodeTranscode.playerFailed')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
instance.loadSource(url)
|
|
||||||
instance.attachMedia(video)
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => props.modelValue,
|
|
||||||
(visible) => {
|
|
||||||
if (visible) {
|
|
||||||
start(props.url)
|
|
||||||
} else {
|
|
||||||
destroy()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
onBeforeUnmount(destroy)
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<el-dialog
|
|
||||||
:model-value="modelValue"
|
|
||||||
:title="title"
|
|
||||||
width="720px"
|
|
||||||
destroy-on-close
|
|
||||||
class="rendition-player-dialog"
|
|
||||||
@update:model-value="emit('update:modelValue', $event)"
|
|
||||||
@closed="destroy"
|
|
||||||
>
|
|
||||||
<div class="rendition-player">
|
|
||||||
<video ref="videoRef" class="rendition-player__video" controls playsinline></video>
|
|
||||||
<p v-if="errorMsg" class="rendition-player__error">{{ errorMsg }}</p>
|
|
||||||
<p class="rendition-player__url" :title="url">{{ url }}</p>
|
|
||||||
</div>
|
|
||||||
</el-dialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.rendition-player {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.rendition-player__video {
|
|
||||||
width: 100%;
|
|
||||||
max-height: 62vh;
|
|
||||||
background: #000;
|
|
||||||
border-radius: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.rendition-player__error {
|
|
||||||
margin: 0;
|
|
||||||
font-size: 13px;
|
|
||||||
color: var(--el-color-danger);
|
|
||||||
}
|
|
||||||
|
|
||||||
.rendition-player__url {
|
|
||||||
margin: 0;
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--el-text-color-secondary);
|
|
||||||
word-break: break-all;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,137 +0,0 @@
|
|||||||
<!-- Author: fruit.com.cn -->
|
|
||||||
<!-- 批量上传队列单行:序号、文件名、大小、进度、状态与操作 -->
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { computed } from 'vue'
|
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
|
||||||
import type { UploadQueueItem } from './useUploadQueue'
|
|
||||||
|
|
||||||
const props = defineProps<{
|
|
||||||
item: UploadQueueItem
|
|
||||||
/** 自然排序后的展示序号(从 1 起) */
|
|
||||||
index: number
|
|
||||||
/** 选择阶段才允许移除 */
|
|
||||||
allowRemove: boolean
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
retry: [id: string]
|
|
||||||
remove: [id: string]
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const { t } = useI18n()
|
|
||||||
|
|
||||||
const BYTES_PER_KB = 1024
|
|
||||||
const BYTES_PER_MB = 1024 * 1024
|
|
||||||
|
|
||||||
const sizeLabel = computed(() => {
|
|
||||||
const size = props.item.fileSize
|
|
||||||
if (size >= BYTES_PER_MB) {
|
|
||||||
return `${(size / BYTES_PER_MB).toFixed(1)} MB`
|
|
||||||
}
|
|
||||||
return `${Math.max(1, Math.round(size / BYTES_PER_KB))} KB`
|
|
||||||
})
|
|
||||||
|
|
||||||
const statusLabel = computed(() => t(`episodeBatch.status.${props.item.status}`))
|
|
||||||
|
|
||||||
const statusType = computed(() => {
|
|
||||||
switch (props.item.status) {
|
|
||||||
case 'done':
|
|
||||||
return 'success'
|
|
||||||
case 'failed':
|
|
||||||
return 'danger'
|
|
||||||
case 'paused':
|
|
||||||
return 'warning'
|
|
||||||
case 'merging':
|
|
||||||
case 'uploading':
|
|
||||||
return ''
|
|
||||||
default:
|
|
||||||
return 'info'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const canRetry = computed(() => props.item.status === 'failed')
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="upload-task-row" :class="{ 'is-failed': item.status === 'failed' }">
|
|
||||||
<div class="upload-task-row__meta">
|
|
||||||
<span class="upload-task-row__index">{{ index }}</span>
|
|
||||||
<b class="upload-task-row__name" :title="item.fileName">{{ item.fileName }}</b>
|
|
||||||
<small>{{ sizeLabel }}</small>
|
|
||||||
<el-tag :type="statusType" effect="light" size="small">{{ statusLabel }}</el-tag>
|
|
||||||
</div>
|
|
||||||
<el-progress
|
|
||||||
:percentage="item.percent"
|
|
||||||
:status="
|
|
||||||
item.status === 'failed' ? 'exception' : item.status === 'done' ? 'success' : undefined
|
|
||||||
"
|
|
||||||
:stroke-width="10"
|
|
||||||
/>
|
|
||||||
<p v-if="item.error" class="upload-task-row__error">{{ item.error }}</p>
|
|
||||||
<div class="upload-task-row__actions">
|
|
||||||
<el-button v-if="canRetry" size="small" type="primary" @click="emit('retry', item.id)">
|
|
||||||
{{ t('episodeBatch.retry') }}
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
v-if="allowRemove"
|
|
||||||
size="small"
|
|
||||||
type="danger"
|
|
||||||
text
|
|
||||||
@click="emit('remove', item.id)"
|
|
||||||
>
|
|
||||||
{{ t('episodeBatch.remove') }}
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.upload-task-row {
|
|
||||||
padding: 12px 0;
|
|
||||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
|
||||||
}
|
|
||||||
|
|
||||||
.upload-task-row__meta {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
margin-bottom: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.upload-task-row__index {
|
|
||||||
flex: 0 0 auto;
|
|
||||||
min-width: 1.5em;
|
|
||||||
color: var(--el-text-color-secondary);
|
|
||||||
font-size: 13px;
|
|
||||||
font-variant-numeric: tabular-nums;
|
|
||||||
}
|
|
||||||
|
|
||||||
.upload-task-row__name {
|
|
||||||
flex: 1;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.upload-task-row__error {
|
|
||||||
margin: 6px 0 0;
|
|
||||||
color: var(--el-color-danger);
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.upload-task-row__actions {
|
|
||||||
margin-top: 8px;
|
|
||||||
display: flex;
|
|
||||||
gap: 8px;
|
|
||||||
justify-content: flex-end;
|
|
||||||
margin-left: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.upload-task-row.is-failed {
|
|
||||||
background: color-mix(in srgb, var(--el-color-danger) 6%, transparent);
|
|
||||||
border-radius: 6px;
|
|
||||||
padding-left: 8px;
|
|
||||||
padding-right: 8px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
// Author: fruit.com.cn
|
|
||||||
// 剧集转码面板的状态映射与展示格式化
|
|
||||||
|
|
||||||
export type TranscodeTagType = 'primary' | 'success' | 'warning' | 'danger' | 'info'
|
|
||||||
export type TranscodeProgressStatus = 'success' | 'exception' | undefined
|
|
||||||
|
|
||||||
export const THUMBNAIL_PAGE_SIZE = 100
|
|
||||||
export const THUMBNAIL_PAGE_SIZES = [100, 200, 500]
|
|
||||||
|
|
||||||
const STATUS_KEYS: Record<string, string> = {
|
|
||||||
QUEUED: 'queued',
|
|
||||||
RUNNING: 'running',
|
|
||||||
SUCCESS: 'success',
|
|
||||||
FAILED: 'failed',
|
|
||||||
EMPTY: 'empty',
|
|
||||||
NO_VIDEO: 'noVideo',
|
|
||||||
NO_MEDIA_ASSET: 'noMediaAsset',
|
|
||||||
NO_TASK: 'noTask',
|
|
||||||
NO_EPISODE: 'noEpisode',
|
|
||||||
EPISODE_NOT_FOUND: 'episodeNotFound',
|
|
||||||
INVALID: 'invalid',
|
|
||||||
READY: 'ready'
|
|
||||||
}
|
|
||||||
const BYTES_PER_KB = 1024
|
|
||||||
const BYTES_PER_MB = BYTES_PER_KB * 1024
|
|
||||||
const BYTES_PER_GB = BYTES_PER_MB * 1024
|
|
||||||
const SECONDS_PER_MINUTE = 60
|
|
||||||
const MILLIS_PER_SECOND = 1000
|
|
||||||
|
|
||||||
export function transcodeStatusKey(status?: string): string {
|
|
||||||
return STATUS_KEYS[String(status || '').toUpperCase()] || 'unknown'
|
|
||||||
}
|
|
||||||
|
|
||||||
export function transcodeStatusType(status?: string): TranscodeTagType {
|
|
||||||
switch (String(status || '').toUpperCase()) {
|
|
||||||
case 'SUCCESS':
|
|
||||||
return 'success'
|
|
||||||
case 'RUNNING':
|
|
||||||
return 'warning'
|
|
||||||
case 'FAILED':
|
|
||||||
return 'danger'
|
|
||||||
case 'QUEUED':
|
|
||||||
return 'primary'
|
|
||||||
default:
|
|
||||||
return 'info'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function transcodeProgressStatus(status?: string): TranscodeProgressStatus {
|
|
||||||
const normalized = String(status || '').toUpperCase()
|
|
||||||
if (normalized === 'SUCCESS') return 'success'
|
|
||||||
if (normalized === 'FAILED') return 'exception'
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
export function safeTranscodeProgress(value?: number): number {
|
|
||||||
return Math.min(100, Math.max(0, Number(value || 0)))
|
|
||||||
}
|
|
||||||
|
|
||||||
export function renditionStatusLabelKey(status?: string): string {
|
|
||||||
return transcodeStatusKey(status)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function renditionStatusType(status?: string): TranscodeTagType {
|
|
||||||
const normalized = String(status || '').toUpperCase()
|
|
||||||
if (normalized === 'READY') return 'success'
|
|
||||||
if (normalized === 'FAILED') return 'danger'
|
|
||||||
return 'info'
|
|
||||||
}
|
|
||||||
|
|
||||||
export function formatBytes(value?: number): string {
|
|
||||||
const size = Number(value || 0)
|
|
||||||
if (size >= BYTES_PER_GB) return `${(size / BYTES_PER_GB).toFixed(2)} GB`
|
|
||||||
if (size >= BYTES_PER_MB) return `${(size / BYTES_PER_MB).toFixed(1)} MB`
|
|
||||||
if (size >= BYTES_PER_KB) return `${Math.round(size / BYTES_PER_KB)} KB`
|
|
||||||
return `${size} B`
|
|
||||||
}
|
|
||||||
|
|
||||||
export function formatDuration(seconds?: number): string {
|
|
||||||
const total = Math.max(0, Number(seconds || 0))
|
|
||||||
const minutes = Math.floor(total / SECONDS_PER_MINUTE)
|
|
||||||
const remainder = total % SECONDS_PER_MINUTE
|
|
||||||
return `${String(minutes).padStart(2, '0')}:${String(remainder).padStart(2, '0')}`
|
|
||||||
}
|
|
||||||
|
|
||||||
export function formatTimeMs(milliseconds?: number): string {
|
|
||||||
const totalMs = Math.max(0, Number(milliseconds || 0))
|
|
||||||
const totalSeconds = Math.floor(totalMs / MILLIS_PER_SECOND)
|
|
||||||
const minutes = Math.floor(totalSeconds / SECONDS_PER_MINUTE)
|
|
||||||
const seconds = totalSeconds % SECONDS_PER_MINUTE
|
|
||||||
const tenths = Math.floor((totalMs % MILLIS_PER_SECOND) / 100)
|
|
||||||
return `${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}.${tenths}`
|
|
||||||
}
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
// Author: fruit.com.cn
|
|
||||||
/** 剧集批量上传断点会话:localStorage 读写与清理 */
|
|
||||||
|
|
||||||
export const UPLOAD_SESSION_KEY = 'reel_upload_sessions'
|
|
||||||
export const UPLOAD_SESSION_TTL_MS = 24 * 60 * 60 * 1000
|
|
||||||
|
|
||||||
export interface UploadSessionRecord {
|
|
||||||
uploadId: string
|
|
||||||
fileName: string
|
|
||||||
fileSize: number
|
|
||||||
lastModified: number
|
|
||||||
dramaId: string
|
|
||||||
bizType: string
|
|
||||||
createdAt: number
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 读取全部会话,解析失败时返回空数组。 */
|
|
||||||
export function loadUploadSessions(): UploadSessionRecord[] {
|
|
||||||
try {
|
|
||||||
const raw = localStorage.getItem(UPLOAD_SESSION_KEY)
|
|
||||||
if (!raw) return []
|
|
||||||
const parsed = JSON.parse(raw)
|
|
||||||
return Array.isArray(parsed) ? (parsed as UploadSessionRecord[]) : []
|
|
||||||
} catch {
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 覆盖写入全部会话。 */
|
|
||||||
export function saveUploadSessions(sessions: UploadSessionRecord[]): void {
|
|
||||||
localStorage.setItem(UPLOAD_SESSION_KEY, JSON.stringify(sessions))
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 按 dramaId 过滤且未超过 TTL 的未完成会话。 */
|
|
||||||
export function listPendingSessions(dramaId: string, now = Date.now()): UploadSessionRecord[] {
|
|
||||||
const dramaKey = String(dramaId)
|
|
||||||
return loadUploadSessions().filter(
|
|
||||||
(item) =>
|
|
||||||
String(item.dramaId) === dramaKey &&
|
|
||||||
now - Number(item.createdAt || 0) <= UPLOAD_SESSION_TTL_MS
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 新增或按 uploadId 覆盖一条会话。 */
|
|
||||||
export function upsertUploadSession(record: UploadSessionRecord): void {
|
|
||||||
const next = loadUploadSessions().filter((item) => item.uploadId !== record.uploadId)
|
|
||||||
next.push(record)
|
|
||||||
saveUploadSessions(next)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 按 uploadId 移除会话。 */
|
|
||||||
export function removeUploadSession(uploadId: string): void {
|
|
||||||
if (!uploadId) return
|
|
||||||
saveUploadSessions(loadUploadSessions().filter((item) => item.uploadId !== uploadId))
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 批量移除会话。 */
|
|
||||||
export function removeUploadSessions(uploadIds: string[]): void {
|
|
||||||
if (!uploadIds.length) return
|
|
||||||
const idSet = new Set(uploadIds)
|
|
||||||
saveUploadSessions(loadUploadSessions().filter((item) => !idSet.has(item.uploadId)))
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 用文件名 + size + lastModified 匹配本地文件。 */
|
|
||||||
export function matchFileForSession(session: UploadSessionRecord, files: File[]): File | undefined {
|
|
||||||
return files.find(
|
|
||||||
(file) =>
|
|
||||||
file.name === session.fileName &&
|
|
||||||
file.size === session.fileSize &&
|
|
||||||
file.lastModified === session.lastModified
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,352 +0,0 @@
|
|||||||
// Author: fruit.com.cn
|
|
||||||
/** 剧集批量上传队列:手动开始、文件并发、进度加权、断点会话、失败隔离 */
|
|
||||||
|
|
||||||
import { computed, ref } from 'vue'
|
|
||||||
import { getUploadProgressApi } from '@/api/admin/media'
|
|
||||||
import { probeVideoDuration, resumeUpload, uploadFile } from '@/utils/uploader'
|
|
||||||
import {
|
|
||||||
listPendingSessions,
|
|
||||||
matchFileForSession,
|
|
||||||
removeUploadSession,
|
|
||||||
type UploadSessionRecord,
|
|
||||||
upsertUploadSession
|
|
||||||
} from './uploadSessions'
|
|
||||||
|
|
||||||
export type UploadItemStatus = 'waiting' | 'uploading' | 'merging' | 'done' | 'failed' | 'paused'
|
|
||||||
|
|
||||||
export interface UploadQueueItem {
|
|
||||||
id: string
|
|
||||||
file: File
|
|
||||||
fileName: string
|
|
||||||
fileSize: number
|
|
||||||
lastModified: number
|
|
||||||
percent: number
|
|
||||||
status: UploadItemStatus
|
|
||||||
error: string
|
|
||||||
uploadId: string
|
|
||||||
assetId?: number
|
|
||||||
url?: string
|
|
||||||
durationSec?: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface UseUploadQueueOptions {
|
|
||||||
/** 当前短剧 id(调用时读取,避免切换剧后闭包过期) */
|
|
||||||
getDramaId: () => string
|
|
||||||
bizType?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
const FILE_CONCURRENCY = 2
|
|
||||||
const CHUNK_CONCURRENCY = 3
|
|
||||||
const DEFAULT_BIZ_TYPE = 'EPISODE'
|
|
||||||
const MERGING_PERCENT = 95
|
|
||||||
const MAX_PERCENT = 100
|
|
||||||
|
|
||||||
let queueSeq = 0
|
|
||||||
|
|
||||||
function nextItemId(): string {
|
|
||||||
queueSeq += 1
|
|
||||||
return `uq-${Date.now()}-${queueSeq}`
|
|
||||||
}
|
|
||||||
|
|
||||||
function extractErrorMessage(error: unknown): string {
|
|
||||||
if (error instanceof Error && error.message) return error.message
|
|
||||||
return String(error || 'upload failed')
|
|
||||||
}
|
|
||||||
|
|
||||||
function isHttpNotFound(error: unknown): boolean {
|
|
||||||
const status = (error as { response?: { status?: number } })?.response?.status
|
|
||||||
return status === 404
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 文件名自然排序(数字感知),保证队列序号稳定。 */
|
|
||||||
function compareFileName(a: string, b: string): number {
|
|
||||||
return a.localeCompare(b, undefined, { numeric: true, sensitivity: 'base' })
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建上传队列控制器。
|
|
||||||
* @param options dramaId 与可选 bizType
|
|
||||||
*/
|
|
||||||
export function useUploadQueue(options: UseUploadQueueOptions) {
|
|
||||||
const items = ref<UploadQueueItem[]>([])
|
|
||||||
const paused = ref(false)
|
|
||||||
/** 用户是否已点过「开始上传」;选文件阶段不派发、不占用并发。 */
|
|
||||||
const started = ref(false)
|
|
||||||
const bizType = options.bizType || DEFAULT_BIZ_TYPE
|
|
||||||
let running = 0
|
|
||||||
|
|
||||||
const overallPercent = computed(() => {
|
|
||||||
const list = items.value
|
|
||||||
if (!list.length) return 0
|
|
||||||
const totalBytes = list.reduce((sum, item) => sum + item.fileSize, 0)
|
|
||||||
if (totalBytes <= 0) return 0
|
|
||||||
const weighted = list.reduce((sum, item) => sum + item.fileSize * item.percent, 0)
|
|
||||||
return Math.min(MAX_PERCENT, Math.round(weighted / totalBytes))
|
|
||||||
})
|
|
||||||
|
|
||||||
const isUploading = computed(() =>
|
|
||||||
items.value.some((item) => item.status === 'uploading' || item.status === 'merging')
|
|
||||||
)
|
|
||||||
|
|
||||||
/** 关闭弹窗需二次确认:仅在已开始且仍有未完成任务时。 */
|
|
||||||
const hasActiveUpload = computed(() => {
|
|
||||||
if (!started.value) return false
|
|
||||||
return items.value.some(
|
|
||||||
(item) =>
|
|
||||||
item.status === 'waiting' ||
|
|
||||||
item.status === 'uploading' ||
|
|
||||||
item.status === 'merging' ||
|
|
||||||
item.status === 'paused'
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
const canStart = computed(() => {
|
|
||||||
if (isUploading.value) return false
|
|
||||||
return items.value.some((item) => item.status === 'waiting' || item.status === 'paused')
|
|
||||||
})
|
|
||||||
|
|
||||||
const doneItems = computed(() => items.value.filter((item) => item.status === 'done'))
|
|
||||||
|
|
||||||
const failedCount = computed(() => items.value.filter((item) => item.status === 'failed').length)
|
|
||||||
|
|
||||||
/** 已开始且队列已无进行中任务时,可展示结果汇总。 */
|
|
||||||
const showResultSummary = computed(
|
|
||||||
() => started.value && items.value.length > 0 && !hasActiveUpload.value
|
|
||||||
)
|
|
||||||
|
|
||||||
function persistSession(item: UploadQueueItem, uploadId: string): void {
|
|
||||||
item.uploadId = uploadId
|
|
||||||
upsertUploadSession({
|
|
||||||
uploadId,
|
|
||||||
fileName: item.fileName,
|
|
||||||
fileSize: item.fileSize,
|
|
||||||
lastModified: item.lastModified,
|
|
||||||
dramaId: String(options.getDramaId()),
|
|
||||||
bizType,
|
|
||||||
createdAt: Date.now()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearSession(uploadId: string): void {
|
|
||||||
if (uploadId) removeUploadSession(uploadId)
|
|
||||||
}
|
|
||||||
|
|
||||||
function sortItemsByName(): void {
|
|
||||||
items.value.sort((a, b) => compareFileName(a.fileName, b.fileName))
|
|
||||||
}
|
|
||||||
|
|
||||||
async function runOne(item: UploadQueueItem, resumeId?: string): Promise<void> {
|
|
||||||
item.status = 'uploading'
|
|
||||||
item.error = ''
|
|
||||||
try {
|
|
||||||
const durationSec = await probeVideoDuration(item.file)
|
|
||||||
item.durationSec = durationSec
|
|
||||||
const uploadOptions = {
|
|
||||||
bizType,
|
|
||||||
concurrency: CHUNK_CONCURRENCY,
|
|
||||||
durationSec,
|
|
||||||
onSession: (uploadId: string) => persistSession(item, uploadId),
|
|
||||||
onProgress: (percent: number) => {
|
|
||||||
item.percent = percent
|
|
||||||
if (percent >= MERGING_PERCENT && item.status === 'uploading') {
|
|
||||||
item.status = 'merging'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const asset = resumeId
|
|
||||||
? await resumeUpload(item.file, resumeId, uploadOptions)
|
|
||||||
: await uploadFile(item.file, uploadOptions)
|
|
||||||
item.percent = MAX_PERCENT
|
|
||||||
item.status = 'done'
|
|
||||||
item.assetId = asset.id
|
|
||||||
item.url = asset.url
|
|
||||||
if (asset.durationSec != null) item.durationSec = asset.durationSec
|
|
||||||
clearSession(item.uploadId || resumeId || '')
|
|
||||||
} catch (error) {
|
|
||||||
item.status = 'failed'
|
|
||||||
item.error = extractErrorMessage(error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function pump(): void {
|
|
||||||
if (!started.value || paused.value) return
|
|
||||||
while (running < FILE_CONCURRENCY && !paused.value) {
|
|
||||||
const next = items.value.find((item) => item.status === 'waiting')
|
|
||||||
if (!next) return
|
|
||||||
// 立刻占位,避免同步 while 循环把同一项派发两次
|
|
||||||
next.status = 'uploading'
|
|
||||||
running += 1
|
|
||||||
const resumeId = next.uploadId || undefined
|
|
||||||
void runOne(next, resumeId).finally(() => {
|
|
||||||
running -= 1
|
|
||||||
if (!paused.value) pump()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 入队本地文件(调用方已完成类型/大小校验);只展示待上传,不发起请求。 */
|
|
||||||
function enqueue(files: File[]): void {
|
|
||||||
const sorted = [...files].sort((a, b) => compareFileName(a.name, b.name))
|
|
||||||
for (const file of sorted) {
|
|
||||||
items.value.push({
|
|
||||||
id: nextItemId(),
|
|
||||||
file,
|
|
||||||
fileName: file.name,
|
|
||||||
fileSize: file.size,
|
|
||||||
lastModified: file.lastModified,
|
|
||||||
percent: 0,
|
|
||||||
status: 'waiting',
|
|
||||||
error: '',
|
|
||||||
uploadId: ''
|
|
||||||
})
|
|
||||||
}
|
|
||||||
sortItemsByName()
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 开始或继续派发(含断点续传项上的 uploadId)。 */
|
|
||||||
function start(): void {
|
|
||||||
if (!items.value.length) return
|
|
||||||
started.value = true
|
|
||||||
paused.value = false
|
|
||||||
for (const item of items.value) {
|
|
||||||
if (item.status === 'paused') item.status = 'waiting'
|
|
||||||
}
|
|
||||||
void pump()
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 暂停:不派新任务;进行中分片跑完。 */
|
|
||||||
function pause(): void {
|
|
||||||
if (!started.value) return
|
|
||||||
paused.value = true
|
|
||||||
for (const item of items.value) {
|
|
||||||
if (item.status === 'waiting') item.status = 'paused'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 重试单个失败项。 */
|
|
||||||
function retry(id: string): void {
|
|
||||||
const item = items.value.find((row) => row.id === id)
|
|
||||||
if (!item || item.status !== 'failed') return
|
|
||||||
item.error = ''
|
|
||||||
item.percent = item.uploadId ? item.percent : 0
|
|
||||||
item.status = paused.value ? 'paused' : 'waiting'
|
|
||||||
if (started.value && !paused.value) void pump()
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 重试全部失败项。 */
|
|
||||||
function retryAll(): void {
|
|
||||||
for (const item of items.value) {
|
|
||||||
if (item.status === 'failed') {
|
|
||||||
item.error = ''
|
|
||||||
item.status = paused.value ? 'paused' : 'waiting'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (started.value && !paused.value) void pump()
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 仅选择阶段可移除;已开始上传后禁止直接移除,避免脏会话。 */
|
|
||||||
function remove(id: string): void {
|
|
||||||
if (started.value) return
|
|
||||||
const index = items.value.findIndex((row) => row.id === id)
|
|
||||||
if (index < 0) return
|
|
||||||
const [removed] = items.value.splice(index, 1)
|
|
||||||
clearSession(removed.uploadId)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 清空队列并清理本队列会话。 */
|
|
||||||
function clear(): void {
|
|
||||||
for (const item of items.value) {
|
|
||||||
clearSession(item.uploadId)
|
|
||||||
}
|
|
||||||
items.value = []
|
|
||||||
paused.value = false
|
|
||||||
started.value = false
|
|
||||||
running = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 读取当前剧未完成会话(24h 内)。 */
|
|
||||||
function getPendingSessions(): UploadSessionRecord[] {
|
|
||||||
return listPendingSessions(String(options.getDramaId()))
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用本地重选文件匹配会话并入队(待上传);不自动开始,由用户点「开始上传」续传。
|
|
||||||
* @returns matched / unmatched 会话列表
|
|
||||||
*/
|
|
||||||
async function resumeFromSessions(
|
|
||||||
sessions: UploadSessionRecord[],
|
|
||||||
files: File[]
|
|
||||||
): Promise<{ matched: UploadSessionRecord[]; unmatched: UploadSessionRecord[] }> {
|
|
||||||
const matched: UploadSessionRecord[] = []
|
|
||||||
const unmatched: UploadSessionRecord[] = []
|
|
||||||
for (const session of sessions) {
|
|
||||||
const file = matchFileForSession(session, files)
|
|
||||||
if (!file) {
|
|
||||||
unmatched.push(session)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const progressRes = await getUploadProgressApi(session.uploadId)
|
|
||||||
const progress = progressRes?.data
|
|
||||||
if (!progress) {
|
|
||||||
unmatched.push(session)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if (String(progress.status || '').toLowerCase() === 'completed') {
|
|
||||||
clearSession(session.uploadId)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
items.value.push({
|
|
||||||
id: nextItemId(),
|
|
||||||
file,
|
|
||||||
fileName: file.name,
|
|
||||||
fileSize: file.size,
|
|
||||||
lastModified: file.lastModified,
|
|
||||||
percent: Math.min(MERGING_PERCENT, Number(progress.percent) || 0),
|
|
||||||
status: 'waiting',
|
|
||||||
error: '',
|
|
||||||
uploadId: session.uploadId
|
|
||||||
})
|
|
||||||
matched.push(session)
|
|
||||||
} catch (error) {
|
|
||||||
if (isHttpNotFound(error)) {
|
|
||||||
clearSession(session.uploadId)
|
|
||||||
} else {
|
|
||||||
unmatched.push(session)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sortItemsByName()
|
|
||||||
return { matched, unmatched }
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 放弃续传:清理给定会话。 */
|
|
||||||
function abandonSessions(sessions: UploadSessionRecord[]): void {
|
|
||||||
for (const session of sessions) {
|
|
||||||
clearSession(session.uploadId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
items,
|
|
||||||
overallPercent,
|
|
||||||
hasActiveUpload,
|
|
||||||
isUploading,
|
|
||||||
canStart,
|
|
||||||
doneItems,
|
|
||||||
failedCount,
|
|
||||||
showResultSummary,
|
|
||||||
started,
|
|
||||||
paused,
|
|
||||||
enqueue,
|
|
||||||
start,
|
|
||||||
pause,
|
|
||||||
retry,
|
|
||||||
retryAll,
|
|
||||||
remove,
|
|
||||||
clear,
|
|
||||||
getPendingSessions,
|
|
||||||
resumeFromSessions,
|
|
||||||
abandonSessions
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
// Author: fruit.com.cn
|
|
||||||
/** 剧集视频大小上限,单文件上传与批量上传共用。 */
|
|
||||||
export const MAX_VIDEO_SIZE = 500 * 1024 * 1024
|
|
||||||
|
|
||||||
/** 允许的视频扩展名(小写,不含点),单文件与批量上传同源。 */
|
|
||||||
export const VIDEO_EXTENSIONS: string[] = ['mp4', 'mov', 'mkv', 'webm']
|
|
||||||
|
|
||||||
/** el-upload / input[type=file] 的 accept 属性,与 VIDEO_EXTENSIONS 保持一致。 */
|
|
||||||
export const VIDEO_ACCEPT_ATTR = '.mp4,.mov,.mkv,.webm,video/*'
|
|
||||||
@@ -1,324 +1,145 @@
|
|||||||
<!-- Author: fruit.com.cn -->
|
<!-- Author: fruit.com.cn -->
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup>
|
||||||
import { nextTick, onBeforeUnmount, onMounted, ref } from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
import PageHeading from '@/views/components/PageHeading.vue'
|
import PageHeading from '@/views/components/PageHeading.vue'
|
||||||
import DashboardMetricWall from '@/views/dashboard/DashboardMetricWall.vue'
|
import { getDashboardOverviewApi, getTranscodeBoardApi } from '@/api/admin/dashboard'
|
||||||
import echarts from '@/plugins/echarts'
|
|
||||||
import {
|
|
||||||
getDashboardDistributionApi,
|
|
||||||
getDashboardOverviewApi,
|
|
||||||
getDashboardTrendApi,
|
|
||||||
getTranscodeBoardApi
|
|
||||||
} from '@/api/admin/dashboard'
|
|
||||||
import type {
|
|
||||||
DashboardDistribution,
|
|
||||||
DashboardOverview,
|
|
||||||
DashboardTrend,
|
|
||||||
TranscodeBoard
|
|
||||||
} from '@/api/admin/dashboard'
|
|
||||||
import { dateCell } from '@/utils/format'
|
import { dateCell } from '@/utils/format'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 指标展示配置:key 与后端 /admin/dashboard/overview 返回的字段一一对应,
|
||||||
|
* 不在前端编字段;口径说明见后端 DashboardService 注释与 docs/api-phase1.md「2.8」。
|
||||||
|
*/
|
||||||
|
const GROUPS = [
|
||||||
|
{
|
||||||
|
key: 'user',
|
||||||
|
title: '用户',
|
||||||
|
metrics: [
|
||||||
|
{ key: 'total', label: '总用户数' },
|
||||||
|
{ key: 'newToday', label: '今日新增' },
|
||||||
|
{ key: 'new7d', label: '近 7 天新增' },
|
||||||
|
{ key: 'active7d', label: '近 7 天活跃' },
|
||||||
|
{ key: 'banned', label: '封禁' },
|
||||||
|
{ key: 'limited', label: '受限' },
|
||||||
|
{ key: 'deactivated', label: '已注销' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'content',
|
||||||
|
title: '内容',
|
||||||
|
metrics: [
|
||||||
|
{ key: 'dramaTotal', label: '短剧总数' },
|
||||||
|
{ key: 'dramaPublished', label: '已上线短剧' },
|
||||||
|
{ key: 'dramaReviewing', label: '待审短剧' },
|
||||||
|
{ key: 'dramaDraft', label: '草稿短剧' },
|
||||||
|
{ key: 'dramaOffline', label: '已下线短剧' },
|
||||||
|
{ key: 'episodeTotal', label: '剧集总数' },
|
||||||
|
{ key: 'episodePublished', label: '已上线剧集' },
|
||||||
|
{ key: 'episodeWithMedia', label: '有片源剧集' },
|
||||||
|
{ key: 'commentPending', label: '待审评论' },
|
||||||
|
{ key: 'reportPending', label: '待处理举报' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'playback',
|
||||||
|
title: '播放',
|
||||||
|
metrics: [
|
||||||
|
{ key: 'viewTotal', label: '累计观看' },
|
||||||
|
{ key: 'playTotal', label: '累计播放' },
|
||||||
|
{ key: 'watchedDramas', label: '看过的剧(去重)' },
|
||||||
|
{ key: 'finishedDramas', label: '看过且完播' },
|
||||||
|
{ key: 'finishRate', label: '完播率' },
|
||||||
|
{ key: 'playEvents7d', label: '近 7 天播放流水' },
|
||||||
|
{ key: 'playEventsTotal', label: '播放流水总量' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'revenue',
|
||||||
|
title: '收入',
|
||||||
|
metrics: [
|
||||||
|
{ key: 'orderTotal', label: '订单总数' },
|
||||||
|
{ key: 'orderDelivered', label: '已交付订单' },
|
||||||
|
{ key: 'orderRefunded', label: '已退款订单' },
|
||||||
|
{ key: 'paidAmount', label: '已支付金额' },
|
||||||
|
{ key: 'coinRecharged', label: '金币充值' },
|
||||||
|
{ key: 'coinConsumed', label: '金币消耗' },
|
||||||
|
{ key: 'coinBalance', label: '金币余额' },
|
||||||
|
{ key: 'entitlementActive', label: '有效权益' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'cost',
|
||||||
|
title: '成本',
|
||||||
|
metrics: [
|
||||||
|
{ key: 'transcodeQueued', label: '转码排队' },
|
||||||
|
{ key: 'transcodeRunning', label: '转码中' },
|
||||||
|
{ key: 'transcodeFailed', label: '转码失败' },
|
||||||
|
{ key: 'transcodeSuccess', label: '转码成功' },
|
||||||
|
{ key: 'renditions', label: '多码率产物' },
|
||||||
|
{ key: 'otpSent7d', label: '近 7 天验证码' },
|
||||||
|
{ key: 'cdnTrafficBytes', label: 'CDN 流量' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const overview = ref<DashboardOverview | null>(null)
|
const overview = ref(null)
|
||||||
const trend = ref<DashboardTrend | null>(null)
|
const transcode = ref(null)
|
||||||
const distribution = ref<DashboardDistribution | null>(null)
|
|
||||||
const transcode = ref<TranscodeBoard | null>(null)
|
|
||||||
const lastUpdated = ref('')
|
const lastUpdated = ref('')
|
||||||
|
|
||||||
/** ECharts 容器 ref 与实例,统一管理 resize / dispose。 */
|
async function load() {
|
||||||
const trendRef = ref<HTMLElement>()
|
|
||||||
const dramaPieRef = ref<HTMLElement>()
|
|
||||||
const transcodePieRef = ref<HTMLElement>()
|
|
||||||
const episodePieRef = ref<HTMLElement>()
|
|
||||||
const chartInstances: echarts.ECharts[] = []
|
|
||||||
|
|
||||||
const statusLabel = {
|
|
||||||
reviewing: '待审',
|
|
||||||
published: '已上线',
|
|
||||||
draft: '草稿',
|
|
||||||
offline: '已下线'
|
|
||||||
} as const
|
|
||||||
|
|
||||||
const transcodeStatusLabel = {
|
|
||||||
QUEUED: '排队中',
|
|
||||||
RUNNING: '执行中',
|
|
||||||
SUCCESS: '成功',
|
|
||||||
FAILED: '失败',
|
|
||||||
CANCELED: '已取消'
|
|
||||||
} as const
|
|
||||||
|
|
||||||
function renderCharts() {
|
|
||||||
disposeAll()
|
|
||||||
renderTrend()
|
|
||||||
renderDramaPie()
|
|
||||||
renderTranscodePie()
|
|
||||||
renderEpisodePie()
|
|
||||||
renderQueueBar()
|
|
||||||
}
|
|
||||||
|
|
||||||
const queueBarRef = ref<HTMLElement>()
|
|
||||||
function renderQueueBar() {
|
|
||||||
if (!queueBarRef.value || !transcode.value) return
|
|
||||||
const q = transcode.value.queue || {}
|
|
||||||
const chart = echarts.init(queueBarRef.value)
|
|
||||||
chartInstances.push(chart)
|
|
||||||
chart.setOption({
|
|
||||||
tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } },
|
|
||||||
grid: { left: 80, right: 24, top: 16, bottom: 24 },
|
|
||||||
xAxis: { type: 'value', splitLine: { lineStyle: { type: 'dashed' } } },
|
|
||||||
yAxis: { type: 'category', data: ['排队', '执行中', '成功', '失败'] },
|
|
||||||
series: [
|
|
||||||
{
|
|
||||||
type: 'bar',
|
|
||||||
data: [q.queued || 0, q.running || 0, q.success || 0, q.failed || 0],
|
|
||||||
itemStyle: {
|
|
||||||
borderRadius: [0, 4, 4, 0],
|
|
||||||
color: (p: { dataIndex: number }) =>
|
|
||||||
['#F6BD16', '#5B8FF9', '#5AD8A6', '#E86452'][p.dataIndex]
|
|
||||||
},
|
|
||||||
label: { show: true, position: 'right' }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadAndRender() {
|
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
const [board, t, dist, queue] = await Promise.all([
|
const [board, queue] = await Promise.all([getDashboardOverviewApi(), getTranscodeBoardApi()])
|
||||||
getDashboardOverviewApi(),
|
|
||||||
getDashboardTrendApi(),
|
|
||||||
getDashboardDistributionApi(),
|
|
||||||
getTranscodeBoardApi()
|
|
||||||
])
|
|
||||||
overview.value = board.data || null
|
overview.value = board.data || null
|
||||||
trend.value = t.data || null
|
|
||||||
distribution.value = dist.data || null
|
|
||||||
transcode.value = queue.data || null
|
transcode.value = queue.data || null
|
||||||
lastUpdated.value = new Date().toLocaleString()
|
lastUpdated.value = new Date().toLocaleString()
|
||||||
await nextTick()
|
|
||||||
renderCharts()
|
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function disposeAll() {
|
/** 取不到的指标后端返回 null,这里显示「暂无数据源」而不是 0 */
|
||||||
chartInstances.forEach((c) => c.dispose())
|
function display(value) {
|
||||||
chartInstances.length = 0
|
if (value === null || value === undefined) return '暂无数据源'
|
||||||
|
if (typeof value === 'number' && !Number.isInteger(value)) return value.toFixed(3)
|
||||||
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
const basePieSeriesOption = {
|
function groupValue(groupKey, metricKey) {
|
||||||
type: 'pie' as const,
|
return overview.value?.[groupKey]?.[metricKey]
|
||||||
radius: ['40%', '70%'],
|
|
||||||
avoidLabelOverlap: true,
|
|
||||||
itemStyle: { borderRadius: 6, borderColor: '#fff', borderWidth: 2 },
|
|
||||||
label: { show: false, position: 'center' },
|
|
||||||
emphasis: {
|
|
||||||
label: { show: true, fontSize: 16, fontWeight: 'bold' }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderTrend() {
|
onMounted(load)
|
||||||
if (!trendRef.value || !trend.value) return
|
|
||||||
const chart = echarts.init(trendRef.value)
|
|
||||||
chartInstances.push(chart)
|
|
||||||
chart.setOption({
|
|
||||||
tooltip: { trigger: 'axis', axisPointer: { type: 'cross' } },
|
|
||||||
legend: { top: 0, textStyle: { fontSize: 12 } },
|
|
||||||
grid: { left: 48, right: 48, top: 40, bottom: 28 },
|
|
||||||
xAxis: { type: 'category', data: trend.value.dates, boundaryGap: false },
|
|
||||||
yAxis: [
|
|
||||||
{ type: 'value', name: '用户/播放', splitLine: { lineStyle: { type: 'dashed' } } },
|
|
||||||
{ type: 'value', name: '转码任务', splitLine: { show: false } }
|
|
||||||
],
|
|
||||||
series: [
|
|
||||||
{
|
|
||||||
name: '新增用户',
|
|
||||||
type: 'line',
|
|
||||||
smooth: true,
|
|
||||||
yAxisIndex: 0,
|
|
||||||
data: trend.value.newUsers,
|
|
||||||
itemStyle: { color: '#5B8FF9' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '播放事件',
|
|
||||||
type: 'line',
|
|
||||||
smooth: true,
|
|
||||||
yAxisIndex: 0,
|
|
||||||
data: trend.value.playEvents,
|
|
||||||
itemStyle: { color: '#5AD8A6' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '新增转码',
|
|
||||||
type: 'bar',
|
|
||||||
yAxisIndex: 1,
|
|
||||||
data: trend.value.newTranscodes,
|
|
||||||
itemStyle: { color: '#F6BD16', borderRadius: [3, 3, 0, 0] }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '转码成功',
|
|
||||||
type: 'bar',
|
|
||||||
yAxisIndex: 1,
|
|
||||||
data: trend.value.transcodeSuccess,
|
|
||||||
itemStyle: { color: '#945FB9', borderRadius: [3, 3, 0, 0] }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderDramaPie() {
|
|
||||||
if (!dramaPieRef.value || !distribution.value) return
|
|
||||||
const data = Object.entries(distribution.value.dramaStatus || {}).map(([k, v]) => ({
|
|
||||||
name: (statusLabel as Record<string, string>)[k] || k,
|
|
||||||
value: v
|
|
||||||
}))
|
|
||||||
const chart = echarts.init(dramaPieRef.value)
|
|
||||||
chartInstances.push(chart)
|
|
||||||
chart.setOption({
|
|
||||||
tooltip: { trigger: 'item', formatter: '{b}: {c} ({d}%)' },
|
|
||||||
legend: { bottom: 0, itemWidth: 12, itemHeight: 12, textStyle: { fontSize: 12 } },
|
|
||||||
color: ['#F6BD16', '#5AD8A6', '#5B8FF9', '#E86452'],
|
|
||||||
series: [{ ...basePieSeriesOption, name: '短剧状态', data }]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderTranscodePie() {
|
|
||||||
if (!transcodePieRef.value || !distribution.value) return
|
|
||||||
const data = Object.entries(distribution.value.transcodeStatus || {}).map(([k, v]) => ({
|
|
||||||
name: (transcodeStatusLabel as Record<string, string>)[k] || k,
|
|
||||||
value: v
|
|
||||||
}))
|
|
||||||
const chart = echarts.init(transcodePieRef.value)
|
|
||||||
chartInstances.push(chart)
|
|
||||||
chart.setOption({
|
|
||||||
tooltip: { trigger: 'item', formatter: '{b}: {c} ({d}%)' },
|
|
||||||
legend: { bottom: 0, itemWidth: 12, itemHeight: 12, textStyle: { fontSize: 12 } },
|
|
||||||
color: ['#F6BD16', '#5B8FF9', '#5AD8A6', '#E86452', '#C9C9C9'],
|
|
||||||
series: [{ ...basePieSeriesOption, name: '转码状态', data }]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderEpisodePie() {
|
|
||||||
if (!episodePieRef.value || !distribution.value) return
|
|
||||||
const data = Object.entries(distribution.value.episodeMedia || {}).map(([k, v]) => ({
|
|
||||||
name: k,
|
|
||||||
value: v
|
|
||||||
}))
|
|
||||||
const chart = echarts.init(episodePieRef.value)
|
|
||||||
chartInstances.push(chart)
|
|
||||||
chart.setOption({
|
|
||||||
tooltip: { trigger: 'item', formatter: '{b}: {c} ({d}%)' },
|
|
||||||
legend: { bottom: 0, itemWidth: 12, itemHeight: 12, textStyle: { fontSize: 12 } },
|
|
||||||
color: ['#5AD8A6', '#E86452'],
|
|
||||||
series: [{ ...basePieSeriesOption, name: '片源覆盖', data }]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function onResize() {
|
|
||||||
chartInstances.forEach((c) => c.resize())
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(loadAndRender)
|
|
||||||
window.addEventListener('resize', onResize)
|
|
||||||
onBeforeUnmount(() => {
|
|
||||||
disposeAll()
|
|
||||||
window.removeEventListener('resize', onResize)
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<PageHeading
|
<PageHeading
|
||||||
eyebrow="数据看板"
|
eyebrow="数据看板"
|
||||||
title="运营大盘"
|
title="运营大盘"
|
||||||
description="用户、设备、留存、内容、播放与成本总览,以及近 7 天趋势。"
|
description="用户、内容、播放、收入与成本总览,以及转码队列。"
|
||||||
>
|
>
|
||||||
<el-button :loading="loading" @click="loadAndRender">刷新</el-button>
|
<el-button :loading="loading" @click="load">刷新</el-button>
|
||||||
</PageHeading>
|
</PageHeading>
|
||||||
|
|
||||||
<div v-loading="loading" class="board-wrap">
|
<section v-loading="loading" class="panel">
|
||||||
<DashboardMetricWall :overview="overview" :trend="trend" />
|
<p class="console-hint"
|
||||||
|
>数据时间:{{ lastUpdated }}(口径见每组的后端定义,缺数据源显示「暂无数据源」)</p
|
||||||
<!-- 趋势折线图(双 Y 轴 + 柱) -->
|
|
||||||
<section class="panel chart-panel">
|
|
||||||
<div class="panel-heading">
|
|
||||||
<div>
|
|
||||||
<h2>近 7 天趋势</h2>
|
|
||||||
<p>每日新增用户 / 播放事件 / 转码任务</p>
|
|
||||||
</div>
|
|
||||||
<span class="muted">数据时间:{{ lastUpdated }}</span>
|
|
||||||
</div>
|
|
||||||
<div ref="trendRef" class="chart chart-lg"></div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<!-- 分布饼图组 -->
|
|
||||||
<section class="panel">
|
|
||||||
<div class="panel-heading">
|
|
||||||
<div>
|
|
||||||
<h2>状态分布</h2>
|
|
||||||
<p>短剧状态 / 转码状态 / 片源覆盖</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="pie-row">
|
|
||||||
<div class="pie-cell">
|
|
||||||
<div class="pie-title">短剧状态</div>
|
|
||||||
<div ref="dramaPieRef" class="chart chart-pie"></div>
|
|
||||||
</div>
|
|
||||||
<div class="pie-cell">
|
|
||||||
<div class="pie-title">转码状态</div>
|
|
||||||
<div ref="transcodePieRef" class="chart chart-pie"></div>
|
|
||||||
</div>
|
|
||||||
<div class="pie-cell">
|
|
||||||
<div class="pie-title">片源覆盖</div>
|
|
||||||
<div ref="episodePieRef" class="chart chart-pie"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<!-- 转码队列 + 失败明细 -->
|
|
||||||
<section class="panel transcode-panel">
|
|
||||||
<div class="panel-heading">
|
|
||||||
<div>
|
|
||||||
<h2>转码看板</h2>
|
|
||||||
<p>队列积压与失败任务明细</p>
|
|
||||||
</div>
|
|
||||||
<p class="muted">{{ transcode?.notes?.join(';') || '' }}</p>
|
|
||||||
</div>
|
|
||||||
<div class="transcode-grid">
|
|
||||||
<div ref="queueBarRef" class="chart chart-bar"></div>
|
|
||||||
<div class="transcode-fail">
|
|
||||||
<h3>失败任务(最近 20 条)</h3>
|
|
||||||
<el-table
|
|
||||||
:data="transcode?.failedTasks || []"
|
|
||||||
border
|
|
||||||
class="drama-el-table"
|
|
||||||
empty-text="当前没有失败的转码任务"
|
|
||||||
size="small"
|
|
||||||
>
|
>
|
||||||
<el-table-column prop="id" label="任务ID" width="100" />
|
<div v-for="group in GROUPS" :key="group.key" class="board-group">
|
||||||
<el-table-column prop="episodeId" label="剧集" width="100" />
|
<h3 class="board-title">{{ group.title }}</h3>
|
||||||
<el-table-column prop="status" label="状态" width="90" />
|
<div class="board-grid">
|
||||||
<el-table-column prop="retryCount" label="重试" width="70" />
|
<div v-for="metric in group.metrics" :key="metric.key" class="board-card">
|
||||||
<el-table-column
|
<span class="board-label">{{ metric.label }}</span>
|
||||||
prop="errorMsg"
|
<span
|
||||||
label="失败原因"
|
class="board-value"
|
||||||
min-width="220"
|
:class="{ 'board-value-empty': groupValue(group.key, metric.key) === null }"
|
||||||
show-overflow-tooltip
|
>
|
||||||
/>
|
{{ display(groupValue(group.key, metric.key)) }}
|
||||||
<el-table-column
|
</span>
|
||||||
prop="createdAt"
|
</div>
|
||||||
label="创建时间"
|
|
||||||
min-width="160"
|
|
||||||
show-overflow-tooltip
|
|
||||||
:formatter="dateCell"
|
|
||||||
/>
|
|
||||||
</el-table>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
|
||||||
|
|
||||||
<!-- 口径说明 -->
|
|
||||||
<el-alert
|
<el-alert
|
||||||
v-if="overview?.notes?.length"
|
v-if="overview?.notes?.length"
|
||||||
class="board-notes"
|
class="board-notes"
|
||||||
@@ -331,105 +152,31 @@ onBeforeUnmount(() => {
|
|||||||
<li v-for="note in overview.notes" :key="note">{{ note }}</li>
|
<li v-for="note in overview.notes" :key="note">{{ note }}</li>
|
||||||
</ul>
|
</ul>
|
||||||
</el-alert>
|
</el-alert>
|
||||||
</div>
|
</section>
|
||||||
|
|
||||||
|
<section class="panel board-transcode">
|
||||||
|
<h3 class="board-title">转码看板</h3>
|
||||||
|
<p class="console-hint">
|
||||||
|
{{ transcode?.notes?.join(';') || '' }}
|
||||||
|
</p>
|
||||||
|
<el-table
|
||||||
|
:data="transcode?.failedTasks || []"
|
||||||
|
border
|
||||||
|
class="drama-el-table"
|
||||||
|
empty-text="当前没有失败的转码任务"
|
||||||
|
>
|
||||||
|
<el-table-column prop="id" label="任务ID" width="90" />
|
||||||
|
<el-table-column prop="episodeId" label="剧集ID" width="90" />
|
||||||
|
<el-table-column prop="status" label="状态" width="110" />
|
||||||
|
<el-table-column prop="retryCount" label="重试次数" width="100" />
|
||||||
|
<el-table-column prop="errorMsg" label="失败原因" min-width="240" show-overflow-tooltip />
|
||||||
|
<el-table-column
|
||||||
|
prop="createdAt"
|
||||||
|
label="创建时间"
|
||||||
|
min-width="165"
|
||||||
|
show-overflow-tooltip
|
||||||
|
:formatter="dateCell"
|
||||||
|
/>
|
||||||
|
</el-table>
|
||||||
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped lang="less">
|
|
||||||
.board-wrap {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.panel {
|
|
||||||
padding: 20px 24px;
|
|
||||||
background: var(--el-bg-color);
|
|
||||||
border: 1px solid var(--el-border-color-lighter);
|
|
||||||
border-radius: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.panel-heading {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: flex-start;
|
|
||||||
margin-bottom: 12px;
|
|
||||||
|
|
||||||
h2 {
|
|
||||||
margin: 0;
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
h3 {
|
|
||||||
margin: 0 0 8px;
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
p {
|
|
||||||
margin: 4px 0 0;
|
|
||||||
font-size: 13px;
|
|
||||||
color: var(--el-text-color-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.muted {
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--el-text-color-placeholder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.chart {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chart-lg {
|
|
||||||
height: 320px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chart-pie {
|
|
||||||
height: 220px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chart-bar {
|
|
||||||
height: 220px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.pie-row {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(3, 1fr);
|
|
||||||
gap: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.pie-cell {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
.pie-title {
|
|
||||||
margin-bottom: 4px;
|
|
||||||
font-size: 13px;
|
|
||||||
color: var(--el-text-color-secondary);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.transcode-grid {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 1fr 2fr;
|
|
||||||
gap: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.board-notes {
|
|
||||||
:deep(ul) {
|
|
||||||
padding-left: 18px;
|
|
||||||
margin: 4px 0 0;
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (width <= 900px) {
|
|
||||||
.pie-row,
|
|
||||||
.transcode-grid {
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,445 +0,0 @@
|
|||||||
<!-- Author: fruit.com.cn -->
|
|
||||||
<!-- 工作台可视化大屏:用户、设备、留存与内容趋势。 -->
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
||||||
import echarts from '@/plugins/echarts'
|
|
||||||
import type { DashboardOverview, DashboardTrend } from '@/api/admin/dashboard'
|
|
||||||
import { formatCount } from '@/utils/format'
|
|
||||||
|
|
||||||
const props = defineProps<{
|
|
||||||
overview: DashboardOverview | null
|
|
||||||
trend?: DashboardTrend | null
|
|
||||||
fallback?: Record<string, number>
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const trendRef = ref<HTMLElement>()
|
|
||||||
const deviceRef = ref<HTMLElement>()
|
|
||||||
const clock = ref('')
|
|
||||||
let trendChart: echarts.ECharts | null = null
|
|
||||||
let deviceChart: echarts.ECharts | null = null
|
|
||||||
let timer = 0
|
|
||||||
|
|
||||||
const AXIS = '#909399'
|
|
||||||
const SPLIT = '#e6e8eb'
|
|
||||||
const BRAND = '#c4322a'
|
|
||||||
const AMBER = '#e9aa4b'
|
|
||||||
|
|
||||||
const kpis = computed(() => [
|
|
||||||
{ label: '总用户数', value: text('user', 'total'), accent: BRAND },
|
|
||||||
{ label: '今日新增', value: text('user', 'newToday'), accent: '#55b987' },
|
|
||||||
{ label: '近 7 天新增', value: text('user', 'new7d'), accent: AMBER },
|
|
||||||
{ label: '近 7 天活跃', value: text('user', 'active7d'), accent: '#d3615b' },
|
|
||||||
{ label: '累计播放', value: text('playback', 'viewTotal'), accent: BRAND },
|
|
||||||
{ label: '已上线短剧', value: text('content', 'dramaPublished'), accent: '#55b987' }
|
|
||||||
])
|
|
||||||
|
|
||||||
const rails = computed(() => [
|
|
||||||
{ label: '短剧总数', value: text('content', 'dramaTotal') },
|
|
||||||
{ label: '待审核', value: text('content', 'dramaReviewing') },
|
|
||||||
{ label: '有片源', value: text('content', 'episodeWithMedia') },
|
|
||||||
{ label: '近 7 天播放', value: text('playback', 'playEvents7d') },
|
|
||||||
{ label: '完播率', value: rate('playback', 'finishRate') },
|
|
||||||
{ label: '金币消耗', value: text('revenue', 'coinConsumed') },
|
|
||||||
{ label: '转码中', value: text('cost', 'transcodeRunning') },
|
|
||||||
{ label: '转码排队', value: text('cost', 'transcodeQueued') }
|
|
||||||
])
|
|
||||||
|
|
||||||
const retentionDay = computed(() => percent('user', 'retention1d'))
|
|
||||||
const retentionWeek = computed(() => percent('user', 'retention7d'))
|
|
||||||
|
|
||||||
function metric(group: string, key: string) {
|
|
||||||
const source = props.overview?.[group as keyof DashboardOverview]
|
|
||||||
if (source && typeof source === 'object') {
|
|
||||||
const value = (source as Record<string, number | null>)[key]
|
|
||||||
if (value !== undefined && value !== null) return Number(value)
|
|
||||||
}
|
|
||||||
const fallback = props.fallback?.[`${group}.${key}`]
|
|
||||||
return fallback == null ? null : Number(fallback)
|
|
||||||
}
|
|
||||||
|
|
||||||
function text(group: string, key: string) {
|
|
||||||
const value = metric(group, key)
|
|
||||||
return value == null || Number.isNaN(value) ? '--' : formatCount(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
function percent(group: string, key: string) {
|
|
||||||
const value = metric(group, key)
|
|
||||||
if (value == null || Number.isNaN(value)) return null
|
|
||||||
return Math.max(0, Math.min(100, Math.round(value * 1000) / 10))
|
|
||||||
}
|
|
||||||
|
|
||||||
function rate(group: string, key: string) {
|
|
||||||
const value = percent(group, key)
|
|
||||||
return value == null ? '--' : `${value.toFixed(1)}%`
|
|
||||||
}
|
|
||||||
|
|
||||||
function tick() {
|
|
||||||
clock.value = new Date().toLocaleString('zh-CN', { hour12: false })
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderCharts() {
|
|
||||||
renderTrend()
|
|
||||||
renderDevices()
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderTrend() {
|
|
||||||
if (!trendRef.value) return
|
|
||||||
trendChart = trendChart ?? echarts.init(trendRef.value)
|
|
||||||
const trend = props.trend
|
|
||||||
trendChart.setOption({
|
|
||||||
backgroundColor: 'transparent',
|
|
||||||
tooltip: {
|
|
||||||
trigger: 'axis',
|
|
||||||
backgroundColor: '#fff',
|
|
||||||
borderColor: '#e6e8eb',
|
|
||||||
textStyle: { color: '#303640' }
|
|
||||||
},
|
|
||||||
legend: { top: 0, left: 0, textStyle: { color: AXIS }, itemWidth: 12, itemHeight: 8 },
|
|
||||||
grid: { left: 42, right: 16, top: 32, bottom: 24 },
|
|
||||||
xAxis: {
|
|
||||||
type: 'category',
|
|
||||||
data: trend?.dates ?? [],
|
|
||||||
axisLine: { lineStyle: { color: 'rgba(255,255,255,.16)' } },
|
|
||||||
axisLabel: { color: AXIS, fontSize: 11 }
|
|
||||||
},
|
|
||||||
yAxis: {
|
|
||||||
type: 'value',
|
|
||||||
splitLine: { lineStyle: { color: SPLIT, type: 'dashed' } },
|
|
||||||
axisLabel: { color: AXIS, fontSize: 11 }
|
|
||||||
},
|
|
||||||
series: [
|
|
||||||
{
|
|
||||||
name: '新增用户',
|
|
||||||
type: 'line',
|
|
||||||
smooth: true,
|
|
||||||
showSymbol: false,
|
|
||||||
data: trend?.newUsers ?? [],
|
|
||||||
lineStyle: { width: 2, color: BRAND },
|
|
||||||
areaStyle: { color: 'rgba(196, 50, 42, 0.12)' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '播放事件',
|
|
||||||
type: 'line',
|
|
||||||
smooth: true,
|
|
||||||
showSymbol: false,
|
|
||||||
data: trend?.playEvents ?? [],
|
|
||||||
lineStyle: { width: 2, color: AMBER }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderDevices() {
|
|
||||||
if (!deviceRef.value) return
|
|
||||||
deviceChart = deviceChart ?? echarts.init(deviceRef.value)
|
|
||||||
const android = metric('user', 'androidActive7d') ?? 0
|
|
||||||
const ios = metric('user', 'iosActive7d') ?? 0
|
|
||||||
deviceChart.setOption({
|
|
||||||
backgroundColor: 'transparent',
|
|
||||||
tooltip: {
|
|
||||||
trigger: 'item',
|
|
||||||
backgroundColor: '#fff',
|
|
||||||
borderColor: '#e6e8eb',
|
|
||||||
textStyle: { color: '#303640' }
|
|
||||||
},
|
|
||||||
legend: { bottom: 0, textStyle: { color: AXIS }, itemWidth: 10, itemHeight: 10 },
|
|
||||||
title: {
|
|
||||||
text: formatCount(android + ios),
|
|
||||||
subtext: '活跃设备',
|
|
||||||
left: 'center',
|
|
||||||
top: '38%',
|
|
||||||
textStyle: { color: '#303640', fontSize: 22, fontWeight: 700 },
|
|
||||||
subtextStyle: { color: AXIS, fontSize: 12 }
|
|
||||||
},
|
|
||||||
series: [
|
|
||||||
{
|
|
||||||
type: 'pie',
|
|
||||||
radius: ['58%', '76%'],
|
|
||||||
center: ['50%', '46%'],
|
|
||||||
label: { show: false },
|
|
||||||
data: [
|
|
||||||
{ name: 'Android', value: android, itemStyle: { color: '#55b987' } },
|
|
||||||
{ name: 'iOS', value: ios, itemStyle: { color: BRAND } }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function onResize() {
|
|
||||||
trendChart?.resize()
|
|
||||||
deviceChart?.resize()
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => [props.overview, props.trend],
|
|
||||||
() => nextTick(renderCharts),
|
|
||||||
{ deep: true }
|
|
||||||
)
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
tick()
|
|
||||||
timer = window.setInterval(tick, 1000)
|
|
||||||
window.addEventListener('resize', onResize)
|
|
||||||
nextTick(renderCharts)
|
|
||||||
})
|
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
|
||||||
window.clearInterval(timer)
|
|
||||||
window.removeEventListener('resize', onResize)
|
|
||||||
trendChart?.dispose()
|
|
||||||
deviceChart?.dispose()
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<section class="screen">
|
|
||||||
<header class="screen-head">
|
|
||||||
<h2>运营概览</h2>
|
|
||||||
<time>{{ clock }}</time>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<div class="kpi-row">
|
|
||||||
<article v-for="item in kpis" :key="item.label" class="kpi">
|
|
||||||
<i :style="{ background: item.accent }"></i>
|
|
||||||
<div>
|
|
||||||
<strong>{{ item.value }}</strong>
|
|
||||||
<span>{{ item.label }}</span>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="viz-row">
|
|
||||||
<article class="panel trend-panel">
|
|
||||||
<h3>近 7 日新增与播放</h3>
|
|
||||||
<div ref="trendRef" class="chart"></div>
|
|
||||||
</article>
|
|
||||||
<article class="panel">
|
|
||||||
<h3>活跃设备占比</h3>
|
|
||||||
<div ref="deviceRef" class="chart"></div>
|
|
||||||
</article>
|
|
||||||
<article class="panel retain">
|
|
||||||
<h3>用户留存</h3>
|
|
||||||
<div class="rings">
|
|
||||||
<div class="ring" :style="{ '--p': `${retentionDay ?? 0}%` }">
|
|
||||||
<strong>{{ retentionDay == null ? '--' : `${retentionDay.toFixed(1)}%` }}</strong>
|
|
||||||
<span>次日留存</span>
|
|
||||||
</div>
|
|
||||||
<div class="ring week" :style="{ '--p': `${retentionWeek ?? 0}%` }">
|
|
||||||
<strong>{{ retentionWeek == null ? '--' : `${retentionWeek.toFixed(1)}%` }}</strong>
|
|
||||||
<span>7 日留存</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="rail">
|
|
||||||
<div v-for="item in rails" :key="item.label">
|
|
||||||
<strong>{{ item.value }}</strong>
|
|
||||||
<span>{{ item.label }}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped lang="less">
|
|
||||||
.screen {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 12px;
|
|
||||||
min-width: 0;
|
|
||||||
min-height: 0;
|
|
||||||
color: #303640;
|
|
||||||
}
|
|
||||||
|
|
||||||
.screen-head {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
h2 {
|
|
||||||
margin: 0;
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: #2f343c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
time {
|
|
||||||
font-size: 12px;
|
|
||||||
color: #909399;
|
|
||||||
font-variant-numeric: tabular-nums;
|
|
||||||
}
|
|
||||||
|
|
||||||
.kpi-row,
|
|
||||||
.viz-row,
|
|
||||||
.rail {
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.kpi-row {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(6, minmax(0, 1fr));
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.kpi {
|
|
||||||
display: flex;
|
|
||||||
gap: 10px;
|
|
||||||
align-items: center;
|
|
||||||
min-width: 0;
|
|
||||||
min-height: 72px;
|
|
||||||
padding: 12px 14px;
|
|
||||||
background: #fff;
|
|
||||||
border: 1px solid #e6e8eb;
|
|
||||||
border-radius: 6px;
|
|
||||||
|
|
||||||
i {
|
|
||||||
width: 3px;
|
|
||||||
height: 32px;
|
|
||||||
border-radius: 3px;
|
|
||||||
flex: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
strong {
|
|
||||||
display: block;
|
|
||||||
overflow: hidden;
|
|
||||||
font-size: 22px;
|
|
||||||
line-height: 1.1;
|
|
||||||
color: #303640;
|
|
||||||
font-variant-numeric: tabular-nums;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
span {
|
|
||||||
display: block;
|
|
||||||
margin-top: 4px;
|
|
||||||
font-size: 12px;
|
|
||||||
color: #909399;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.viz-row {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.8fr) minmax(0, 0.7fr);
|
|
||||||
gap: 12px;
|
|
||||||
flex: 1;
|
|
||||||
min-height: 220px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.panel {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
min-width: 0;
|
|
||||||
min-height: 0;
|
|
||||||
padding: 12px 14px 8px;
|
|
||||||
background: #fff;
|
|
||||||
border: 1px solid #e6e8eb;
|
|
||||||
border-radius: 6px;
|
|
||||||
|
|
||||||
h3 {
|
|
||||||
margin: 0;
|
|
||||||
font-size: 13px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: #2f343c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.chart {
|
|
||||||
width: 100%;
|
|
||||||
height: 240px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.rings {
|
|
||||||
display: flex;
|
|
||||||
flex: 1;
|
|
||||||
justify-content: space-around;
|
|
||||||
align-items: center;
|
|
||||||
min-height: 180px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ring {
|
|
||||||
--p: 0%;
|
|
||||||
|
|
||||||
display: grid;
|
|
||||||
width: 112px;
|
|
||||||
height: 112px;
|
|
||||||
background: conic-gradient(#c4322a var(--p), #f5d9d8 0);
|
|
||||||
border-radius: 50%;
|
|
||||||
place-items: center;
|
|
||||||
|
|
||||||
&::after {
|
|
||||||
width: 82px;
|
|
||||||
height: 82px;
|
|
||||||
background: #fff;
|
|
||||||
border-radius: 50%;
|
|
||||||
content: '';
|
|
||||||
grid-area: 1 / 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
strong,
|
|
||||||
span {
|
|
||||||
grid-area: 1 / 1;
|
|
||||||
z-index: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
strong {
|
|
||||||
margin-top: -12px;
|
|
||||||
font-size: 16px;
|
|
||||||
color: #303640;
|
|
||||||
}
|
|
||||||
|
|
||||||
span {
|
|
||||||
margin-top: 24px;
|
|
||||||
font-size: 12px;
|
|
||||||
color: #909399;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.week {
|
|
||||||
background: conic-gradient(#e9aa4b var(--p), #fff5e7 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
.rail {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(8, minmax(0, 1fr));
|
|
||||||
gap: 12px;
|
|
||||||
|
|
||||||
div {
|
|
||||||
min-width: 0;
|
|
||||||
padding: 10px 8px;
|
|
||||||
text-align: center;
|
|
||||||
background: #fff;
|
|
||||||
border: 1px solid #e6e8eb;
|
|
||||||
border-radius: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
strong {
|
|
||||||
display: block;
|
|
||||||
overflow: hidden;
|
|
||||||
font-size: 16px;
|
|
||||||
color: #303640;
|
|
||||||
font-variant-numeric: tabular-nums;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
span {
|
|
||||||
font-size: 12px;
|
|
||||||
color: #909399;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (width <= 760px) {
|
|
||||||
.kpi-row {
|
|
||||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
||||||
}
|
|
||||||
|
|
||||||
.viz-row,
|
|
||||||
.rail {
|
|
||||||
grid-template-columns: minmax(0, 1fr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<!-- Author: fruit.com.cn -->
|
<!-- Author: fruit.com.cn -->
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, reactive, ref } from 'vue'
|
import { computed, onMounted, reactive, ref } from 'vue'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import PageHeading from '@/views/components/PageHeading.vue'
|
import PageHeading from '@/views/components/PageHeading.vue'
|
||||||
import { useRbac } from '@/stores/rbac'
|
import { useRbac } from '@/stores/rbac'
|
||||||
@@ -26,23 +26,16 @@ const canWordUpdate = can('sensitive-word:update')
|
|||||||
const activeTab = ref('comments')
|
const activeTab = ref('comments')
|
||||||
|
|
||||||
const COMMENT_STATUS = [
|
const COMMENT_STATUS = [
|
||||||
{ value: '', label: '全部状态', tag: 'info' },
|
|
||||||
{ value: 'pending', label: '待审核', tag: 'warning' },
|
{ value: 'pending', label: '待审核', tag: 'warning' },
|
||||||
{ value: 'published', label: '已发布', tag: 'success' },
|
{ value: 'published', label: '已发布', tag: 'success' },
|
||||||
{ value: 'rejected', label: '已驳回', tag: 'danger' },
|
{ value: 'rejected', label: '已驳回', tag: 'danger' },
|
||||||
{ value: 'deleted', label: '已删除', tag: 'info' }
|
{ value: 'deleted', label: '已删除', tag: 'info' }
|
||||||
]
|
]
|
||||||
const REPORT_STATUS = [
|
const REPORT_STATUS = [
|
||||||
{ value: '', label: '全部状态', tag: 'info' },
|
|
||||||
{ value: 'pending', label: '待处理', tag: 'warning' },
|
{ value: 'pending', label: '待处理', tag: 'warning' },
|
||||||
{ value: 'handled', label: '已处理', tag: 'success' },
|
{ value: 'handled', label: '已处理', tag: 'success' },
|
||||||
{ value: 'rejected', label: '已驳回', tag: 'info' }
|
{ value: 'rejected', label: '已驳回', tag: 'info' }
|
||||||
]
|
]
|
||||||
const REPORT_TARGET_TYPES = {
|
|
||||||
COMMENT: { label: '评论', tag: 'warning' },
|
|
||||||
USER: { label: '用户', tag: 'success' },
|
|
||||||
DRAMA: { label: '短剧', tag: 'info' }
|
|
||||||
}
|
|
||||||
const WORD_LEVELS = [
|
const WORD_LEVELS = [
|
||||||
{ value: 'BLOCK', label: '禁止发布' },
|
{ value: 'BLOCK', label: '禁止发布' },
|
||||||
{ value: 'REVIEW', label: '转人工审核' },
|
{ value: 'REVIEW', label: '转人工审核' },
|
||||||
@@ -55,22 +48,6 @@ function meta(list, value) {
|
|||||||
function levelText(level) {
|
function levelText(level) {
|
||||||
return WORD_LEVELS.find((item) => item.value === level)?.label || level
|
return WORD_LEVELS.find((item) => item.value === level)?.label || level
|
||||||
}
|
}
|
||||||
function commentEpisodeText(row) {
|
|
||||||
if (row.episodeNo) return `第 ${row.episodeNo} 集`
|
|
||||||
return row.episodeId ? `分集 #${row.episodeId}` : '未关联分集'
|
|
||||||
}
|
|
||||||
function commentContentTooltip(row) {
|
|
||||||
return `短剧 ID:${row.dramaId} / 分集 ID:${row.episodeId || '未关联'}`
|
|
||||||
}
|
|
||||||
function reportTargetMeta(type) {
|
|
||||||
return REPORT_TARGET_TYPES[type] || { label: type || '-', tag: 'info' }
|
|
||||||
}
|
|
||||||
function reportTargetSummary(row) {
|
|
||||||
return row.targetSummary || `${reportTargetMeta(row.targetType).label} #${row.targetId}`
|
|
||||||
}
|
|
||||||
function reporterText(row) {
|
|
||||||
return row.reporterNickname || row.reporterUid || `#${row.reporterId}`
|
|
||||||
}
|
|
||||||
|
|
||||||
const comments = reactive({
|
const comments = reactive({
|
||||||
rows: [],
|
rows: [],
|
||||||
@@ -78,7 +55,7 @@ const comments = reactive({
|
|||||||
loading: false,
|
loading: false,
|
||||||
page: 1,
|
page: 1,
|
||||||
size: 10,
|
size: 10,
|
||||||
status: '',
|
status: 'pending',
|
||||||
keyword: ''
|
keyword: ''
|
||||||
})
|
})
|
||||||
async function loadComments() {
|
async function loadComments() {
|
||||||
@@ -146,7 +123,7 @@ const reports = reactive({
|
|||||||
loading: false,
|
loading: false,
|
||||||
page: 1,
|
page: 1,
|
||||||
size: 10,
|
size: 10,
|
||||||
status: ''
|
status: 'pending'
|
||||||
})
|
})
|
||||||
async function loadReports() {
|
async function loadReports() {
|
||||||
reports.loading = true
|
reports.loading = true
|
||||||
@@ -294,6 +271,11 @@ function onTabChange(name) {
|
|||||||
if (name === 'reports') loadReports()
|
if (name === 'reports') loadReports()
|
||||||
if (name === 'words') loadWords()
|
if (name === 'words') loadWords()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleTargetText = computed(() => {
|
||||||
|
const row = handleTarget.value
|
||||||
|
return row ? `${row.targetType} #${row.targetId}` : ''
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -343,17 +325,7 @@ function onTabChange(name) {
|
|||||||
<el-table-column prop="id" label="ID" width="80" />
|
<el-table-column prop="id" label="ID" width="80" />
|
||||||
<el-table-column prop="nickname" label="用户" min-width="120" show-overflow-tooltip />
|
<el-table-column prop="nickname" label="用户" min-width="120" show-overflow-tooltip />
|
||||||
<el-table-column prop="content" label="内容" min-width="220" show-overflow-tooltip />
|
<el-table-column prop="content" label="内容" min-width="220" show-overflow-tooltip />
|
||||||
<el-table-column label="短剧 / 分集" min-width="190">
|
<el-table-column prop="dramaId" label="短剧ID" width="90" />
|
||||||
<template #default="{ row }">
|
|
||||||
<el-tooltip :content="commentContentTooltip(row)" placement="top">
|
|
||||||
<div class="episode-table-title">
|
|
||||||
<b>{{ row.dramaTitle || `短剧 #${row.dramaId}` }}</b>
|
|
||||||
<small>{{ commentEpisodeText(row) }}</small>
|
|
||||||
<small v-if="row.episodeTitle">{{ row.episodeTitle }}</small>
|
|
||||||
</div>
|
|
||||||
</el-tooltip>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="状态" width="100">
|
<el-table-column label="状态" width="100">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-tag :type="meta(COMMENT_STATUS, row.status).tag" effect="light">{{
|
<el-tag :type="meta(COMMENT_STATUS, row.status).tag" effect="light">{{
|
||||||
@@ -438,22 +410,8 @@ function onTabChange(name) {
|
|||||||
empty-text="没有符合条件的工单"
|
empty-text="没有符合条件的工单"
|
||||||
>
|
>
|
||||||
<el-table-column prop="id" label="工单ID" width="90" />
|
<el-table-column prop="id" label="工单ID" width="90" />
|
||||||
<el-table-column label="对象" min-width="240">
|
<el-table-column prop="targetType" label="对象" width="100" />
|
||||||
<template #default="{ row }">
|
<el-table-column prop="targetId" label="对象ID" width="90" />
|
||||||
<el-tooltip placement="top">
|
|
||||||
<template #content>
|
|
||||||
<div>原始对象:#{{ row.targetId }}</div>
|
|
||||||
<div v-if="row.commentContent">评论内容:{{ row.commentContent }}</div>
|
|
||||||
</template>
|
|
||||||
<div class="episode-table-title">
|
|
||||||
<el-tag :type="reportTargetMeta(row.targetType).tag" size="small" effect="light">
|
|
||||||
{{ reportTargetMeta(row.targetType).label }}
|
|
||||||
</el-tag>
|
|
||||||
<b>{{ reportTargetSummary(row) }}</b>
|
|
||||||
</div>
|
|
||||||
</el-tooltip>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="reasonCode" label="原因码" width="120" />
|
<el-table-column prop="reasonCode" label="原因码" width="120" />
|
||||||
<el-table-column
|
<el-table-column
|
||||||
prop="description"
|
prop="description"
|
||||||
@@ -461,9 +419,7 @@ function onTabChange(name) {
|
|||||||
min-width="180"
|
min-width="180"
|
||||||
show-overflow-tooltip
|
show-overflow-tooltip
|
||||||
/>
|
/>
|
||||||
<el-table-column label="举报人" min-width="140" show-overflow-tooltip>
|
<el-table-column prop="reporterId" label="举报人" width="90" />
|
||||||
<template #default="{ row }">{{ reporterText(row) }}</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="状态" width="100">
|
<el-table-column label="状态" width="100">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-tag :type="meta(REPORT_STATUS, row.status).tag" effect="light">{{
|
<el-tag :type="meta(REPORT_STATUS, row.status).tag" effect="light">{{
|
||||||
@@ -594,12 +550,7 @@ function onTabChange(name) {
|
|||||||
<el-dialog v-model="handleVisible" title="处理举报工单" width="480px">
|
<el-dialog v-model="handleVisible" title="处理举报工单" width="480px">
|
||||||
<el-form label-position="top">
|
<el-form label-position="top">
|
||||||
<el-form-item label="工单对象">
|
<el-form-item label="工单对象">
|
||||||
<div v-if="handleTarget" class="episode-table-title">
|
<el-input :model-value="handleTargetText" disabled />
|
||||||
<el-tag :type="reportTargetMeta(handleTarget.targetType).tag" size="small" effect="light">
|
|
||||||
{{ reportTargetMeta(handleTarget.targetType).label }}
|
|
||||||
</el-tag>
|
|
||||||
<b>{{ reportTargetSummary(handleTarget) }}</b>
|
|
||||||
</div>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="处理结论">
|
<el-form-item label="处理结论">
|
||||||
<el-radio-group v-model="handleForm.status">
|
<el-radio-group v-model="handleForm.status">
|
||||||
|
|||||||
@@ -1,519 +0,0 @@
|
|||||||
<!-- Author: fruit.com.cn -->
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import type { FormInstance, FormRules } from 'element-plus'
|
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
||||||
import { computed, ref } from 'vue'
|
|
||||||
import PageHeading from '@/views/components/PageHeading.vue'
|
|
||||||
import { AppIcons } from '@/constants/icons'
|
|
||||||
import { dateCell } from '@/utils/format'
|
|
||||||
import {
|
|
||||||
batchCreateAppVersionsApi,
|
|
||||||
deleteAppVersionApi,
|
|
||||||
listAppVersionsApi,
|
|
||||||
updateAppVersionApi,
|
|
||||||
updateAppVersionStatusApi
|
|
||||||
} from '@/api/admin/appVersion'
|
|
||||||
import type { AppVersionItem, AppVersionSaveData } from '@/api/admin/appVersion'
|
|
||||||
|
|
||||||
const platformOptions = [
|
|
||||||
{ label: 'Android', value: 'ANDROID' },
|
|
||||||
{ label: 'iOS', value: 'IOS' }
|
|
||||||
]
|
|
||||||
const statusOptions = [
|
|
||||||
{ label: '已发布', value: 1 },
|
|
||||||
{ label: '已下架', value: 0 }
|
|
||||||
]
|
|
||||||
|
|
||||||
interface FilterState {
|
|
||||||
platform: string
|
|
||||||
status: number | undefined
|
|
||||||
keyword: string
|
|
||||||
}
|
|
||||||
|
|
||||||
const loading = ref(false)
|
|
||||||
const list = ref<AppVersionItem[]>([])
|
|
||||||
const total = ref(0)
|
|
||||||
const pageIndex = ref(1)
|
|
||||||
const pageSize = ref(20)
|
|
||||||
const filter = ref<FilterState>({ platform: '', status: undefined, keyword: '' })
|
|
||||||
|
|
||||||
const dialogOpen = ref(false)
|
|
||||||
const formLoading = ref(false)
|
|
||||||
const editingId = ref<string | null>(null)
|
|
||||||
const formRef = ref<FormInstance>()
|
|
||||||
|
|
||||||
/** 新建时两个平台一起配(各自可启停),编辑时用单份。 */
|
|
||||||
interface PlatformBlock {
|
|
||||||
enabled: boolean
|
|
||||||
data: AppVersionSaveData
|
|
||||||
}
|
|
||||||
const emptyPlatform = (platform: 'ANDROID' | 'IOS'): AppVersionSaveData => ({
|
|
||||||
platform,
|
|
||||||
versionCode: 0,
|
|
||||||
versionName: '',
|
|
||||||
downloadUrl: '',
|
|
||||||
updateContent: '',
|
|
||||||
forceUpdate: 0,
|
|
||||||
minSupportedCode: 0
|
|
||||||
})
|
|
||||||
const androidBlock = ref<PlatformBlock>({ enabled: true, data: emptyPlatform('ANDROID') })
|
|
||||||
const iosBlock = ref<PlatformBlock>({ enabled: true, data: emptyPlatform('IOS') })
|
|
||||||
const editForm = ref<AppVersionSaveData>(emptyPlatform('ANDROID'))
|
|
||||||
|
|
||||||
const rules: FormRules = {
|
|
||||||
platform: [{ required: true, message: '请选择平台', trigger: 'change' }],
|
|
||||||
versionCode: [
|
|
||||||
{ required: true, message: '请填写整数版本号', trigger: 'blur' },
|
|
||||||
{ type: 'number', min: 1, max: 999999, message: '范围 1~999999', trigger: 'blur' }
|
|
||||||
],
|
|
||||||
versionName: [
|
|
||||||
{ required: true, message: '请填写展示版本号', trigger: 'blur' },
|
|
||||||
{ max: 32, message: '最长 32 字符', trigger: 'blur' }
|
|
||||||
],
|
|
||||||
downloadUrl: [
|
|
||||||
{ required: true, message: '请填写下载地址', trigger: 'blur' },
|
|
||||||
{ max: 512, message: '最长 512 字符', trigger: 'blur' }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
async function fetchList() {
|
|
||||||
loading.value = true
|
|
||||||
try {
|
|
||||||
const res = await listAppVersionsApi({
|
|
||||||
pageIndex: pageIndex.value,
|
|
||||||
pageSize: pageSize.value,
|
|
||||||
platform: filter.value.platform || undefined,
|
|
||||||
status: filter.value.status,
|
|
||||||
keyword: filter.value.keyword.trim() || undefined
|
|
||||||
})
|
|
||||||
list.value = res.data?.list ?? []
|
|
||||||
total.value = res.data?.total ?? 0
|
|
||||||
} catch {
|
|
||||||
/* axios interceptor 已弹消息 */
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function openCreate() {
|
|
||||||
editingId.value = null
|
|
||||||
androidBlock.value = { enabled: true, data: emptyPlatform('ANDROID') }
|
|
||||||
iosBlock.value = { enabled: true, data: emptyPlatform('IOS') }
|
|
||||||
dialogOpen.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
function openEdit(row: AppVersionItem) {
|
|
||||||
editingId.value = row.id
|
|
||||||
editForm.value = {
|
|
||||||
platform: row.platform,
|
|
||||||
versionCode: row.versionCode,
|
|
||||||
versionName: row.versionName,
|
|
||||||
downloadUrl: row.downloadUrl,
|
|
||||||
updateContent: row.updateContent ?? '',
|
|
||||||
forceUpdate: row.forceUpdate === 1 ? 1 : 0,
|
|
||||||
minSupportedCode: row.minSupportedCode
|
|
||||||
}
|
|
||||||
dialogOpen.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
async function submit() {
|
|
||||||
formLoading.value = true
|
|
||||||
try {
|
|
||||||
if (editingId.value) {
|
|
||||||
await updateAppVersionApi(editingId.value, editForm.value)
|
|
||||||
ElMessage.success('已更新')
|
|
||||||
} else {
|
|
||||||
const toCreate: AppVersionSaveData[] = []
|
|
||||||
if (androidBlock.value.enabled) toCreate.push(androidBlock.value.data)
|
|
||||||
if (iosBlock.value.enabled) toCreate.push(iosBlock.value.data)
|
|
||||||
if (toCreate.length === 0) {
|
|
||||||
ElMessage.warning('至少启用一个平台')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
await batchCreateAppVersionsApi(toCreate)
|
|
||||||
ElMessage.success(`已创建 ${toCreate.length} 条版本`)
|
|
||||||
}
|
|
||||||
dialogOpen.value = false
|
|
||||||
await fetchList()
|
|
||||||
} catch {
|
|
||||||
/* axios interceptor 已弹消息 */
|
|
||||||
} finally {
|
|
||||||
formLoading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function toggleStatus(row: AppVersionItem) {
|
|
||||||
const next = row.status === 1 ? 0 : 1
|
|
||||||
await updateAppVersionStatusApi(row.id, next as 0 | 1)
|
|
||||||
ElMessage.success(next === 1 ? '已发布' : '已下架')
|
|
||||||
await fetchList()
|
|
||||||
}
|
|
||||||
|
|
||||||
async function remove(row: AppVersionItem) {
|
|
||||||
await ElMessageBox.confirm(
|
|
||||||
`确认删除 ${row.platformText} ${row.versionName}(${row.versionCode})?`,
|
|
||||||
'删除版本',
|
|
||||||
{ type: 'warning', confirmButtonText: '删除', cancelButtonText: '取消' }
|
|
||||||
)
|
|
||||||
await deleteAppVersionApi(row.id)
|
|
||||||
ElMessage.success('已删除')
|
|
||||||
await fetchList()
|
|
||||||
}
|
|
||||||
|
|
||||||
const forceText = computed(() => (v: number) => (v === 1 ? '强制' : '可选升级'))
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<PageHeading eyebrow="后台管理" title="版本管理" description="App 版本发布、上下架与删除。" />
|
|
||||||
|
|
||||||
<section class="toolbar">
|
|
||||||
<el-form :inline="true" :model="filter" @submit.prevent="fetchList">
|
|
||||||
<el-form-item label="平台">
|
|
||||||
<el-select v-model="filter.platform" clearable placeholder="全部" style="width: 120px">
|
|
||||||
<el-option
|
|
||||||
v-for="o in platformOptions"
|
|
||||||
:key="o.value"
|
|
||||||
:label="o.label"
|
|
||||||
:value="o.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="状态">
|
|
||||||
<el-select v-model="filter.status" clearable placeholder="全部" style="width: 120px">
|
|
||||||
<el-option v-for="o in statusOptions" :key="o.value" :label="o.label" :value="o.value" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="关键字">
|
|
||||||
<el-input
|
|
||||||
v-model="filter.keyword"
|
|
||||||
placeholder="匹配 versionName"
|
|
||||||
clearable
|
|
||||||
style="width: 180px"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item>
|
|
||||||
<el-button type="primary" :icon="AppIcons.search" @click="fetchList">查询</el-button>
|
|
||||||
<el-button plain @click="openCreate" :icon="AppIcons.add">新建版本</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<el-table :data="list" v-loading="loading" border stripe>
|
|
||||||
<el-table-column prop="platformText" label="平台" width="100" />
|
|
||||||
<el-table-column prop="versionCode" label="版本码" width="90" />
|
|
||||||
<el-table-column prop="versionName" label="展示版本" width="120" />
|
|
||||||
<el-table-column prop="downloadUrl" label="下载地址" show-overflow-tooltip min-width="220">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-link :href="row.downloadUrl" target="_blank" type="primary" :underline="false">
|
|
||||||
{{ row.downloadUrl }}
|
|
||||||
</el-link>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="forceUpdate" label="升级" width="80">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-tag :type="row.forceUpdate === 1 ? 'danger' : 'info'" size="small">
|
|
||||||
{{ forceText(row.forceUpdate) }}
|
|
||||||
</el-tag>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="minSupportedCode" label="兜底最低" width="100" />
|
|
||||||
<el-table-column prop="status" label="状态" width="90">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-tag :type="row.status === 1 ? 'success' : 'info'" size="small">
|
|
||||||
{{ row.statusText }}
|
|
||||||
</el-tag>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="releasedAt" label="发布时间" width="160" :formatter="dateCell" />
|
|
||||||
<el-table-column prop="createdAt" label="创建时间" width="160" :formatter="dateCell" />
|
|
||||||
<el-table-column label="操作" width="240" fixed="right">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-button size="small" link type="primary" @click="openEdit(row)">编辑</el-button>
|
|
||||||
<el-button size="small" link type="warning" @click="toggleStatus(row)">
|
|
||||||
{{ row.status === 1 ? '下架' : '发布' }}
|
|
||||||
</el-button>
|
|
||||||
<el-button size="small" link type="danger" @click="remove(row)">删除</el-button>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
|
|
||||||
<el-pagination
|
|
||||||
class="pagination"
|
|
||||||
v-model:current-page="pageIndex"
|
|
||||||
v-model:page-size="pageSize"
|
|
||||||
:total="total"
|
|
||||||
layout="total, sizes, prev, pager, next"
|
|
||||||
:page-sizes="[10, 20, 50]"
|
|
||||||
@current-change="fetchList"
|
|
||||||
@size-change="fetchList"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<el-dialog
|
|
||||||
v-model="dialogOpen"
|
|
||||||
:title="editingId ? '编辑版本' : '新建版本'"
|
|
||||||
width="820px"
|
|
||||||
@close="() => formRef?.resetFields()"
|
|
||||||
>
|
|
||||||
<!-- 编辑模式:单平台 -->
|
|
||||||
<el-form
|
|
||||||
v-if="editingId"
|
|
||||||
ref="formRef"
|
|
||||||
:model="editForm"
|
|
||||||
:rules="rules"
|
|
||||||
label-width="120px"
|
|
||||||
v-loading="formLoading"
|
|
||||||
>
|
|
||||||
<el-row :gutter="12">
|
|
||||||
<el-col :span="8">
|
|
||||||
<el-form-item label="整数版本" prop="versionCode">
|
|
||||||
<el-input-number
|
|
||||||
v-model="editForm.versionCode"
|
|
||||||
:min="1"
|
|
||||||
:max="999999"
|
|
||||||
controls-position="right"
|
|
||||||
class="w-full"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="16">
|
|
||||||
<el-form-item label="展示版本" prop="versionName">
|
|
||||||
<el-input v-model="editForm.versionName" placeholder="如 1.2.0" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
<el-form-item label="下载地址" prop="downloadUrl">
|
|
||||||
<el-input v-model="editForm.downloadUrl" placeholder="Android apk / iOS App Store 链接" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-row :gutter="12">
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="强制升级">
|
|
||||||
<el-switch
|
|
||||||
v-model="editForm.forceUpdate"
|
|
||||||
:active-value="1"
|
|
||||||
:inactive-value="0"
|
|
||||||
active-text="强制"
|
|
||||||
inactive-text="可选"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="兜底最低版本">
|
|
||||||
<el-input-number
|
|
||||||
v-model="editForm.minSupportedCode"
|
|
||||||
:min="0"
|
|
||||||
controls-position="right"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
<el-form-item label="更新说明">
|
|
||||||
<el-input
|
|
||||||
v-model="editForm.updateContent"
|
|
||||||
type="textarea"
|
|
||||||
:rows="3"
|
|
||||||
placeholder="换行分隔多条更新内容"
|
|
||||||
maxlength="2000"
|
|
||||||
show-word-limit
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
|
|
||||||
<!-- 新建模式:Android + iOS 两块 -->
|
|
||||||
<div v-else class="dual-blocks" v-loading="formLoading">
|
|
||||||
<div class="platform-block" :class="{ disabled: !androidBlock.enabled }">
|
|
||||||
<header>
|
|
||||||
<span class="platform-title">Android</span>
|
|
||||||
<el-switch
|
|
||||||
v-model="androidBlock.enabled"
|
|
||||||
active-text="启用"
|
|
||||||
inactive-text="跳过"
|
|
||||||
inline-prompt
|
|
||||||
/>
|
|
||||||
</header>
|
|
||||||
<el-form
|
|
||||||
:model="androidBlock.data"
|
|
||||||
:rules="rules"
|
|
||||||
label-width="120px"
|
|
||||||
:disabled="!androidBlock.enabled"
|
|
||||||
>
|
|
||||||
<el-row :gutter="12">
|
|
||||||
<el-col :span="8">
|
|
||||||
<el-form-item label="整数版本" prop="versionCode">
|
|
||||||
<el-input-number
|
|
||||||
v-model="androidBlock.data.versionCode"
|
|
||||||
:min="1"
|
|
||||||
:max="999999"
|
|
||||||
controls-position="right"
|
|
||||||
class="w-full"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="16">
|
|
||||||
<el-form-item label="展示版本" prop="versionName">
|
|
||||||
<el-input v-model="androidBlock.data.versionName" placeholder="如 1.2.0" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
<el-form-item label="下载地址" prop="downloadUrl">
|
|
||||||
<el-input v-model="androidBlock.data.downloadUrl" placeholder="apk 下载链接" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-row :gutter="12">
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="强制升级">
|
|
||||||
<el-switch
|
|
||||||
v-model="androidBlock.data.forceUpdate"
|
|
||||||
:active-value="1"
|
|
||||||
:inactive-value="0"
|
|
||||||
active-text="强制"
|
|
||||||
inactive-text="可选"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="兜底最低">
|
|
||||||
<el-input-number
|
|
||||||
v-model="androidBlock.data.minSupportedCode"
|
|
||||||
:min="0"
|
|
||||||
controls-position="right"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
<el-form-item label="更新说明">
|
|
||||||
<el-input
|
|
||||||
v-model="androidBlock.data.updateContent"
|
|
||||||
type="textarea"
|
|
||||||
:rows="3"
|
|
||||||
placeholder="换行分隔多条"
|
|
||||||
maxlength="2000"
|
|
||||||
show-word-limit
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="platform-block" :class="{ disabled: !iosBlock.enabled }">
|
|
||||||
<header>
|
|
||||||
<span class="platform-title">iOS</span>
|
|
||||||
<el-switch
|
|
||||||
v-model="iosBlock.enabled"
|
|
||||||
active-text="启用"
|
|
||||||
inactive-text="跳过"
|
|
||||||
inline-prompt
|
|
||||||
/>
|
|
||||||
</header>
|
|
||||||
<el-form
|
|
||||||
:model="iosBlock.data"
|
|
||||||
:rules="rules"
|
|
||||||
label-width="120px"
|
|
||||||
:disabled="!iosBlock.enabled"
|
|
||||||
>
|
|
||||||
<el-row :gutter="12">
|
|
||||||
<el-col :span="8">
|
|
||||||
<el-form-item label="整数版本" prop="versionCode">
|
|
||||||
<el-input-number
|
|
||||||
v-model="iosBlock.data.versionCode"
|
|
||||||
:min="1"
|
|
||||||
:max="999999"
|
|
||||||
controls-position="right"
|
|
||||||
class="w-full"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="16">
|
|
||||||
<el-form-item label="展示版本" prop="versionName">
|
|
||||||
<el-input v-model="iosBlock.data.versionName" placeholder="如 1.2.0" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
<el-form-item label="下载地址" prop="downloadUrl">
|
|
||||||
<el-input v-model="iosBlock.data.downloadUrl" placeholder="App Store 链接" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-row :gutter="12">
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="强制升级">
|
|
||||||
<el-switch
|
|
||||||
v-model="iosBlock.data.forceUpdate"
|
|
||||||
:active-value="1"
|
|
||||||
:inactive-value="0"
|
|
||||||
active-text="强制"
|
|
||||||
inactive-text="可选"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="兜底最低">
|
|
||||||
<el-input-number
|
|
||||||
v-model="iosBlock.data.minSupportedCode"
|
|
||||||
:min="0"
|
|
||||||
controls-position="right"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
<el-form-item label="更新说明">
|
|
||||||
<el-input
|
|
||||||
v-model="iosBlock.data.updateContent"
|
|
||||||
type="textarea"
|
|
||||||
:rows="3"
|
|
||||||
placeholder="换行分隔多条"
|
|
||||||
maxlength="2000"
|
|
||||||
show-word-limit
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<template #footer>
|
|
||||||
<el-button @click="dialogOpen = false">取消</el-button>
|
|
||||||
<el-button type="primary" :loading="formLoading" @click="submit">
|
|
||||||
{{ editingId ? '保存' : '创建并发布' }}
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped lang="less">
|
|
||||||
.toolbar {
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.pagination {
|
|
||||||
margin-top: 12px;
|
|
||||||
justify-content: flex-end;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dual-blocks {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.platform-block {
|
|
||||||
padding: 14px 16px 4px;
|
|
||||||
background: var(--el-fill-color-blank);
|
|
||||||
border: 1px solid var(--el-border-color-lighter);
|
|
||||||
border-radius: 8px;
|
|
||||||
|
|
||||||
header {
|
|
||||||
display: flex;
|
|
||||||
padding-bottom: 8px;
|
|
||||||
margin-bottom: 6px;
|
|
||||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
|
|
||||||
.platform-title {
|
|
||||||
font-size: 15px;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.disabled {
|
|
||||||
border-style: dashed;
|
|
||||||
opacity: 0.5;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
<!-- Author: fruit.com.cn -->
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { onMounted, reactive, ref } from 'vue'
|
|
||||||
import { ElMessage } from 'element-plus'
|
|
||||||
import {
|
|
||||||
listLegalDocumentsApi,
|
|
||||||
saveLegalDocumentsApi,
|
|
||||||
type LegalDocument
|
|
||||||
} from '@/api/admin/legalDocument'
|
|
||||||
|
|
||||||
const languages = [
|
|
||||||
{ code: 'zh', label: '中文' },
|
|
||||||
{ code: 'en', label: 'English' },
|
|
||||||
{ code: 'id', label: 'Indonesia' }
|
|
||||||
]
|
|
||||||
|
|
||||||
const documents = [
|
|
||||||
{ code: 'terms', label: '服务条款', path: '/terms' },
|
|
||||||
{ code: 'privacy', label: '隐私协议', path: '/privacy' }
|
|
||||||
]
|
|
||||||
|
|
||||||
const loading = ref(false)
|
|
||||||
const saving = ref(false)
|
|
||||||
const activeDoc = ref('terms')
|
|
||||||
const form = reactive<Record<string, LegalDocument>>({})
|
|
||||||
|
|
||||||
const blank = (docCode: string, lang: string): LegalDocument => ({
|
|
||||||
docCode,
|
|
||||||
lang,
|
|
||||||
title: '',
|
|
||||||
content: ''
|
|
||||||
})
|
|
||||||
|
|
||||||
const fieldKey = (docCode: string, lang: string) => `${docCode}:${lang}`
|
|
||||||
|
|
||||||
function ensureFields() {
|
|
||||||
for (const doc of documents) {
|
|
||||||
for (const lang of languages) {
|
|
||||||
const key = fieldKey(doc.code, lang.code)
|
|
||||||
if (!form[key]) form[key] = blank(doc.code, lang.code)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function load() {
|
|
||||||
loading.value = true
|
|
||||||
try {
|
|
||||||
ensureFields()
|
|
||||||
const res = await listLegalDocumentsApi()
|
|
||||||
for (const item of res.data || []) {
|
|
||||||
form[fieldKey(item.docCode, item.lang)] = { ...item }
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function save() {
|
|
||||||
saving.value = true
|
|
||||||
try {
|
|
||||||
ensureFields()
|
|
||||||
const items = documents.flatMap((doc) =>
|
|
||||||
languages.map((lang) => ({ ...form[fieldKey(doc.code, lang.code)], title: '' }))
|
|
||||||
)
|
|
||||||
await saveLegalDocumentsApi(items)
|
|
||||||
ElMessage.success('协议已保存')
|
|
||||||
await load()
|
|
||||||
} finally {
|
|
||||||
saving.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(load)
|
|
||||||
ensureFields()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="page-heading">
|
|
||||||
<div>
|
|
||||||
<div class="eyebrow">系统管理</div>
|
|
||||||
<h1>协议设置</h1>
|
|
||||||
<p>服务条款与隐私协议各维护中文、英文、印尼语。正文用 Markdown,打开后的页面不另加标题。</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<section v-loading="loading" class="panel settings-panel">
|
|
||||||
<el-tabs v-model="activeDoc">
|
|
||||||
<el-tab-pane v-for="doc in documents" :key="doc.code" :name="doc.code" :label="doc.label" />
|
|
||||||
</el-tabs>
|
|
||||||
<template v-for="doc in documents" :key="doc.code">
|
|
||||||
<div v-show="activeDoc === doc.code">
|
|
||||||
<p class="legal-path"
|
|
||||||
>公开地址:{{ doc.path }}/zh 、{{ doc.path }}/en 、{{ doc.path }}/id</p
|
|
||||||
>
|
|
||||||
<div v-for="lang in languages" :key="`${doc.code}-${lang.code}`" class="legal-block">
|
|
||||||
<h2>{{ lang.label }}</h2>
|
|
||||||
<el-input
|
|
||||||
v-model="form[`${doc.code}:${lang.code}`].content"
|
|
||||||
type="textarea"
|
|
||||||
:rows="14"
|
|
||||||
placeholder="直接写 Markdown,页面不再另加标题"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<el-button type="primary" :loading="saving" @click="save">保存</el-button>
|
|
||||||
</section>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.legal-path {
|
|
||||||
margin: 0 0 12px;
|
|
||||||
color: var(--el-text-color-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.legal-block + .legal-block {
|
|
||||||
margin-top: 8px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,364 +0,0 @@
|
|||||||
<!-- Author: fruit.com.cn -->
|
|
||||||
<!-- 后台转码档位与缩略图雪碧图配置 -->
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { AppIcons } from '@/constants/icons'
|
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
|
||||||
import PageHeading from '@/views/components/PageHeading.vue'
|
|
||||||
import { useTranscodeSettings } from './composables/useTranscodeSettings'
|
|
||||||
|
|
||||||
const { t } = useI18n()
|
|
||||||
const {
|
|
||||||
form,
|
|
||||||
formRef,
|
|
||||||
rules,
|
|
||||||
loading,
|
|
||||||
saving,
|
|
||||||
backfilling,
|
|
||||||
loadError,
|
|
||||||
canManage,
|
|
||||||
qualityRules,
|
|
||||||
positiveEvenRule,
|
|
||||||
positiveIntegerRule,
|
|
||||||
enabledRules,
|
|
||||||
loadProfile,
|
|
||||||
addRung,
|
|
||||||
deleteRung,
|
|
||||||
saveProfile,
|
|
||||||
runBackfill
|
|
||||||
} = useTranscodeSettings()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<PageHeading
|
|
||||||
:eyebrow="t('transcodeSettings.eyebrow')"
|
|
||||||
:title="t('transcodeSettings.title')"
|
|
||||||
:description="t('transcodeSettings.description')"
|
|
||||||
>
|
|
||||||
<el-tooltip :content="t('transcodeSettings.backfillTip')" placement="top">
|
|
||||||
<el-button
|
|
||||||
type="success"
|
|
||||||
plain
|
|
||||||
:loading="backfilling"
|
|
||||||
:disabled="!canManage || loading"
|
|
||||||
@click="runBackfill"
|
|
||||||
>
|
|
||||||
<AppIcon v-if="!backfilling" :icon="AppIcons.videoPlay" />
|
|
||||||
{{ t('transcodeSettings.backfill') }}
|
|
||||||
</el-button>
|
|
||||||
</el-tooltip>
|
|
||||||
<el-button :disabled="loading" @click="loadProfile">
|
|
||||||
<AppIcon :icon="AppIcons.refresh" />
|
|
||||||
{{ t('transcodeSettings.reload') }}
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
type="primary"
|
|
||||||
class="primary-button"
|
|
||||||
:loading="saving"
|
|
||||||
:disabled="!canManage || loading"
|
|
||||||
@click="saveProfile"
|
|
||||||
>
|
|
||||||
<AppIcon :icon="AppIcons.check" />
|
|
||||||
{{ t('transcodeSettings.save') }}
|
|
||||||
</el-button>
|
|
||||||
</PageHeading>
|
|
||||||
|
|
||||||
<el-alert
|
|
||||||
v-if="loadError"
|
|
||||||
class="transcode-alert"
|
|
||||||
:title="loadError"
|
|
||||||
type="error"
|
|
||||||
show-icon
|
|
||||||
:closable="false"
|
|
||||||
/>
|
|
||||||
<el-alert
|
|
||||||
v-if="!canManage"
|
|
||||||
class="transcode-alert"
|
|
||||||
:title="t('transcodeSettings.noPermission')"
|
|
||||||
type="warning"
|
|
||||||
show-icon
|
|
||||||
:closable="false"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<el-form
|
|
||||||
ref="formRef"
|
|
||||||
v-loading="loading"
|
|
||||||
:model="form"
|
|
||||||
:rules="rules"
|
|
||||||
label-position="top"
|
|
||||||
class="transcode-form"
|
|
||||||
>
|
|
||||||
<section class="panel transcode-panel">
|
|
||||||
<div class="transcode-section-heading">
|
|
||||||
<div>
|
|
||||||
<h2>{{ t('transcodeSettings.enabled') }}</h2>
|
|
||||||
<p>{{ t('transcodeSettings.enabledDescription') }}</p>
|
|
||||||
</div>
|
|
||||||
<el-switch v-model="form.enabled" size="large" />
|
|
||||||
</div>
|
|
||||||
<div class="transcode-grid transcode-grid--compact">
|
|
||||||
<el-form-item :label="t('transcodeSettings.segmentSeconds')" prop="segmentSeconds">
|
|
||||||
<el-input-number
|
|
||||||
v-model="form.segmentSeconds"
|
|
||||||
controls-position="right"
|
|
||||||
:min="2"
|
|
||||||
:max="10"
|
|
||||||
:precision="0"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="panel transcode-panel">
|
|
||||||
<div class="transcode-section-heading">
|
|
||||||
<div>
|
|
||||||
<h2>{{ t('transcodeSettings.ladderTitle') }}</h2>
|
|
||||||
<p>{{ t('transcodeSettings.ladderDescription') }}</p>
|
|
||||||
</div>
|
|
||||||
<el-button type="primary" plain @click="addRung">
|
|
||||||
<AppIcon :icon="AppIcons.add" />
|
|
||||||
{{ t('transcodeSettings.addRung') }}
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<el-table
|
|
||||||
:data="form.ladder"
|
|
||||||
border
|
|
||||||
class="transcode-table"
|
|
||||||
:empty-text="t('transcodeSettings.emptyLadder')"
|
|
||||||
>
|
|
||||||
<el-table-column type="index" width="60" label="#" />
|
|
||||||
<el-table-column :label="t('transcodeSettings.quality')" min-width="150">
|
|
||||||
<template #default="{ row, $index }">
|
|
||||||
<el-form-item
|
|
||||||
:prop="`ladder.${$index}.quality`"
|
|
||||||
:rules="qualityRules($index)"
|
|
||||||
class="table-form-item"
|
|
||||||
>
|
|
||||||
<el-input v-model="row.quality" maxlength="16" />
|
|
||||||
</el-form-item>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column :label="t('transcodeSettings.width')" min-width="120">
|
|
||||||
<template #default="{ row, $index }">
|
|
||||||
<el-form-item
|
|
||||||
:prop="`ladder.${$index}.width`"
|
|
||||||
:rules="positiveEvenRule()"
|
|
||||||
class="table-form-item"
|
|
||||||
>
|
|
||||||
<el-input-number
|
|
||||||
v-model="row.width"
|
|
||||||
controls-position="right"
|
|
||||||
:min="2"
|
|
||||||
:precision="0"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column :label="t('transcodeSettings.height')" min-width="120">
|
|
||||||
<template #default="{ row, $index }">
|
|
||||||
<el-form-item
|
|
||||||
:prop="`ladder.${$index}.height`"
|
|
||||||
:rules="positiveEvenRule()"
|
|
||||||
class="table-form-item"
|
|
||||||
>
|
|
||||||
<el-input-number
|
|
||||||
v-model="row.height"
|
|
||||||
controls-position="right"
|
|
||||||
:min="2"
|
|
||||||
:precision="0"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column :label="t('transcodeSettings.videoBitrateKbps')" min-width="150">
|
|
||||||
<template #default="{ row, $index }">
|
|
||||||
<el-form-item
|
|
||||||
:prop="`ladder.${$index}.videoBitrateKbps`"
|
|
||||||
:rules="positiveIntegerRule()"
|
|
||||||
class="table-form-item"
|
|
||||||
>
|
|
||||||
<el-input-number
|
|
||||||
v-model="row.videoBitrateKbps"
|
|
||||||
controls-position="right"
|
|
||||||
:min="1"
|
|
||||||
:precision="0"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column :label="t('transcodeSettings.audioBitrateKbps')" min-width="150">
|
|
||||||
<template #default="{ row, $index }">
|
|
||||||
<el-form-item
|
|
||||||
:prop="`ladder.${$index}.audioBitrateKbps`"
|
|
||||||
:rules="positiveIntegerRule()"
|
|
||||||
class="table-form-item"
|
|
||||||
>
|
|
||||||
<el-input-number
|
|
||||||
v-model="row.audioBitrateKbps"
|
|
||||||
controls-position="right"
|
|
||||||
:min="1"
|
|
||||||
:precision="0"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column :label="t('transcodeSettings.rowEnabled')" width="100" align="center">
|
|
||||||
<template #default="{ row, $index }">
|
|
||||||
<el-form-item
|
|
||||||
:prop="`ladder.${$index}.enabled`"
|
|
||||||
:rules="enabledRules"
|
|
||||||
class="table-form-item table-form-item--center"
|
|
||||||
>
|
|
||||||
<el-switch v-model="row.enabled" />
|
|
||||||
</el-form-item>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="" width="72" align="center" fixed="right">
|
|
||||||
<template #default="{ $index }">
|
|
||||||
<el-tooltip :content="t('transcodeSettings.deleteRung')" placement="top">
|
|
||||||
<el-button circle type="danger" plain @click="deleteRung($index)">
|
|
||||||
<AppIcon :icon="AppIcons.delete" />
|
|
||||||
</el-button>
|
|
||||||
</el-tooltip>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="panel transcode-panel">
|
|
||||||
<div class="transcode-section-heading">
|
|
||||||
<div>
|
|
||||||
<h2>{{ t('transcodeSettings.spriteTitle') }}</h2>
|
|
||||||
<p>{{ t('transcodeSettings.spriteDescription') }}</p>
|
|
||||||
</div>
|
|
||||||
<el-switch v-model="form.sprite.enabled" size="large" />
|
|
||||||
</div>
|
|
||||||
<div class="transcode-grid">
|
|
||||||
<el-form-item :label="t('transcodeSettings.intervalSeconds')" prop="sprite.intervalSeconds">
|
|
||||||
<el-input-number
|
|
||||||
v-model="form.sprite.intervalSeconds"
|
|
||||||
controls-position="right"
|
|
||||||
:min="1"
|
|
||||||
:max="10"
|
|
||||||
:precision="0"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item :label="t('transcodeSettings.columns')" prop="sprite.columns">
|
|
||||||
<el-input-number
|
|
||||||
v-model="form.sprite.columns"
|
|
||||||
controls-position="right"
|
|
||||||
:min="5"
|
|
||||||
:max="20"
|
|
||||||
:precision="0"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item :label="t('transcodeSettings.thumbWidth')" prop="sprite.thumbWidth">
|
|
||||||
<el-input-number
|
|
||||||
v-model="form.sprite.thumbWidth"
|
|
||||||
controls-position="right"
|
|
||||||
:min="120"
|
|
||||||
:max="240"
|
|
||||||
:precision="0"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</div>
|
|
||||||
<div class="transcode-footer">
|
|
||||||
<el-button
|
|
||||||
type="primary"
|
|
||||||
class="primary-button"
|
|
||||||
:loading="saving"
|
|
||||||
:disabled="!canManage || loading"
|
|
||||||
@click="saveProfile"
|
|
||||||
>
|
|
||||||
<AppIcon :icon="AppIcons.check" />
|
|
||||||
{{ t('transcodeSettings.save') }}
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</el-form>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped lang="less">
|
|
||||||
.transcode-alert {
|
|
||||||
margin-bottom: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.transcode-form {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.transcode-panel {
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.transcode-section-heading {
|
|
||||||
display: flex;
|
|
||||||
align-items: flex-start;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 16px;
|
|
||||||
margin-bottom: 18px;
|
|
||||||
|
|
||||||
h2 {
|
|
||||||
margin: 0;
|
|
||||||
font-size: 18px;
|
|
||||||
font-weight: 700;
|
|
||||||
}
|
|
||||||
|
|
||||||
p {
|
|
||||||
margin: 6px 0 0;
|
|
||||||
line-height: 1.5;
|
|
||||||
color: var(--el-text-color-secondary);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.transcode-grid {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(3, minmax(180px, 1fr));
|
|
||||||
gap: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.transcode-grid--compact {
|
|
||||||
grid-template-columns: minmax(180px, 320px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.transcode-table {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.table-form-item {
|
|
||||||
margin-bottom: 0;
|
|
||||||
|
|
||||||
:deep(.el-input-number) {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.el-form-item__error) {
|
|
||||||
position: static;
|
|
||||||
margin-top: 4px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.table-form-item--center {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.transcode-footer {
|
|
||||||
display: flex;
|
|
||||||
justify-content: flex-end;
|
|
||||||
margin-top: 18px;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (width <= 900px) {
|
|
||||||
.transcode-grid {
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
}
|
|
||||||
|
|
||||||
.transcode-section-heading {
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
// Author: fruit.com.cn
|
|
||||||
|
|
||||||
import type {
|
|
||||||
MediaTranscodeLadderRung,
|
|
||||||
MediaTranscodeProfile,
|
|
||||||
MediaTranscodeSprite
|
|
||||||
} from '@/api/admin/types'
|
|
||||||
|
|
||||||
export const MIN_SEGMENT_SECONDS = 2
|
|
||||||
export const MAX_SEGMENT_SECONDS = 10
|
|
||||||
export const MIN_SPRITE_INTERVAL = 1
|
|
||||||
export const MAX_SPRITE_INTERVAL = 10
|
|
||||||
export const MIN_SPRITE_COLUMNS = 5
|
|
||||||
export const MAX_SPRITE_COLUMNS = 20
|
|
||||||
export const MIN_THUMB_WIDTH = 120
|
|
||||||
export const MAX_THUMB_WIDTH = 240
|
|
||||||
export const MAX_QUALITY_LENGTH = 16
|
|
||||||
|
|
||||||
export const defaultSprite = (): MediaTranscodeSprite => ({
|
|
||||||
enabled: true,
|
|
||||||
intervalSeconds: 1,
|
|
||||||
columns: 10,
|
|
||||||
thumbWidth: 160
|
|
||||||
})
|
|
||||||
|
|
||||||
export const defaultRung = (): MediaTranscodeLadderRung => ({
|
|
||||||
quality: '',
|
|
||||||
width: 640,
|
|
||||||
height: 360,
|
|
||||||
videoBitrateKbps: 400,
|
|
||||||
audioBitrateKbps: 64,
|
|
||||||
enabled: true
|
|
||||||
})
|
|
||||||
|
|
||||||
/** 与后端缺省值一致的四档配置。 */
|
|
||||||
export const defaultProfile = (): MediaTranscodeProfile => ({
|
|
||||||
enabled: true,
|
|
||||||
segmentSeconds: 6,
|
|
||||||
ladder: [
|
|
||||||
{
|
|
||||||
quality: '360p',
|
|
||||||
width: 640,
|
|
||||||
height: 360,
|
|
||||||
videoBitrateKbps: 400,
|
|
||||||
audioBitrateKbps: 64,
|
|
||||||
enabled: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
quality: '480p',
|
|
||||||
width: 854,
|
|
||||||
height: 480,
|
|
||||||
videoBitrateKbps: 800,
|
|
||||||
audioBitrateKbps: 64,
|
|
||||||
enabled: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
quality: '720p',
|
|
||||||
width: 1280,
|
|
||||||
height: 720,
|
|
||||||
videoBitrateKbps: 1600,
|
|
||||||
audioBitrateKbps: 96,
|
|
||||||
enabled: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
quality: '1080p',
|
|
||||||
width: 1920,
|
|
||||||
height: 1080,
|
|
||||||
videoBitrateKbps: 3200,
|
|
||||||
audioBitrateKbps: 128,
|
|
||||||
enabled: true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
sprite: defaultSprite()
|
|
||||||
})
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
// Author: fruit.com.cn
|
|
||||||
|
|
||||||
import type { MediaTranscodeProfile } from '@/api/admin/types'
|
|
||||||
import { defaultProfile, defaultRung, defaultSprite } from './transcodeProfileDefaults'
|
|
||||||
|
|
||||||
/** 用服务端响应回填表单,同时保持字段名与后端完全一致。 */
|
|
||||||
export const applyProfileToForm = (
|
|
||||||
form: MediaTranscodeProfile,
|
|
||||||
profile?: MediaTranscodeProfile | null
|
|
||||||
): void => {
|
|
||||||
const source = profile || defaultProfile()
|
|
||||||
form.enabled = Boolean(source.enabled)
|
|
||||||
form.segmentSeconds = Number(source.segmentSeconds)
|
|
||||||
form.sprite = { ...defaultSprite(), ...(source.sprite || {}) }
|
|
||||||
const ladder =
|
|
||||||
Array.isArray(source.ladder) && source.ladder.length ? source.ladder : [defaultRung()]
|
|
||||||
form.ladder.splice(
|
|
||||||
0,
|
|
||||||
form.ladder.length,
|
|
||||||
...ladder.map((row) => ({
|
|
||||||
quality: row.quality || '',
|
|
||||||
width: Number(row.width),
|
|
||||||
height: Number(row.height),
|
|
||||||
videoBitrateKbps: Number(row.videoBitrateKbps),
|
|
||||||
audioBitrateKbps: Number(row.audioBitrateKbps),
|
|
||||||
enabled: Boolean(row.enabled)
|
|
||||||
}))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 生成只包含后端约定字段的 PUT 请求体。 */
|
|
||||||
export const buildProfilePayload = (form: MediaTranscodeProfile): MediaTranscodeProfile => ({
|
|
||||||
enabled: form.enabled,
|
|
||||||
segmentSeconds: Number(form.segmentSeconds),
|
|
||||||
ladder: form.ladder.map((row) => ({
|
|
||||||
quality: row.quality.trim(),
|
|
||||||
width: Number(row.width),
|
|
||||||
height: Number(row.height),
|
|
||||||
videoBitrateKbps: Number(row.videoBitrateKbps),
|
|
||||||
audioBitrateKbps: Number(row.audioBitrateKbps),
|
|
||||||
enabled: Boolean(row.enabled)
|
|
||||||
})),
|
|
||||||
sprite: {
|
|
||||||
enabled: Boolean(form.sprite.enabled),
|
|
||||||
intervalSeconds: Number(form.sprite.intervalSeconds),
|
|
||||||
columns: Number(form.sprite.columns),
|
|
||||||
thumbWidth: Number(form.sprite.thumbWidth)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
// Author: fruit.com.cn
|
|
||||||
|
|
||||||
import type { FormItemRule, FormRules } from 'element-plus'
|
|
||||||
import type { MediaTranscodeProfile } from '@/api/admin/types'
|
|
||||||
import {
|
|
||||||
MAX_QUALITY_LENGTH,
|
|
||||||
MAX_SEGMENT_SECONDS,
|
|
||||||
MAX_SPRITE_COLUMNS,
|
|
||||||
MAX_SPRITE_INTERVAL,
|
|
||||||
MAX_THUMB_WIDTH,
|
|
||||||
MIN_SPRITE_COLUMNS,
|
|
||||||
MIN_SEGMENT_SECONDS,
|
|
||||||
MIN_SPRITE_INTERVAL,
|
|
||||||
MIN_THUMB_WIDTH
|
|
||||||
} from './transcodeProfileDefaults'
|
|
||||||
|
|
||||||
type Translate = (key: string, named?: Record<string, unknown>) => string
|
|
||||||
|
|
||||||
const rangeRule = (min: number, max: number, t: Translate): FormItemRule => ({
|
|
||||||
trigger: 'change',
|
|
||||||
validator: (_rule, value, callback) => {
|
|
||||||
const parsed = Number(value)
|
|
||||||
callback(
|
|
||||||
Number.isInteger(parsed) && parsed >= min && parsed <= max
|
|
||||||
? undefined
|
|
||||||
: new Error(t('transcodeSettings.validation.range', { min, max }))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
export const positiveIntegerRule = (t: Translate): FormItemRule => ({
|
|
||||||
trigger: 'change',
|
|
||||||
validator: (_rule, value, callback) => {
|
|
||||||
const parsed = Number(value)
|
|
||||||
callback(
|
|
||||||
Number.isInteger(parsed) && parsed > 0
|
|
||||||
? undefined
|
|
||||||
: new Error(t('transcodeSettings.validation.positiveInteger'))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
export const positiveEvenRule = (t: Translate): FormItemRule => ({
|
|
||||||
trigger: 'change',
|
|
||||||
validator: (_rule, value, callback) => {
|
|
||||||
const parsed = Number(value)
|
|
||||||
callback(
|
|
||||||
Number.isInteger(parsed) && parsed > 0 && parsed % 2 === 0
|
|
||||||
? undefined
|
|
||||||
: new Error(t('transcodeSettings.validation.positiveEven'))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
export const createProfileRules = (t: Translate): FormRules => ({
|
|
||||||
segmentSeconds: [rangeRule(MIN_SEGMENT_SECONDS, MAX_SEGMENT_SECONDS, t)],
|
|
||||||
'sprite.intervalSeconds': [rangeRule(MIN_SPRITE_INTERVAL, MAX_SPRITE_INTERVAL, t)],
|
|
||||||
'sprite.columns': [rangeRule(MIN_SPRITE_COLUMNS, MAX_SPRITE_COLUMNS, t)],
|
|
||||||
'sprite.thumbWidth': [rangeRule(MIN_THUMB_WIDTH, MAX_THUMB_WIDTH, t)]
|
|
||||||
})
|
|
||||||
|
|
||||||
export const createQualityRules = (
|
|
||||||
form: MediaTranscodeProfile,
|
|
||||||
index: number,
|
|
||||||
t: Translate
|
|
||||||
): FormItemRule[] => [
|
|
||||||
{
|
|
||||||
trigger: 'blur',
|
|
||||||
validator: (_rule, value, callback) => {
|
|
||||||
const quality = String(value ?? '').trim()
|
|
||||||
if (!quality) {
|
|
||||||
callback(new Error(t('transcodeSettings.validation.required')))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (quality.length > MAX_QUALITY_LENGTH) {
|
|
||||||
callback(new Error(t('transcodeSettings.validation.qualityTooLong')))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const duplicate = form.ladder.some(
|
|
||||||
(row, rowIndex) => rowIndex !== index && row.quality.trim() === quality
|
|
||||||
)
|
|
||||||
callback(duplicate ? new Error(t('transcodeSettings.validation.qualityUnique')) : undefined)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
export const createEnabledRules = (form: MediaTranscodeProfile, t: Translate): FormItemRule[] => [
|
|
||||||
{
|
|
||||||
trigger: 'change',
|
|
||||||
validator: (_rule, _value, callback) => {
|
|
||||||
callback(
|
|
||||||
form.ladder.some((row) => row.enabled)
|
|
||||||
? undefined
|
|
||||||
: new Error(t('transcodeSettings.validation.atLeastOneEnabled'))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
// Author: fruit.com.cn
|
|
||||||
|
|
||||||
import { nextTick } from 'vue'
|
|
||||||
import type { ComputedRef, Ref } from 'vue'
|
|
||||||
import { ElMessage } from 'element-plus'
|
|
||||||
import type { FormInstance } from 'element-plus'
|
|
||||||
import { getMediaTranscodeProfileApi, saveMediaTranscodeProfileApi } from '@/api/admin/media'
|
|
||||||
import { runTranscodeBackfillApi } from '@/api/admin/transcode'
|
|
||||||
import type { MediaTranscodeProfile } from '@/api/admin/types'
|
|
||||||
import { applyProfileToForm, buildProfilePayload } from './transcodeProfileModel'
|
|
||||||
|
|
||||||
type Translate = (key: string, named?: Record<string, unknown>) => string
|
|
||||||
|
|
||||||
interface SettingsContext {
|
|
||||||
form: MediaTranscodeProfile
|
|
||||||
formRef: Ref<FormInstance | undefined>
|
|
||||||
loading: Ref<boolean>
|
|
||||||
saving: Ref<boolean>
|
|
||||||
backfilling: Ref<boolean>
|
|
||||||
loadError: Ref<string>
|
|
||||||
canManage: ComputedRef<boolean>
|
|
||||||
t: Translate
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 读取服务端配置并回填表单。 */
|
|
||||||
export const loadTranscodeProfile = async (context: SettingsContext): Promise<void> => {
|
|
||||||
context.loading.value = true
|
|
||||||
context.loadError.value = ''
|
|
||||||
try {
|
|
||||||
const response = await getMediaTranscodeProfileApi()
|
|
||||||
if (response.code !== 0) {
|
|
||||||
context.loadError.value = response.message || context.t('transcodeSettings.loadFailed')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
applyProfileToForm(context.form, response.data)
|
|
||||||
} catch {
|
|
||||||
context.loadError.value = context.t('transcodeSettings.loadFailed')
|
|
||||||
} finally {
|
|
||||||
context.loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const validateProfile = async (context: SettingsContext): Promise<boolean> => {
|
|
||||||
if (!context.form.ladder.length) {
|
|
||||||
ElMessage.warning(context.t('transcodeSettings.validation.atLeastOneEnabled'))
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
await context.formRef.value?.validate()
|
|
||||||
return true
|
|
||||||
} catch (fields) {
|
|
||||||
const firstField = Object.keys((fields || {}) as Record<string, unknown>)[0]
|
|
||||||
if (firstField) {
|
|
||||||
await nextTick()
|
|
||||||
context.formRef.value?.scrollToField(firstField)
|
|
||||||
}
|
|
||||||
ElMessage.warning(context.t('transcodeSettings.validation.fixErrors'))
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 校验并保存,成功后用服务端返回值回填。 */
|
|
||||||
export const saveTranscodeProfile = async (context: SettingsContext): Promise<void> => {
|
|
||||||
if (!context.canManage.value || context.saving.value || !(await validateProfile(context))) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
context.saving.value = true
|
|
||||||
try {
|
|
||||||
const response = await saveMediaTranscodeProfileApi(buildProfilePayload(context.form))
|
|
||||||
if (response.code !== 0) {
|
|
||||||
ElMessage.error(response.message || context.t('transcodeSettings.saveFailed'))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
applyProfileToForm(context.form, response.data)
|
|
||||||
ElMessage.success(context.t('transcodeSettings.saved'))
|
|
||||||
} catch {
|
|
||||||
ElMessage.error(context.t('transcodeSettings.saveFailed'))
|
|
||||||
} finally {
|
|
||||||
context.saving.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 手动补齐转码:扫一遍缺码率产物/帧图的分集并入队。 */
|
|
||||||
export const runTranscodeBackfill = async (context: SettingsContext): Promise<void> => {
|
|
||||||
if (!context.canManage.value || context.backfilling.value) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
context.backfilling.value = true
|
|
||||||
try {
|
|
||||||
const response = await runTranscodeBackfillApi()
|
|
||||||
if (response.code !== 0) {
|
|
||||||
ElMessage.error(response.message || context.t('transcodeSettings.backfillFailed'))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const triggered = response.data?.triggered ?? 0
|
|
||||||
if (triggered > 0) {
|
|
||||||
ElMessage.success(context.t('transcodeSettings.backfillDone', { count: triggered }))
|
|
||||||
} else {
|
|
||||||
ElMessage.info(context.t('transcodeSettings.backfillEmpty'))
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
ElMessage.error(context.t('transcodeSettings.backfillFailed'))
|
|
||||||
} finally {
|
|
||||||
context.backfilling.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
// Author: fruit.com.cn
|
|
||||||
|
|
||||||
import { computed, nextTick, onMounted, reactive, ref } from 'vue'
|
|
||||||
import type { FormInstance } from 'element-plus'
|
|
||||||
import type { MediaTranscodeProfile } from '@/api/admin/types'
|
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
|
||||||
import { useRbac } from '@/stores/rbac'
|
|
||||||
import { defaultProfile, defaultRung } from './transcodeProfileDefaults'
|
|
||||||
import {
|
|
||||||
createEnabledRules,
|
|
||||||
createProfileRules,
|
|
||||||
createQualityRules,
|
|
||||||
positiveEvenRule,
|
|
||||||
positiveIntegerRule
|
|
||||||
} from './transcodeProfileRules'
|
|
||||||
import {
|
|
||||||
loadTranscodeProfile,
|
|
||||||
runTranscodeBackfill,
|
|
||||||
saveTranscodeProfile
|
|
||||||
} from './transcodeSettingsActions'
|
|
||||||
|
|
||||||
/** 转码设置页的响应式状态与动作装配。 */
|
|
||||||
export function useTranscodeSettings() {
|
|
||||||
const { t } = useI18n()
|
|
||||||
const { can } = useRbac()
|
|
||||||
const formRef = ref<FormInstance>()
|
|
||||||
const loading = ref(false)
|
|
||||||
const saving = ref(false)
|
|
||||||
const backfilling = ref(false)
|
|
||||||
const loadError = ref('')
|
|
||||||
const form = reactive<MediaTranscodeProfile>(defaultProfile())
|
|
||||||
const canManage = computed(() => can('episode:upload'))
|
|
||||||
const context = { form, formRef, loading, saving, backfilling, loadError, canManage, t }
|
|
||||||
const rules = computed(() => createProfileRules(t))
|
|
||||||
const enabledRules = computed(() => createEnabledRules(form, t))
|
|
||||||
const qualityRules = (index: number) => createQualityRules(form, index, t)
|
|
||||||
|
|
||||||
const addRung = (): void => {
|
|
||||||
form.ladder.push(defaultRung())
|
|
||||||
nextTick(() => formRef.value?.clearValidate())
|
|
||||||
}
|
|
||||||
|
|
||||||
const deleteRung = (index: number): void => {
|
|
||||||
form.ladder.splice(index, 1)
|
|
||||||
nextTick(() => formRef.value?.clearValidate())
|
|
||||||
}
|
|
||||||
|
|
||||||
const loadProfile = () => loadTranscodeProfile(context)
|
|
||||||
const saveProfile = () => saveTranscodeProfile(context)
|
|
||||||
onMounted(loadProfile)
|
|
||||||
|
|
||||||
return {
|
|
||||||
form,
|
|
||||||
formRef,
|
|
||||||
rules,
|
|
||||||
loading,
|
|
||||||
saving,
|
|
||||||
backfilling,
|
|
||||||
loadError,
|
|
||||||
canManage,
|
|
||||||
qualityRules,
|
|
||||||
positiveEvenRule: () => positiveEvenRule(t),
|
|
||||||
positiveIntegerRule: () => positiveIntegerRule(t),
|
|
||||||
enabledRules,
|
|
||||||
loadProfile,
|
|
||||||
addRung,
|
|
||||||
deleteRung,
|
|
||||||
saveProfile,
|
|
||||||
runBackfill: () => runTranscodeBackfill(context)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,10 +9,7 @@ import { useRbac } from '@/stores/rbac'
|
|||||||
import {
|
import {
|
||||||
APP_USER_STATUS,
|
APP_USER_STATUS,
|
||||||
COUNTRY_OPTIONS,
|
COUNTRY_OPTIONS,
|
||||||
countryText,
|
|
||||||
formatDateTime,
|
|
||||||
formatDuration,
|
formatDuration,
|
||||||
platformText,
|
|
||||||
statusMeta,
|
statusMeta,
|
||||||
useAppUsers
|
useAppUsers
|
||||||
} from './composables/useAppUsers'
|
} from './composables/useAppUsers'
|
||||||
@@ -27,7 +24,6 @@ const {
|
|||||||
keyword,
|
keyword,
|
||||||
statusFilter,
|
statusFilter,
|
||||||
countryFilter,
|
countryFilter,
|
||||||
platformFilter,
|
|
||||||
currentPage,
|
currentPage,
|
||||||
pageSize,
|
pageSize,
|
||||||
detailVisible,
|
detailVisible,
|
||||||
@@ -56,11 +52,6 @@ const SOURCE_TEXT = {
|
|||||||
FAVORITE: '收藏'
|
FAVORITE: '收藏'
|
||||||
}
|
}
|
||||||
const BAN_TYPE_TEXT = { BAN: '封禁', LIMIT: '限制', MUTE: '禁言' }
|
const BAN_TYPE_TEXT = { BAN: '封禁', LIMIT: '限制', MUTE: '禁言' }
|
||||||
const PLATFORM_OPTIONS = [
|
|
||||||
{ value: '', label: '全部系统' },
|
|
||||||
{ value: 'ANDROID', label: 'Android' },
|
|
||||||
{ value: 'IOS', label: 'iOS' }
|
|
||||||
]
|
|
||||||
const APPEAL_TEXT = {
|
const APPEAL_TEXT = {
|
||||||
none: '未申诉',
|
none: '未申诉',
|
||||||
pending: '待处理',
|
pending: '待处理',
|
||||||
@@ -124,20 +115,6 @@ function canBeBanned(row) {
|
|||||||
:value="item.value"
|
:value="item.value"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
<el-select
|
|
||||||
v-model="platformFilter"
|
|
||||||
class="app-user-platform"
|
|
||||||
clearable
|
|
||||||
placeholder="全部系统"
|
|
||||||
@change="queryUsers"
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="item in PLATFORM_OPTIONS"
|
|
||||||
:key="item.value"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
<el-select
|
<el-select
|
||||||
v-model="countryFilter"
|
v-model="countryFilter"
|
||||||
class="app-user-country"
|
class="app-user-country"
|
||||||
@@ -187,24 +164,21 @@ function canBeBanned(row) {
|
|||||||
<template v-else>{{ avatarText(row) }}</template>
|
<template v-else>{{ avatarText(row) }}</template>
|
||||||
</span>
|
</span>
|
||||||
<div class="app-user-meta">
|
<div class="app-user-meta">
|
||||||
<span class="app-user-name" :title="row.nickname || ''">
|
<span class="app-user-name" :title="row.nickname">{{
|
||||||
昵称: {{ row.nickname || '未设置昵称' }}
|
row.nickname || '未设置昵称'
|
||||||
</span>
|
}}</span>
|
||||||
<span class="app-user-uid">UID: {{ row.uid }}</span>
|
<span class="app-user-uid" :title="row.uid">{{ row.uid }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="系统" width="110" show-overflow-tooltip>
|
|
||||||
<template #default="{ row }">{{ platformText(row) }}</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="手机 / 邮箱" min-width="150" show-overflow-tooltip>
|
<el-table-column label="手机 / 邮箱" min-width="150" show-overflow-tooltip>
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<span class="app-user-mono">{{ row.maskedTarget || '—' }}</span>
|
<span class="app-user-mono">{{ row.maskedTarget || '—' }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="国家" width="110">
|
<el-table-column label="国家" width="90">
|
||||||
<template #default="{ row }">{{ countryText(row.countryCode) }}</template>
|
<template #default="{ row }">{{ row.countryCode || '—' }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="状态" width="90">
|
<el-table-column label="状态" width="90">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
@@ -270,8 +244,8 @@ function canBeBanned(row) {
|
|||||||
<template v-else>{{ avatarText(detail) }}</template>
|
<template v-else>{{ avatarText(detail) }}</template>
|
||||||
</span>
|
</span>
|
||||||
<div class="app-user-meta">
|
<div class="app-user-meta">
|
||||||
<span class="app-user-name"> 昵称: {{ detail.nickname || '未设置昵称' }} </span>
|
<span class="app-user-name">{{ detail.nickname || '未设置昵称' }}</span>
|
||||||
<span class="app-user-uid">UID: {{ detail.uid }}</span>
|
<span class="app-user-uid">{{ detail.uid }}</span>
|
||||||
</div>
|
</div>
|
||||||
<el-tag :type="statusMeta(detail.status).tag" effect="light" style="margin-left: auto">
|
<el-tag :type="statusMeta(detail.status).tag" effect="light" style="margin-left: auto">
|
||||||
{{ statusMeta(detail.status).label }}
|
{{ statusMeta(detail.status).label }}
|
||||||
@@ -284,10 +258,7 @@ function canBeBanned(row) {
|
|||||||
{{ detail.maskedTarget || '—' }}
|
{{ detail.maskedTarget || '—' }}
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
<el-descriptions-item label="国家 / 地区">
|
<el-descriptions-item label="国家 / 地区">
|
||||||
{{ countryText(detail.countryCode) }}
|
{{ detail.countryCode || '—' }} / {{ detail.regionCode || '—' }}
|
||||||
<template v-if="detail.regionCode && detail.regionCode !== detail.countryCode">
|
|
||||||
/ {{ countryText(detail.regionCode) }}
|
|
||||||
</template>
|
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
<el-descriptions-item label="语言">{{ detail.language || '—' }}</el-descriptions-item>
|
<el-descriptions-item label="语言">{{ detail.language || '—' }}</el-descriptions-item>
|
||||||
<el-descriptions-item label="时区">{{ detail.timezone || '—' }}</el-descriptions-item>
|
<el-descriptions-item label="时区">{{ detail.timezone || '—' }}</el-descriptions-item>
|
||||||
@@ -297,7 +268,6 @@ function canBeBanned(row) {
|
|||||||
<el-descriptions-item label="最后登录">{{
|
<el-descriptions-item label="最后登录">{{
|
||||||
detail.lastLoginAt || '—'
|
detail.lastLoginAt || '—'
|
||||||
}}</el-descriptions-item>
|
}}</el-descriptions-item>
|
||||||
<el-descriptions-item label="系统">{{ platformText(detail) }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="会员">
|
<el-descriptions-item label="会员">
|
||||||
{{ detail.vipLevel ? `等级 ${detail.vipLevel}` : '未开通(第二阶段)' }}
|
{{ detail.vipLevel ? `等级 ${detail.vipLevel}` : '未开通(第二阶段)' }}
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
@@ -329,17 +299,12 @@ function canBeBanned(row) {
|
|||||||
<el-table-column label="完成" width="70">
|
<el-table-column label="完成" width="70">
|
||||||
<template #default="{ row }">{{ row.finished ? '是' : '否' }}</template>
|
<template #default="{ row }">{{ row.finished ? '是' : '否' }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="系统" width="100" show-overflow-tooltip>
|
|
||||||
<template #default="{ row }">{{ platformText(row) }}</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="来源" width="80">
|
<el-table-column label="来源" width="80">
|
||||||
<template #default="{ row }">{{
|
<template #default="{ row }">{{
|
||||||
SOURCE_TEXT[row.source] || row.source || '—'
|
SOURCE_TEXT[row.source] || row.source || '—'
|
||||||
}}</template>
|
}}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="时间" width="160">
|
<el-table-column prop="watchedAt" label="时间" width="160" show-overflow-tooltip />
|
||||||
<template #default="{ row }">{{ formatDateTime(row.watchedAt) }}</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
</el-table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,194 +0,0 @@
|
|||||||
<!-- Author: fruit.com.cn -->
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import { onMounted, reactive, ref } from 'vue'
|
|
||||||
import dayjs from 'dayjs'
|
|
||||||
import PageHeading from '@/views/components/PageHeading.vue'
|
|
||||||
import AppUserCell from '@/views/components/AppUserCell.vue'
|
|
||||||
import { pageFavoritesApi } from '@/api/admin/engagement'
|
|
||||||
import { platformText } from './composables/useAppUsers'
|
|
||||||
|
|
||||||
const PAGE_SIZES = [10, 20, 50]
|
|
||||||
const PLATFORM_OPTIONS = [
|
|
||||||
{ value: '', label: '全部系统' },
|
|
||||||
{ value: 'ANDROID', label: 'Android' },
|
|
||||||
{ value: 'IOS', label: 'iOS' }
|
|
||||||
]
|
|
||||||
|
|
||||||
const filters = reactive({
|
|
||||||
keyword: '',
|
|
||||||
deviceId: '',
|
|
||||||
dramaTitle: '',
|
|
||||||
platform: '',
|
|
||||||
range: null
|
|
||||||
})
|
|
||||||
const rows = ref([])
|
|
||||||
const total = ref(0)
|
|
||||||
const loading = ref(false)
|
|
||||||
const pageIndex = ref(1)
|
|
||||||
const pageSize = ref(10)
|
|
||||||
|
|
||||||
async function load() {
|
|
||||||
loading.value = true
|
|
||||||
try {
|
|
||||||
const res = await pageFavoritesApi({
|
|
||||||
pageIndex: pageIndex.value,
|
|
||||||
pageSize: pageSize.value,
|
|
||||||
keyword: filters.keyword.trim() || undefined,
|
|
||||||
deviceId: filters.deviceId.trim() || undefined,
|
|
||||||
dramaTitle: filters.dramaTitle.trim() || undefined,
|
|
||||||
platform: filters.platform || undefined,
|
|
||||||
startTime: filters.range?.[0] || undefined,
|
|
||||||
endTime: filters.range?.[1] || undefined
|
|
||||||
})
|
|
||||||
rows.value = res.data?.list || []
|
|
||||||
total.value = res.data?.total || 0
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function search() {
|
|
||||||
pageIndex.value = 1
|
|
||||||
load()
|
|
||||||
}
|
|
||||||
|
|
||||||
function resetFilters() {
|
|
||||||
Object.assign(filters, {
|
|
||||||
keyword: '',
|
|
||||||
deviceId: '',
|
|
||||||
dramaTitle: '',
|
|
||||||
platform: '',
|
|
||||||
range: null
|
|
||||||
})
|
|
||||||
search()
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleSizeChange() {
|
|
||||||
pageIndex.value = 1
|
|
||||||
load()
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatTime(value) {
|
|
||||||
return value && dayjs(value).isValid() ? dayjs(value).format('YYYY-MM-DD HH:mm:ss') : '—'
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(load)
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<PageHeading eyebrow="用户管理" title="收藏列表" />
|
|
||||||
<section class="panel">
|
|
||||||
<div class="console-toolbar">
|
|
||||||
<el-input
|
|
||||||
v-model="filters.keyword"
|
|
||||||
class="console-keyword"
|
|
||||||
clearable
|
|
||||||
placeholder="uid / 昵称"
|
|
||||||
@keyup.enter="search"
|
|
||||||
/>
|
|
||||||
<el-input
|
|
||||||
v-model="filters.deviceId"
|
|
||||||
class="console-keyword"
|
|
||||||
clearable
|
|
||||||
placeholder="设备 ID"
|
|
||||||
@keyup.enter="search"
|
|
||||||
/>
|
|
||||||
<el-input
|
|
||||||
v-model="filters.dramaTitle"
|
|
||||||
class="console-keyword"
|
|
||||||
clearable
|
|
||||||
placeholder="短剧名称"
|
|
||||||
@keyup.enter="search"
|
|
||||||
/>
|
|
||||||
<el-select v-model="filters.platform" class="console-select" placeholder="全部系统">
|
|
||||||
<el-option
|
|
||||||
v-for="item in PLATFORM_OPTIONS"
|
|
||||||
:key="item.value"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
|
|
||||||
<el-date-picker
|
|
||||||
v-model="filters.range"
|
|
||||||
class="engagement-range"
|
|
||||||
type="datetimerange"
|
|
||||||
value-format="YYYY-MM-DD HH:mm:ss"
|
|
||||||
range-separator="至"
|
|
||||||
start-placeholder="开始时间"
|
|
||||||
end-placeholder="结束时间"
|
|
||||||
/>
|
|
||||||
<el-button type="primary" @click="search">查询</el-button>
|
|
||||||
<el-button @click="resetFilters">重置</el-button>
|
|
||||||
<span class="console-count">共 {{ total }} 条</span>
|
|
||||||
</div>
|
|
||||||
<el-table
|
|
||||||
v-loading="loading"
|
|
||||||
:data="rows"
|
|
||||||
row-key="id"
|
|
||||||
border
|
|
||||||
class="drama-el-table"
|
|
||||||
empty-text="暂无收藏"
|
|
||||||
>
|
|
||||||
<el-table-column label="用户" min-width="200">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<AppUserCell :row="row" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="系统" width="100">
|
|
||||||
<template #default="{ row }">{{ platformText(row) }}</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="短剧" min-width="220">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<div class="engagement-drama">
|
|
||||||
<el-image
|
|
||||||
v-if="row.dramaCover"
|
|
||||||
:src="row.dramaCover"
|
|
||||||
fit="cover"
|
|
||||||
class="engagement-cover"
|
|
||||||
/>
|
|
||||||
<span>{{ row.dramaTitle || `短剧 #${row.dramaId || '—'}` }}</span>
|
|
||||||
<el-tag v-if="row.dramaPublished === false" type="info" size="small" effect="plain"
|
|
||||||
>未发布</el-tag
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="收藏时间" min-width="170">
|
|
||||||
<template #default="{ row }">{{ formatTime(row.createdAt) }}</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
<div class="pagination">
|
|
||||||
<el-pagination
|
|
||||||
v-model:current-page="pageIndex"
|
|
||||||
v-model:page-size="pageSize"
|
|
||||||
:page-sizes="PAGE_SIZES"
|
|
||||||
:total="total"
|
|
||||||
layout="total, sizes, prev, pager, next, jumper"
|
|
||||||
background
|
|
||||||
@current-change="load"
|
|
||||||
@size-change="handleSizeChange"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.engagement-range {
|
|
||||||
width: 360px;
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.engagement-drama {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.engagement-cover {
|
|
||||||
width: 40px;
|
|
||||||
height: 56px;
|
|
||||||
flex: none;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,201 +0,0 @@
|
|||||||
<!-- Author: fruit.com.cn -->
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import { onMounted, reactive, ref } from 'vue'
|
|
||||||
import dayjs from 'dayjs'
|
|
||||||
import PageHeading from '@/views/components/PageHeading.vue'
|
|
||||||
import AppUserCell from '@/views/components/AppUserCell.vue'
|
|
||||||
import { pageLikesApi } from '@/api/admin/engagement'
|
|
||||||
import { platformText } from './composables/useAppUsers'
|
|
||||||
|
|
||||||
const PAGE_SIZES = [10, 20, 50]
|
|
||||||
const TARGET_OPTIONS = [
|
|
||||||
{ value: '', label: '全部' },
|
|
||||||
{ value: 'DRAMA', label: '短剧' },
|
|
||||||
{ value: 'EPISODE', label: '剧集' },
|
|
||||||
{ value: 'COMMENT', label: '评论' }
|
|
||||||
]
|
|
||||||
const PLATFORM_OPTIONS = [
|
|
||||||
{ value: '', label: '全部系统' },
|
|
||||||
{ value: 'ANDROID', label: 'Android' },
|
|
||||||
{ value: 'IOS', label: 'iOS' }
|
|
||||||
]
|
|
||||||
|
|
||||||
const filters = reactive({
|
|
||||||
keyword: '',
|
|
||||||
deviceId: '',
|
|
||||||
dramaTitle: '',
|
|
||||||
range: null,
|
|
||||||
targetType: '',
|
|
||||||
platform: ''
|
|
||||||
})
|
|
||||||
const rows = ref([])
|
|
||||||
const total = ref(0)
|
|
||||||
const loading = ref(false)
|
|
||||||
const pageIndex = ref(1)
|
|
||||||
const pageSize = ref(10)
|
|
||||||
|
|
||||||
async function load() {
|
|
||||||
loading.value = true
|
|
||||||
try {
|
|
||||||
const res = await pageLikesApi({
|
|
||||||
pageIndex: pageIndex.value,
|
|
||||||
pageSize: pageSize.value,
|
|
||||||
keyword: filters.keyword.trim() || undefined,
|
|
||||||
deviceId: filters.deviceId.trim() || undefined,
|
|
||||||
dramaTitle: filters.dramaTitle.trim() || undefined,
|
|
||||||
targetType: filters.targetType || undefined,
|
|
||||||
platform: filters.platform || undefined,
|
|
||||||
startTime: filters.range?.[0] || undefined,
|
|
||||||
endTime: filters.range?.[1] || undefined
|
|
||||||
})
|
|
||||||
rows.value = res.data?.list || []
|
|
||||||
total.value = res.data?.total || 0
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function search() {
|
|
||||||
pageIndex.value = 1
|
|
||||||
load()
|
|
||||||
}
|
|
||||||
|
|
||||||
function resetFilters() {
|
|
||||||
Object.assign(filters, {
|
|
||||||
keyword: '',
|
|
||||||
deviceId: '',
|
|
||||||
dramaTitle: '',
|
|
||||||
range: null,
|
|
||||||
targetType: '',
|
|
||||||
platform: ''
|
|
||||||
})
|
|
||||||
search()
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleSizeChange() {
|
|
||||||
pageIndex.value = 1
|
|
||||||
load()
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatTime(value) {
|
|
||||||
return value && dayjs(value).isValid() ? dayjs(value).format('YYYY-MM-DD HH:mm:ss') : '—'
|
|
||||||
}
|
|
||||||
|
|
||||||
function targetText(row) {
|
|
||||||
if (row.targetType === 'COMMENT') return row.commentSummary || '—'
|
|
||||||
if (row.targetType === 'EPISODE') return `${row.dramaTitle || '—'} 第 ${row.episodeNo ?? '—'} 集`
|
|
||||||
return row.dramaTitle || '—'
|
|
||||||
}
|
|
||||||
|
|
||||||
function typeText(type) {
|
|
||||||
return TARGET_OPTIONS.find((item) => item.value === type)?.label || type || '—'
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(load)
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<PageHeading eyebrow="用户管理" title="点赞列表" />
|
|
||||||
<section class="panel">
|
|
||||||
<div class="console-toolbar">
|
|
||||||
<el-input
|
|
||||||
v-model="filters.keyword"
|
|
||||||
class="console-keyword"
|
|
||||||
clearable
|
|
||||||
placeholder="uid / 昵称"
|
|
||||||
@keyup.enter="search"
|
|
||||||
/>
|
|
||||||
<el-input
|
|
||||||
v-model="filters.deviceId"
|
|
||||||
class="console-keyword"
|
|
||||||
clearable
|
|
||||||
placeholder="设备 ID"
|
|
||||||
@keyup.enter="search"
|
|
||||||
/>
|
|
||||||
<el-input
|
|
||||||
v-model="filters.dramaTitle"
|
|
||||||
class="console-keyword"
|
|
||||||
clearable
|
|
||||||
placeholder="短剧名称"
|
|
||||||
@keyup.enter="search"
|
|
||||||
/>
|
|
||||||
<el-select v-model="filters.targetType" class="console-select" placeholder="全部目标类型">
|
|
||||||
<el-option
|
|
||||||
v-for="item in TARGET_OPTIONS"
|
|
||||||
:key="item.value"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
<el-select v-model="filters.platform" class="console-select" placeholder="全部系统">
|
|
||||||
<el-option
|
|
||||||
v-for="item in PLATFORM_OPTIONS"
|
|
||||||
:key="item.value"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
<el-date-picker
|
|
||||||
v-model="filters.range"
|
|
||||||
class="engagement-range"
|
|
||||||
type="datetimerange"
|
|
||||||
value-format="YYYY-MM-DD HH:mm:ss"
|
|
||||||
range-separator="至"
|
|
||||||
start-placeholder="开始时间"
|
|
||||||
end-placeholder="结束时间"
|
|
||||||
/>
|
|
||||||
<el-button type="primary" @click="search">查询</el-button>
|
|
||||||
<el-button @click="resetFilters">重置</el-button>
|
|
||||||
<span class="console-count">共 {{ total }} 条</span>
|
|
||||||
</div>
|
|
||||||
<el-table
|
|
||||||
v-loading="loading"
|
|
||||||
:data="rows"
|
|
||||||
row-key="id"
|
|
||||||
border
|
|
||||||
class="drama-el-table"
|
|
||||||
empty-text="暂无点赞"
|
|
||||||
>
|
|
||||||
<el-table-column label="用户" min-width="200">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<AppUserCell :row="row" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="系统" width="100">
|
|
||||||
<template #default="{ row }">{{ platformText(row) }}</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="目标类型" width="110">
|
|
||||||
<template #default="{ row }">{{ typeText(row.targetType) }}</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="目标" min-width="200" show-overflow-tooltip>
|
|
||||||
<template #default="{ row }"
|
|
||||||
><span :title="targetText(row)">{{ targetText(row) }}</span></template
|
|
||||||
>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="dramaTitle" label="所属短剧" min-width="180" show-overflow-tooltip />
|
|
||||||
<el-table-column label="点赞时间" min-width="170">
|
|
||||||
<template #default="{ row }">{{ formatTime(row.createdAt) }}</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
<div class="pagination">
|
|
||||||
<el-pagination
|
|
||||||
v-model:current-page="pageIndex"
|
|
||||||
v-model:page-size="pageSize"
|
|
||||||
:page-sizes="PAGE_SIZES"
|
|
||||||
:total="total"
|
|
||||||
layout="total, sizes, prev, pager, next, jumper"
|
|
||||||
background
|
|
||||||
@current-change="load"
|
|
||||||
@size-change="handleSizeChange"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.engagement-range {
|
|
||||||
width: 360px;
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,264 +0,0 @@
|
|||||||
<!-- Author: fruit.com.cn -->
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import { onMounted, reactive, ref } from 'vue'
|
|
||||||
import PageHeading from '@/views/components/PageHeading.vue'
|
|
||||||
import AppUserCell from '@/views/components/AppUserCell.vue'
|
|
||||||
import { pageWatchHistoryApi } from '@/api/admin/appUser'
|
|
||||||
import { formatDateTime, formatDuration, platformText } from './composables/useAppUsers'
|
|
||||||
|
|
||||||
const SOURCE_OPTIONS = [
|
|
||||||
{ value: '', label: '全部' },
|
|
||||||
{ value: 'HOME', label: '首页' },
|
|
||||||
{ value: 'DETAIL', label: '详情页' },
|
|
||||||
{ value: 'SEARCH', label: '搜索' },
|
|
||||||
{ value: 'FAVORITE', label: '收藏' }
|
|
||||||
]
|
|
||||||
|
|
||||||
const FINISHED_OPTIONS = [
|
|
||||||
{ value: '', label: '全部' },
|
|
||||||
{ value: true, label: '已看完' },
|
|
||||||
{ value: false, label: '未看完' }
|
|
||||||
]
|
|
||||||
|
|
||||||
const PLATFORM_OPTIONS = [
|
|
||||||
{ value: '', label: '全部系统' },
|
|
||||||
{ value: 'ANDROID', label: 'Android' },
|
|
||||||
{ value: 'IOS', label: 'iOS' }
|
|
||||||
]
|
|
||||||
|
|
||||||
const filters = reactive({
|
|
||||||
keyword: '',
|
|
||||||
dramaTitle: '',
|
|
||||||
source: '',
|
|
||||||
finished: '',
|
|
||||||
platform: '',
|
|
||||||
range: null
|
|
||||||
})
|
|
||||||
const rows = ref([])
|
|
||||||
const total = ref(0)
|
|
||||||
const loading = ref(false)
|
|
||||||
const pageIndex = ref(1)
|
|
||||||
const pageSize = ref(10)
|
|
||||||
|
|
||||||
async function load() {
|
|
||||||
loading.value = true
|
|
||||||
try {
|
|
||||||
const res = await pageWatchHistoryApi({
|
|
||||||
pageIndex: pageIndex.value,
|
|
||||||
pageSize: pageSize.value,
|
|
||||||
keyword: filters.keyword.trim() || undefined,
|
|
||||||
dramaTitle: filters.dramaTitle.trim() || undefined,
|
|
||||||
source: filters.source || undefined,
|
|
||||||
finished: filters.finished === '' ? undefined : filters.finished,
|
|
||||||
platform: filters.platform || undefined,
|
|
||||||
startTime: filters.range?.[0] || undefined,
|
|
||||||
endTime: filters.range?.[1] || undefined
|
|
||||||
})
|
|
||||||
rows.value = res.data?.list || []
|
|
||||||
total.value = res.data?.total || 0
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function search() {
|
|
||||||
pageIndex.value = 1
|
|
||||||
load()
|
|
||||||
}
|
|
||||||
|
|
||||||
function resetFilters() {
|
|
||||||
filters.keyword = ''
|
|
||||||
filters.dramaTitle = ''
|
|
||||||
filters.source = ''
|
|
||||||
filters.finished = ''
|
|
||||||
filters.platform = ''
|
|
||||||
filters.range = null
|
|
||||||
search()
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleSizeChange() {
|
|
||||||
pageIndex.value = 1
|
|
||||||
load()
|
|
||||||
}
|
|
||||||
|
|
||||||
function sourceText(source) {
|
|
||||||
return SOURCE_OPTIONS.find((item) => item.value === source)?.label || source || '—'
|
|
||||||
}
|
|
||||||
|
|
||||||
function episodeText(row) {
|
|
||||||
if (row.episodeNo) return `第 ${row.episodeNo} 集`
|
|
||||||
return row.episodeId ? `分集 #${row.episodeId}` : '未关联分集'
|
|
||||||
}
|
|
||||||
|
|
||||||
function progressText(row) {
|
|
||||||
if (!row.durationMs) return '—'
|
|
||||||
return `${formatDuration(row.positionMs)} / ${formatDuration(row.durationMs)}`
|
|
||||||
}
|
|
||||||
|
|
||||||
function contentTooltip(row) {
|
|
||||||
return `短剧 ID:${row.dramaId} / 分集 ID:${row.episodeId || '未关联'}`
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(load)
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<PageHeading
|
|
||||||
eyebrow="用户管理"
|
|
||||||
title="观看记录"
|
|
||||||
description="跨用户检索观看流水,核对短剧、分集、进度与来源。"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<section class="panel">
|
|
||||||
<div class="console-toolbar">
|
|
||||||
<el-input
|
|
||||||
v-model="filters.keyword"
|
|
||||||
class="console-keyword"
|
|
||||||
clearable
|
|
||||||
placeholder="uid / 昵称"
|
|
||||||
@keyup.enter="search"
|
|
||||||
@clear="search"
|
|
||||||
/>
|
|
||||||
<el-input
|
|
||||||
v-model="filters.dramaTitle"
|
|
||||||
class="console-keyword"
|
|
||||||
clearable
|
|
||||||
placeholder="短剧名称"
|
|
||||||
@keyup.enter="search"
|
|
||||||
@clear="search"
|
|
||||||
/>
|
|
||||||
<el-select
|
|
||||||
v-model="filters.source"
|
|
||||||
class="console-select"
|
|
||||||
placeholder="全部来源"
|
|
||||||
@change="search"
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="item in SOURCE_OPTIONS"
|
|
||||||
:key="item.value"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
<el-select
|
|
||||||
v-model="filters.finished"
|
|
||||||
class="console-select"
|
|
||||||
placeholder="全部完成状态"
|
|
||||||
@change="search"
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="item in FINISHED_OPTIONS"
|
|
||||||
:key="String(item.value)"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
<el-select
|
|
||||||
v-model="filters.platform"
|
|
||||||
class="console-select"
|
|
||||||
placeholder="全部系统"
|
|
||||||
@change="search"
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="item in PLATFORM_OPTIONS"
|
|
||||||
:key="item.value"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
<el-date-picker
|
|
||||||
v-model="filters.range"
|
|
||||||
class="watch-history-range"
|
|
||||||
type="datetimerange"
|
|
||||||
value-format="YYYY-MM-DD HH:mm:ss"
|
|
||||||
range-separator="至"
|
|
||||||
start-placeholder="开始时间"
|
|
||||||
end-placeholder="结束时间"
|
|
||||||
@change="search"
|
|
||||||
/>
|
|
||||||
<el-button type="primary" @click="search">查询</el-button>
|
|
||||||
<el-button @click="resetFilters">重置</el-button>
|
|
||||||
<span class="console-count">共 {{ total }} 条</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<el-table
|
|
||||||
v-loading="loading"
|
|
||||||
:data="rows"
|
|
||||||
row-key="id"
|
|
||||||
border
|
|
||||||
class="drama-el-table"
|
|
||||||
empty-text="暂无符合条件的观看记录"
|
|
||||||
>
|
|
||||||
<el-table-column label="观看时间" min-width="170">
|
|
||||||
<template #default="{ row }">{{ formatDateTime(row.watchedAt) }}</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="用户" min-width="200">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<AppUserCell :row="row" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="系统" width="100">
|
|
||||||
<template #default="{ row }">{{ platformText(row) }}</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="短剧" min-width="190">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-tooltip :content="contentTooltip(row)" placement="top">
|
|
||||||
<div class="episode-table-title">
|
|
||||||
<b>{{ row.dramaTitle || `短剧 #${row.dramaId}` }}</b>
|
|
||||||
<el-tag v-if="row.dramaPublished === false" type="info" size="small" effect="plain"
|
|
||||||
>已下线</el-tag
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</el-tooltip>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="分集" min-width="180" show-overflow-tooltip>
|
|
||||||
<template #default="{ row }">
|
|
||||||
<div class="episode-table-title">
|
|
||||||
<b>{{ episodeText(row) }}</b>
|
|
||||||
<small v-if="row.episodeTitle">{{ row.episodeTitle }}</small>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="进度" min-width="120">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<span class="app-user-mono">{{ progressText(row) }}</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="完成" width="92">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-tag :type="row.finished ? 'success' : 'info'" effect="light">
|
|
||||||
{{ row.finished ? '已看完' : '未看完' }}
|
|
||||||
</el-tag>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="来源" width="96">
|
|
||||||
<template #default="{ row }">{{ sourceText(row.source) }}</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="deviceId" label="设备" min-width="150" show-overflow-tooltip>
|
|
||||||
<template #default="{ row }">{{ row.deviceId || '—' }}</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
|
|
||||||
<div class="pagination">
|
|
||||||
<el-pagination
|
|
||||||
v-model:current-page="pageIndex"
|
|
||||||
v-model:page-size="pageSize"
|
|
||||||
:page-sizes="[10, 20, 50]"
|
|
||||||
:total="total"
|
|
||||||
layout="total, sizes, prev, pager, next, jumper"
|
|
||||||
background
|
|
||||||
@current-change="load"
|
|
||||||
@size-change="handleSizeChange"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.watch-history-range {
|
|
||||||
width: 360px;
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
// Author: fruit.com.cn
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
import { onMounted, reactive, ref } from 'vue'
|
import { onMounted, reactive, ref } from 'vue'
|
||||||
import dayjs from 'dayjs'
|
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import {
|
import {
|
||||||
getAppUserApi,
|
getAppUserApi,
|
||||||
@@ -29,88 +28,12 @@ export const COUNTRY_OPTIONS = [
|
|||||||
{ value: 'CN', label: '中国' }
|
{ value: 'CN', label: '中国' }
|
||||||
]
|
]
|
||||||
|
|
||||||
/** 国家码 → 中文名,与后端 CountryProfile 保持一致;未收录的仍显示原码 */
|
|
||||||
const COUNTRY_TEXT = {
|
|
||||||
ID: '印度尼西亚',
|
|
||||||
MY: '马来西亚',
|
|
||||||
SG: '新加坡',
|
|
||||||
TH: '泰国',
|
|
||||||
VN: '越南',
|
|
||||||
PH: '菲律宾',
|
|
||||||
KH: '柬埔寨',
|
|
||||||
MM: '缅甸',
|
|
||||||
LA: '老挝',
|
|
||||||
BN: '文莱',
|
|
||||||
CN: '中国',
|
|
||||||
TW: '中国台湾',
|
|
||||||
HK: '中国香港',
|
|
||||||
MO: '中国澳门',
|
|
||||||
JP: '日本',
|
|
||||||
KR: '韩国',
|
|
||||||
IN: '印度',
|
|
||||||
PK: '巴基斯坦',
|
|
||||||
BD: '孟加拉国',
|
|
||||||
LK: '斯里兰卡',
|
|
||||||
NP: '尼泊尔',
|
|
||||||
US: '美国',
|
|
||||||
CA: '加拿大',
|
|
||||||
MX: '墨西哥',
|
|
||||||
BR: '巴西',
|
|
||||||
AR: '阿根廷',
|
|
||||||
CL: '智利',
|
|
||||||
CO: '哥伦比亚',
|
|
||||||
PE: '秘鲁',
|
|
||||||
VE: '委内瑞拉',
|
|
||||||
EC: '厄瓜多尔',
|
|
||||||
GT: '危地马拉',
|
|
||||||
DO: '多米尼加',
|
|
||||||
GB: '英国',
|
|
||||||
DE: '德国',
|
|
||||||
FR: '法国',
|
|
||||||
ES: '西班牙',
|
|
||||||
IT: '意大利',
|
|
||||||
NL: '荷兰',
|
|
||||||
PL: '波兰',
|
|
||||||
RU: '俄罗斯',
|
|
||||||
UA: '乌克兰',
|
|
||||||
TR: '土耳其',
|
|
||||||
SA: '沙特阿拉伯',
|
|
||||||
AE: '阿联酋',
|
|
||||||
IL: '以色列',
|
|
||||||
EG: '埃及',
|
|
||||||
NG: '尼日利亚',
|
|
||||||
ZA: '南非',
|
|
||||||
KE: '肯尼亚',
|
|
||||||
MA: '摩洛哥',
|
|
||||||
AU: '澳大利亚',
|
|
||||||
NZ: '新西兰'
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 国家列统一展示中文名,无值时显示横线 */
|
|
||||||
export function countryText(code) {
|
|
||||||
const value = (code || '').toUpperCase()
|
|
||||||
return COUNTRY_TEXT[value] || value || '—'
|
|
||||||
}
|
|
||||||
|
|
||||||
export function statusMeta(status) {
|
export function statusMeta(status) {
|
||||||
return (
|
return (
|
||||||
APP_USER_STATUS.find((item) => item.value === status) || { label: status || '-', tag: 'info' }
|
APP_USER_STATUS.find((item) => item.value === status) || { label: status || '-', tag: 'info' }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const PLATFORM_TEXT = { ANDROID: 'Android', IOS: 'iOS', WEB: 'Web' }
|
|
||||||
|
|
||||||
/** 客户端平台,只有 iOS / Android 两种取值(缺记录显示横线)。 */
|
|
||||||
export function platformText(row) {
|
|
||||||
const platform = row?.platform || ''
|
|
||||||
return PLATFORM_TEXT[platform] || platform || '—'
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 后端返回 ISO 时间串,统一格式化成后台可读的本地时间 */
|
|
||||||
export function formatDateTime(value) {
|
|
||||||
return value && dayjs(value).isValid() ? dayjs(value).format('YYYY-MM-DD HH:mm:ss') : '—'
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 毫秒转 mm:ss,观看流水里的进度用 */
|
/** 毫秒转 mm:ss,观看流水里的进度用 */
|
||||||
export function formatDuration(ms) {
|
export function formatDuration(ms) {
|
||||||
const total = Math.max(0, Math.floor((ms || 0) / 1000))
|
const total = Math.max(0, Math.floor((ms || 0) / 1000))
|
||||||
@@ -127,7 +50,6 @@ export function useAppUsers() {
|
|||||||
const keyword = ref('')
|
const keyword = ref('')
|
||||||
const statusFilter = ref(undefined)
|
const statusFilter = ref(undefined)
|
||||||
const countryFilter = ref(undefined)
|
const countryFilter = ref(undefined)
|
||||||
const platformFilter = ref(undefined)
|
|
||||||
const currentPage = ref(1)
|
const currentPage = ref(1)
|
||||||
const pageSize = ref(10)
|
const pageSize = ref(10)
|
||||||
|
|
||||||
@@ -150,8 +72,7 @@ export function useAppUsers() {
|
|||||||
pageSize: pageSize.value,
|
pageSize: pageSize.value,
|
||||||
keyword: keyword.value.trim() || undefined,
|
keyword: keyword.value.trim() || undefined,
|
||||||
status: statusFilter.value,
|
status: statusFilter.value,
|
||||||
countryCode: countryFilter.value,
|
countryCode: countryFilter.value
|
||||||
platform: platformFilter.value || undefined
|
|
||||||
})
|
})
|
||||||
users.value = res.data?.list || []
|
users.value = res.data?.list || []
|
||||||
total.value = res.data?.total || 0
|
total.value = res.data?.total || 0
|
||||||
@@ -169,7 +90,6 @@ export function useAppUsers() {
|
|||||||
keyword.value = ''
|
keyword.value = ''
|
||||||
statusFilter.value = undefined
|
statusFilter.value = undefined
|
||||||
countryFilter.value = undefined
|
countryFilter.value = undefined
|
||||||
platformFilter.value = undefined
|
|
||||||
queryUsers()
|
queryUsers()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,7 +176,6 @@ export function useAppUsers() {
|
|||||||
keyword,
|
keyword,
|
||||||
statusFilter,
|
statusFilter,
|
||||||
countryFilter,
|
countryFilter,
|
||||||
platformFilter,
|
|
||||||
currentPage,
|
currentPage,
|
||||||
pageSize,
|
pageSize,
|
||||||
detailVisible,
|
detailVisible,
|
||||||
|
|||||||
Vendored
-1
@@ -48,7 +48,6 @@ declare global {
|
|||||||
|
|
||||||
declare interface IResponse<T = any> {
|
declare interface IResponse<T = any> {
|
||||||
code: number
|
code: number
|
||||||
message?: string
|
|
||||||
data: T extends any ? T : T & any
|
data: T extends any ? T : T & any
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-4
@@ -139,10 +139,7 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
|
|||||||
hmr: {
|
hmr: {
|
||||||
overlay: false
|
overlay: false
|
||||||
},
|
},
|
||||||
// 必须同时监听 IPv6:Windows 上 localhost 先解析成 ::1,
|
host: '0.0.0.0'
|
||||||
// 只绑 0.0.0.0 会让每次新建连接都等 IPv6 超时(约 2s)再回退到 IPv4,
|
|
||||||
// 表现为页面白屏很久。'::' 是双栈,IPv4 局域网访问同样可用。
|
|
||||||
host: '::'
|
|
||||||
},
|
},
|
||||||
optimizeDeps: {
|
optimizeDeps: {
|
||||||
include: [
|
include: [
|
||||||
|
|||||||
Reference in new issue
Block a user