Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
abf9b50c
authored
Apr 15, 2023
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
REVIEW 素材管理的重构
parent
71fd9af2
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
21 additions
and
41 deletions
+21
-41
src/views/mp/components/img.png
+0
-0
src/views/mp/material/components/ImageTable.vue
+0
-0
src/views/mp/material/components/UploadFile.vue
+0
-3
src/views/mp/material/components/UploadVideo.vue
+0
-2
src/views/mp/material/components/VideoTable.vue
+0
-2
src/views/mp/material/components/VoiceTable.vue
+0
-2
src/views/mp/material/components/upload.ts
+7
-9
src/views/mp/material/index.vue
+14
-23
No files found.
src/views/mp/components/img.png
deleted
100644 → 0
View file @
71fd9af2
15 KB
src/views/mp/material/components/
Waterfall
.vue
→
src/views/mp/material/components/
ImageTable
.vue
View file @
abf9b50c
File moved
src/views/mp/material/components/Upload.vue
→
src/views/mp/material/components/Upload
File
.vue
View file @
abf9b50c
...
@@ -20,7 +20,6 @@
...
@@ -20,7 +20,6 @@
</
template
>
</
template
>
</el-upload>
</el-upload>
</template>
</template>
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
type
{
UploadProps
,
UploadUserFile
}
from
'element-plus'
import
type
{
UploadProps
,
UploadUserFile
}
from
'element-plus'
import
{
import
{
...
@@ -66,5 +65,3 @@ const handleUploadSuccess: UploadProps['onSuccess'] = (res: any) => {
...
@@ -66,5 +65,3 @@ const handleUploadSuccess: UploadProps['onSuccess'] = (res: any) => {
emit
(
'uploaded'
)
emit
(
'uploaded'
)
}
}
</
script
>
</
script
>
<
style
scoped
></
style
>
src/views/mp/material/components/UploadVideo.vue
View file @
abf9b50c
...
@@ -123,5 +123,3 @@ const handleUploadSuccess: UploadProps['onSuccess'] = (res: any) => {
...
@@ -123,5 +123,3 @@ const handleUploadSuccess: UploadProps['onSuccess'] = (res: any) => {
emit
(
'uploaded'
)
emit
(
'uploaded'
)
}
}
</
script
>
</
script
>
<
style
scoped
></
style
>
src/views/mp/material/components/VideoTable.vue
View file @
abf9b50c
...
@@ -57,5 +57,3 @@ const handleDownload = (url: string) => {
...
@@ -57,5 +57,3 @@ const handleDownload = (url: string) => {
window
.
open
(
url
,
'_blank'
)
window
.
open
(
url
,
'_blank'
)
}
}
</
script
>
</
script
>
<
style
scoped
></
style
>
src/views/mp/material/components/VoiceTable.vue
View file @
abf9b50c
...
@@ -49,5 +49,3 @@ const emit = defineEmits<{
...
@@ -49,5 +49,3 @@ const emit = defineEmits<{
(
e
:
'delete'
,
v
:
number
)
(
e
:
'delete'
,
v
:
number
)
}
>
()
}
>
()
</
script
>
</
script
>
<
style
scoped
></
style
>
src/views/mp/material/components/upload.ts
View file @
abf9b50c
import
type
{
UploadProps
,
UploadRawFile
}
from
'element-plus'
import
type
{
UploadProps
,
UploadRawFile
}
from
'element-plus'
import
{
getAccessToken
}
from
'@/utils/auth'
import
{
getAccessToken
}
from
'@/utils/auth'
const
message
=
useMessage
()
// 消息
const
message
=
useMessage
()
const
HEADERS
=
{
Authorization
:
'Bearer '
+
getAccessToken
()
}
// 请求头
// const UPLOAD_URL = 'http://127.0.0.1:8000/upload/' // 上传地址
const
HEADERS
=
{
Authorization
:
'Bearer '
+
getAccessToken
()
}
const
UPLOAD_URL
=
import
.
meta
.
env
.
VITE_BASE_URL
+
'/admin-api/mp/material/upload-permanent'
// 上传地址
const
UPLOAD_URL
=
'http://127.0.0.1:8000/upload/'
//import.meta.env.VITE_BASE_URL + '/admin-api/mp/material/upload-permanent'
enum
MaterialType
{
enum
MaterialType
{
Image
=
'image'
,
Image
=
'image'
,
...
@@ -22,7 +21,6 @@ const beforeUpload = (rawFile: UploadRawFile, materialType: MaterialType): boole
...
@@ -22,7 +21,6 @@ const beforeUpload = (rawFile: UploadRawFile, materialType: MaterialType): boole
let
allowTypes
:
string
[]
=
[]
let
allowTypes
:
string
[]
=
[]
let
maxSizeMB
=
0
let
maxSizeMB
=
0
let
name
=
''
let
name
=
''
switch
(
materialType
)
{
switch
(
materialType
)
{
case
MaterialType
.
Image
:
case
MaterialType
.
Image
:
allowTypes
=
[
'image/jpeg'
,
'image/png'
,
'image/gif'
,
'image/bmp'
,
'image/jpg'
]
allowTypes
=
[
'image/jpeg'
,
'image/png'
,
'image/gif'
,
'image/bmp'
,
'image/jpg'
]
...
@@ -38,18 +36,18 @@ const beforeUpload = (rawFile: UploadRawFile, materialType: MaterialType): boole
...
@@ -38,18 +36,18 @@ const beforeUpload = (rawFile: UploadRawFile, materialType: MaterialType): boole
allowTypes
=
[
'video/mp4'
]
allowTypes
=
[
'video/mp4'
]
maxSizeMB
=
10
maxSizeMB
=
10
name
=
'视频'
name
=
'视频'
break
}
}
// 格式不正确
if
(
!
allowTypes
.
includes
(
rawFile
.
type
))
{
if
(
!
allowTypes
.
includes
(
rawFile
.
type
))
{
message
.
error
(
`上传
${
name
}
格式不对!`
)
message
.
error
(
`上传
${
name
}
格式不对!`
)
return
false
return
false
}
}
// 大小不正确
if
(
rawFile
.
size
/
1024
/
1024
>
maxSizeMB
)
{
if
(
rawFile
.
size
/
1024
/
1024
>
maxSizeMB
)
{
message
.
error
(
`上传
${
name
}
大小不能超过
${
maxSizeMB
}
M!`
)
message
.
error
(
`上传
${
name
}
大小不能超过
${
maxSizeMB
}
M!`
)
return
false
return
false
}
}
return
true
return
true
}
}
...
...
src/views/mp/material/index.vue
View file @
abf9b50c
...
@@ -16,14 +16,15 @@
...
@@ -16,14 +16,15 @@
<template
#
label
>
<template
#
label
>
<span>
<Icon
icon=
"ep:picture"
/>
图片
</span>
<span>
<Icon
icon=
"ep:picture"
/>
图片
</span>
</
template
>
</
template
>
<Upload
<Upload
File
v-hasPermi=
"['mp:material:upload-permanent']"
v-hasPermi=
"['mp:material:upload-permanent']"
:type=
"MaterialType.Image"
:type=
"MaterialType.Image"
@
uploaded=
"getList"
@
uploaded=
"getList"
>
>
支持 bmp/png/jpeg/jpg/gif 格式,大小不超过 2M
支持 bmp/png/jpeg/jpg/gif 格式,大小不超过 2M
</Upload>
</UploadFile>
<Waterfall
:loading=
"loading"
:list=
"list"
@
delete=
"handleDelete"
/>
<!-- 列表 -->
<ImageTable
:loading=
"loading"
:list=
"list"
@
delete=
"handleDelete"
/>
<!-- 分页组件 -->
<!-- 分页组件 -->
<Pagination
<Pagination
:total=
"total"
:total=
"total"
...
@@ -38,14 +39,13 @@
...
@@ -38,14 +39,13 @@
<
template
#
label
>
<
template
#
label
>
<span>
<Icon
icon=
"ep:microphone"
/>
语音
</span>
<span>
<Icon
icon=
"ep:microphone"
/>
语音
</span>
</
template
>
</
template
>
<Upload
<Upload
File
v-hasPermi=
"['mp:material:upload-permanent']"
v-hasPermi=
"['mp:material:upload-permanent']"
:type=
"MaterialType.Voice"
:type=
"MaterialType.Voice"
@
uploaded=
"getList"
@
uploaded=
"getList"
>
>
格式支持 mp3/wma/wav/amr,文件大小不超过 2M,播放长度不超过 60s
格式支持 mp3/wma/wav/amr,文件大小不超过 2M,播放长度不超过 60s
</Upload>
</UploadFile>
<!-- 列表 -->
<!-- 列表 -->
<VoiceTable
:list=
"list"
:loading=
"loading"
@
delete=
"handleDelete"
/>
<VoiceTable
:list=
"list"
:loading=
"loading"
@
delete=
"handleDelete"
/>
<!-- 分页组件 -->
<!-- 分页组件 -->
...
@@ -71,7 +71,6 @@
...
@@ -71,7 +71,6 @@
>
>
<!-- 新建视频的弹窗 -->
<!-- 新建视频的弹窗 -->
<UploadVideo
v-model=
"showCreateVideo"
/>
<UploadVideo
v-model=
"showCreateVideo"
/>
<!-- 列表 -->
<!-- 列表 -->
<VideoTable
:list=
"list"
:loading=
"loading"
@
delete=
"handleDelete"
/>
<VideoTable
:list=
"list"
:loading=
"loading"
@
delete=
"handleDelete"
/>
<!-- 分页组件 -->
<!-- 分页组件 -->
...
@@ -85,21 +84,18 @@
...
@@ -85,21 +84,18 @@
</el-tabs>
</el-tabs>
</ContentWrap>
</ContentWrap>
</template>
</template>
<
script
lang=
"ts"
setup
name=
"MpMaterial"
>
<
script
lang=
"ts"
setup
name=
"MpMaterial"
>
import
WxAccountSelect
from
'@/views/mp/components/wx-account-select/main.vue'
import
WxAccountSelect
from
'@/views/mp/components/wx-account-select/main.vue'
import
Waterfall
from
'./components/Waterfall
.vue'
import
ImageTable
from
'./components/ImageTable
.vue'
import
VoiceTable
from
'./components/VoiceTable.vue'
import
VoiceTable
from
'./components/VoiceTable.vue'
import
VideoTable
from
'./components/VideoTable.vue'
import
VideoTable
from
'./components/VideoTable.vue'
import
Upload
from
'./components/Upload
.vue'
import
Upload
File
from
'./components/UploadFile
.vue'
import
UploadVideo
from
'./components/UploadVideo.vue'
import
UploadVideo
from
'./components/UploadVideo.vue'
import
{
MaterialType
}
from
'./components/upload'
import
{
MaterialType
}
from
'./components/upload'
import
*
as
MpMaterialApi
from
'@/api/mp/material'
import
*
as
MpMaterialApi
from
'@/api/mp/material'
const
message
=
useMessage
()
// 消息
const
message
=
useMessage
()
const
type
=
ref
<
MaterialType
>
(
MaterialType
.
Image
)
// 素材类型
// 素材类型
const
type
=
ref
<
MaterialType
>
(
MaterialType
.
Image
)
const
loading
=
ref
(
false
)
// 遮罩层
const
loading
=
ref
(
false
)
// 遮罩层
const
list
=
ref
<
any
[]
>
([])
// 总条数
const
list
=
ref
<
any
[]
>
([])
// 总条数
const
total
=
ref
(
0
)
// 数据列表
const
total
=
ref
(
0
)
// 数据列表
...
@@ -116,9 +112,7 @@ const queryParams: QueryParams = reactive({
...
@@ -116,9 +112,7 @@ const queryParams: QueryParams = reactive({
accountId
:
undefined
,
accountId
:
undefined
,
permanent
:
true
permanent
:
true
})
})
const
showCreateVideo
=
ref
(
false
)
// 是否新建视频的弹窗
// === 视频上传,独有变量 ===
const
showCreateVideo
=
ref
(
false
)
/** 侦听公众号变化 **/
/** 侦听公众号变化 **/
const
onAccountChanged
=
(
id
?:
number
)
=>
{
const
onAccountChanged
=
(
id
?:
number
)
=>
{
...
@@ -126,7 +120,6 @@ const onAccountChanged = (id?: number) => {
...
@@ -126,7 +120,6 @@ const onAccountChanged = (id?: number) => {
getList
()
getList
()
}
}
// ======================== 列表查询 ========================
/** 查询列表 */
/** 查询列表 */
const
getList
=
async
()
=>
{
const
getList
=
async
()
=>
{
loading
.
value
=
true
loading
.
value
=
true
...
@@ -148,21 +141,19 @@ const handleQuery = () => {
...
@@ -148,21 +141,19 @@ const handleQuery = () => {
getList
()
getList
()
}
}
/** 处理 table 切换 */
const
onTabChange
=
()
=>
{
const
onTabChange
=
()
=>
{
// 提前情况数据,避免
tab
切换后显示垃圾数据
// 提前情况数据,避免
tab
切换后显示垃圾数据
list
.
value
=
[]
list
.
value
=
[]
total
.
value
=
0
total
.
value
=
0
// 从第一页开始查询
// 从第一页开始查询
handleQuery
()
handleQuery
()
}
}
/
/ ======================== 其它操作 ========================
/
** 处理删除操作 */
const
handleDelete
=
async
(
id
:
number
)
=>
{
const
handleDelete
=
async
(
id
:
number
)
=>
{
await
message
.
confirm
(
'此操作将永久删除该文件, 是否继续?'
)
await
message
.
confirm
(
'此操作将永久删除该文件, 是否继续?'
)
await
MpMaterialApi
.
deletePermanentMaterial
(
id
)
await
MpMaterialApi
.
deletePermanentMaterial
(
id
)
message
.
alertSuccess
(
'删除成功'
)
message
.
alertSuccess
(
'删除成功'
)
}
}
</
script
>
</
script
>
<
style
lang=
"scss"
scoped
></
style
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment