@jx3box/jx3box-common-ui 9.3.2 → 9.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,919 @@
1
+ <!--
2
+ * @Author: zhusha
3
+ * @Date: 2025-05-13 10:00:27
4
+ * @LastEditors: zhusha
5
+ * @LastEditTime: 2025-05-20 16:13:32
6
+ * @Description: 悬浮窗组件
7
+ * 关于搜索跳转的问题:如果项目需要跳转微信原生界面,需要引入微信sdk,并使用微信提供的api进行跳转
8
+ <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script> 版本可根据需要查询微信官方文档
9
+ 然后在需要跳转的地方使用以下代码进行跳转
10
+ 例如: wx.miniProgram.navigateTo({ url: "/pages/search/search-detail/search-detail?" + params });
11
+ params为跳转的参数,需要根据项目实际情况进行修改,且需转为&连接的字符串形式,例如: "keyword=1&type=2",可参考以下函数
12
+ miniprogramParams() {
13
+ const params = [];
14
+ for (const key in this.miniprogram) {
15
+ if (this.miniprogram.hasOwnProperty(key)) {
16
+ // params.push(encodeURIComponent(key) + '=' + encodeURIComponent(this.miniprogram[key]));
17
+ params.push(encodeURIComponent(key) + '=' + this.miniprogram[key]);
18
+ }
19
+ }
20
+ return params.join('&');
21
+ }
22
+ *
23
+ * Copyright (c) 2025 by zhusha, email: no email, All Rights Reserved.
24
+ -->
25
+ <template>
26
+ <div class="p-suspend">
27
+ <!-- 初始按钮及配置 -->
28
+ <div class="m-home-box" v-if="btnConfig.showHome">
29
+ <div class="m-base">
30
+ <!-- // TODO自定义展现基础插槽 -->
31
+ <slot name="default"></slot>
32
+ </div>
33
+ <div class="m-more" v-if="btnConfig.showMore" @click="setMore">
34
+ <img class="u-icon" src="../assets/img/suspend/more.svg" svg-inline /> 更多
35
+ </div>
36
+ </div>
37
+ <!-- 样式分类(icon&more) -->
38
+ <div class="m-icon-box" v-if="btnConfig.showIcon">
39
+ <div class="m-btn-box">
40
+ <!-- 搜索按钮-->
41
+ <div v-if="btnConfig.showSearch" class="u-icon-d" @click="search">
42
+ <img class="u-icon" src="../assets/img/suspend/search.svg" svg-inline />
43
+ </div>
44
+ <!-- 固定按钮-->
45
+ <div v-if="btnConfig.showFixed" class="u-icon-d" @click="clickDrawer({ type: 'pin', text: '固定按钮' }, 1)">
46
+ <img class="u-icon active" src="../assets/img/suspend/pin_touchbar_24.svg" svg-inline
47
+ v-if="!fixIsActive" />
48
+ <img class="u-icon active" src="../assets/img/suspend/pin_slash_24.svg" svg-inline v-else />
49
+ </div>
50
+ <!-- 收藏按钮-->
51
+ <div v-if="btnConfig.showCollect" class="u-icon-d"
52
+ @click="clickDrawer({ type: 'collect', text: '收藏' }, 1)">
53
+ <img class="u-icon active" src="../assets/img/suspend/collect.svg" svg-inline v-if="!isCollect" />
54
+ <img class="u-icon active" src="../assets/img/suspend/collect_slash.svg" svg-inline v-else />
55
+ </div>
56
+ <!-- 稍后在看 -->
57
+ <div v-if="btnConfig.showLaterOn" class="u-icon-d" @click="laterOn">
58
+ <img class="u-icon" src="../assets/img/suspend/later-on.svg" svg-inline />
59
+ </div>
60
+
61
+ </div>
62
+ <div class="m-more" v-if="btnConfig.showMore" @click="setMore">
63
+ <img class="u-icon" src="../assets/img/suspend/more.svg" svg-inline /> 更多
64
+ </div>
65
+ </div>
66
+ <!-- 抽屉弹出层,支持默认样式和自定义插槽样式 -->
67
+ <el-drawer :title="drawerConfig.drawerTitle" :visible.sync="drawer" :direction="drawerConfig.direction"
68
+ :with-header="false" custom-class="u-drawer" :modal-append-to-body="false" append-to-body class="p-drawer">
69
+ <div class="p-drawer-box" v-show="areaKey === 'home'">
70
+ <div class="u-drawer-box">
71
+ <div class="u-item top" v-for="item in drawerFiltration(drawerType.one)" :key="item.type"
72
+ @click="clickDrawer(item)">
73
+ <div class="u-icon" v-if="item.icon || item.icon_slash">
74
+ <img :src="item.type == 'pin' ? fixIsActive ? item.icon_slash : item.icon : item.icon"
75
+ svg-inline />
76
+ </div>
77
+ <div class="u-self" v-if="item.isSlot">
78
+ <!-- 三个圆堆叠式展示 -->
79
+ <div class="u-circle-top">
80
+ <div v-if="fixList?.[0]">
81
+ <div class="u-text-r" v-if="fixList?.[0]?.type == 'text'">
82
+ {{ fixList?.[0]?.title.match(/[\u3400-\u9FFF\uF900-\uFAFF]/)?.[0] || '固' }}
83
+ </div>
84
+ <img :src="fixList?.[0]?.imgUrl" class="u-icon" v-else>
85
+ </div>
86
+ <img src="../assets/img/suspend/circle.svg" svg-inline v-else />
87
+
88
+ </div>
89
+ <div class="u-circle-bottom">
90
+ <div class="u-circle" v-for="(item, index) in 2" :key="item">
91
+ <div v-if="fixList?.[index + 1]">
92
+ <div class="u-text-r" v-if="fixList?.[index + 1]?.type == 'text'">
93
+ {{ fixList?.[index + 1].title.match(/[\u3400-\u9FFF\uF900-\uFAFF]/)?.[0] || '固' }}
94
+ </div>
95
+ <img :src="fixList?.[index + 1].imgUrl" class="u-icon" v-else>
96
+ </div>
97
+ <img src="../assets/img/suspend/circle.svg" svg-inline v-else />
98
+ </div>
99
+ </div>
100
+
101
+ </div>
102
+ <div class="u-text" :class="item.type">
103
+ {{ item.type == 'pin' ? fixIsActive ? item.text_slash : item.text : item.text }}
104
+ </div>
105
+ </div>
106
+ </div>
107
+ <div class="u-drawer-box">
108
+ <div class="u-item" v-for="item in drawerFiltration(drawerType.two)" :key="item.type"
109
+ @click="clickDrawer(item)">
110
+ <div class="u-icon" v-if="item.icon">
111
+ <img :src="item.icon" svg-inline />
112
+ </div>
113
+ <div class="u-text" :class="item.type">
114
+ {{ item.text }}
115
+ </div>
116
+ </div>
117
+ </div>
118
+ <div class="u-drawer-box">
119
+ <div class="u-item" :class="item.type" v-for="item in drawerFiltration(drawerType.three)"
120
+ :key="item.type" @click="clickDrawer(item)">
121
+ <div class="u-author" v-if="item.isSlot">
122
+ <div class="u-avatar">
123
+ <img :src="drawerConfig.author.avatar">
124
+ <!-- <slot name="avatar"></slot> -->
125
+ </div>
126
+ <div class="u-author-name">
127
+ <!-- <slot name="author"></slot> -->
128
+ {{ drawerConfig.author.name }}
129
+ </div>
130
+
131
+ </div>
132
+ <div class="u-text" v-if="!item.isSlot">
133
+ {{ item.text }}
134
+ </div>
135
+ </div>
136
+ </div>
137
+ </div>
138
+ <!-- 收藏区域 、订阅区域 -->
139
+ <div class="p-drawer-collect" v-show="areaKey === 'collect' || areaKey === 'rss'">
140
+ <div class="u-collect-icon">
141
+ <img src="../assets/img/suspend/collect_touchbar_100.svg" svg-inline
142
+ v-if="areaKey === 'collect' && !isCollect" />
143
+ <img src="../assets/img/suspend/collect_slash_touchbar_100.svg" svg-inline
144
+ v-if="areaKey === 'collect' && isCollect" />
145
+ <img src="../assets/img/suspend/rss_touchbar_100.svg" svg-inline
146
+ v-if="areaKey === 'rss' && !isSubscribe" />
147
+ <img src="../assets/img/suspend/report_100.svg" svg-inline
148
+ v-if="areaKey === 'rss' && isSubscribe" />
149
+ <div class="u-text"
150
+ v-if="(areaKey === 'collect' && !isCollect) || (areaKey === 'rss' && !isSubscribe)">
151
+ {{ areaKey === 'collect' ? '收藏' : '订阅' }}作品
152
+ </div>
153
+ </div>
154
+ <div class="u-collect-tips" v-if="areaKey === 'collect'">
155
+ {{ isCollect ? '你已经收藏该作品' : '喜欢程度不够?可以试试添加到稍后再看' }}
156
+ </div>
157
+ <div class="u-collect-tips" v-if="areaKey === 'rss'">
158
+ {{ isSubscribe ? '你已经订阅该作品' : '喜欢程度不够?可以试试添加到稍后再看' }}
159
+ </div>
160
+ <div class="u-btn-box">
161
+ <div class="u-btn collect" @click="collectOrSubscribe">
162
+ {{ areaKey === 'collect' ? isCollect ? '取消收藏' : '收藏' : isSubscribe ? '取消订阅' : '订阅' }}作品
163
+ </div>
164
+ <div class="u-btn" @click="laterOn">添加到稍后再看</div>
165
+ </div>
166
+ </div>
167
+ <!-- 固定配置相关页面 -->
168
+ <div class="p-drawer-fix" v-show="areaKey === 'pin' || areaKey === 'fix'">
169
+ <!-- 固定,取消固定,超量 -->
170
+ <div class="u-collect-icon" v-if="!fixIsEdit">
171
+ <img src="../assets/img/suspend/pin_touchbar_100.svg" svg-inline
172
+ v-if="!fixIsActive && !fixIsFull" />
173
+ <img src="../assets/img/suspend/pin_slash_touchbar.svg" svg-inline
174
+ v-if="fixIsActive && !fixIsFull" />
175
+ <img src="../assets/img/suspend/report_100.svg" svg-inline v-if="fixIsFull" />
176
+ <div class="u-text">{{ fixIsActive ? '取消固定' : '固定内容' }}</div>
177
+ </div>
178
+ <div class="u-collect-tips" v-if="!fixIsActive && !fixIsEdit">
179
+ 你可以随时在其他页面查看固定的内容
180
+ </div>
181
+ <div class="u-edit-title" v-if="fixIsEdit">固定内容</div>
182
+ <div class="u-pin-box">
183
+ <div class="u-item" v-if="!fixIsEdit">
184
+ <div class="u-text-r" v-if="fixPageConfig.type == 'text'">
185
+ {{ fixPageConfig.title.match(/[\u3400-\u9FFF\uF900-\uFAFF]/)?.[0] || '固' }}
186
+ </div>
187
+ <img :src="fixPageConfig.imgUrl" class="u-icon" v-else>
188
+ <div class="u-text">{{ fixPageConfig.title }}</div>
189
+ </div>
190
+ <!-- 只在编辑界面显示 -->
191
+ <div class="u-item" v-for="(item, index) in fixIsEdit ? fixList : []" :key="'fix' + index">
192
+ <div class="u-text-r" v-if="item.type == 'text'">
193
+ {{ item.title.match(/[\u3400-\u9FFF\uF900-\uFAFF]/)?.[0] || '固' }}
194
+ </div>
195
+ <img src="https://cdn.jx3box.com/upload/avatar/2024/3/20/8_7694562.png" class="u-icon" v-else>
196
+ <div class="u-text">{{ item.title }}</div>
197
+ <div class="u-slash" v-if="fixIsEdit" @click="cancelFix(item)">
198
+ <img src="../assets/img/suspend/pin_slash_touchbar_24.svg" svg-inline />
199
+ </div>
200
+ </div>
201
+ <!-- 不足三个时显示空位,只在编辑界面显示 -->
202
+ <div class="u-item" v-for="(item, index) in fixIsEdit ? (3 - fixList.length) : 0"
203
+ :key="'fix_no' + index">
204
+ <img src="../assets/img/suspend/circle.svg" svg-inline class="u-icon">
205
+ </div>
206
+ </div>
207
+ <div class="u-btn-box" v-if="!fixIsEdit">
208
+ <div class="u-btn collect" @click="fixClick">确定</div>
209
+ <!-- <div class="u-btn">编辑固定内容</div> -->
210
+ </div>
211
+ <div class="u-collect-tips" v-if="fixIsActive && !fixIsEdit">
212
+ 你可以在原页面再次将其固定
213
+ </div>
214
+ <div class="u-collect-tips edit" v-if="fixIsEdit">
215
+ 在支持固定的页面可以按
216
+ <img src="../assets/img/suspend/pin_touchbar_24.svg" svg-inline class="u-icon" />
217
+ 将页面固定
218
+ </div>
219
+ </div>
220
+
221
+ </el-drawer>
222
+ </div>
223
+ </template>
224
+
225
+ <script>
226
+ import {
227
+ subscribeAuthor,
228
+ unsubscribeAuthor,
229
+ subscribePost,
230
+ unsubscribePost,
231
+ subscribeArticle,
232
+ unsubscribeArticle,
233
+ subscribeWiki,
234
+ unsubscribeWiki,
235
+ getSubscribeStatus,
236
+ getSubscribePostStatus,
237
+ getSubscribeArticleStatus,
238
+ getSubscribeWikiStatus,
239
+ later,
240
+ setCollect,
241
+ getCollectList,
242
+ cancelCollect,
243
+ } from '../service/suspend'
244
+ export default {
245
+ components: {},
246
+ props: {
247
+ btnOptions: {
248
+ type: Object,
249
+ default: () => {
250
+ return {}
251
+ }
252
+ },
253
+ //通用弹出框配置
254
+ drawerOptions: {
255
+ type: Object,
256
+ default: () => {
257
+ return {}
258
+ },
259
+ },
260
+ //固定页缓存相关配置
261
+ fixPageOptions: {
262
+ type: Object,
263
+ default: () => {
264
+ return {}
265
+ }
266
+ },
267
+ },
268
+ data() {
269
+ return {
270
+ isDarkModeStatus: false,
271
+ drawer: false,
272
+ areaKey: 'home',
273
+ //弹窗type组合
274
+ drawerType: {
275
+ one: [
276
+ { type: 'search', text: '搜索内容', icon: require('../assets/img/suspend/search_touchbar.svg') },
277
+ { type: 'pin', text: '固定本页', icon: require('../assets/img/suspend/pin_touchbar.svg'), text_slash: '取消固定', icon_slash: require('../assets/img/suspend/pin_slash_touchbar_40.svg') },
278
+ { type: 'fix', text: '查看固定', icon: null, isSlot: true },
279
+ ],
280
+ two: [
281
+ { type: 'collect', text: '收藏作品', icon: require('../assets/img/suspend/collect_touchbar.svg') },
282
+ { type: 'rss', text: '订阅作品', icon: require('../assets/img/suspend/rss_touchbar.svg') },
283
+ { type: 'laterOn', text: '稍后再看', icon: require('../assets/img/suspend/lafter_touchbar.svg') },
284
+ ],
285
+ three: [
286
+ { type: 'user', text: '作者', isSlot: true, },
287
+ { type: 'report', text: '举报' },
288
+ ]
289
+ },
290
+ fixList: [],
291
+ fixIsEdit: false, //固定页是否编辑状态
292
+ //是否已收藏
293
+ isCollect: false,
294
+ collectInfo: {},
295
+ //是否已订阅
296
+ isSubscribe: false,
297
+ subscribeInfo: {},
298
+ };
299
+ },
300
+ computed: {
301
+ btnConfig() {
302
+ const defaultConfig = {
303
+ showHome: false, //是否显示home区域,和Icon区域二选一
304
+ showIcon: true, //是否显示icon区域,此处为false后,则下列配置无效
305
+ showSearch: true, //是否显示搜索图标
306
+ showFixed: true, //是否显示固定图标
307
+ showCollect: true, //是否显示收藏图标
308
+ showLaterOn: true, //是否显示稍后再看图标
309
+ showMore: true, //是否显示更多
310
+ }
311
+ return Object.assign({}, defaultConfig, this.btnOptions);
312
+ },
313
+ drawerConfig() {
314
+ const defaultConfig = {
315
+ hideType: ['report'], //需要隐藏的type,如['search','pin']
316
+ direction: 'btt', //弹出框方向,btt、ttb、rtl、ltr
317
+ drawerTitle: '',//弹出框标题
318
+ author: {
319
+ name: '', //作者名称
320
+ avatar: '', //作者头像
321
+ author_id: '', //作者id
322
+ },
323
+ subscribeType: '', //订阅类型,用于区分调用百科、文章、作者、帖子等订阅接口,
324
+ postType: '',//订阅、收藏接口的type,如'face','bps','article'等
325
+ id: '', //页面数据ID,用于收藏订阅操作
326
+ title: document.title || '', //默认固定标题,默认取页面标题
327
+ url: window.location.href, //默认取浏览器地址
328
+ laterOn: {
329
+ author_id: 0,
330
+ content_meta_id: 0
331
+ }
332
+ }
333
+ return Object.assign({}, defaultConfig, this.drawerOptions);
334
+ },
335
+ fixPageConfig() {
336
+ const defaultConfig = {
337
+ key: 'jx3box-common-fixed', //默认本地缓存Key
338
+ type: 'text', //默认固定类型,text、img
339
+ imgUrl: '', //type是img时需传入图片url用作显示
340
+ title: document.title || '', //默认固定标题,默认取页面标题
341
+ url: window.location.href, //默认取浏览器地址
342
+ }
343
+ return Object.assign({}, defaultConfig, this.fixPageOptions);
344
+ },
345
+ //通过drawerConfig判断是否显示弹窗
346
+ drawerIsShow() {
347
+ return Object.keys(this.drawerConfig).length > 0;
348
+ },
349
+ //通过drawerConfig判断是否显示作者信息
350
+ drawerIsAuthor() {
351
+ return Object.keys(this.drawerConfig.author).length > 0;
352
+ },
353
+ // 通过fixList判断是否已满
354
+ fixIsFull() {
355
+ return this.fixList.length >= 3;
356
+ },
357
+ // 通过fixList判断当前界面是否已经存在固定列表内
358
+ fixIsActive() {
359
+ return this.fixList.some(item => item.url === this.fixPageConfig.url);
360
+ },
361
+ },
362
+ created() {
363
+ this.isDarkModeFun();
364
+ this.fixList = JSON.parse(localStorage.getItem(this.fixPageConfig.key)) || [];
365
+ this.getCollectInfo();
366
+ this.getSubscribeInfo();
367
+ },
368
+ methods: {
369
+ isDarkModeFun() {
370
+ // 使用 window.matchMedia 检查系统是否启用了暗色模式
371
+ const mediaQueryList = window.matchMedia('(prefers-color-scheme: dark)');
372
+ this.isDarkModeStatus = mediaQueryList.matches;
373
+ },
374
+ //搜索按钮点击事件
375
+ search() {
376
+ this.$emit('search');
377
+ },
378
+ //打开更多弹窗,父级界面如需在界面其他操作后打开,可通过ref调用此方法
379
+ // 例如:this.$refs.suspendCommon.setMore()
380
+ setMore() {
381
+ this.drawer = true;
382
+ this.areaKey = 'home'
383
+ },
384
+ // 筛选弹窗type,过滤掉需隐藏的type
385
+ drawerFiltration(arr) {
386
+ if (this.drawerConfig.hideType.length > 0) {
387
+ return arr.filter(item => !this.drawerConfig.hideType.includes(item.type));
388
+ }
389
+ return arr;
390
+ },
391
+ /**
392
+ * @description: 弹出层按钮的点击事件通过emit传递给父组件处理
393
+ * @param {*} item 按钮的type和text
394
+ * @param {type} 1 代表从默认图标的点击事件,需要打开弹窗
395
+ * @return {*}
396
+ * 组件可处理事件交由组件处理,但点击事件依旧抛出,便于特殊情况处理
397
+ * */
398
+ clickDrawer(item, type) {
399
+ if (type == 1) this.drawer = true;
400
+ // 支持切换界面的 type
401
+ let switchType = ['collect', 'rss', 'pin', 'fix'];
402
+ if (switchType.includes(item.type)) {
403
+ this.areaKey = item.type;
404
+ }
405
+ // 如果点击的是search
406
+ if (item.type === 'search') {
407
+ this.search();
408
+ }
409
+ //查看固定页转到编辑状态
410
+ if (item.type === 'fix') {
411
+ this.fixIsEdit = true;
412
+ } else {
413
+ this.fixIsEdit = false;
414
+ }
415
+ //稍后在看处理
416
+ if (item.type === 'laterOn') this.laterOn()
417
+ this.$emit('clickBtn', { type: item.type, text: item.text });
418
+ },
419
+ /**
420
+ * @description: 固定页的确认点击事件,操作结束后areaKey转到home界面
421
+ * @return {*}
422
+ */
423
+ fixClick() {
424
+ // 判断是否已满,已满则不进行操作
425
+ if (this.fixIsFull) return;
426
+ // 判断是否已经存在,存在则执行删除操作
427
+ if (this.fixIsActive) {
428
+ this.fixList = this.fixList.filter(item => item.url !== this.fixPageConfig.url);
429
+ localStorage.setItem(this.fixPageConfig.key, JSON.stringify(this.fixList));
430
+ } else {
431
+ let json = {
432
+ type: this.fixPageConfig.type,
433
+ title: this.fixPageConfig.title,
434
+ url: this.fixPageConfig.url,
435
+ imgUrl: this.fixPageConfig.imgUrl,
436
+ }
437
+ this.fixList.push(json);
438
+ localStorage.setItem(this.fixPageConfig.key, JSON.stringify(this.fixList));
439
+ }
440
+ this.areaKey = 'home';
441
+ this.$emit('fixPage');
442
+ },
443
+
444
+ /**
445
+ * @description: 查看固定页取消固定
446
+ * @param {*} value
447
+ * @return {*}
448
+ * */
449
+ cancelFix(value) {
450
+ this.fixList = this.fixList.filter(item => item.url !== value.url);
451
+ localStorage.setItem(this.fixPageConfig.key, JSON.stringify(this.fixList));
452
+ this.areaKey = 'home';
453
+ this.$emit('fixCancelIndividually');
454
+ },
455
+ /**
456
+ * @description: 收藏或订阅,操作完成后areaKey转到home界面
457
+ * @return {*}
458
+ */
459
+ collectOrSubscribe() {
460
+ this.areaKey == 'collect' ? this.collect() : this.subscribe()
461
+ },
462
+
463
+ /**
464
+ * @description: 收藏或取消操作,操作完成后更新界面,无需跳转
465
+ */
466
+ collect() {
467
+ let drawerConfig = this.drawerConfig
468
+ if (this.isCollect) {
469
+ //取消,需传入收藏id
470
+ cancelCollect(this.collectInfo.id,).then(res => {
471
+ this.isCollect = false;
472
+ this.collectInfo = {}
473
+ })
474
+ } else {
475
+ setCollect(drawerConfig.id, drawerConfig.postType, drawerConfig.title).then(res => {
476
+ this.isCollect = true;
477
+ this.collectInfo = res.data?.data
478
+ })
479
+ }
480
+ this.$emit('collect', { isCollect: this.isCollect });
481
+ },
482
+ //获取收藏信息
483
+ getCollectInfo() {
484
+ getCollectList(this.drawerConfig.id, this.drawerConfig.postType).then(res => {
485
+ this.collectInfo = res.data.data
486
+ this.isCollect = this.collectInfo?.id > 0
487
+ })
488
+ },
489
+ /**
490
+ * @description: 订阅或取消操作,操作完成后更新界面,无需跳转,需根据subscribeType判断接口调用
491
+ */
492
+ subscribe() {
493
+ let drawerConfig = this.drawerConfig
494
+ // 作者相关接口
495
+ if (drawerConfig.subscribeType === 'author') {
496
+ if (this.isSubscribe) {
497
+ unsubscribeAuthor(drawerConfig.author.author_id).then(res => {
498
+ this.isSubscribe = false;
499
+ this.subscribeInfo = {}
500
+ })
501
+ } else {
502
+ subscribeAuthor(drawerConfig.author.author_id, { title: drawerConfig.title }).then(res => {
503
+ this.isSubscribe = true;
504
+ this.subscribeInfo = res.data?.data
505
+ })
506
+ }
507
+ }
508
+ //帖子
509
+ if (drawerConfig.subscribeType === 'community') {
510
+ if (this.isSubscribe) {
511
+ unsubscribePost(drawerConfig.id).then(res => {
512
+ this.isSubscribe = false;
513
+ this.subscribeInfo = {}
514
+ })
515
+ } else {
516
+ subscribePost(drawerConfig.id, { title: drawerConfig.title }).then(res => {
517
+ this.isSubscribe = true;
518
+ this.subscribeInfo = res.data?.data
519
+ })
520
+ }
521
+ }
522
+ //文章
523
+ if (drawerConfig.subscribeType === 'posts') {
524
+ if (this.isSubscribe) {
525
+ unsubscribeArticle(drawerConfig.postType, drawerConfig.id).then(res => {
526
+ this.isSubscribe = false;
527
+ this.subscribeInfo = {}
528
+ })
529
+ } else {
530
+ subscribeArticle(drawerConfig.postType, drawerConfig.id, { title: drawerConfig.title }).then(res => {
531
+ this.isSubscribe = true;
532
+ this.subscribeInfo = res.data?.data
533
+ })
534
+ }
535
+ }
536
+ //百科
537
+ if (drawerConfig.subscribeType === 'wiki') {
538
+ if (this.isSubscribe) {
539
+ unsubscribeWiki(drawerConfig.postType, drawerConfig.id).then(res => {
540
+ this.isSubscribe = false;
541
+ this.subscribeInfo = {}
542
+ })
543
+ } else {
544
+ subscribeWiki(drawerConfig.postType, drawerConfig.id, { title: drawerConfig.title }).then(res => {
545
+ this.isSubscribe = true;
546
+ this.subscribeInfo = res.data?.data
547
+ })
548
+ }
549
+ }
550
+ this.$emit('subscribe', { isSubscribe: this.isSubscribe });
551
+ },
552
+ /**
553
+ * 订阅状态查询
554
+ */
555
+ getSubscribeInfo() {
556
+ let drawerConfig = this.drawerConfig
557
+ // 作者相关接口
558
+ if (drawerConfig.subscribeType === 'author') {
559
+ getAuthorSubscribe(drawerConfig.author.author_id).then(res => {
560
+ this.isSubscribe = res.data.data?.subscribed
561
+ this.subscribeInfo = res.data.data
562
+ })
563
+ }
564
+ //帖子
565
+ if (drawerConfig.subscribeType === 'community') {
566
+ getSubscribePostStatus(drawerConfig.id).then(res => {
567
+
568
+ this.isSubscribe = res.data.data?.subscribed
569
+ this.subscribeInfo = res.data.data
570
+ })
571
+ }
572
+ //文章
573
+ if (drawerConfig.subscribeType === 'posts') {
574
+ getSubscribeArticleStatus(drawerConfig.postType, drawerConfig.id).then(res => {
575
+ this.isSubscribe = res.data.data?.subscribed
576
+ this.subscribeInfo = res.data.data
577
+ })
578
+ }
579
+ //百科
580
+ if (drawerConfig.subscribeType === 'wiki') {
581
+ getSubscribeWikiStatus(drawerConfig.postType, drawerConfig.id).then(res => {
582
+
583
+ this.isSubscribe = res.data.data?.subscribed
584
+ this.subscribeInfo = res.data.data
585
+
586
+ })
587
+ }
588
+ },
589
+ /**
590
+ * @description: 稍后再看,操作完成后areaKey转到home界面
591
+ * @return {*}
592
+ */
593
+ laterOn() {
594
+ let drawerConfig = this.drawerConfig
595
+ let params = {
596
+ author_id: parseInt(drawerConfig.laterOn.author_id),
597
+ banner: "",
598
+ category: drawerConfig.postType,
599
+ content_meta_id: parseInt(drawerConfig.laterOn.content_meta_id),
600
+ link: drawerConfig.url,
601
+ title: drawerConfig.title
602
+ }
603
+ later(params).then(res => {
604
+ console.log(res)
605
+ this.areaKey = 'home';
606
+ this.$emit('laterOn');
607
+ })
608
+
609
+ },
610
+ },
611
+ };
612
+ </script>
613
+
614
+ <style lang="less">
615
+ @bgColor: #282828;
616
+ @color: #FEDAA3;
617
+ @color2: #24292E;
618
+
619
+ html {
620
+ font-size: clamp(16px, calc(100vw / 414 * 16), 36px);
621
+ }
622
+
623
+ .p-suspend {
624
+ .pf;
625
+ .z(1994);
626
+ bottom: 0;
627
+ margin: auto;
628
+
629
+ .w(23.438rem);
630
+ padding: 1.25rem 0px 1.5rem 0px;
631
+ border-radius: 1.25rem 1.25rem 0 0;
632
+ background: @bgColor;
633
+ color: @color;
634
+ .fz(1rem, 1.5rem);
635
+ .bold(700);
636
+
637
+ .m-home-box,
638
+ .m-icon-box {
639
+ .flex;
640
+ .flex(o);
641
+ }
642
+
643
+ .m-btn-box {
644
+ .flex;
645
+ align-items: center;
646
+ justify-content: space-between;
647
+ flex: auto;
648
+ // gap: 3rem;
649
+ padding: 0 1.25rem;
650
+
651
+ .u-icon-d {
652
+ .flex;
653
+ .flex(o);
654
+ .size(1.5rem);
655
+
656
+ .u-icon {
657
+ &.active {
658
+ fill: #FEDAA3;
659
+ stroke: #FEDAA3
660
+ }
661
+ }
662
+ }
663
+ }
664
+
665
+ .m-more {
666
+ .w(7.5rem);
667
+ .flex;
668
+ .flex(o);
669
+ flex-shrink: 0;
670
+ border-left: 0.5px solid rgba(254, 218, 163, 0.2);
671
+ gap: 0.5rem
672
+ }
673
+ }
674
+
675
+ .p-drawer {
676
+ .size(100%);
677
+ .lt(0);
678
+
679
+ .u-drawer {
680
+ border-radius: 1.25rem 1.25rem 0 0;
681
+ position: fixed !important;
682
+ bottom: 0;
683
+ margin: auto;
684
+ outline: none;
685
+ -webkit-tap-highlight-color: transparent;
686
+ user-select: none;
687
+ -webkit-touch-callout: none;
688
+ .w(23.438rem);
689
+ .h(auto) !important;
690
+ padding: 1.25rem 0.75rem 2.5rem 0.75rem;
691
+ background: @bgColor;
692
+
693
+ // .el-drawer__body {}
694
+
695
+ .p-drawer-box {
696
+ .flex;
697
+ flex-direction: column;
698
+ gap: 0.75rem;
699
+ }
700
+
701
+ .u-drawer-box {
702
+ .flex;
703
+ .w(100%);
704
+ align-items: center;
705
+ justify-content: space-between;
706
+ gap: 0.75rem;
707
+
708
+ .u-item {
709
+ border-radius: 12px;
710
+ background: rgba(255, 255, 255, 0.05);
711
+ .flex;
712
+ .flex(o);
713
+ flex-direction: column;
714
+ gap: 0.75rem;
715
+ flex: auto;
716
+ padding: 0.75rem 0;
717
+ box-sizing: border-box;
718
+
719
+ &.top {
720
+ .h(6.875rem);
721
+ }
722
+
723
+
724
+ &.report {
725
+ max-width: 50%;
726
+ }
727
+
728
+ .u-icon {
729
+ .flex;
730
+ .flex(o);
731
+ }
732
+
733
+ .u-self {
734
+ .h(2.5rem);
735
+
736
+ .flex;
737
+ flex-direction: column;
738
+ .flex(o);
739
+
740
+ img {
741
+ .size(1.5rem);
742
+ .r(50%);
743
+ }
744
+
745
+ .u-circle-top {
746
+ .pr;
747
+ bottom: -0.75rem;
748
+ }
749
+
750
+ .u-circle-bottom {
751
+ .flex;
752
+ gap: 0;
753
+ }
754
+
755
+ .u-text-r {
756
+ .size(1.5rem);
757
+ .r(50%);
758
+ background-color: #D9D9D9;
759
+ .flex;
760
+ .flex(o);
761
+ }
762
+ }
763
+
764
+ .u-text {
765
+ color: #ACAEAF;
766
+ .fz(0.875rem, 1.25rem);
767
+ .bold(700);
768
+
769
+ &.search,
770
+ &.fix {
771
+ color: #FEDAA3;
772
+ }
773
+
774
+ }
775
+
776
+ .u-author {
777
+ //作者名字最多显示8个中文字符,超出后,第八个中文字符用...代替
778
+
779
+ .fz(0.875rem, 1.25rem);
780
+ .bold(700);
781
+ .flex;
782
+ .flex(o);
783
+ gap: 0.2rem;
784
+ padding: 0 0.75rem;
785
+ box-sizing: border-box;
786
+ color: #ACAEAF;
787
+ .w(100%);
788
+
789
+ .u-avatar {
790
+ .size(1.25rem);
791
+ overflow: hidden;
792
+ .r(50%);
793
+ flex-shrink: 0;
794
+ }
795
+
796
+ .u-author-name {
797
+ flex: auto;
798
+ overflow: hidden;
799
+ text-overflow: ellipsis;
800
+ white-space: nowrap;
801
+ min-width: 0;
802
+ }
803
+ }
804
+ }
805
+ }
806
+
807
+ .p-drawer-fix,
808
+ .p-drawer-collect {
809
+ color: rgba(255, 255, 255, 0.40);
810
+
811
+ .u-collect-icon {
812
+ .flex;
813
+ .flex(o);
814
+ flex-direction: column;
815
+ .w(100%);
816
+ .mb(1.25rem);
817
+
818
+ .u-text {
819
+ .fz(0.875rem, 1.25rem);
820
+ }
821
+ }
822
+
823
+ .u-collect-tips {
824
+ .fz(0.75rem, 1rem);
825
+ text-align: center;
826
+
827
+ .mb(1.25rem);
828
+
829
+ &.edit {
830
+ .flex;
831
+ align-items: center;
832
+ .fz(0.875rem, 1.25rem);
833
+ }
834
+ }
835
+
836
+ .u-btn-box {
837
+ .flex;
838
+ .flex(o);
839
+ gap: 0.75rem;
840
+ .mb(1.25rem);
841
+
842
+ .u-btn {
843
+ .flex;
844
+ .flex(o);
845
+ .fz(1rem, 1.5rem);
846
+ .bold(700);
847
+ border-radius: 0.75rem;
848
+ background: rgba(255, 255, 255, 0.10);
849
+ padding: 0.75rem 1rem;
850
+ color: rgba(255, 255, 255, 0.40);
851
+ flex: auto;
852
+
853
+ &.collect {
854
+ background-color: @color;
855
+ color: @color2;
856
+ }
857
+ }
858
+ }
859
+ }
860
+
861
+ .p-drawer-fix {
862
+ .u-edit-title {
863
+ .mb(1.25rem);
864
+ color: rgba(255, 255, 255, 0.60);
865
+ .fz(0.875rem, 1.25rem);
866
+ .bold(700);
867
+ }
868
+
869
+ .u-pin-box {
870
+ .mb(1.25rem);
871
+ .flex;
872
+ flex-direction: column;
873
+ gap: 0.75rem;
874
+
875
+ .u-item {
876
+ .flex;
877
+ align-items: center;
878
+ gap: 0.75rem;
879
+ padding: 0.5rem 1rem;
880
+ align-self: stretch;
881
+ .r(0.5rem);
882
+ background: rgba(255, 255, 255, 0.10);
883
+
884
+ .u-text-r,
885
+ .u-icon {
886
+ .size(1.875rem);
887
+ .r(50%);
888
+ flex-shrink: 0;
889
+ }
890
+
891
+ .u-text-r {
892
+ .flex;
893
+ .flex(o);
894
+ background-color: #D9D9D9;
895
+ color: #000;
896
+ }
897
+
898
+ .u-text {
899
+ flex: auto;
900
+ overflow: hidden;
901
+ text-overflow: ellipsis;
902
+ white-space: nowrap;
903
+ min-width: 0;
904
+ color: #fff;
905
+ }
906
+
907
+ .u-slash {
908
+ .flex;
909
+ .flex(o);
910
+ .size(1.875rem);
911
+ flex-shrink: 0;
912
+ }
913
+ }
914
+ }
915
+ }
916
+ }
917
+
918
+ }
919
+ </style>