From 8b641f9905b5e12a1b57c357fa838089359ed268 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Wed, 2 Dec 2020 10:24:38 +0800 Subject: [PATCH] feat: halo-dev/halo#1174 (#270) --- src/api/sheet.js | 11 ++++ src/store/modules/option.js | 1 + .../sheet/components/SheetSettingDrawer.vue | 12 +++- src/views/system/optiontabs/PermalinkTab.vue | 62 ++++++++++++------- 4 files changed, 63 insertions(+), 23 deletions(-) diff --git a/src/api/sheet.js b/src/api/sheet.js index b139a107..13dce2be 100644 --- a/src/api/sheet.js +++ b/src/api/sheet.js @@ -96,4 +96,15 @@ sheetApi.sheetStatus = { text: '回收站' } } + +sheetApi.permalinkType = { + SECONDARY: { + type: 'SECONDARY', + text: '二级路径' + }, + ROOT: { + type: 'ROOT', + text: '根路径' + }, +} export default sheetApi diff --git a/src/store/modules/option.js b/src/store/modules/option.js index 57a049ae..f6420c8c 100644 --- a/src/store/modules/option.js +++ b/src/store/modules/option.js @@ -9,6 +9,7 @@ const keys = [ 'attachment_upload_max_files', 'sheet_prefix', 'post_permalink_type', + 'sheet_permalink_type', 'archives_prefix', 'path_suffix', 'default_editor', diff --git a/src/views/sheet/components/SheetSettingDrawer.vue b/src/views/sheet/components/SheetSettingDrawer.vue index 40843798..bdfb2d21 100644 --- a/src/views/sheet/components/SheetSettingDrawer.vue +++ b/src/views/sheet/components/SheetSettingDrawer.vue @@ -296,10 +296,20 @@ export default { return datetimeFormat(new Date(), 'YYYY-MM-DD HH:mm:ss') }, fullPath() { + const permalinkType = this.options.sheet_permalink_type const blogUrl = this.options.blog_url const sheetPrefix = this.options.sheet_prefix const pathSuffix = this.options.path_suffix ? this.options.path_suffix : '' - return `${blogUrl}/${sheetPrefix}/${this.selectedSheet.slug ? this.selectedSheet.slug : '{slug}'}${pathSuffix}` + switch (permalinkType) { + case 'SECONDARY': + return `${blogUrl}/${sheetPrefix}/${ + this.selectedSheet.slug ? this.selectedSheet.slug : '{slug}' + }${pathSuffix}` + case 'ROOT': + return `${blogUrl}/${this.selectedSheet.slug ? this.selectedSheet.slug : '{slug}'}${pathSuffix}` + default: + return '' + } }, }, methods: { diff --git a/src/views/system/optiontabs/PermalinkTab.vue b/src/views/system/optiontabs/PermalinkTab.vue index a618571a..16a79ed0 100644 --- a/src/views/system/optiontabs/PermalinkTab.vue +++ b/src/views/system/optiontabs/PermalinkTab.vue @@ -18,13 +18,47 @@ {{ permalinkType[item].text }} + >{{ postPermalinkType[item].text }} - + + + + + + + + + + + + + + + + {{ sheetPermalinkType[item].text }} + + + @@ -48,24 +82,6 @@ - - - - - - - - - - - -