1
This commit is contained in:
@@ -4,16 +4,39 @@
|
|||||||
<template #header>
|
<template #header>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<span>系列管理</span>
|
<span>系列管理</span>
|
||||||
<div>
|
<div class="header-right">
|
||||||
<el-input v-model="keyword" placeholder="搜索系列标题" clearable
|
<el-input v-model="keyword" placeholder="搜索系列标题" clearable
|
||||||
style="width: 200px; margin-right: 8px" @keyup.enter="load" />
|
style="width: 200px; margin-right: 8px" @keyup.enter="load" />
|
||||||
<el-button :loading="syncAllLoading" @click="syncAll">同步新剧</el-button>
|
|
||||||
<el-button type="primary" @click="showCreate">+ 新建系列</el-button>
|
<el-dropdown trigger="click" @command="handleBatchCmd">
|
||||||
|
<el-button :loading="batchLoading">批量更新 <el-icon class="el-icon--right"><arrow-down /></el-icon></el-button>
|
||||||
|
<template #dropdown>
|
||||||
|
<el-dropdown-menu>
|
||||||
|
<el-dropdown-item command="rebuild" :disabled="batchLoading">
|
||||||
|
<el-icon><refresh-left /></el-icon> 重算集数(total_episodes)
|
||||||
|
</el-dropdown-item>
|
||||||
|
<el-dropdown-item command="syncDrama" :disabled="batchLoading">
|
||||||
|
<el-icon><download /></el-icon> 同步短剧采集(新集数)
|
||||||
|
</el-dropdown-item>
|
||||||
|
<el-dropdown-item command="syncSources" :disabled="batchLoading">
|
||||||
|
<el-icon><collection-tag /></el-icon> 同步视频采集源
|
||||||
|
</el-dropdown-item>
|
||||||
|
</el-dropdown-menu>
|
||||||
|
</template>
|
||||||
|
</el-dropdown>
|
||||||
|
|
||||||
|
<el-button v-if="selectedIds.length" type="warning" plain
|
||||||
|
style="margin-left: 8px"
|
||||||
|
@click="showBatchEdit">批量编辑(已选 {{ selectedIds.length }})</el-button>
|
||||||
|
|
||||||
|
<el-button type="primary" style="margin-left: 8px" @click="showCreate">+ 新建系列</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<el-table :data="list" v-loading="loading" stripe>
|
<el-table :data="list" v-loading="loading" stripe
|
||||||
|
@selection-change="onSelectionChange">
|
||||||
|
<el-table-column type="selection" width="42" />
|
||||||
<el-table-column prop="id" label="ID" width="70" />
|
<el-table-column prop="id" label="ID" width="70" />
|
||||||
<el-table-column prop="title" label="系列标题" min-width="160">
|
<el-table-column prop="title" label="系列标题" min-width="160">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
@@ -106,12 +129,41 @@
|
|||||||
<el-button type="primary" :loading="submitting" @click="save">保存</el-button>
|
<el-button type="primary" :loading="submitting" @click="save">保存</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
|
<!-- 批量编辑弹窗 -->
|
||||||
|
<el-dialog v-model="batchDialogVisible" title="批量编辑系列" width="400px">
|
||||||
|
<div style="margin-bottom: 12px; color: #606266; font-size: 13px">
|
||||||
|
共选中 <b>{{ selectedIds.length }}</b> 个系列,只修改下面勾选的字段:
|
||||||
|
</div>
|
||||||
|
<el-form :model="batchForm" label-width="80px">
|
||||||
|
<el-form-item label="状态">
|
||||||
|
<el-switch v-model="batchForm.touchStatus" active-text="修改" inactive-text="不改" />
|
||||||
|
<el-select v-if="batchForm.touchStatus" v-model="batchForm.status"
|
||||||
|
style="width: 120px; margin-left: 12px">
|
||||||
|
<el-option label="正常" :value="1" />
|
||||||
|
<el-option label="隐藏" :value="0" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="分类">
|
||||||
|
<el-switch v-model="batchForm.touchCategory" active-text="修改" inactive-text="不改" />
|
||||||
|
<el-select v-if="batchForm.touchCategory" v-model="batchForm.category_id"
|
||||||
|
placeholder="请选择" style="width: 180px; margin-left: 12px">
|
||||||
|
<el-option v-for="c in categories" :key="c.id" :label="c.name" :value="c.id" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="batchDialogVisible = false">取消</el-button>
|
||||||
|
<el-button type="primary" :loading="batchSubmitting" @click="batchSave">保存</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { reactive, ref, onMounted } from 'vue'
|
import { reactive, ref, onMounted } from 'vue'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
|
import { ArrowDown, RefreshLeft, Download, CollectionTag } from '@element-plus/icons-vue'
|
||||||
import request from '@/api/request'
|
import request from '@/api/request'
|
||||||
|
|
||||||
const list = ref([])
|
const list = ref([])
|
||||||
@@ -125,13 +177,25 @@ const dialogVisible = ref(false)
|
|||||||
const editing = ref(null)
|
const editing = ref(null)
|
||||||
const submitting = ref(false)
|
const submitting = ref(false)
|
||||||
const coverUploading = ref(false)
|
const coverUploading = ref(false)
|
||||||
const syncAllLoading = ref(false)
|
|
||||||
const syncingId = ref(0)
|
const syncingId = ref(0)
|
||||||
|
const selectedIds = ref([])
|
||||||
|
const batchLoading = ref(false)
|
||||||
|
const batchDialogVisible = ref(false)
|
||||||
|
const batchSubmitting = ref(false)
|
||||||
|
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
title: '', cover_url: '', description: '', category_id: 0,
|
title: '', cover_url: '', description: '', category_id: 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const batchForm = reactive({
|
||||||
|
touchStatus: false, status: 1,
|
||||||
|
touchCategory: false, category_id: 0,
|
||||||
|
})
|
||||||
|
|
||||||
|
function onSelectionChange(rows) {
|
||||||
|
selectedIds.value = rows.map(r => r.id)
|
||||||
|
}
|
||||||
|
|
||||||
async function uploadCover(file) {
|
async function uploadCover(file) {
|
||||||
if (!file || !file.raw) return
|
if (!file || !file.raw) return
|
||||||
const allowed = ['image/jpeg', 'image/png', 'image/webp', 'image/gif']
|
const allowed = ['image/jpeg', 'image/png', 'image/webp', 'image/gif']
|
||||||
@@ -247,20 +311,66 @@ async function syncOne(row) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function syncAll() {
|
// ---------- 批量操作 ----------
|
||||||
syncAllLoading.value = true
|
|
||||||
|
async function handleBatchCmd(cmd) {
|
||||||
|
batchLoading.value = true
|
||||||
try {
|
try {
|
||||||
await request({ url: '/admin/collection/sync-all', method: 'post', data: { pages: 2 } })
|
if (cmd === 'rebuild') {
|
||||||
ElMessage.success('已触发后台同步,稍后刷新查看')
|
await ElMessageBox.confirm(
|
||||||
setTimeout(load, 15000)
|
'将遍历全部系列,按已发布视频真实数量重算 total_episodes。确定执行?',
|
||||||
|
'确认', { type: 'warning' }
|
||||||
|
)
|
||||||
|
const r = await request({ url: '/admin/series/rebuild-counts', method: 'post' })
|
||||||
|
ElMessage.success(`共 ${r.total} 个系列,修复了 ${r.fixed} 个`)
|
||||||
|
load()
|
||||||
|
} else if (cmd === 'syncDrama') {
|
||||||
|
const r = await request({
|
||||||
|
url: '/admin/collection/sync-all', method: 'post', data: { pages: 2 },
|
||||||
|
})
|
||||||
|
ElMessage.success(`已触发后台增量同步(pages=2),稍后刷新查看`)
|
||||||
|
setTimeout(load, 15000)
|
||||||
|
} else if (cmd === 'syncSources') {
|
||||||
|
await ElMessageBox.confirm(
|
||||||
|
'将同时触发所有 23 个视频采集源的全量同步(异步后台执行)。确定?',
|
||||||
|
'确认', { type: 'warning' }
|
||||||
|
)
|
||||||
|
const r = await request({ url: '/admin/collection/sources/sync-all', method: 'post' })
|
||||||
|
ElMessage.success(`已触发 ${r.started?.length || 0} 个采集源同步`)
|
||||||
|
}
|
||||||
} catch (e) {} finally {
|
} catch (e) {} finally {
|
||||||
syncAllLoading.value = false
|
batchLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function showBatchEdit() {
|
||||||
|
Object.assign(batchForm, { touchStatus: false, status: 1, touchCategory: false, category_id: 0 })
|
||||||
|
batchDialogVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
async function batchSave() {
|
||||||
|
if (!batchForm.touchStatus && !batchForm.touchCategory) {
|
||||||
|
ElMessage.warning('至少勾选一个要修改的字段')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
batchSubmitting.value = true
|
||||||
|
try {
|
||||||
|
const data = { series_ids: selectedIds.value }
|
||||||
|
if (batchForm.touchStatus) data.status = batchForm.status
|
||||||
|
if (batchForm.touchCategory) data.category_id = batchForm.category_id
|
||||||
|
const r = await request({ url: '/admin/series/batch', method: 'put', data })
|
||||||
|
ElMessage.success(`已更新 ${r.affected} 个系列`)
|
||||||
|
batchDialogVisible.value = false
|
||||||
|
load()
|
||||||
|
} catch (e) {} finally {
|
||||||
|
batchSubmitting.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.header { display: flex; justify-content: space-between; align-items: center; }
|
.header { display: flex; justify-content: space-between; align-items: center; }
|
||||||
|
.header-right { display: flex; align-items: center; }
|
||||||
.title-col { display: flex; align-items: center; gap: 8px; }
|
.title-col { display: flex; align-items: center; gap: 8px; }
|
||||||
.cover { width: 40px; height: 40px; border-radius: 4px; object-fit: cover; }
|
.cover { width: 40px; height: 40px; border-radius: 4px; object-fit: cover; }
|
||||||
.cover-upload { display: flex; align-items: center; }
|
.cover-upload { display: flex; align-items: center; }
|
||||||
|
|||||||
@@ -56,6 +56,11 @@ class FeedPlayerPool {
|
|||||||
/// 会让视频在后台继续出声(切到"我的"听到同一视频声音的根因)
|
/// 会让视频在后台继续出声(切到"我的"听到同一视频声音的根因)
|
||||||
bool _suspended = false;
|
bool _suspended = false;
|
||||||
|
|
||||||
|
/// 断点续播记录:suspend 时保存当前槽位置(stop 断下载但位置不丢),
|
||||||
|
/// rebind 重新 open 后 seek 回断点再播;用后即清
|
||||||
|
int _resumeVideoId = -1;
|
||||||
|
Duration _resumePosition = Duration.zero;
|
||||||
|
|
||||||
/// 最近一次 bindWindow(resume 时需等在途 open 完成再 play,避免 play 被
|
/// 最近一次 bindWindow(resume 时需等在途 open 完成再 play,避免 play 被
|
||||||
/// open(play:false) 内部的 pause 覆盖导致恢复后不播)
|
/// open(play:false) 内部的 pause 覆盖导致恢复后不播)
|
||||||
Future<void>? _pendingBind;
|
Future<void>? _pendingBind;
|
||||||
@@ -63,7 +68,16 @@ class FeedPlayerPool {
|
|||||||
/// 初始化(创建 3 槽位并订阅各自进度流)
|
/// 初始化(创建 3 槽位并订阅各自进度流)
|
||||||
void init() {
|
void init() {
|
||||||
for (var i = 0; i < slotCount; i++) {
|
for (var i = 0; i < slotCount; i++) {
|
||||||
final player = _playerFactory?.call() ?? Player();
|
// bufferSize 映射 mpv demuxer-max-bytes(前向缓存,默认 32MB)。
|
||||||
|
// 压到 6MB:pause 时最多再缓冲 ~6MB(当前 HLS 片段下完即停),
|
||||||
|
// 不会像默认配置那样暂停后还预读后续多个分片偷跑流量;
|
||||||
|
// 恢复播放时 demuxer 缓存仍在,从暂停位置无缝继续(抖音行为)。
|
||||||
|
final player = _playerFactory?.call() ??
|
||||||
|
Player(
|
||||||
|
configuration: PlayerConfiguration(
|
||||||
|
bufferSize: 6 * 1024 * 1024,
|
||||||
|
),
|
||||||
|
);
|
||||||
final slot = PlayerSlot(player);
|
final slot = PlayerSlot(player);
|
||||||
_slots.add(slot);
|
_slots.add(slot);
|
||||||
_hookSlot(slot);
|
_hookSlot(slot);
|
||||||
@@ -132,6 +146,15 @@ class FeedPlayerPool {
|
|||||||
slot.videoId = item.videoId;
|
slot.videoId = item.videoId;
|
||||||
slot.completeNotified = false;
|
slot.completeNotified = false;
|
||||||
if (item.url.isNotEmpty) {
|
if (item.url.isNotEmpty) {
|
||||||
|
// 断点续播:open 前设置 mpv start 属性,mpv 在文件加载完成后自动
|
||||||
|
// 定位到断点。注意不能 open 后再复位 start——open() 发出 loadfile
|
||||||
|
// 即返回、文件异步加载,过早复位会让 mpv 加载时读到 none 从头播。
|
||||||
|
// 所以每次 open 前都显式设置(断点秒数或 none),无残留污染
|
||||||
|
final resumePos =
|
||||||
|
(i == index && item.videoId == _resumeVideoId && _resumeVideoId >= 0)
|
||||||
|
? _resumePosition
|
||||||
|
: Duration.zero;
|
||||||
|
await _setMpvStart(slot.player, resumePos);
|
||||||
// 经本地代理:HLS 分片 1G LRU 缓存,回看命中缓存不再下载
|
// 经本地代理:HLS 分片 1G LRU 缓存,回看命中缓存不再下载
|
||||||
await slot.player.open(Media(LocalMediaServer.I.wrap(item.url)), play: false);
|
await slot.player.open(Media(LocalMediaServer.I.wrap(item.url)), play: false);
|
||||||
// await 期间用户可能又翻页:本次绑定已过期,退出(最新绑定会接管)
|
// await 期间用户可能又翻页:本次绑定已过期,退出(最新绑定会接管)
|
||||||
@@ -141,33 +164,65 @@ class FeedPlayerPool {
|
|||||||
|
|
||||||
// 4. 当前槽:播放(播前再校验代际与挂起态,防过期调用/后台挂起时唤醒媒体)
|
// 4. 当前槽:播放(播前再校验代际与挂起态,防过期调用/后台挂起时唤醒媒体)
|
||||||
if (gen != _generation || _suspended) return;
|
if (gen != _generation || _suspended) return;
|
||||||
|
// 断点已在 step 3 经 mpv start 属性应用,此处消费掉记录
|
||||||
|
_resumeVideoId = -1;
|
||||||
|
_resumePosition = Duration.zero;
|
||||||
currentSlot.player.play();
|
currentSlot.player.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 挂起(切出首页底部 Tab / App 退后台 / 切走当前策略):
|
/// 设置 mpv start 属性(zero 表示复位为 none)。仅 Native 平台有效,
|
||||||
/// 立即暂停当前槽,并阻止在途 bindWindow 的 open 完成后自动播放
|
/// 测试注入的 fake player 无 platform,静默忽略
|
||||||
void suspend() {
|
Future<void> _setMpvStart(Player player, Duration pos) async {
|
||||||
_suspended = true;
|
|
||||||
try {
|
try {
|
||||||
currentSlot.player.pause();
|
final platform = player.platform;
|
||||||
|
if (platform is NativePlayer) {
|
||||||
|
await platform.setProperty(
|
||||||
|
'start',
|
||||||
|
pos > Duration.zero
|
||||||
|
? (pos.inMilliseconds / 1000).toStringAsFixed(3)
|
||||||
|
: 'none',
|
||||||
|
);
|
||||||
|
}
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 恢复(切回首页 / App 回前台 / 策略切回):解除挂起;若 bind 仍在 open,
|
/// 挂起(切出首页底部 Tab / App 退后台 / 切走当前策略):
|
||||||
/// 等其完成后再 play,避免 play 被 open(play:false) 的内部 pause 覆盖
|
/// 记录当前槽播放位置后 stop 全部槽位。mpv 的 pause 只停播放线程,
|
||||||
|
/// demuxer 对 HLS 流仍持续预读分片(实测 demuxer-max-bytes 限不住),
|
||||||
|
/// 只有 stop 能可靠断开下载;位置存到 _resumePosition,恢复时 rebind
|
||||||
|
/// 重新 open + seek 续播(分片走本地代理磁盘缓存,零流量)
|
||||||
|
void suspend() {
|
||||||
|
_suspended = true;
|
||||||
|
// 使在途 bindWindow 过期:其 open 完成后不得再 play
|
||||||
|
_generation++;
|
||||||
|
for (var s = 0; s < slotCount; s++) {
|
||||||
|
final slot = _slots[s];
|
||||||
|
if (slot.videoId < 0) continue;
|
||||||
|
if (s == slotOf(_currentIndex)) {
|
||||||
|
_resumeVideoId = slot.videoId;
|
||||||
|
_resumePosition = slot.player.state.position;
|
||||||
|
}
|
||||||
|
unawaited(slot.player.stop());
|
||||||
|
slot.videoId = -1;
|
||||||
|
slot.completeNotified = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 恢复(切回首页 / App 回前台 / 策略切回):先等待在途 bindWindow 的 open 完成
|
||||||
|
/// (否则 play 会被 open(play:false) 的内部 pause 覆盖导致恢复后不播),然后解除
|
||||||
|
/// 挂起并 play。_suspended 必须在 await 之后才解除——否则等待期间 completed
|
||||||
|
/// listener 的 auto-loop 会因为看到 _suspended=false 而提前 play
|
||||||
Future<void> resume() async {
|
Future<void> resume() async {
|
||||||
_suspended = false;
|
|
||||||
final pending = _pendingBind;
|
final pending = _pendingBind;
|
||||||
if (pending != null) {
|
if (pending != null) {
|
||||||
try {
|
try {
|
||||||
await pending;
|
await pending;
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
if (!_suspended) {
|
_suspended = false;
|
||||||
try {
|
try {
|
||||||
currentSlot.player.play();
|
currentSlot.player.play();
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 每槽位独立订阅:≥95% 或播完触发一次 complete 回调
|
/// 每槽位独立订阅:≥95% 或播完触发一次 complete 回调
|
||||||
@@ -223,6 +278,9 @@ class FeedPlayerPool {
|
|||||||
_generation++;
|
_generation++;
|
||||||
// stopAll 后通常跟着 rebind 重新播放(如从登录页返回),解除挂起态
|
// stopAll 后通常跟着 rebind 重新播放(如从登录页返回),解除挂起态
|
||||||
_suspended = false;
|
_suspended = false;
|
||||||
|
// 彻底重置语义:清掉 suspend 保存的断点,rebind 从头播
|
||||||
|
_resumeVideoId = -1;
|
||||||
|
_resumePosition = Duration.zero;
|
||||||
for (final slot in _slots) {
|
for (final slot in _slots) {
|
||||||
if (slot.videoId < 0) continue;
|
if (slot.videoId < 0) continue;
|
||||||
unawaited(slot.player.stop());
|
unawaited(slot.player.stop());
|
||||||
|
|||||||
@@ -57,13 +57,16 @@ class _FeedScreenState extends ConsumerState<FeedScreen>
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// App 退后台挂起、回前台恢复播放(suspend/resume 防在途 open 竞态)
|
/// App 退后台挂起、回前台从断点续播。inactive(下拉通知栏等瞬时态)
|
||||||
|
/// 只轻量 pause 当前槽防出声;paused(真退后台)才走 suspend(stop)
|
||||||
|
/// 彻底断下载——避免瞬时 inactive 触发 stop+重载的画面闪烁
|
||||||
@override
|
@override
|
||||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||||
final notifier = ref.read(feedProvider(_strategy).notifier);
|
final notifier = ref.read(feedProvider(_strategy).notifier);
|
||||||
if (state == AppLifecycleState.paused ||
|
if (state == AppLifecycleState.paused) {
|
||||||
state == AppLifecycleState.inactive) {
|
|
||||||
notifier.pool.suspend();
|
notifier.pool.suspend();
|
||||||
|
} else if (state == AppLifecycleState.inactive) {
|
||||||
|
notifier.pool.pauseCurrent();
|
||||||
} else if (state == AppLifecycleState.resumed) {
|
} else if (state == AppLifecycleState.resumed) {
|
||||||
// 仅在首页 Tab 可见时恢复(在"我的"等页面回前台不播)
|
// 仅在首页 Tab 可见时恢复(在"我的"等页面回前台不播)
|
||||||
if (ref.read(feedTabVisibleProvider)) {
|
if (ref.read(feedTabVisibleProvider)) {
|
||||||
@@ -99,11 +102,15 @@ class _FeedScreenState extends ConsumerState<FeedScreen>
|
|||||||
.events
|
.events
|
||||||
.listen(_handleEvent);
|
.listen(_handleEvent);
|
||||||
_pageController.jumpToPage(0);
|
_pageController.jumpToPage(0);
|
||||||
// jumpToPage 触发新策略 bindWindow 后再 resume:等其在途 open 完成再播放,
|
// jumpToPage 后 resume + rebindCurrent:suspend 已 stop 槽位,仅 play
|
||||||
// 同时解除新策略池可能残留的挂起态
|
// 播不起来,必须 rebind 重新 open(有断点记录则 seek 续播)
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
unawaited(ref.read(feedProvider(_strategy).notifier).pool.resume());
|
unawaited(() async {
|
||||||
|
final n = ref.read(feedProvider(_strategy).notifier);
|
||||||
|
await n.pool.resume();
|
||||||
|
await n.rebindCurrent();
|
||||||
|
}());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,10 @@ class _FeedVideoPageState extends ConsumerState<FeedVideoPage> {
|
|||||||
int _likeBurstTrigger = 0;
|
int _likeBurstTrigger = 0;
|
||||||
Map<String, dynamic>? _seriesData;
|
Map<String, dynamic>? _seriesData;
|
||||||
|
|
||||||
|
/// 清屏模式:隐藏右侧互动栏与底部信息区,只留画面和进度条。
|
||||||
|
/// 单击屏幕仍是暂停/继续;恢复显示只能通过长按菜单的「恢复清屏」
|
||||||
|
bool _cleanMode = false;
|
||||||
|
|
||||||
static const _rates = [1.0, 1.5, 2.0, 3.0];
|
static const _rates = [1.0, 1.5, 2.0, 3.0];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -174,6 +178,25 @@ class _FeedVideoPageState extends ConsumerState<FeedVideoPage> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// 清屏 / 恢复清屏:隐藏右侧互动栏与底部信息,只留进度条。
|
||||||
|
// 恢复只能从长按菜单进入,避免单击误触把界面弹回来
|
||||||
|
ListTile(
|
||||||
|
contentPadding: EdgeInsets.zero,
|
||||||
|
leading: Icon(_cleanMode
|
||||||
|
? Icons.fullscreen
|
||||||
|
: Icons.fullscreen_exit),
|
||||||
|
title: Text(_cleanMode ? '恢复清屏' : '清屏'),
|
||||||
|
subtitle: Text(_cleanMode
|
||||||
|
? '重新显示点赞、评论、收藏、作者与标题'
|
||||||
|
: '隐藏点赞、评论、收藏、作者与标题'),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(sheetContext).pop();
|
||||||
|
setState(() => _cleanMode = !_cleanMode);
|
||||||
|
showTopToast(
|
||||||
|
context, _cleanMode ? '已清屏,长按视频可恢复' : '已恢复显示');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
// 下载(已下载/下载中置灰)
|
// 下载(已下载/下载中置灰)
|
||||||
Builder(builder: (_) {
|
Builder(builder: (_) {
|
||||||
final dm = ref.read(downloadManagerProvider);
|
final dm = ref.read(downloadManagerProvider);
|
||||||
@@ -341,6 +364,7 @@ class _FeedVideoPageState extends ConsumerState<FeedVideoPage> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
behavior: HitTestBehavior.opaque,
|
behavior: HitTestBehavior.opaque,
|
||||||
|
// 单击始终暂停/继续(清屏态也一样),恢复清屏需走长按菜单
|
||||||
onTap: widget.pool.toggleCurrent,
|
onTap: widget.pool.toggleCurrent,
|
||||||
onDoubleTap: _onDoubleTap,
|
onDoubleTap: _onDoubleTap,
|
||||||
onLongPress: _onLongPress,
|
onLongPress: _onLongPress,
|
||||||
@@ -349,23 +373,27 @@ class _FeedVideoPageState extends ConsumerState<FeedVideoPage> {
|
|||||||
child: Stack(
|
child: Stack(
|
||||||
fit: StackFit.expand,
|
fit: StackFit.expand,
|
||||||
children: [
|
children: [
|
||||||
// 底部渐变(提升文字可读性)
|
// 底部渐变(提升文字可读性):清屏时一并淡出
|
||||||
const Positioned(
|
Positioned(
|
||||||
left: 0, right: 0, bottom: 0, height: 160,
|
left: 0, right: 0, bottom: 0, height: 160,
|
||||||
child: IgnorePointer(
|
child: IgnorePointer(
|
||||||
child: DecoratedBox(
|
child: AnimatedOpacity(
|
||||||
decoration: BoxDecoration(
|
opacity: _cleanMode ? 0 : 1,
|
||||||
gradient: LinearGradient(
|
duration: const Duration(milliseconds: 200),
|
||||||
begin: Alignment.topCenter,
|
child: const DecoratedBox(
|
||||||
end: Alignment.bottomCenter,
|
decoration: BoxDecoration(
|
||||||
colors: [Colors.transparent, Colors.black54],
|
gradient: LinearGradient(
|
||||||
|
begin: Alignment.topCenter,
|
||||||
|
end: Alignment.bottomCenter,
|
||||||
|
colors: [Colors.transparent, Colors.black54],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
// 播放器(含抖音风格细进度条)
|
// 播放器(含抖音风格细进度条)——清屏时仍保留
|
||||||
VideoPlayerView(
|
VideoPlayerView(
|
||||||
pool: widget.pool,
|
pool: widget.pool,
|
||||||
slotIndex: widget.slotIndex,
|
slotIndex: widget.slotIndex,
|
||||||
@@ -380,54 +408,60 @@ class _FeedVideoPageState extends ConsumerState<FeedVideoPage> {
|
|||||||
// 右侧互动栏(头像/点赞/评论/收藏 — 分享已移至长按菜单)
|
// 右侧互动栏(头像/点赞/评论/收藏 — 分享已移至长按菜单)
|
||||||
Positioned(
|
Positioned(
|
||||||
right: 8, bottom: 96,
|
right: 8, bottom: 96,
|
||||||
child: InteractionBar(
|
child: _HidableOverlay(
|
||||||
item: widget.item,
|
hidden: _cleanMode,
|
||||||
onLike: widget.onLike,
|
child: InteractionBar(
|
||||||
onFavorite: widget.onFavorite,
|
item: widget.item,
|
||||||
onComment: widget.onComment,
|
onLike: widget.onLike,
|
||||||
|
onFavorite: widget.onFavorite,
|
||||||
|
onComment: widget.onComment,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
// 左下信息区 + 系列标题(系列标题在信息区上方,不重叠)
|
// 左下信息区 + 系列标题(系列标题在信息区上方,不重叠)
|
||||||
Positioned(
|
Positioned(
|
||||||
left: 12, right: 88, bottom: 24,
|
left: 12, right: 88, bottom: 24,
|
||||||
child: Column(
|
child: _HidableOverlay(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
hidden: _cleanMode,
|
||||||
mainAxisSize: MainAxisSize.min,
|
child: Column(
|
||||||
children: [
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
// 系列标题(当前视频属于系列时显示,点击弹出系列列表)
|
mainAxisSize: MainAxisSize.min,
|
||||||
if (_hasSeries)
|
children: [
|
||||||
GestureDetector(
|
// 系列标题(当前视频属于系列时显示,点击弹出系列列表)
|
||||||
onTap: _showSeriesSheet,
|
if (_hasSeries)
|
||||||
child: Container(
|
GestureDetector(
|
||||||
margin: const EdgeInsets.only(bottom: 8),
|
onTap: _showSeriesSheet,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
margin: const EdgeInsets.only(bottom: 8),
|
||||||
color: Colors.black54,
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
|
||||||
borderRadius: BorderRadius.circular(8),
|
decoration: BoxDecoration(
|
||||||
),
|
color: Colors.black54,
|
||||||
child: Row(
|
borderRadius: BorderRadius.circular(8),
|
||||||
mainAxisSize: MainAxisSize.min,
|
),
|
||||||
children: [
|
child: Row(
|
||||||
const Icon(Icons.playlist_play, color: Colors.white, size: 16),
|
mainAxisSize: MainAxisSize.min,
|
||||||
const SizedBox(width: 4),
|
children: [
|
||||||
Text(
|
const Icon(Icons.playlist_play, color: Colors.white, size: 16),
|
||||||
_seriesTitle,
|
const SizedBox(width: 4),
|
||||||
style: const TextStyle(
|
Text(
|
||||||
color: Colors.white,
|
_seriesTitle,
|
||||||
fontSize: 13,
|
style: const TextStyle(
|
||||||
fontWeight: FontWeight.w600,
|
color: Colors.white,
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(width: 2),
|
||||||
const SizedBox(width: 2),
|
const Icon(Icons.chevron_right, color: Colors.white, size: 14),
|
||||||
const Icon(Icons.chevron_right, color: Colors.white, size: 14),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
// 视频信息(昵称/标题/描述)
|
||||||
// 视频信息(昵称/标题/描述)
|
VideoInfoSection(item: widget.item),
|
||||||
VideoInfoSection(item: widget.item),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -436,3 +470,24 @@ class _FeedVideoPageState extends ConsumerState<FeedVideoPage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 可隐藏浮层:淡出 + 禁用点击。隐藏时仍占位但不拦截手势,
|
||||||
|
/// 保证点击/长按能穿透到下层的手势层
|
||||||
|
class _HidableOverlay extends StatelessWidget {
|
||||||
|
const _HidableOverlay({required this.hidden, required this.child});
|
||||||
|
|
||||||
|
final bool hidden;
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return IgnorePointer(
|
||||||
|
ignoring: hidden,
|
||||||
|
child: AnimatedOpacity(
|
||||||
|
opacity: hidden ? 0 : 1,
|
||||||
|
duration: const Duration(milliseconds: 200),
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ class _HomeShellState extends ConsumerState<HomeShell> {
|
|||||||
|
|
||||||
void _onTabSelected(int i) {
|
void _onTabSelected(int i) {
|
||||||
if (i == _index) return;
|
if (i == _index) return;
|
||||||
// 切到非首页:挂起所有 Feed 策略的播放器池(IndexedStack 保活,
|
// 切到非首页:挂起所有 Feed 策略池——suspend 记录断点后 stop 全槽位
|
||||||
// suspend 会同时阻止在途 open 完成后自动播放,杜绝后台幽灵声)
|
// (mpv pause 停不住 HLS 预读,只有 stop 能可靠断下载);
|
||||||
|
// 回首页 rebind 重新 open + seek 断点续播,缓存分片零流量(抖音行为)
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
for (final s in _feedStrategies) {
|
for (final s in _feedStrategies) {
|
||||||
ref.read(feedProvider(s).notifier).pool.suspend();
|
ref.read(feedProvider(s).notifier).pool.suspend();
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@ name: video_app
|
|||||||
description: "短视频应用(Flutter,iOS/Android 双端)"
|
description: "短视频应用(Flutter,iOS/Android 双端)"
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
|
|
||||||
version: 1.3.7+23
|
version: 1.3.15+31
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.9.2
|
sdk: ^3.9.2
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ CELERY_RESULT_BACKEND=redis://127.0.0.1:6379/2
|
|||||||
# ===== JWT =====
|
# ===== JWT =====
|
||||||
JWT_SECRET=0e79fddb233856d260b0072a979d483c1c07dbdb0c8c9b1d66bd3f540499093c
|
JWT_SECRET=0e79fddb233856d260b0072a979d483c1c07dbdb0c8c9b1d66bd3f540499093c
|
||||||
ACCESS_TOKEN_TTL=7200
|
ACCESS_TOKEN_TTL=7200
|
||||||
REFRESH_TOKEN_TTL=2592000
|
REFRESH_TOKEN_TTL=15552000
|
||||||
ADMIN_TOKEN_TTL=43200
|
ADMIN_TOKEN_TTL=43200
|
||||||
|
|
||||||
# ===== 对象存储 OSS(未接 OSS 时媒体走本地 /static)=====
|
# ===== 对象存储 OSS(未接 OSS 时媒体走本地 /static)=====
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ from fastapi import APIRouter, Depends, Query, Request
|
|||||||
from pydantic import BaseModel, BaseModel as _BM, Field as _F, Field as _Field
|
from pydantic import BaseModel, BaseModel as _BM, Field as _F, Field as _Field
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
from app.core.response import ok
|
from app.core import errors
|
||||||
|
from app.core.response import ok, BizException
|
||||||
from app.database import get_db
|
from app.database import get_db
|
||||||
from app.deps import AdminIdentity, require_roles
|
from app.deps import AdminIdentity, require_roles
|
||||||
from app.redis_client import get_redis
|
from app.redis_client import get_redis
|
||||||
@@ -620,6 +621,77 @@ class _VideoSeriesBind(BaseModel):
|
|||||||
episode_no: int = _Field(ge=1)
|
episode_no: int = _Field(ge=1)
|
||||||
|
|
||||||
|
|
||||||
|
# ---------- 批量操作(必须在 /series/{series_id} 路由之前注册,否则被参数路由抢先匹配)----------
|
||||||
|
|
||||||
|
class _SeriesRebuildResp(BaseModel):
|
||||||
|
total: int = 0
|
||||||
|
fixed: int = 0
|
||||||
|
|
||||||
|
|
||||||
|
@router.post("/series/rebuild-counts")
|
||||||
|
async def rebuild_series_counts(db: AsyncSession = Depends(get_db),
|
||||||
|
admin: AdminIdentity = Depends(require_super)):
|
||||||
|
"""重算所有系列的 total_episodes(按 status=2 的视频真实计数)"""
|
||||||
|
from app.models.video import Series, Video
|
||||||
|
from sqlalchemy import select, func
|
||||||
|
|
||||||
|
rows = (await db.execute(select(Series.id, Series.total_episodes))).all()
|
||||||
|
total = len(rows)
|
||||||
|
fixed = 0
|
||||||
|
for sid, old_cnt in rows:
|
||||||
|
new_cnt = (await db.execute(
|
||||||
|
select(func.count(Video.id)).where(Video.series_id == sid, Video.status == 2)
|
||||||
|
)).scalar_one()
|
||||||
|
if old_cnt != new_cnt:
|
||||||
|
s = await db.get(Series, sid)
|
||||||
|
s.total_episodes = new_cnt
|
||||||
|
fixed += 1
|
||||||
|
await db.commit()
|
||||||
|
return ok(_SeriesRebuildResp(total=total, fixed=fixed))
|
||||||
|
|
||||||
|
|
||||||
|
class _SeriesBatchUpdate(BaseModel):
|
||||||
|
series_ids: list[int] = _Field(min_length=1, max_length=200)
|
||||||
|
status: int | None = _Field(None, ge=0, le=1)
|
||||||
|
category_id: int | None = _Field(None, ge=0)
|
||||||
|
|
||||||
|
|
||||||
|
@router.put("/series/batch")
|
||||||
|
async def batch_update_series(req: _SeriesBatchUpdate, request: Request,
|
||||||
|
db: AsyncSession = Depends(get_db),
|
||||||
|
admin: AdminIdentity = Depends(require_super)):
|
||||||
|
"""批量编辑系列属性(当前支持 status / category_id)"""
|
||||||
|
from app.models.admin import AdminLog
|
||||||
|
from app.models.video import Series
|
||||||
|
from sqlalchemy import select
|
||||||
|
|
||||||
|
if req.status is None and req.category_id is None:
|
||||||
|
raise BizException(errors.PARAM_ERROR, "至少要传一个要修改的字段")
|
||||||
|
|
||||||
|
stmt = select(Series).where(Series.id.in_(req.series_ids))
|
||||||
|
rows = (await db.execute(stmt)).scalars().all()
|
||||||
|
affected = 0
|
||||||
|
for s in rows:
|
||||||
|
changed = False
|
||||||
|
if req.status is not None and s.status != req.status:
|
||||||
|
s.status = req.status
|
||||||
|
changed = True
|
||||||
|
if req.category_id is not None and s.category_id != req.category_id:
|
||||||
|
s.category_id = req.category_id
|
||||||
|
changed = True
|
||||||
|
if changed:
|
||||||
|
affected += 1
|
||||||
|
|
||||||
|
db.add(AdminLog(
|
||||||
|
admin_id=admin.admin_id, action="series_batch_update",
|
||||||
|
target=f"series:{','.join(str(i) for i in req.series_ids)}",
|
||||||
|
detail=f"status={req.status} category_id={req.category_id} affected={affected}",
|
||||||
|
ip=_ip(request),
|
||||||
|
))
|
||||||
|
await db.commit()
|
||||||
|
return ok({"affected": affected})
|
||||||
|
|
||||||
|
|
||||||
@router.post("/series")
|
@router.post("/series")
|
||||||
async def create_series(req: _SeriesCreate, db: AsyncSession = Depends(get_db),
|
async def create_series(req: _SeriesCreate, db: AsyncSession = Depends(get_db),
|
||||||
admin: AdminIdentity = Depends(require_super)):
|
admin: AdminIdentity = Depends(require_super)):
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -28,7 +28,7 @@ from app.services import config_service, invite_service, membership_service, sen
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
REFRESH_TTL = 30 * 24 * 3600
|
REFRESH_TTL = settings.refresh_token_ttl # 与 .env 的 REFRESH_TOKEN_TTL 同步
|
||||||
DEACTIVATE_FREEZE_DAYS = 7
|
DEACTIVATE_FREEZE_DAYS = 7
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user