Skip to content

Commit 7ca4f94

Browse files
committed
feat: 添加发布头条通知组件并在多个页面中引用
1 parent 84d0f50 commit 7ca4f94

8 files changed

Lines changed: 299 additions & 0 deletions

File tree

Lines changed: 252 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
<template>
2+
<div class="m-publish-headline-notice" v-if="visible">
3+
<div class="m-publish-headline-notice__card">
4+
<div class="u-accent-line"></div>
5+
<div class="u-left">
6+
<span class="u-status" :class="statusClass">
7+
<span class="u-pulse-dot"></span>
8+
<span>{{ statusText }}</span>
9+
</span>
10+
<p class="u-title">
11+
<span>你的作品即将在</span>
12+
<span class="u-time">{{ publishTime }}</span
13+
>登上<span class="u-highlight">魔盒头条</span>
14+
</p>
15+
</div>
16+
<div class="u-right">
17+
<span class="u-suffix">※ 根据实际情况可能会调整</span>
18+
</div>
19+
</div>
20+
</div>
21+
</template>
22+
23+
<script>
24+
import dayjs from "dayjs";
25+
import { getUpcomingDesignTask } from "@/service/publish/cms";
26+
27+
export default {
28+
name: "PublishHeadlineNotice",
29+
props: {
30+
sourceType: {
31+
type: String,
32+
default: "",
33+
},
34+
sourceId: {
35+
type: [String, Number],
36+
default: "",
37+
},
38+
client: {
39+
type: String,
40+
default: "",
41+
},
42+
},
43+
data() {
44+
return {
45+
task: null,
46+
};
47+
},
48+
computed: {
49+
visible() {
50+
return !!this.task?.published_at;
51+
},
52+
title() {
53+
if (!this.visible) return "";
54+
return `你的作品即将在${this.publishTime}登上魔盒头条(根据实际情况可能会调整)`;
55+
},
56+
publishTime() {
57+
if (!this.visible) return "";
58+
return dayjs(this.task.published_at).format("YYYY-MM-DD HH:mm:ss");
59+
},
60+
statusText() {
61+
const map = {
62+
0: "未开始",
63+
1: "进行中",
64+
2: "已就绪",
65+
};
66+
return map[this.task?.flow] || "未开始";
67+
},
68+
statusClass() {
69+
const map = {
70+
0: "is-pending",
71+
1: "is-progress",
72+
2: "is-ready",
73+
};
74+
return map[this.task?.flow] || "is-pending";
75+
},
76+
queryKey() {
77+
return [this.sourceType, this.sourceId, this.client].join("|");
78+
},
79+
isMock() {
80+
const query = `${location.search}&${location.hash.split("?")[1] || ""}`;
81+
return new URLSearchParams(query).get("headline_mock") === "1";
82+
},
83+
},
84+
watch: {
85+
queryKey: {
86+
immediate: true,
87+
handler() {
88+
this.loadData();
89+
},
90+
},
91+
},
92+
methods: {
93+
loadData() {
94+
if (this.isMock) {
95+
this.task = {
96+
id: 0,
97+
flow: 2,
98+
published_at: dayjs().add(3, "day").format("YYYY-MM-DD HH:mm:ss"),
99+
};
100+
return;
101+
}
102+
103+
if (!this.sourceType || !this.sourceId) {
104+
this.task = null;
105+
return;
106+
}
107+
108+
getUpcomingDesignTask({
109+
source_type: this.sourceType,
110+
source_id: String(this.sourceId),
111+
client: this.client || undefined,
112+
})
113+
.then((res) => {
114+
const data = res.data.data;
115+
this.task = data?.exists ? data.task : null;
116+
})
117+
.catch(() => {
118+
this.task = null;
119+
});
120+
},
121+
},
122+
};
123+
</script>
124+
125+
<style lang="less">
126+
.m-publish-headline-notice {
127+
margin-top: 12px;
128+
129+
&__card {
130+
position: relative;
131+
overflow: hidden;
132+
display: flex;
133+
align-items: center;
134+
justify-content: space-between;
135+
gap: 8px;
136+
width: 100%;
137+
max-width: 100%;
138+
min-height: 48px;
139+
padding: 10px 20px 10px 24px;
140+
box-sizing: border-box;
141+
border: 1px solid #f1f5f9;
142+
border-radius: 6px;
143+
background-color: #f8fafc;
144+
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
145+
}
146+
147+
.u-accent-line {
148+
position: absolute;
149+
left: 0;
150+
top: 8px;
151+
bottom: 8px;
152+
width: 4px;
153+
border-top-right-radius: 999px;
154+
border-bottom-right-radius: 999px;
155+
background: linear-gradient(180deg, #ec4899 0%, #f43f5e 100%);
156+
box-shadow: 1px 0 6px rgba(236, 72, 153, 0.3);
157+
}
158+
159+
.u-left {
160+
display: flex;
161+
align-items: center;
162+
gap: 12px;
163+
min-width: 0;
164+
}
165+
166+
.u-right {
167+
flex-shrink: 0;
168+
}
169+
170+
.u-suffix {
171+
white-space: nowrap;
172+
font-size: 12px;
173+
font-weight: 500;
174+
color: #94a3b8;
175+
}
176+
177+
.u-title {
178+
min-width: 0;
179+
margin: 0;
180+
overflow: hidden;
181+
text-overflow: ellipsis;
182+
white-space: nowrap;
183+
font-size: 14px;
184+
line-height: 1.5;
185+
letter-spacing: 0.025em;
186+
color: #475569;
187+
}
188+
189+
.u-time {
190+
font-weight: 750;
191+
color: #1e293b;
192+
}
193+
194+
.u-highlight {
195+
font-weight: 750;
196+
color: #db2777;
197+
}
198+
199+
.u-status {
200+
flex-shrink: 0;
201+
display: inline-flex;
202+
align-items: center;
203+
gap: 6px;
204+
height: 28px;
205+
padding: 0 10px;
206+
border: 1px solid rgba(251, 207, 232, 0.8);
207+
border-radius: 999px;
208+
background-color: #fdf2f8;
209+
color: #be185d;
210+
white-space: nowrap;
211+
font-size: 12px;
212+
font-weight: 600;
213+
line-height: 28px;
214+
}
215+
216+
.u-status.is-pending {
217+
color: #475569;
218+
background-color: #f8fafc;
219+
border-color: #cbd5e1;
220+
}
221+
222+
.u-status.is-progress {
223+
color: #c2410c;
224+
background-color: #fff7ed;
225+
border-color: #fed7aa;
226+
}
227+
228+
.u-status.is-ready {
229+
color: #be185d;
230+
background-color: #fdf2f8;
231+
border-color: rgba(251, 207, 232, 0.8);
232+
}
233+
234+
.u-pulse-dot {
235+
width: 6px;
236+
height: 6px;
237+
border-radius: 50%;
238+
background-color: currentColor;
239+
animation: headline-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
240+
}
241+
242+
@keyframes headline-pulse {
243+
0%,
244+
100% {
245+
opacity: 1;
246+
}
247+
50% {
248+
opacity: 0.4;
249+
}
250+
}
251+
}
252+
</style>

src/post/bps.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@
102102
<cms-banner v-model="post.post_banner"></cms-banner>
103103
<publish-design-task :data="post"></publish-design-task>
104104
</div>
105+
<publish-headline-notice
106+
:source-type="post.post_type"
107+
:source-id="id"
108+
:client="post.client"
109+
></publish-headline-notice>
105110

106111
<div class="m-publish-doc">
107112
<el-alert
@@ -164,6 +169,7 @@ import publish_guide from "@/components/publish/publish_guide.vue";
164169
import publish_mix_subtype from "@/components/publish/publish_mix_subtype.vue";
165170
import publish_wujie from "@/components/publish/publish_wujie.vue";
166171
import publish_reading_history from "@/components/publish/publish_reading_history.vue";
172+
import publish_headline_notice from "@/components/publish/publish_headline_notice.vue";
167173
168174
// 数据逻辑
169175
import { push, pull, setPostMeta, pushAdmin } from "@/service/publish/cms.js";
@@ -199,6 +205,7 @@ export default {
199205
"publish-mix-subtype": publish_mix_subtype,
200206
"publish-wujie": publish_wujie,
201207
"publish-reading-history": publish_reading_history,
208+
"publish-headline-notice": publish_headline_notice,
202209
},
203210
data: function () {
204211
return {

src/post/community.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@
133133
</div>
134134
</div>
135135
</div>
136+
<publish-headline-notice
137+
source-type="community"
138+
:source-id="id"
139+
:client="post.client"
140+
></publish-headline-notice>
136141

137142
<div class="m-publish-doc">
138143
<el-alert
@@ -180,6 +185,7 @@ import publish_category from "@/components/publish/publish_category.vue";
180185
import publish_at_authors from "@/components/publish/publish_at_authors.vue";
181186
import publish_reading_history from "@/components/publish/publish_reading_history.vue";
182187
import publish_client from "@/components/publish/publish_client.vue";
188+
import publish_headline_notice from "@/components/publish/publish_headline_notice.vue";
183189
184190
// 数据逻辑
185191
import { cmsMetaMixin } from "@/utils/cmsMetaMixin";
@@ -201,6 +207,7 @@ export default {
201207
"publish-client": publish_client,
202208
"publish-at-authors": publish_at_authors,
203209
"publish-reading-history": publish_reading_history,
210+
"publish-headline-notice": publish_headline_notice,
204211
},
205212
data: function () {
206213
return {

src/post/fb.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@
8585
<cms-banner v-model="post.post_banner"></cms-banner>
8686
<publish-design-task :data="post"></publish-design-task>
8787
</div>
88+
<publish-headline-notice
89+
:source-type="post.post_type"
90+
:source-id="id"
91+
:client="post.client"
92+
></publish-headline-notice>
8893

8994
<div class="m-publish-doc">
9095
<el-alert
@@ -146,6 +151,7 @@ import publish_revision from "@/components/publish/publish_revision.vue";
146151
import publish_at_authors from "@/components/publish/publish_at_authors.vue";
147152
import publish_guide from "@/components/publish/publish_guide.vue";
148153
import publish_reading_history from "@/components/publish/publish_reading_history.vue";
154+
import publish_headline_notice from "@/components/publish/publish_headline_notice.vue";
149155
150156
// 数据逻辑
151157
import { push, pushAdmin } from "@/service/publish/cms.js";
@@ -176,6 +182,7 @@ export default {
176182
"publish-at-authors": publish_at_authors,
177183
"publish-guide": publish_guide,
178184
"publish-reading-history": publish_reading_history,
185+
"publish-headline-notice": publish_headline_notice,
179186
},
180187
data: function () {
181188
return {

src/post/macro.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@
110110
<cms-banner v-model="post.post_banner"></cms-banner>
111111
<publish-design-task :data="post"></publish-design-task>
112112
</div>
113+
<publish-headline-notice
114+
:source-type="post.post_type"
115+
:source-id="id"
116+
:client="post.client"
117+
></publish-headline-notice>
113118

114119
<div class="m-publish-doc">
115120
<el-alert
@@ -179,6 +184,7 @@ import pz_haste from "@/components/publish/pz_haste.vue";
179184
import publish_guide from "@/components/publish/publish_guide.vue";
180185
import publish_wujie from "@/components/publish/publish_wujie.vue";
181186
import publish_reading_history from "@/components/publish/publish_reading_history.vue";
187+
import publish_headline_notice from "@/components/publish/publish_headline_notice.vue";
182188
183189
// 数据逻辑
184190
import { push, pushAdmin, getBreadCrumb } from "@/service/publish/cms.js";
@@ -217,6 +223,7 @@ export default {
217223
"publish-wujie": publish_wujie,
218224
"wujie-skill-sequence": wujie_skill_sequence,
219225
"publish-reading-history": publish_reading_history,
226+
"publish-headline-notice": publish_headline_notice,
220227
},
221228
data: function () {
222229
return {

src/post/pvp.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@
104104
<cms-banner v-model="post.post_banner"></cms-banner>
105105
<publish-design-task :data="post"></publish-design-task>
106106
</div>
107+
<publish-headline-notice
108+
:source-type="post.post_type"
109+
:source-id="id"
110+
:client="post.client"
111+
></publish-headline-notice>
107112

108113
<div class="m-publish-doc">
109114
<el-alert
@@ -167,6 +172,7 @@ import publish_guide from "@/components/publish/publish_guide.vue";
167172
import publish_mix_subtype from "@/components/publish/publish_mix_subtype.vue";
168173
import publish_wujie from "@/components/publish/publish_wujie.vue";
169174
import publish_reading_history from "@/components/publish/publish_reading_history.vue";
175+
import publish_headline_notice from "@/components/publish/publish_headline_notice.vue";
170176
171177
// 数据逻辑
172178
import { push, pushAdmin } from "@/service/publish/cms.js";
@@ -198,6 +204,7 @@ export default {
198204
"publish-mix-subtype": publish_mix_subtype,
199205
"publish-wujie": publish_wujie,
200206
"publish-reading-history": publish_reading_history,
207+
"publish-headline-notice": publish_headline_notice,
201208
},
202209
data: function () {
203210
return {

0 commit comments

Comments
 (0)