feat: category password (halo-dev/console#292)

* feat: category increase password

* fix: progress bar.

* feat: category password.

Co-authored-by: xiangbei.yzx <xiangbei.yzx@alibaba-inc.com>
pull/3445/head
Ryan Wang 2021-02-05 10:26:10 +08:00 committed by GitHub
parent 6b41171307
commit 2cf450b9ec
3 changed files with 60 additions and 32 deletions

View File

@ -26,12 +26,14 @@ router.beforeEach(async(to, from, next) => {
next({ next({
name: 'Install' name: 'Install'
}) })
onProgressTimerDone()
return return
} }
if (to.name === 'Login') { if (to.name === 'Login') {
next({ next({
name: 'Dashboard' name: 'Dashboard'
}) })
onProgressTimerDone()
return return
} }
@ -53,9 +55,16 @@ router.beforeEach(async(to, from, next) => {
redirect: to.fullPath redirect: to.fullPath
} }
}) })
onProgressTimerDone()
}) })
router.afterEach(() => { router.afterEach(() => {
clearTimeout(progressTimer) onProgressTimerDone()
NProgress.done()
}) })
function onProgressTimerDone() {
if (progressTimer) {
clearTimeout(progressTimer)
NProgress.done()
}
}

View File

@ -57,6 +57,16 @@
</a> </a>
</a-input> </a-input>
</a-form-model-item> </a-form-model-item>
<a-form-model-item
label="密码:"
help="* 分类密码"
prop="password"
>
<a-input-password
v-model="form.model.password"
autocomplete="new-password"
/>
</a-form-model-item>
<a-form-model-item <a-form-model-item
label="描述:" label="描述:"
help="* 分类描述,需要主题支持" help="* 分类描述,需要主题支持"
@ -166,7 +176,7 @@
slot="title" slot="title"
style="max-width: 300px;display: block;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" style="max-width: 300px;display: block;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"
> >
{{ item.name }} {{ item.name }}{{ item.password?'(加密)':'' }}
</span> </span>
</a-list-item-meta> </a-list-item-meta>
@ -184,6 +194,13 @@
:loading="table.loading" :loading="table.loading"
:scrollToFirstRowOnChange="true" :scrollToFirstRowOnChange="true"
> >
<span
slot="name"
slot-scope="text,record"
class="cursor-pointer"
>
{{ record.name }}{{ record.password?'(加密)':'' }}
</span>
<span <span
slot="postCount" slot="postCount"
slot-scope="text,record" slot-scope="text,record"
@ -239,17 +256,13 @@ const columns = [
title: '名称', title: '名称',
ellipsis: true, ellipsis: true,
dataIndex: 'name', dataIndex: 'name',
scopedSlots: { customRender: 'name' },
}, },
{ {
title: '别名', title: '别名',
ellipsis: true, ellipsis: true,
dataIndex: 'slug', dataIndex: 'slug',
}, },
{
title: '描述',
ellipsis: true,
dataIndex: 'description',
},
{ {
title: '文章数', title: '文章数',
dataIndex: 'postCount', dataIndex: 'postCount',

View File

@ -54,7 +54,7 @@
<a-select-option <a-select-option
v-for="category in categories" v-for="category in categories"
:key="category.id" :key="category.id"
>{{ category.name }} ({{ category.postCount }})</a-select-option> >{{ category.name }}({{ category.postCount }})</a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
</a-col> </a-col>
@ -281,6 +281,7 @@
v-for="(category, categoryIndex) in item.categories" v-for="(category, categoryIndex) in item.categories"
:key="'category_' + categoryIndex" :key="'category_' + categoryIndex"
color="blue" color="blue"
@click="handleSelectCategory(category)"
style="margin-bottom: 8px" style="margin-bottom: 8px"
>{{ category.name }}</a-tag> >{{ category.name }}</a-tag>
<br /> <br />
@ -368,7 +369,8 @@
v-for="(category, index) in categoriesOfPost" v-for="(category, index) in categoriesOfPost"
:key="index" :key="index"
color="blue" color="blue"
style="margin-bottom: 8px" @click="handleSelectCategory(category)"
style="margin-bottom: 8px;cursor:pointer"
>{{ >{{
category.name category.name
}}</a-tag> }}</a-tag>
@ -534,48 +536,48 @@ const columns = [
dataIndex: 'title', dataIndex: 'title',
width: '150px', width: '150px',
ellipsis: true, ellipsis: true,
scopedSlots: { customRender: 'postTitle' } scopedSlots: { customRender: 'postTitle' },
}, },
{ {
title: '状态', title: '状态',
className: 'status', className: 'status',
dataIndex: 'statusProperty', dataIndex: 'statusProperty',
width: '100px', width: '100px',
scopedSlots: { customRender: 'status' } scopedSlots: { customRender: 'status' },
}, },
{ {
title: '分类', title: '分类',
dataIndex: 'categories', dataIndex: 'categories',
scopedSlots: { customRender: 'categories' } scopedSlots: { customRender: 'categories' },
}, },
{ {
title: '标签', title: '标签',
dataIndex: 'tags', dataIndex: 'tags',
scopedSlots: { customRender: 'tags' } scopedSlots: { customRender: 'tags' },
}, },
{ {
title: '评论', title: '评论',
width: '70px', width: '70px',
dataIndex: 'commentCount', dataIndex: 'commentCount',
scopedSlots: { customRender: 'commentCount' } scopedSlots: { customRender: 'commentCount' },
}, },
{ {
title: '访问', title: '访问',
width: '70px', width: '70px',
dataIndex: 'visits', dataIndex: 'visits',
scopedSlots: { customRender: 'visits' } scopedSlots: { customRender: 'visits' },
}, },
{ {
title: '发布时间', title: '发布时间',
dataIndex: 'createTime', dataIndex: 'createTime',
width: '170px', width: '170px',
scopedSlots: { customRender: 'createTime' } scopedSlots: { customRender: 'createTime' },
}, },
{ {
title: '操作', title: '操作',
width: '180px', width: '180px',
scopedSlots: { customRender: 'action' } scopedSlots: { customRender: 'action' },
} },
] ]
export default { export default {
name: 'PostList', name: 'PostList',
@ -584,7 +586,7 @@ export default {
TagSelect, TagSelect,
CategoryTree, CategoryTree,
PostSettingDrawer, PostSettingDrawer,
TargetCommentDrawer TargetCommentDrawer,
}, },
mixins: [mixin, mixinDevice], mixins: [mixin, mixinDevice],
data() { data() {
@ -594,7 +596,7 @@ export default {
page: 1, page: 1,
size: 10, size: 10,
sort: null, sort: null,
total: 1 total: 1,
}, },
queryParam: { queryParam: {
page: 0, page: 0,
@ -602,7 +604,7 @@ export default {
sort: null, sort: null,
keyword: null, keyword: null,
categoryId: null, categoryId: null,
status: null status: null,
}, },
// //
columns, columns,
@ -611,8 +613,8 @@ export default {
selectedMetas: [ selectedMetas: [
{ {
key: '', key: '',
value: '' value: '',
} },
], ],
posts: [], posts: [],
postsLoading: false, postsLoading: false,
@ -621,7 +623,7 @@ export default {
postCommentVisible: false, postCommentVisible: false,
selectedPost: {}, selectedPost: {},
selectedTagIds: [], selectedTagIds: [],
selectedCategoryIds: [] selectedCategoryIds: [],
} }
}, },
computed: { computed: {
@ -630,7 +632,7 @@ export default {
post.statusProperty = this.postStatus[post.status] post.statusProperty = this.postStatus[post.status]
return post return post
}) })
} },
}, },
beforeMount() { beforeMount() {
this.handleListCategories() this.handleListCategories()
@ -672,8 +674,8 @@ export default {
const path = this.$router.history.current.path const path = this.$router.history.current.path
this.$router.push({ path, query: params }).catch((err) => err) this.$router.push({ path, query: params }).catch((err) => err)
} }
} },
} },
}, },
methods: { methods: {
handleListPosts(enableLoading = true) { handleListPosts(enableLoading = true) {
@ -720,8 +722,8 @@ export default {
return { return {
props: { props: {
disabled: this.queryParam.status == null || this.queryParam.status === '', disabled: this.queryParam.status == null || this.queryParam.status === '',
name: post.title name: post.title,
} },
} }
}, },
handlePaginationChange(page, pageSize) { handlePaginationChange(page, pageSize) {
@ -742,6 +744,10 @@ export default {
this.handleClearRowKeys() this.handleClearRowKeys()
this.handlePaginationChange(1, this.pagination.size) this.handlePaginationChange(1, this.pagination.size)
}, },
handleSelectCategory(category) {
this.queryParam.categoryId = category.id
this.handleQuery()
},
handleEditStatusClick(postId, status) { handleEditStatusClick(postId, status) {
postApi postApi
.updateStatus(postId, status) .updateStatus(postId, status)
@ -841,7 +847,7 @@ export default {
}, },
onRefreshPostMetasFromSetting(metas) { onRefreshPostMetasFromSetting(metas) {
this.selectedMetas = metas this.selectedMetas = metas
} },
} },
} }
</script> </script>