Skip to content

Commit 0e7adf7

Browse files
author
Taois
committed
feat: 完成适配推送功能
正确执行推送逻辑
1 parent b882342 commit 0e7adf7

File tree

3 files changed

+234
-28
lines changed

3 files changed

+234
-28
lines changed

dashboard/src/components/Breadcrumb.vue

Lines changed: 164 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,35 +31,68 @@
3131

3232
<!-- 右侧控制按钮和时间 -->
3333
<div class="header-right">
34-
<a-button type="outline" status="success" shape="round" @click="minimize">
34+
<a-button type="outline" status="success" shape="round" @click="handlePush">
3535
<template #icon>
36-
<icon-bug />
36+
<icon-send />
3737
</template>
38-
<template #default>调试</template>
38+
<template #default>推送</template>
3939
</a-button>
4040

41-
<a-button type="outline" status="success" shape="round" @click="maximize">
41+
<a-button type="outline" status="success" shape="round" @click="handleGlobalAction">
4242
<template #icon>
43-
<icon-settings />
43+
<icon-thunderbolt />
4444
</template>
45-
<template #default>设置</template>
46-
</a-button>
47-
48-
<a-button type="outline" status="success" shape="round" @click="closeWindow">
49-
<template #icon>
50-
<icon-user />
51-
</template>
52-
<template #default>用户设置</template>
45+
<template #default>全局动作</template>
5346
</a-button>
5447

5548
<!-- 时间显示插槽 -->
5649
<slot name="default"></slot>
5750
</div>
5851
</div>
52+
53+
<!-- 推送内容输入弹窗 -->
54+
<a-modal
55+
v-model:visible="showPushModal"
56+
title="推送内容"
57+
:width="600"
58+
@ok="confirmPush"
59+
@cancel="cancelPush"
60+
ok-text="确认推送"
61+
cancel-text="取消"
62+
:ok-button-props="{ disabled: !pushContent.trim() }"
63+
>
64+
<div class="push-modal-content">
65+
<div class="push-description">
66+
<icon-send class="push-icon" />
67+
<span>请输入要推送的内容(vod_id):</span>
68+
</div>
69+
<a-textarea
70+
v-model="pushContent"
71+
placeholder="请输入要推送的内容...&#10;支持多行输入,每行一个vod_id"
72+
:rows="6"
73+
:max-length="1000"
74+
show-word-limit
75+
allow-clear
76+
autofocus
77+
class="push-textarea"
78+
/>
79+
<div class="push-hint">
80+
<div class="hint-item">
81+
<icon-info-circle class="hint-icon" />
82+
<span>输入的内容将作为vod_id调用push_agent源的详情接口</span>
83+
</div>
84+
<div class="hint-item">
85+
<icon-bulb class="hint-icon" />
86+
<span>支持多行输入,系统将使用第一行非空内容作为vod_id</span>
87+
</div>
88+
</div>
89+
</div>
90+
</a-modal>
5991
</template>
6092

