Add verification for form.

pull/40/head
ruibaby 2019-08-28 09:46:10 +08:00
parent a15d780870
commit 0d82e795df
10 changed files with 440 additions and 51 deletions

View File

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

View File

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

View File

@ -275,37 +275,43 @@
destroyOnClose
@close="()=>this.logDrawerVisible = false"
>
<a-row
type="flex"
align="middle"
<a-skeleton
active
:loading="logsLoading"
:paragraph="{rows: 18}"
>
<a-col :span="24">
<a-list :dataSource="formattedLogsDatas">
<a-list-item
slot="renderItem"
slot-scope="item, index"
:key="index"
>
<a-list-item-meta :description="item.createTime | timeAgo">
<span slot="title">{{ item.type }}</span>
</a-list-item-meta>
<div>{{ item.content }}</div>
</a-list-item>
<a-row
type="flex"
align="middle"
>
<a-col :span="24">
<a-list :dataSource="formattedLogsDatas">
<a-list-item
slot="renderItem"
slot-scope="item, index"
:key="index"
>
<a-list-item-meta :description="item.createTime | timeAgo">
<span slot="title">{{ item.type }}</span>
</a-list-item-meta>
<div>{{ item.content }}</div>
</a-list-item>
<div class="page-wrapper">
<a-pagination
class="pagination"
:total="logPagination.total"
:defaultPageSize="logPagination.size"
:pageSizeOptions="['50', '100','150','200']"
showSizeChanger
@showSizeChange="onPaginationChange"
@change="onPaginationChange"
/>
</div>
</a-list>
</a-col>
</a-row>
<div class="page-wrapper">
<a-pagination
class="pagination"
:total="logPagination.total"
:defaultPageSize="logPagination.size"
:pageSizeOptions="['50', '100','150','200']"
showSizeChanger
@showSizeChange="onPaginationChange"
@change="onPaginationChange"
/>
</div>
</a-list>
</a-col>
</a-row>
</a-skeleton>
<a-divider class="divider-transparent" />
<div class="bottom-control">
<a-popconfirm
@ -353,6 +359,7 @@ export default {
activityLoading: true,
writeLoading: true,
logLoading: true,
logsLoading: true,
countsLoading: true,
logDrawerVisible: false,
postData: [],
@ -462,12 +469,18 @@ export default {
},
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 => {
this.$message.success('发表成功!')
this.journal = {}
this.photoList = []
// this.photoList = []
this.showMoreOptions = false
})
},
@ -480,6 +493,10 @@ export default {
this.loadLogs()
},
loadLogs() {
this.logsLoading = true
setTimeout(() => {
this.logsLoading = false
}, 500)
this.logPagination.page = this.logPagination.page - 1
logApi.pageBy(this.logPagination).then(response => {
this.logs = response.data.data.content
@ -504,11 +521,11 @@ export default {
</script>
<style scoped="scoped">
.more-options-btn{
margin-left: 15px;
text-decoration: none;
}
a {
text-decoration: none;
}
.more-options-btn {
margin-left: 15px;
text-decoration: none;
}
a {
text-decoration: none;
}
</style>

View File

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

View File

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

View File

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

View File

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

View File

@ -208,12 +208,26 @@ export default {
},
saveSheet() {
this.createOrUpdateSheet(
() => this.$message.success('页面创建成功!'),
() => this.$message.success('页面更新成功!'),
() => this.$message.success('页面发布成功!'),
() => this.$message.success('页面发布成功!'),
false
)
},
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) {
sheetApi.update(this.selectedSheet.id, this.selectedSheet, autoSave).then(response => {
this.$log.debug('Updated sheet', response.data.data)

View File

@ -736,6 +736,260 @@ export default {
})
},
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 => {
this.loadOptions()
this.loadUser()
@ -807,6 +1061,27 @@ export default {
this.logoDrawerVisible = false
},
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 => {
this.$message.info(response.data.message)
})

View File

@ -211,6 +211,27 @@ export default {
userApi.updatePassword(this.passwordParam.oldPassword, this.passwordParam.newPassword).then(response => {})
},
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 => {
this.user = response.data.data
this.setUser(Object.assign({}, this.user))