From ae74af59fc2db7c7340d911cbe1a5d818ddb3a7e Mon Sep 17 00:00:00 2001 From: dhb52 Date: Sat, 15 Apr 2023 16:54:36 +0800 Subject: [PATCH 1/9] =?UTF-8?q?fix:=20=E5=A2=9E=E5=8A=A0=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/mp/material/components/UploadFile.vue | 5 +++-- src/views/mp/material/components/UploadVideo.vue | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/views/mp/material/components/UploadFile.vue b/src/views/mp/material/components/UploadFile.vue index 3ab62224..93e6dd41 100644 --- a/src/views/mp/material/components/UploadFile.vue +++ b/src/views/mp/material/components/UploadFile.vue @@ -7,6 +7,7 @@ :file-list="fileList" :data="uploadData" :on-progress="() => (uploading = true)" + :on-error="(err: Error) => message.error(`上传失败: ${err.message}`)" :before-upload="beforeUpload" :on-success="handleUploadSuccess" > @@ -33,7 +34,7 @@ import { const message = useMessage() -const props = defineProps<{ type: boolean }>() +const props = defineProps<{ type: MaterialType }>() const fileList = ref([]) const emit = defineEmits<{ @@ -47,7 +48,7 @@ const uploadData: UploadData = reactive({ }) const uploading = ref(false) -const beforeUpload = props.type == MaterialType.Image ? beforeImageUpload : beforeVoiceUpload +const beforeUpload = props.type === MaterialType.Image ? beforeImageUpload : beforeVoiceUpload const handleUploadSuccess: UploadProps['onSuccess'] = (res: any) => { if (res.code !== 0) { diff --git a/src/views/mp/material/components/UploadVideo.vue b/src/views/mp/material/components/UploadVideo.vue index 816711d1..1221273b 100644 --- a/src/views/mp/material/components/UploadVideo.vue +++ b/src/views/mp/material/components/UploadVideo.vue @@ -9,6 +9,7 @@ :data="uploadData" :before-upload="beforeVideoUpload" :on-progress="() => (uploading = true)" + :on-error="(err: Error) => message.error(`上传失败: ${err.message}`)" :on-success="handleUploadSuccess" ref="uploadVideoRef" :auto-upload="false" From b5fb700e4e2488d1117748ccadec6ba00426c279 Mon Sep 17 00:00:00 2001 From: dhb52 Date: Sun, 16 Apr 2023 22:30:00 +0800 Subject: [PATCH 2/9] =?UTF-8?q?refactor:=20mp/draft=E6=8B=86=E5=88=86?= =?UTF-8?q?=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/mp/draft/components/CoverSelect.vue | 183 +++++ src/views/mp/draft/components/DraftTable.vue | 87 +++ src/views/mp/draft/components/NewsForm.vue | 302 ++++++++ src/views/mp/draft/components/index.ts | 7 + src/views/mp/draft/components/types.ts | 40 + src/views/mp/draft/index.vue | 719 +++--------------- 6 files changed, 704 insertions(+), 634 deletions(-) create mode 100644 src/views/mp/draft/components/CoverSelect.vue create mode 100644 src/views/mp/draft/components/DraftTable.vue create mode 100644 src/views/mp/draft/components/NewsForm.vue create mode 100644 src/views/mp/draft/components/index.ts create mode 100644 src/views/mp/draft/components/types.ts diff --git a/src/views/mp/draft/components/CoverSelect.vue b/src/views/mp/draft/components/CoverSelect.vue new file mode 100644 index 00000000..2c9c64b1 --- /dev/null +++ b/src/views/mp/draft/components/CoverSelect.vue @@ -0,0 +1,183 @@ + + + + + diff --git a/src/views/mp/draft/components/DraftTable.vue b/src/views/mp/draft/components/DraftTable.vue new file mode 100644 index 00000000..63cee31f --- /dev/null +++ b/src/views/mp/draft/components/DraftTable.vue @@ -0,0 +1,87 @@ + + + + + diff --git a/src/views/mp/draft/components/NewsForm.vue b/src/views/mp/draft/components/NewsForm.vue new file mode 100644 index 00000000..a2b88a5b --- /dev/null +++ b/src/views/mp/draft/components/NewsForm.vue @@ -0,0 +1,302 @@ + + + + + diff --git a/src/views/mp/draft/components/index.ts b/src/views/mp/draft/components/index.ts new file mode 100644 index 00000000..51e843d3 --- /dev/null +++ b/src/views/mp/draft/components/index.ts @@ -0,0 +1,7 @@ +import type { Article, NewsItem, NewsItemList } from './types' +import { createEmptyNewsItem } from './types' +import DraftTable from './DraftTable.vue' +import NewsForm from './NewsForm.vue' + +export { DraftTable, NewsForm, createEmptyNewsItem } +export type { Article, NewsItem, NewsItemList } diff --git a/src/views/mp/draft/components/types.ts b/src/views/mp/draft/components/types.ts new file mode 100644 index 00000000..a8cf00c3 --- /dev/null +++ b/src/views/mp/draft/components/types.ts @@ -0,0 +1,40 @@ +interface NewsItem { + title: string + thumbMediaId: string + author: string + digest: string + showCoverPic: string + content: string + contentSourceUrl: string + needOpenComment: string + onlyFansCanComment: string + thumbUrl: string +} + +interface NewsItemList { + newsItem: NewsItem[] +} + +interface Article { + mediaId: string + content: NewsItemList + updateTime: number +} + +const createEmptyNewsItem = (): NewsItem => { + return { + title: '', + thumbMediaId: '', + author: '', + digest: '', + showCoverPic: '', + content: '', + contentSourceUrl: '', + needOpenComment: '', + onlyFansCanComment: '', + thumbUrl: '' + } +} + +export type { Article, NewsItem, NewsItemList } +export { createEmptyNewsItem } diff --git a/src/views/mp/draft/index.vue b/src/views/mp/draft/index.vue index cf0bb10d..9e188ec4 100644 --- a/src/views/mp/draft/index.vue +++ b/src/views/mp/draft/index.vue @@ -14,7 +14,13 @@ - + 新增 @@ -23,40 +29,13 @@ -
- -
+
-
- - - - -
-
-
-
- -
{{ news.title }}
-
-
- 下移 - 删除 - -
-
-
-
-
{{ news.title }}
-
- -
-
-
- 下移 - - 上移 - 删除 - -
-
-
- - - - - -
-
- -
- - - - - - - - - -

封面:

-
- - -
- - - 素材库选择 - - -
- - - -
-
- -

摘要:

- -
-
- - - - -
-
-
- -
-
+ + + + + + From 84dcac77b16ccb6ff8e9cec14ac077d0cc60fdb8 Mon Sep 17 00:00:00 2001 From: dhb52 Date: Sun, 16 Apr 2023 22:32:59 +0800 Subject: [PATCH 3/9] =?UTF-8?q?refactor:=20=E4=BA=8B=E4=BB=B6=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E5=91=BD=E5=90=8D=EF=BC=9AonXxx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mp/material/components/UploadFile.vue | 31 +++++++++++++------ .../mp/material/components/UploadVideo.vue | 22 +++++++------ src/views/mp/material/components/upload.ts | 1 - 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/src/views/mp/material/components/UploadFile.vue b/src/views/mp/material/components/UploadFile.vue index 93e6dd41..be7e323b 100644 --- a/src/views/mp/material/components/UploadFile.vue +++ b/src/views/mp/material/components/UploadFile.vue @@ -6,13 +6,13 @@ :limit="1" :file-list="fileList" :data="uploadData" - :on-progress="() => (uploading = true)" - :on-error="(err: Error) => message.error(`上传失败: ${err.message}`)" - :before-upload="beforeUpload" - :on-success="handleUploadSuccess" + :on-progress="(isUploading = true)" + :on-error="onUploadError" + :before-upload="onBeforeUpload" + :on-success="onUploadSuccess" > - - {{ uploading ? '正在上传' : '点击上传' }} + + {{ isUploading ? '正在上传' : '点击上传' }} + @@ -513,9 +294,9 @@ const deleteMaterial = () => { } .clearfix::after { - content: ''; display: table; clear: both; + content: ''; } div { @@ -523,116 +304,50 @@ div { } .weixin-hd { - color: #fff; - text-align: center; position: relative; bottom: 426px; - left: 0px; + left: 0; width: 300px; height: 64px; + color: #fff; + text-align: center; background: transparent url('./assets/menu_head.png') no-repeat 0 0; background-position: 0 0; background-size: 100%; } .weixin-title { - color: #fff; - font-size: 14px; - width: 100%; - text-align: center; position: absolute; top: 33px; - left: 0px; + left: 0; + width: 100%; + font-size: 14px; + color: #fff; + text-align: center; } .weixin-menu { - background: transparent url('./assets/menu_foot.png') no-repeat 0 0; padding-left: 43px; font-size: 12px; -} - -.menu_option { - width: 40% !important; + background: transparent url('./assets/menu_foot.png') no-repeat 0 0; } .public-account-management { - min-width: 1200px; - width: 1200px; + // width: 1200px; + // min-width: 1200px; margin: 0 auto; .left { - float: left; + position: relative; display: inline-block; + float: left; width: 350px; height: 715px; + padding: 518px 25px 88px; background: url('./assets/iphone_backImg.png') no-repeat; background-size: 100% auto; - padding: 518px 25px 88px; - position: relative; box-sizing: border-box; - /*第一级菜单*/ - .menu_main { - .menu_bottom { - position: relative; - float: left; - display: inline-block; - box-sizing: border-box; - width: 85.5px; - text-align: center; - border: 1px solid #ebedee; - background-color: #fff; - cursor: pointer; - - &.menu_addicon { - height: 46px; - line-height: 46px; - } - - .menu_item { - height: 44px; - line-height: 44px; - // text-align: center; - box-sizing: border-box; - width: 100%; - display: flex; - align-items: center; - justify-content: center; - - &.active { - border: 1px solid #2bb673; - } - } - - .menu_subItem { - height: 44px; - line-height: 44px; - text-align: center; - box-sizing: border-box; - - &.active { - border: 1px solid #2bb673; - } - } - } - - i { - color: #2bb673; - } - - /*第二级菜单*/ - .submenu { - position: absolute; - width: 85.5px; - bottom: 45px; - - .subtitle { - background-color: #fff; - box-sizing: border-box; - } - } - } - .save_div { margin-top: 15px; text-align: center; @@ -644,85 +359,29 @@ div { } } - /*右边菜单内容*/ + /* 右边菜单内容 */ .right { float: left; width: 63%; - background-color: #e8e7e7; padding: 20px; margin-left: 20px; - -webkit-box-sizing: border-box; + background-color: #e8e7e7; + box-sizing: border-box; box-sizing: border-box; - - .configure_page { - .delete_btn { - text-align: right; - margin-bottom: 15px; - } - - .menu_content { - margin-top: 20px; - } - - .configur_content { - margin-top: 20px; - background-color: #fff; - padding: 20px 10px; - border-radius: 5px; - } - - .blue { - color: #29b6f6; - margin-top: 10px; - } - - .applet { - margin-bottom: 20px; - - span { - width: 20%; - } - } - - .input_width { - width: 40%; - } - - .material { - .input_width { - width: 30%; - } - - .el-textarea { - width: 80%; - } - } - } - } - - .el-input { - width: 70%; - margin-right: 2%; } } From 39d8ecbfc7bf24124d22e22bcd71d449f2cb590a Mon Sep 17 00:00:00 2001 From: dhb52 Date: Tue, 18 Apr 2023 11:18:37 +0800 Subject: [PATCH 6/9] =?UTF-8?q?refactor:=20MP/wx-reply=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E6=8A=BD=E7=A6=BBuseUpload=E9=92=A9=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/mp/components/wx-reply/main.vue | 640 ++++++++++------------ src/views/mp/hooks/useUpload.ts | 50 ++ 2 files changed, 326 insertions(+), 364 deletions(-) create mode 100644 src/views/mp/hooks/useUpload.ts diff --git a/src/views/mp/components/wx-reply/main.vue b/src/views/mp/components/wx-reply/main.vue index 4768eb31..8e8b3eee 100644 --- a/src/views/mp/components/wx-reply/main.vue +++ b/src/views/mp/components/wx-reply/main.vue @@ -8,7 +8,7 @@ ④ 支持发送【视频】消息时,支持新建视频 --> From cddf1ee87894051a0fc20cf93049145cdfb2ba39 Mon Sep 17 00:00:00 2001 From: dhb52 Date: Tue, 18 Apr 2023 11:19:54 +0800 Subject: [PATCH 8/9] =?UTF-8?q?refactor:=20=E4=BD=BF=E7=94=A8useUpload?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/mp/material/components/upload.ts | 49 ++----------------- .../mp/menu/components/MenuPreviewer.vue | 2 +- 2 files changed, 6 insertions(+), 45 deletions(-) diff --git a/src/views/mp/material/components/upload.ts b/src/views/mp/material/components/upload.ts index ac6f3a1f..dc52a9eb 100644 --- a/src/views/mp/material/components/upload.ts +++ b/src/views/mp/material/components/upload.ts @@ -1,63 +1,24 @@ import type { UploadProps, UploadRawFile } from 'element-plus' import { getAccessToken } from '@/utils/auth' -const message = useMessage() // 消息 +import { MaterialType, useBeforeUpload } from '@/views/mp/hooks/useUpload' + const HEADERS = { Authorization: 'Bearer ' + getAccessToken() } // 请求头 const UPLOAD_URL = import.meta.env.VITE_BASE_URL + '/admin-api/mp/material/upload-permanent' // 上传地址 -enum MaterialType { - Image = 'image', - Voice = 'voice', - Video = 'video' -} - interface UploadData { type: MaterialType title: string introduction: string } -const beforeUpload = (rawFile: UploadRawFile, materialType: MaterialType): boolean => { - let allowTypes: string[] = [] - let maxSizeMB = 0 - let name = '' - switch (materialType) { - case MaterialType.Image: - allowTypes = ['image/jpeg', 'image/png', 'image/gif', 'image/bmp', 'image/jpg'] - maxSizeMB = 2 - name = '图片' - break - case MaterialType.Voice: - allowTypes = ['audio/mp3', 'audio/mpeg', 'audio/wma', 'audio/wav', 'audio/amr'] - maxSizeMB = 2 - name = '图片' - break - case MaterialType.Video: - allowTypes = ['video/mp4'] - maxSizeMB = 10 - name = '视频' - break - } - // 格式不正确 - if (!allowTypes.includes(rawFile.type)) { - message.error(`上传${name}格式不对!`) - return false - } - // 大小不正确 - if (rawFile.size / 1024 / 1024 > maxSizeMB) { - message.error(`上传${name}大小不能超过${maxSizeMB}M!`) - return false - } - return true -} - const beforeImageUpload: UploadProps['beforeUpload'] = (rawFile: UploadRawFile) => - beforeUpload(rawFile, MaterialType.Image) + useBeforeUpload(MaterialType.Image, 2)(rawFile) const beforeVoiceUpload: UploadProps['beforeUpload'] = (rawFile: UploadRawFile) => - beforeUpload(rawFile, MaterialType.Voice) + useBeforeUpload(MaterialType.Voice, 2)(rawFile) const beforeVideoUpload: UploadProps['beforeUpload'] = (rawFile: UploadRawFile) => - beforeUpload(rawFile, MaterialType.Video) + useBeforeUpload(MaterialType.Video, 10)(rawFile) export { HEADERS, diff --git a/src/views/mp/menu/components/MenuPreviewer.vue b/src/views/mp/menu/components/MenuPreviewer.vue index 9fb45008..aca1c2ae 100644 --- a/src/views/mp/menu/components/MenuPreviewer.vue +++ b/src/views/mp/menu/components/MenuPreviewer.vue @@ -14,7 +14,7 @@
- 发送(S) + 发送(S)
@@ -231,12 +231,8 @@ const sendMsg = async () => { list.value = [...list.value, ...[data]] scrollToBottom() - //ts检查的時候会判断这个组件可能是空的,所以需要进行断言。 - //避免 tab 的数据未清理 - const deleteObj = replySelectRef.value?.deleteObj - if (deleteObj) { - deleteObj() - } + // 发送后清空数据 + replySelectRef.value?.clear() } const loadingMore = () => { @@ -333,6 +329,7 @@ const scrollToBottom = () => { .send-but { float: right; - margin-top: 8px !important; + margin-top: 8px; + margin-bottom: 8px; } diff --git a/src/views/mp/components/wx-reply/components/TabImage.vue b/src/views/mp/components/wx-reply/components/TabImage.vue new file mode 100644 index 00000000..827ef11c --- /dev/null +++ b/src/views/mp/components/wx-reply/components/TabImage.vue @@ -0,0 +1,172 @@ + + + + + diff --git a/src/views/mp/components/wx-reply/components/TabMusic.vue b/src/views/mp/components/wx-reply/components/TabMusic.vue new file mode 100644 index 00000000..5a50cbf0 --- /dev/null +++ b/src/views/mp/components/wx-reply/components/TabMusic.vue @@ -0,0 +1,121 @@ + + + + + diff --git a/src/views/mp/components/wx-reply/components/TabNews.vue b/src/views/mp/components/wx-reply/components/TabNews.vue new file mode 100644 index 00000000..13ae9570 --- /dev/null +++ b/src/views/mp/components/wx-reply/components/TabNews.vue @@ -0,0 +1,78 @@ + + + + + diff --git a/src/views/mp/components/wx-reply/components/TabText.vue b/src/views/mp/components/wx-reply/components/TabText.vue new file mode 100644 index 00000000..f6981a73 --- /dev/null +++ b/src/views/mp/components/wx-reply/components/TabText.vue @@ -0,0 +1,29 @@ + + + + + diff --git a/src/views/mp/components/wx-reply/components/TabVideo.vue b/src/views/mp/components/wx-reply/components/TabVideo.vue new file mode 100644 index 00000000..c924bc2a --- /dev/null +++ b/src/views/mp/components/wx-reply/components/TabVideo.vue @@ -0,0 +1,132 @@ + + + + + diff --git a/src/views/mp/components/wx-reply/components/TabVoice.vue b/src/views/mp/components/wx-reply/components/TabVoice.vue new file mode 100644 index 00000000..7bcefced --- /dev/null +++ b/src/views/mp/components/wx-reply/components/TabVoice.vue @@ -0,0 +1,162 @@ + + + + + diff --git a/src/views/mp/components/wx-reply/components/types.ts b/src/views/mp/components/wx-reply/components/types.ts new file mode 100644 index 00000000..d5273334 --- /dev/null +++ b/src/views/mp/components/wx-reply/components/types.ts @@ -0,0 +1,25 @@ +type ReplyType = '' | 'news' | 'image' | 'voice' | 'video' | 'music' | 'text' + +interface ObjData { + accountId: number + type: ReplyType + name: string | null + content: string | null + mediaId: string | null + url: string | null + title: string | null + description: string | null + thumbMediaId: string | null + thumbMediaUrl: string | null + musicUrl: string | null + hqMusicUrl: string | null + introduction: string | null + articles: any[] +} + +enum NewsType { + Published = '1', + Draft = '2' +} + +export { ObjData, NewsType } diff --git a/src/views/mp/components/wx-reply/main.vue b/src/views/mp/components/wx-reply/main.vue index 8e8b3eee..da523b6c 100644 --- a/src/views/mp/components/wx-reply/main.vue +++ b/src/views/mp/components/wx-reply/main.vue @@ -8,519 +8,63 @@ ④ 支持发送【视频】消息时,支持新建视频 --> -