6193
<script setup>
6294
import { ref } from 'vue'
95+
import { Message, Modal } from '@arco-design/web-vue'
6396
6497
const props = defineProps({
6598
navigation_title: {
@@ -71,14 +104,14 @@ const props = defineProps({
71104
});
72105
const emit = defineEmits([
73106
"handleOpenForm",
74-
"closeWindow",
75-
"maximize",
76-
"minimize",
77107
"refreshPage",
78108
"onSearch",
109+
"handlePush",
79110
]);
80111
81112
const searchValue = ref('')
113+
const showPushModal = ref(false)
114+
const pushContent = ref('')
82115
83116
const handleOpenForm = () => {
84117
emit("handleOpenForm");
@@ -94,14 +127,53 @@ const onSearch = (value) => {
94127
}
95128
};
96129
97-
const closeWindow = () => {
98-
emit("closeWindow");
130+
// 推送按钮点击事件
131+
const handlePush = () => {
132+
showPushModal.value = true
133+
pushContent.value = ''
99134
};
100-
const minimize = () => {
101-
emit("minimize");
135+
136+
// 全局动作按钮点击事件
137+
const handleGlobalAction = () => {
138+
Message.info({
139+
content: '全局动作功能开发中,敬请期待!',
140+
duration: 3000
141+
})
102142
};
103-
const maximize = () => {
104-
emit("maximize");
143+
144+
// 确认推送
145+
const confirmPush = () => {
146+
if (!pushContent.value.trim()) {
147+
Message.error('推送内容不能为空');
148+
return;
149+
}
150+
151+
// 处理多行输入,取第一行非空内容作为vod_id
152+
const lines = pushContent.value.split('\n').map(line => line.trim()).filter(line => line);
153+
154+
if (lines.length === 0) {
155+
Message.error('请输入有效的推送内容');
156+
return;
157+
}
158+
159+
const vodId = lines[0]; // 使用第一行非空内容
160+
161+
if (lines.length > 1) {
162+
Message.info(`检测到多行输入,将使用第一行内容: ${vodId}`);
163+
}
164+
165+
// 触发推送事件,传递处理后的vod_id
166+
emit('handlePush', vodId);
167+
168+
// 关闭弹窗并清空内容
169+
showPushModal.value = false;
170+
pushContent.value = '';
171+
};
172+
173+
// 取消推送
174+
const cancelPush = () => {
175+
showPushModal.value = false
176+
pushContent.value = ''
105177
};
106178
</script>
107179

@@ -171,6 +243,76 @@ const maximize = () => {
171243
margin-left: 8px;
172244
}
173245
246+
/* 推送弹窗样式 */
247+
.push-modal-content {
248+
padding: 20px 0;
249+
}
250+
251+
.push-description {
252+
display: flex;
253+
align-items: center;
254+
margin-bottom: 20px;
255+
font-size: 16px;
256+
color: var(--color-text-1);
257+
font-weight: 500;
258+
}
259+
260+
.push-icon {
261+
margin-right: 8px;
262+
font-size: 18px;
263+
color: var(--color-primary-6);
264+
}
265+
266+
.push-textarea {
267+
margin-bottom: 16px;
268+
}
269+
270+
.push-textarea :deep(.arco-textarea) {
271+
border-radius: 8px;
272+
border: 2px solid var(--color-border-2);
273+
transition: all 0.3s ease;
274+
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
275+
line-height: 1.6;
276+
}
277+
278+
.push-textarea :deep(.arco-textarea:focus) {
279+
border-color: var(--color-primary-6);
280+
box-shadow: 0 0 0 3px var(--color-primary-1);
281+
}
282+
283+
.push-textarea :deep(.arco-textarea::placeholder) {
284+
color: var(--color-text-3);
285+
font-style: italic;
286+
}
287+
288+
.push-hint {
289+
background: var(--color-bg-2);
290+
border-radius: 8px;
291+
padding: 16px;
292+
border-left: 4px solid var(--color-primary-6);
293+
}
294+
295+
.hint-item {
296+
display: flex;
297+
align-items: flex-start;
298+
margin-bottom: 8px;
299+
font-size: 14px;
300+
color: var(--color-text-2);
301+
line-height: 1.5;
302+
}
303+
304+
.hint-item:last-child {
305+
margin-bottom: 0;
306+
}
307+
308+
.hint-icon {
309+
margin-right: 8px;
310+
margin-top: 2px;
311+
font-size: 16px;
312+
color: var(--color-primary-6);
313+
flex-shrink: 0;
314+
}
315+
174316
/* 响应式设计 */
175317
@media (max-width: 1200px) {
176318
.header-center :deep(.arco-input-search) {

dashboard/src/views/Video.vue

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
@maximize="maximize"
77
@closeWindow="closeWindow"
88
@onSearch="onSearch"
9+
@handlePush="handlePush"
910
:now_site_title="form.now_site_title"
1011
>
1112
<!-- 默认插槽的内容放这里 -->
@@ -70,6 +71,7 @@ import { useSiteStore } from "@/stores/siteStore";
7071
import { usePaginationStore } from "@/stores/paginationStore";
7172
import { usePageStateStore } from "@/stores/pageStateStore";
7273
import { useRoute, useRouter } from "vue-router";
74+
import { Message } from "@arco-design/web-vue";
7375
7476
const { nowSite, setCurrentSite } = useSiteStore();
7577
const paginationStore = usePaginationStore();
@@ -407,6 +409,64 @@ const handleOpenForm = () => {
407409
checkNowSite();
408410
};
409411
412+
// 处理推送功能
413+
const handlePush = async (vodId) => {
414+
if (!vodId || !vodId.trim()) {
415+
Message.error("推送内容不能为空");
416+
return;
417+
}
418+
419+
// 检查是否存在push_agent源
420+
const pushAgentSite = form.sites.find(site => site.key === 'push_agent');
421+
422+
if (!pushAgentSite) {
423+
Message.error("没有找到push_agent服务,请检查源配置");
424+
return;
425+
}
426+
427+
try {
428+
console.log('推送功能,使用临时站源:', {
429+
siteName: pushAgentSite.name,
430+
siteKey: pushAgentSite.key,
431+
siteApi: pushAgentSite.api
432+
});
433+
434+
// 参考收藏和历史功能,使用临时源跳转到详情页
435+
router.push({
436+
name: 'VideoDetail',
437+
params: { id: vodId.trim() },
438+
query: {
439+
// 基本视频信息(推送时可能没有完整信息)
440+
name: `推送内容-${vodId.trim()}`,
441+
pic: '',
442+
year: '',
443+
area: '',
444+
type: '',
445+
type_name: '',
446+
remarks: '',
447+
content: '',
448+
actor: '',
449+
director: '',
450+
// 标识从推送进入,使用临时站源
451+
fromPush: 'true',
452+
// 传递push_agent站源信息,不影响全局状态
453+
tempSiteName: pushAgentSite.name,
454+
tempSiteApi: pushAgentSite.api,
455+
tempSiteKey: pushAgentSite.key,
456+
// 传递来源页面信息
457+
sourceRouteName: route.name,
458+
sourceRouteParams: JSON.stringify(route.params),
459+
sourceRouteQuery: JSON.stringify(route.query)
460+
}
461+
});
462+
463+
Message.success(`正在推送内容: ${vodId.trim()}`);
464+
} catch (error) {
465+
console.error("推送失败:", error);
466+
Message.error("推送失败,请重试");
467+
}
468+
};
469+
410470
// 页面加载时获取数据
411471
onMounted(async () => {
412472
getData(); // 页面加载时获取数据

dashboard/src/views/VideoDetail.vue

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
<span v-if="!originalVideoInfo.name">视频详情</span>
1313
<span v-else class="title-with-info">
1414
<span class="title-main">视频详情 - {{ originalVideoInfo.name }}</span>
15-
<span class="title-source" v-if="siteStore.nowSite">
16-
({{ siteStore.nowSite.name }} - ID: {{ originalVideoInfo.id }})
15+
<span class="title-source" v-if="currentSiteInfo.name">
16+
({{ currentSiteInfo.name }} - ID: {{ originalVideoInfo.id }})
1717
</span>
1818
</span>
1919
</div>
@@ -413,19 +413,23 @@ const loadVideoDetail = async () => {
413413
loading.value = true
414414
error.value = ''
415415
416-
// 检查是否从收藏进入,如果是则优先调用T4详情接口获取最新数据
416+
// 检查是否从收藏、历史或推送进入,如果是则优先调用T4详情接口获取最新数据
417417
const fromCollection = route.query.fromCollection === 'true'
418+
const fromHistory = route.query.fromHistory === 'true'
419+
const fromPush = route.query.fromPush === 'true'
418420
419421
try {
420422
// 确定使用的站源信息
421423
let module, apiUrl, siteName
422424
423-
if (fromCollection && route.query.tempSiteKey) {
424-
// 从收藏进入,使用临时站源信息,不影响全局状态
425+
if ((fromCollection || fromHistory || fromPush) && route.query.tempSiteKey) {
426+
// 从收藏、历史或推送进入,使用临时站源信息,不影响全局状态
425427
module = route.query.tempSiteKey
426428
apiUrl = route.query.tempSiteApi
427429
siteName = route.query.tempSiteName
428-
console.log('从收藏进入,使用临时站源:', {
430+
431+
const sourceType = fromCollection ? '收藏' : fromHistory ? '历史' : '推送'
432+
console.log(`${sourceType}进入,使用临时站源:`, {
429433
siteName,
430434
module,
431435
apiUrl

0 commit comments

Comments
 (0)