Add verification for form.

pull/3445/head
ruibaby 2019-08-28 09:46:10 +08:00
parent b5ea3cfbba
commit b84bc5290c
10 changed files with 440 additions and 51 deletions

View File

@ -19,13 +19,17 @@
> >
<div class="attach-detail-img"> <div class="attach-detail-img">
<div v-show="nonsupportPreviewVisible"></div> <div v-show="nonsupportPreviewVisible"></div>
<img :src="attachment.path" v-show="photoPreviewVisible"> <img
:src="attachment.path"
v-show="photoPreviewVisible"
>
<video-player <video-player
class="video-player-box" class="video-player-box"
v-show="videoPreviewVisible" v-show="videoPreviewVisible"
ref="videoPlayer" ref="videoPlayer"
:options="playerOptions" :options="playerOptions"
:playsinline="true"> :playsinline="true"
>
</video-player> </video-player>
</div> </div>
</a-skeleton> </a-skeleton>
@ -182,10 +186,12 @@ export default {
controls: true, controls: true,
loop: false, loop: false,
playbackRates: [0.7, 1.0, 1.5, 2.0], playbackRates: [0.7, 1.0, 1.5, 2.0],
sources: [{ sources: [
{
type: 'video/mp4', type: 'video/mp4',
src: 'https://cdn.theguardian.tv/webM/2015/07/20/150716YesMen_synd_768k_vp8.webm' src: 'https://cdn.theguardian.tv/webM/2015/07/20/150716YesMen_synd_768k_vp8.webm'
}], }
],
poster: '/static/images/author.jpg', poster: '/static/images/author.jpg',
width: document.documentElement.clientWidth, width: document.documentElement.clientWidth,
notSupportedMessage: '此视频暂无法播放,请稍后再试' notSupportedMessage: '此视频暂无法播放,请稍后再试'
@ -253,6 +259,13 @@ export default {
this.editable = !this.editable this.editable = !this.editable
}, },
doUpdateAttachment() { doUpdateAttachment() {
if (!this.attachment.name) {
this.$notification['error']({
message: '提示',
description: '附件名称不能为空!'
})
return
}
attachmentApi.update(this.attachment.id, this.attachment).then(response => { attachmentApi.update(this.attachment.id, this.attachment).then(response => {
this.$log.debug('Updated attachment', response.data.data) this.$log.debug('Updated attachment', response.data.data)
this.$message.success('附件修改成功!') this.$message.success('附件修改成功!')

View File

@ -250,12 +250,12 @@
</a-form-item> </a-form-item>
</a-form> </a-form>
</a-modal> </a-modal>
<CommentDetail <!-- <CommentDetail
v-model="commentDetailVisible" v-model="commentDetailVisible"
v-if="selectComment" v-if="selectComment"
:comment="selectComment" :comment="selectComment"
:type="this.type" :type="this.type"
/> /> -->
</div> </div>
</template> </template>
<script> <script>
@ -439,6 +439,13 @@ export default {
} }
}, },
handleCreateClick() { handleCreateClick() {
if (!this.replyComment.content) {
this.$notification['error']({
message: '提示',
description: '评论内容不能为空!'
})
return
}
commentApi.create(this.type, this.replyComment).then(response => { commentApi.create(this.type, this.replyComment).then(response => {
this.$message.success('回复成功!') this.$message.success('回复成功!')
this.replyComment = {} this.replyComment = {}

View File

@ -274,6 +274,11 @@
:visible="logDrawerVisible" :visible="logDrawerVisible"
destroyOnClose destroyOnClose
@close="()=>this.logDrawerVisible = false" @close="()=>this.logDrawerVisible = false"
>
<a-skeleton
active
:loading="logsLoading"
:paragraph="{rows: 18}"
> >
<a-row <a-row
type="flex" type="flex"
@ -306,6 +311,7 @@
</a-list> </a-list>
</a-col> </a-col>
</a-row> </a-row>
</a-skeleton>
<a-divider class="divider-transparent" /> <a-divider class="divider-transparent" />
<div class="bottom-control"> <div class="bottom-control">
<a-popconfirm <a-popconfirm
@ -353,6 +359,7 @@ export default {
activityLoading: true, activityLoading: true,
writeLoading: true, writeLoading: true,
logLoading: true, logLoading: true,
logsLoading: true,
countsLoading: true, countsLoading: true,
logDrawerVisible: false, logDrawerVisible: false,
postData: [], postData: [],
@ -462,12 +469,18 @@ export default {
}, },
handleCreateJournalClick() { handleCreateJournalClick() {
// //
this.journal.photos = this.journalPhotos // this.journal.photos = this.journalPhotos
if (!this.journal.content) {
this.$notification['error']({
message: '提示',
description: '内容不能为空!'
})
return
}
journalApi.create(this.journal).then(response => { journalApi.create(this.journal).then(response => {
this.$message.success('发表成功!') this.$message.success('发表成功!')
this.journal = {} this.journal = {}
this.photoList = [] // this.photoList = []
this.showMoreOptions = false this.showMoreOptions = false
}) })
}, },
@ -480,6 +493,10 @@ export default {
this.loadLogs() this.loadLogs()
}, },
loadLogs() { loadLogs() {
this.logsLoading = true
setTimeout(() => {
this.logsLoading = false
}, 500)
this.logPagination.page = this.logPagination.page - 1 this.logPagination.page = this.logPagination.page - 1
logApi.pageBy(this.logPagination).then(response => { logApi.pageBy(this.logPagination).then(response => {
this.logs = response.data.data.content this.logs = response.data.data.content

View File

@ -349,6 +349,13 @@ export default {
this.activeTheme(theme.id) this.activeTheme(theme.id)
}, },
handleFetching() { handleFetching() {
if (!this.fetchingUrl) {
this.$notification['error']({
message: '提示',
description: '远程地址不能为空!'
})
return
}
this.fetchButtonLoading = true this.fetchButtonLoading = true
themeApi themeApi
.fetching(this.fetchingUrl) .fetching(this.fetchingUrl)

View File

@ -206,6 +206,13 @@ export default {
}) })
}, },
createOrUpdateCategory() { createOrUpdateCategory() {
if (!this.categoryToCreate.name) {
this.$notification['error']({
message: '提示',
description: '分类名称不能为空!'
})
return
}
if (this.categoryToCreate.id) { if (this.categoryToCreate.id) {
categoryApi.update(this.categoryToCreate.id, this.categoryToCreate).then(response => { categoryApi.update(this.categoryToCreate.id, this.categoryToCreate).then(response => {
this.$message.success('更新成功!') this.$message.success('更新成功!')

View File

@ -132,6 +132,13 @@ export default {
}) })
}, },
createOrUpdateTag() { createOrUpdateTag() {
if (!this.tagToCreate.name) {
this.$notification['error']({
message: '提示',
description: '标签名称不能为空!'
})
return
}
if (this.tagToCreate.id) { if (this.tagToCreate.id) {
tagApi.update(this.tagToCreate.id, this.tagToCreate).then(response => { tagApi.update(this.tagToCreate.id, this.tagToCreate).then(response => {
this.$message.success('更新成功!') this.$message.success('更新成功!')

View File

@ -320,6 +320,13 @@ export default {
this.selectedPost.thumbnail = null this.selectedPost.thumbnail = null
}, },
handlerCreateCategory() { handlerCreateCategory() {
if (!this.categoryToCreate.name) {
this.$notification['error']({
message: '提示',
description: '分类名称不能为空!'
})
return
}
categoryApi.create(this.categoryToCreate).then(response => { categoryApi.create(this.categoryToCreate).then(response => {
this.loadCategories() this.loadCategories()
this.categoryToCreate = {} this.categoryToCreate = {}
@ -338,12 +345,26 @@ export default {
}, },
savePost() { savePost() {
this.createOrUpdatePost( this.createOrUpdatePost(
() => this.$message.success('文章创建成功'), () => this.$message.success('文章发布成功'),
() => this.$message.success('文章更新成功'), () => this.$message.success('文章发布成功'),
false false
) )
}, },
createOrUpdatePost(createSuccess, updateSuccess, autoSave) { createOrUpdatePost(createSuccess, updateSuccess, autoSave) {
if (!this.selectedPost.title) {
this.$notification['error']({
message: '提示',
description: '文章标题不能为空!'
})
return
}
if (!this.selectedPost.originalContent) {
this.$notification['error']({
message: '提示',
description: '文章内容不能为空!'
})
return
}
// Set category ids // Set category ids
this.selectedPost.categoryIds = this.selectedCategoryIds this.selectedPost.categoryIds = this.selectedCategoryIds
// Set tag ids // Set tag ids

View File

@ -208,12 +208,26 @@ export default {
}, },
saveSheet() { saveSheet() {
this.createOrUpdateSheet( this.createOrUpdateSheet(
() => this.$message.success('页面创建成功!'), () => this.$message.success('页面发布成功!'),
() => this.$message.success('页面更新成功!'), () => this.$message.success('页面发布成功!'),
false false
) )
}, },
createOrUpdateSheet(createSuccess, updateSuccess, autoSave) { createOrUpdateSheet(createSuccess, updateSuccess, autoSave) {
if (!this.selectedSheet.title) {
this.$notification['error']({
message: '提示',
description: '页面标题不能为空!'
})
return
}
if (!this.selectedSheet.originalContent) {
this.$notification['error']({
message: '提示',
description: '页面内容不能为空!'
})
return
}
if (this.selectedSheet.id) { if (this.selectedSheet.id) {
sheetApi.update(this.selectedSheet.id, this.selectedSheet, autoSave).then(response => { sheetApi.update(this.selectedSheet.id, this.selectedSheet, autoSave).then(response => {
this.$log.debug('Updated sheet', response.data.data) this.$log.debug('Updated sheet', response.data.data)

View File

@ -736,6 +736,260 @@ export default {
}) })
}, },
handleSaveOptions() { handleSaveOptions() {
if (!this.options.blog_title) {
this.$notification['error']({
message: '提示',
description: '博客标题不能为空!'
})
return
}
if (!this.options.blog_url) {
this.$notification['error']({
message: '提示',
description: '博客地址不能为空!'
})
return
}
//
if (this.options.comment_new_notice || this.options.comment_reply_notice) {
if (!this.options.email_enabled) {
this.$notification['error']({
message: '提示',
description: '新评论通知或回复通知需要打开和配置 SMTP 服务!'
})
return
}
}
//
switch (this.options.attachment_type) {
case 'SMMS':
if (!this.options.smms_api_secret_token) {
this.$notification['error']({
message: '提示',
description: 'Secret Token不能为空'
})
return
}
break
case 'UPYUN':
if (!this.options.oss_upyun_domain) {
this.$notification['error']({
message: '提示',
description: '域名不能为空!'
})
return
}
if (!this.options.oss_upyun_bucket) {
this.$notification['error']({
message: '提示',
description: '空间名称不能为空!'
})
return
}
if (!this.options.oss_upyun_operator) {
this.$notification['error']({
message: '提示',
description: '操作员名称不能为空!'
})
return
}
if (!this.options.oss_upyun_password) {
this.$notification['error']({
message: '提示',
description: '操作员密码不能为空!'
})
return
}
if (!this.options.oss_upyun_source) {
this.$notification['error']({
message: '提示',
description: '文件目录不能为空!'
})
return
}
break
case 'QNYUN':
if (!this.options.oss_qiniu_domain) {
this.$notification['error']({
message: '提示',
description: '域名不能为空!'
})
return
}
if (!this.options.oss_qiniu_access_key) {
this.$notification['error']({
message: '提示',
description: 'Access Key 不能为空!'
})
return
}
if (!this.options.oss_qiniu_secret_key) {
this.$notification['error']({
message: '提示',
description: 'Secret Key 不能为空!'
})
return
}
if (!this.options.oss_qiniu_bucket) {
this.$notification['error']({
message: '提示',
description: 'Bucket 不能为空!'
})
return
}
break
case 'ALIYUN':
if (!this.options.oss_aliyun_bucket_name) {
this.$notification['error']({
message: '提示',
description: 'Bucket 不能为空!'
})
return
}
if (!this.options.oss_aliyun_endpoint) {
this.$notification['error']({
message: '提示',
description: 'EndPoint地域节点 不能为空!'
})
return
}
if (!this.options.oss_aliyun_access_key) {
this.$notification['error']({
message: '提示',
description: 'Access Key 不能为空!'
})
return
}
if (!this.options.oss_aliyun_access_secret) {
this.$notification['error']({
message: '提示',
description: 'Access Secret 不能为空!'
})
return
}
break
case 'BAIDUYUN':
if (!this.options.oss_baiduyun_bucket_name) {
this.$notification['error']({
message: '提示',
description: 'Bucket 不能为空!'
})
return
}
if (!this.options.oss_baiduyun_endpoint) {
this.$notification['error']({
message: '提示',
description: 'EndPoint地域节点 不能为空!'
})
return
}
if (!this.options.oss_baiduyun_access_key) {
this.$notification['error']({
message: '提示',
description: 'Access Key 不能为空!'
})
return
}
if (!this.options.oss_baiduyun_access_secret) {
this.$notification['error']({
message: '提示',
description: 'Access Secret 不能为空!'
})
return
}
break
case 'TENCENTYUN':
if (!this.options.oss_tencentyun_bucket_name) {
this.$notification['error']({
message: '提示',
description: 'Bucket 不能为空!'
})
return
}
if (!this.options.oss_tencentyun_region) {
this.$notification['error']({
message: '提示',
description: '区域不能为空!'
})
return
}
if (!this.options.oss_tencentyun_access_key) {
this.$notification['error']({
message: '提示',
description: 'Secret Id 不能为空!'
})
return
}
if (!this.options.oss_tencentyun_access_secret) {
this.$notification['error']({
message: '提示',
description: 'Secret Key 不能为空!'
})
return
}
break
}
// SMTP
if (this.options.email_enabled) {
if (!this.options.email_host) {
this.$notification['error']({
message: '提示',
description: 'SMTP 地址不能为空!'
})
return
}
if (!this.options.email_protocol) {
this.$notification['error']({
message: '提示',
description: '发送协议不能为空!'
})
return
}
if (!this.options.email_ssl_port) {
this.$notification['error']({
message: '提示',
description: 'SSL 端口不能为空!'
})
return
}
if (!this.options.email_username) {
this.$notification['error']({
message: '提示',
description: '邮箱账号不能为空!'
})
return
}
if (!this.options.email_password) {
this.$notification['error']({
message: '提示',
description: '邮箱密码不能为空!'
})
return
}
if (!this.options.email_from_name) {
this.$notification['error']({
message: '提示',
description: '发件人不能为空!'
})
return
}
}
// API
if (this.options.api_enabled) {
if (!this.options.api_access_key) {
this.$notification['error']({
message: '提示',
description: 'Access key 不能为空!'
})
return
}
}
optionApi.save(this.options).then(response => { optionApi.save(this.options).then(response => {
this.loadOptions() this.loadOptions()
this.loadUser() this.loadUser()
@ -807,6 +1061,27 @@ export default {
this.logoDrawerVisible = false this.logoDrawerVisible = false
}, },
handleTestMailClick() { handleTestMailClick() {
if (!this.mailParam.to) {
this.$notification['error']({
message: '提示',
description: '收件人不能为空!'
})
return
}
if (!this.mailParam.subject) {
this.$notification['error']({
message: '提示',
description: '主题不能为空!'
})
return
}
if (!this.mailParam.content) {
this.$notification['error']({
message: '提示',
description: '内容不能为空!'
})
return
}
mailApi.testMail(this.mailParam).then(response => { mailApi.testMail(this.mailParam).then(response => {
this.$message.info(response.data.message) this.$message.info(response.data.message)
}) })

View File

@ -211,6 +211,27 @@ export default {
userApi.updatePassword(this.passwordParam.oldPassword, this.passwordParam.newPassword).then(response => {}) userApi.updatePassword(this.passwordParam.oldPassword, this.passwordParam.newPassword).then(response => {})
}, },
handleUpdateProfile() { handleUpdateProfile() {
if (!this.user.username) {
this.$notification['error']({
message: '提示',
description: '用户名不能为空!'
})
return
}
if (!this.user.nickname) {
this.$notification['error']({
message: '提示',
description: '用户昵称不能为空!'
})
return
}
if (!this.user.email) {
this.$notification['error']({
message: '提示',
description: '邮箱不能为空!'
})
return
}
userApi.updateProfile(this.user).then(response => { userApi.updateProfile(this.user).then(response => {
this.user = response.data.data this.user = response.data.data
this.setUser(Object.assign({}, this.user)) this.setUser(Object.assign({}, this.user))