mirror of https://github.com/halo-dev/halo-admin
parent
a2e83e8e2f
commit
b412671e92
|
@ -18,7 +18,19 @@
|
||||||
<a-input v-model="selectedPost.title" />
|
<a-input v-model="selectedPost.title" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="文章别名:" :help="fullPath">
|
<a-form-item label="文章别名:" :help="fullPath">
|
||||||
<a-input v-model="selectedPost.slug" />
|
<a-input v-model="selectedPost.slug">
|
||||||
|
<template #addonAfter>
|
||||||
|
<a-popconfirm
|
||||||
|
title="是否确定根据标题重新生成别名?"
|
||||||
|
ok-text="确定"
|
||||||
|
cancel-text="取消"
|
||||||
|
placement="left"
|
||||||
|
@confirm="handleSetPinyinSlug"
|
||||||
|
>
|
||||||
|
<a-icon class="cursor-pointer" type="sync" />
|
||||||
|
</a-popconfirm>
|
||||||
|
</template>
|
||||||
|
</a-input>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
|
||||||
<a-form-item label="发表时间:">
|
<a-form-item label="发表时间:">
|
||||||
|
@ -387,8 +399,10 @@ export default {
|
||||||
this.handleListCategories()
|
this.handleListCategories()
|
||||||
this.handleListPresetMetasField()
|
this.handleListPresetMetasField()
|
||||||
this.handleListCustomTpls()
|
this.handleListCustomTpls()
|
||||||
|
if (!this.selectedPost.slug && !this.selectedPost.id) {
|
||||||
this.handleSetPinyinSlug()
|
this.handleSetPinyinSlug()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
handleListCategories() {
|
handleListCategories() {
|
||||||
categoryApi.listAll().then(response => {
|
categoryApi.listAll().then(response => {
|
||||||
|
@ -534,10 +548,10 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleSetPinyinSlug() {
|
handleSetPinyinSlug() {
|
||||||
if (this.selectedPost.title && this.selectedPost.title !== '' && !this.selectedPost.id) {
|
if (this.selectedPost.title) {
|
||||||
if (pinyin.isSupported()) {
|
if (pinyin.isSupported()) {
|
||||||
let result = ''
|
let result = ''
|
||||||
const tokens = pinyin.parse(this.selectedPost.title)
|
const tokens = pinyin.parse(this.selectedPost.title.replace(/\s+/g, '').toLowerCase())
|
||||||
let lastToken
|
let lastToken
|
||||||
tokens.forEach(token => {
|
tokens.forEach(token => {
|
||||||
if (token.type === 2) {
|
if (token.type === 2) {
|
||||||
|
|
|
@ -18,7 +18,19 @@
|
||||||
<a-input v-model="selectedSheet.title" />
|
<a-input v-model="selectedSheet.title" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="页面别名:" :help="fullPath">
|
<a-form-item label="页面别名:" :help="fullPath">
|
||||||
<a-input v-model="selectedSheet.slug" />
|
<a-input v-model="selectedSheet.slug">
|
||||||
|
<template #addonAfter>
|
||||||
|
<a-popconfirm
|
||||||
|
title="是否确定根据标题重新生成别名?"
|
||||||
|
ok-text="确定"
|
||||||
|
cancel-text="取消"
|
||||||
|
placement="left"
|
||||||
|
@confirm="handleSetPinyinSlug"
|
||||||
|
>
|
||||||
|
<a-icon class="cursor-pointer" type="sync" />
|
||||||
|
</a-popconfirm>
|
||||||
|
</template>
|
||||||
|
</a-input>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="发表时间:">
|
<a-form-item label="发表时间:">
|
||||||
<a-date-picker
|
<a-date-picker
|
||||||
|
@ -272,8 +284,10 @@ export default {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
this.handleListCustomTpls()
|
this.handleListCustomTpls()
|
||||||
this.handleListPresetMetasField()
|
this.handleListPresetMetasField()
|
||||||
|
if (!this.selectedSheet.slug && !this.selectedSheet.id) {
|
||||||
this.handleSetPinyinSlug()
|
this.handleSetPinyinSlug()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
handleListPresetMetasField() {
|
handleListPresetMetasField() {
|
||||||
if (this.metas.length <= 0) {
|
if (this.metas.length <= 0) {
|
||||||
|
@ -397,10 +411,10 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleSetPinyinSlug() {
|
handleSetPinyinSlug() {
|
||||||
if (this.selectedSheet.title && !this.selectedSheet.id) {
|
if (this.selectedSheet.title) {
|
||||||
if (pinyin.isSupported()) {
|
if (pinyin.isSupported()) {
|
||||||
let result = ''
|
let result = ''
|
||||||
const tokens = pinyin.parse(this.selectedSheet.title)
|
const tokens = pinyin.parse(this.selectedSheet.title.replace(/\s+/g, '').toLowerCase())
|
||||||
let lastToken
|
let lastToken
|
||||||
tokens.forEach(token => {
|
tokens.forEach(token => {
|
||||||
if (token.type === 2) {
|
if (token.type === 2) {
|
||||||
|
|
Loading…
Reference in New Issue