|
|
@@ -70,20 +70,24 @@
|
|
|
<el-form-item label="分区">
|
|
|
<el-select v-model="form.categoryPid" placeholder="请选择分区" @change="getCategory">
|
|
|
<el-option
|
|
|
- v-for="item in pCategoryList" :key="item.value"
|
|
|
- :label="item.label" :value="item.value">
|
|
|
- </el-option>
|
|
|
+ v-for="item in pCategoryList"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ />
|
|
|
</el-select>
|
|
|
<el-select v-model="form.categoryId" placeholder="请选择子分区">
|
|
|
<el-option
|
|
|
- v-for="item in categoryList" :key="item.value"
|
|
|
- :label="item.label" :value="item.value">
|
|
|
- </el-option>
|
|
|
+ v-for="item in categoryList"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="标签">
|
|
|
- <el-select v-model="form.tags" style="padding-right: 1px" placeholder="输入标签,用回车添加" @change="getRecommendTags" clearable multiple filterable allow-create default-first-option>
|
|
|
- <el-option v-for="item in rcmdTags" :key="item.value" :label="item.label" :value="item.label"></el-option>
|
|
|
+ <el-select v-model="form.tags" style="padding-right: 1px" placeholder="输入标签,用回车添加" clearable multiple filterable allow-create default-first-option @change="getRecommendTags">
|
|
|
+ <el-option v-for="item in rcmdTags" :key="item.value" :label="item.label" :value="item.label" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="可见范围">
|
|
|
@@ -98,8 +102,8 @@
|
|
|
<el-date-picker
|
|
|
v-model="form.scheduledPubDate"
|
|
|
type="datetime"
|
|
|
- placeholder="选择定时发布的时间">
|
|
|
- </el-date-picker>
|
|
|
+ placeholder="选择定时发布的时间"
|
|
|
+ />
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
</div>
|
|
|
@@ -111,13 +115,13 @@
|
|
|
|
|
|
<script>
|
|
|
import { getServerInfo } from '@/api/content'
|
|
|
-import {videoCategory, addVideoPost } from '@/api/video'
|
|
|
+import { videoCategory, addVideoPost } from '@/api/video'
|
|
|
|
|
|
export default {
|
|
|
name: 'PublishVideo',
|
|
|
data() {
|
|
|
return {
|
|
|
- /***********************************************************************/
|
|
|
+ // ****************************************************************************************************************
|
|
|
options: {
|
|
|
target: '//oss.reghao.cn/',
|
|
|
chunkSize: 1024 * 1024 * 1024 * 10, // 10GiB
|
|
|
@@ -131,12 +135,12 @@ export default {
|
|
|
headers: {
|
|
|
Authorization: ''
|
|
|
},
|
|
|
- withCredentials: true,
|
|
|
+ withCredentials: true
|
|
|
},
|
|
|
attrs: {
|
|
|
accept: 'video/*'
|
|
|
},
|
|
|
- /***********************************************************************/
|
|
|
+ // ****************************************************************************************************************
|
|
|
imgOssUrl: null,
|
|
|
imgHeaders: {
|
|
|
Authorization: ''
|
|
|
@@ -145,7 +149,7 @@ export default {
|
|
|
channelId: 5
|
|
|
},
|
|
|
coverUrl: null,
|
|
|
- /***********************************************************************/
|
|
|
+ // ****************************************************************************************************************
|
|
|
categoryMap: {
|
|
|
Set: function(key, value) { this[key] = value },
|
|
|
Get: function(key) { return this[key] },
|
|
|
@@ -155,7 +159,7 @@ export default {
|
|
|
pCategoryList: [],
|
|
|
categoryList: [],
|
|
|
rcmdTags: [
|
|
|
- /*{ label: "知识点1" }*/
|
|
|
+ /* { label: "知识点1" }*/
|
|
|
],
|
|
|
form: {
|
|
|
videoFileId: null,
|
|
|
@@ -165,9 +169,9 @@ export default {
|
|
|
categoryPid: null,
|
|
|
categoryId: null,
|
|
|
tags: [],
|
|
|
- scope: "1",
|
|
|
+ scope: '1',
|
|
|
scheduledPubDate: null
|
|
|
- },
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
@@ -176,7 +180,7 @@ export default {
|
|
|
const resData = res.data
|
|
|
this.options.target = resData.ossUrl
|
|
|
this.options.chunkSize = resData.maxSize
|
|
|
- this.options.headers.Authorization = "Bearer " + resData.token
|
|
|
+ this.options.headers.Authorization = 'Bearer ' + resData.token
|
|
|
} else {
|
|
|
this.$notify({
|
|
|
title: '提示',
|
|
|
@@ -198,7 +202,7 @@ export default {
|
|
|
if (res.code === 0) {
|
|
|
const resData = res.data
|
|
|
this.imgOssUrl = resData.ossUrl
|
|
|
- this.imgHeaders.Authorization = "Bearer " + resData.token
|
|
|
+ this.imgHeaders.Authorization = 'Bearer ' + resData.token
|
|
|
} else {
|
|
|
this.$notify({
|
|
|
title: '提示',
|
|
|
@@ -220,16 +224,16 @@ export default {
|
|
|
mounted() {
|
|
|
},
|
|
|
methods: {
|
|
|
- /***********************************************************************/
|
|
|
+ // ****************************************************************************************************************
|
|
|
onFileAdded(file) {
|
|
|
- if (file.file.size > 1024*1024*1024*5) {
|
|
|
+ if (file.file.size > 1024 * 1024 * 1024 * 5) {
|
|
|
file.cancel()
|
|
|
this.$notify({
|
|
|
- title: '提示',
|
|
|
- message: '视频文件应小于 5GiB',
|
|
|
- type: 'warning',
|
|
|
- duration: 3000
|
|
|
- })
|
|
|
+ title: '提示',
|
|
|
+ message: '视频文件应小于 5GiB',
|
|
|
+ type: 'warning',
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
return
|
|
|
}
|
|
|
this.setTitle(file.file.name)
|
|
|
@@ -249,7 +253,6 @@ export default {
|
|
|
duration: 3000
|
|
|
})
|
|
|
} else {
|
|
|
- console.log(chunk)
|
|
|
this.$notify({
|
|
|
title: '提示',
|
|
|
message: '视频文件上传失败',
|
|
|
@@ -262,13 +265,13 @@ export default {
|
|
|
const res = JSON.parse(response)
|
|
|
console.log(res.msg)
|
|
|
this.$notify({
|
|
|
- title: '提示',
|
|
|
- message: '视频文件上传错误',
|
|
|
- type: 'warning',
|
|
|
- duration: 3000
|
|
|
- })
|
|
|
+ title: '提示',
|
|
|
+ message: '视频文件上传错误',
|
|
|
+ type: 'warning',
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
},
|
|
|
- /***********************************************************************/
|
|
|
+ // ****************************************************************************************************************
|
|
|
// 选择视频后获取视频的分辨率和时长, 并截取第一秒的内容作为封面
|
|
|
processVideo(file) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
@@ -329,7 +332,7 @@ export default {
|
|
|
type: 'warning',
|
|
|
duration: 3000
|
|
|
})
|
|
|
- return;
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
const formData = new FormData()
|
|
|
@@ -341,27 +344,27 @@ export default {
|
|
|
credentials: 'include',
|
|
|
body: formData
|
|
|
}).then(response => response.json()).then(json => {
|
|
|
- if (json.code === 0) {
|
|
|
- this.coverUrl = URL.createObjectURL(coverFile)
|
|
|
- const resData = json.data
|
|
|
- this.form.coverFileId = resData.uploadId
|
|
|
- } else {
|
|
|
- this.$notify({
|
|
|
- title: '提示',
|
|
|
- message: '视频封面上传失败,请重试!' + json.msg,
|
|
|
- type: 'warning',
|
|
|
- duration: 3000
|
|
|
- })
|
|
|
- }
|
|
|
- }).catch(e => {
|
|
|
- return null
|
|
|
- })
|
|
|
+ if (json.code === 0) {
|
|
|
+ this.coverUrl = URL.createObjectURL(coverFile)
|
|
|
+ const resData = json.data
|
|
|
+ this.form.coverFileId = resData.uploadId
|
|
|
+ } else {
|
|
|
+ this.$notify({
|
|
|
+ title: '提示',
|
|
|
+ message: '视频封面上传失败,请重试!' + json.msg,
|
|
|
+ type: 'warning',
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }).catch(e => {
|
|
|
+ return null
|
|
|
+ })
|
|
|
}
|
|
|
}, 1000) // 1000毫秒,就是截取第一秒,2000毫秒就是截取第2秒,视频1秒通常24帧,也可以换算成截取第几帧。
|
|
|
// 防止拖动进度条的时候重复触发
|
|
|
// videoElem.removeEventListener('canplay', arguments.callee)
|
|
|
},
|
|
|
- /***********************************************************************/
|
|
|
+ // ****************************************************************************************************************
|
|
|
beforeAvatarUpload(file) {
|
|
|
const isJPG = file.type === 'image/jpeg'
|
|
|
const isLt2M = file.size / 1024 / 1024 < 10
|
|
|
@@ -376,7 +379,7 @@ export default {
|
|
|
handleAvatarSuccess(res, file) {
|
|
|
if (res.code === 0) {
|
|
|
const resData = res.data
|
|
|
- this.coverUrl = URL.createObjectURL(file.raw);
|
|
|
+ this.coverUrl = URL.createObjectURL(file.raw)
|
|
|
this.form.coverFileId = resData.uploadId
|
|
|
} else {
|
|
|
this.$notify({
|
|
|
@@ -388,9 +391,8 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
handleOnChange(file, fileList) {
|
|
|
- console.log('封面改变')
|
|
|
},
|
|
|
- /***********************************************************************/
|
|
|
+ // ****************************************************************************************************************
|
|
|
setTitle(title) {
|
|
|
if (title.length > 50) {
|
|
|
this.form.title = title.substring(0, 50)
|
|
|
@@ -401,36 +403,36 @@ export default {
|
|
|
},
|
|
|
getVideoCategory() {
|
|
|
videoCategory().then(res => {
|
|
|
- if (res.code === 0) {
|
|
|
- const resData = res.data
|
|
|
- for (let i = 0; i < resData.length; i++) {
|
|
|
- const name = resData[i].name
|
|
|
- const id = resData[i].id
|
|
|
- this.pCategoryList.push({label: name, value: id})
|
|
|
- this.categoryMap.Set(id, resData[i].children)
|
|
|
- }
|
|
|
- } else {
|
|
|
- this.$notify({
|
|
|
- title: '提示',
|
|
|
- message: res.msg,
|
|
|
- type: 'warning',
|
|
|
- duration: 3000
|
|
|
- })
|
|
|
+ if (res.code === 0) {
|
|
|
+ const resData = res.data
|
|
|
+ for (let i = 0; i < resData.length; i++) {
|
|
|
+ const name = resData[i].name
|
|
|
+ const id = resData[i].id
|
|
|
+ this.pCategoryList.push({ label: name, value: id })
|
|
|
+ this.categoryMap.Set(id, resData[i].children)
|
|
|
}
|
|
|
- }).catch(error => {
|
|
|
+ } else {
|
|
|
this.$notify({
|
|
|
title: '提示',
|
|
|
- message: error.message,
|
|
|
- type: 'error',
|
|
|
+ message: res.msg,
|
|
|
+ type: 'warning',
|
|
|
duration: 3000
|
|
|
})
|
|
|
+ }
|
|
|
+ }).catch(error => {
|
|
|
+ this.$notify({
|
|
|
+ title: '提示',
|
|
|
+ message: error.message,
|
|
|
+ type: 'error',
|
|
|
+ duration: 3000
|
|
|
})
|
|
|
+ })
|
|
|
},
|
|
|
getCategory(id) {
|
|
|
// 重置子分区,清除前一次选择分区时留下的缓存
|
|
|
this.categoryList = []
|
|
|
for (const item of this.categoryMap.Get(id)) {
|
|
|
- this.categoryList.push({label: item.name, value: item.id})
|
|
|
+ this.categoryList.push({ label: item.name, value: item.id })
|
|
|
}
|
|
|
},
|
|
|
// 根据输入的标签获取相似的标签
|
|
|
@@ -442,44 +444,44 @@ export default {
|
|
|
onSubmit() {
|
|
|
if (!this.form.videoFileId) {
|
|
|
this.$notify({
|
|
|
- title: '提示',
|
|
|
- message: '你还没有上传视频',
|
|
|
- type: 'warning',
|
|
|
- duration: 3000
|
|
|
- }
|
|
|
+ title: '提示',
|
|
|
+ message: '你还没有上传视频',
|
|
|
+ type: 'warning',
|
|
|
+ duration: 3000
|
|
|
+ }
|
|
|
)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
if (!this.form.coverFileId) {
|
|
|
this.$notify({
|
|
|
- title: '提示',
|
|
|
- message: '你还没有上传视频封面',
|
|
|
- type: 'warning',
|
|
|
- duration: 3000
|
|
|
- }
|
|
|
+ title: '提示',
|
|
|
+ message: '你还没有上传视频封面',
|
|
|
+ type: 'warning',
|
|
|
+ duration: 3000
|
|
|
+ }
|
|
|
)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
if (this.form.title === '' || this.form.categoryId === -1) {
|
|
|
this.$notify({
|
|
|
- title: '提示',
|
|
|
- message: '分区和稿件标题不能为空',
|
|
|
- type: 'warning',
|
|
|
- duration: 3000
|
|
|
- }
|
|
|
+ title: '提示',
|
|
|
+ message: '分区和稿件标题不能为空',
|
|
|
+ type: 'warning',
|
|
|
+ duration: 3000
|
|
|
+ }
|
|
|
)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
if (this.form.tags.length === 0 || this.form.tags.length > 10) {
|
|
|
this.$notify({
|
|
|
- title: '提示',
|
|
|
- message: '标签最少 1 个, 最多 10 个',
|
|
|
- type: 'warning',
|
|
|
- duration: 3000
|
|
|
- }
|
|
|
+ title: '提示',
|
|
|
+ message: '标签最少 1 个, 最多 10 个',
|
|
|
+ type: 'warning',
|
|
|
+ duration: 3000
|
|
|
+ }
|
|
|
)
|
|
|
return
|
|
|
}
|
|
|
@@ -506,20 +508,20 @@ export default {
|
|
|
})
|
|
|
this.$router.push('/post/video')
|
|
|
} else {
|
|
|
- this.$notify({
|
|
|
- title: '提示',
|
|
|
- message: res.msg,
|
|
|
- type: 'warning',
|
|
|
- duration: 3000
|
|
|
- })
|
|
|
- }
|
|
|
- }).catch(error => {
|
|
|
this.$notify({
|
|
|
title: '提示',
|
|
|
- message: error.message,
|
|
|
+ message: res.msg,
|
|
|
type: 'warning',
|
|
|
duration: 3000
|
|
|
})
|
|
|
+ }
|
|
|
+ }).catch(error => {
|
|
|
+ this.$notify({
|
|
|
+ title: '提示',
|
|
|
+ message: error.message,
|
|
|
+ type: 'warning',
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
})
|
|
|
}
|
|
|
}
|