From 720c3b4a437e6ca546b25376041fd7246976ecca Mon Sep 17 00:00:00 2001 From: terwer Date: Tue, 10 Oct 2023 23:17:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Github=20=E5=92=8C=20Gitlab=20=E7=B3=BB?= =?UTF-8?q?=E5=88=97=E5=B9=B3=E5=8F=B0=E6=94=AF=E6=8C=81=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E8=AE=BE=E7=BD=AE=E4=BD=9C=E8=80=85=E4=B8=BB=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/base/github/commonGithubConfig.ts | 7 ++++++ .../vuepress/vuepressYamlConverterAdaptor.ts | 4 +-- .../singleplatform/base/CommonBlogSetting.vue | 15 ++++++++--- .../base/impl/CommonGithubSetting.vue | 10 +++++--- .../singleplatform/github/VuepressSetting.vue | 25 ++++++++++++++++++- .../gitlab/GitlabvuepressSetting.vue | 23 ++++++++++++++++- src/locales/en_US.ts | 2 ++ src/locales/zh_CN.ts | 2 ++ 8 files changed, 78 insertions(+), 10 deletions(-) diff --git a/src/adaptors/api/base/github/commonGithubConfig.ts b/src/adaptors/api/base/github/commonGithubConfig.ts index df5afcdf..ca6ffd35 100644 --- a/src/adaptors/api/base/github/commonGithubConfig.ts +++ b/src/adaptors/api/base/github/commonGithubConfig.ts @@ -25,6 +25,7 @@ import { PasswordType } from "zhi-blog-api" import { CommonBlogConfig } from "~/src/adaptors/api/base/commonBlogConfig.ts" +import { StrUtil } from "zhi-common" /** * CommonGithubConfig 类用于存储 GitHub 相关配置信息 @@ -60,6 +61,11 @@ class CommonGithubConfig extends CommonBlogConfig { */ public email: string + /** + * 作者主页 + */ + public site: string + /** * Markdown文件名规则(占位符:[yyyy] [MM] [dd] [slug] [filename] ) */ @@ -111,6 +117,7 @@ class CommonGithubConfig extends CommonBlogConfig { this.defaultMsg = "auto published by siyuan-plugin-publisher" this.author = "terwer" this.email = "youweics@163.com" + this.site = StrUtil.pathJoin(this.home, "/" + this.username) this.mdFilenameRule = "[filename].md" this.useMdFilename = false this.usePathCategory = false diff --git a/src/adaptors/api/vuepress/vuepressYamlConverterAdaptor.ts b/src/adaptors/api/vuepress/vuepressYamlConverterAdaptor.ts index d89194a4..52f502f7 100644 --- a/src/adaptors/api/vuepress/vuepressYamlConverterAdaptor.ts +++ b/src/adaptors/api/vuepress/vuepressYamlConverterAdaptor.ts @@ -81,9 +81,9 @@ class VuepressYamlConverterAdaptor extends YamlConvertAdaptor { } // author - let githubUrl = "https://github.com/terwer" const githubCfg = cfg as CommonGithubConfig - if (githubCfg.home) { + let githubUrl = githubCfg.site + if (StrUtil.isEmptyString(githubCfg.site)) { githubUrl = StrUtil.pathJoin(githubCfg.home, "/" + githubCfg.username) } yamlFormatObj.yamlObj.author = { diff --git a/src/components/set/publish/singleplatform/base/CommonBlogSetting.vue b/src/components/set/publish/singleplatform/base/CommonBlogSetting.vue index 7447c39d..d0c8fe82 100644 --- a/src/components/set/publish/singleplatform/base/CommonBlogSetting.vue +++ b/src/components/set/publish/singleplatform/base/CommonBlogSetting.vue @@ -60,12 +60,17 @@ const props = defineProps({ }) // emits -const emit = defineEmits(["onHomeChange"]) +const emit = defineEmits(["onHomeChange", "onApiUrlChange", "onUsernameChange"]) const handleHomeChange = (value: string | number): void => { if (emit) { emit("onHomeChange", value, formData.cfg) } } +const handleUsernameChange = (value: string | number): void => { + if (emit) { + emit("onUsernameChange", value, formData.cfg) + } +} // datas const isLoading = ref(false) @@ -293,7 +298,11 @@ onMounted(async () => { - + { .inline-tip margin 0 padding-left 0 - \ No newline at end of file + diff --git a/src/components/set/publish/singleplatform/base/impl/CommonGithubSetting.vue b/src/components/set/publish/singleplatform/base/impl/CommonGithubSetting.vue index 8f99b9cf..4b7c8ab1 100644 --- a/src/components/set/publish/singleplatform/base/impl/CommonGithubSetting.vue +++ b/src/components/set/publish/singleplatform/base/impl/CommonGithubSetting.vue @@ -80,9 +80,6 @@ const syncDefaultPath = (cfg: any) => { - - {{ formData.advanceBtnText }} - { :placeholder="t('setting.blog.type.github.default.path.tip')" /> + + {{ formData.advanceBtnText }} +
@@ -111,6 +111,10 @@ const syncDefaultPath = (cfg: any) => { + + + + { + if (StrUtil.isEmptyString(cfg.home) || StrUtil.isEmptyString(cfg.username)) { + cfg.site = "" + } else { + cfg.site = StrUtil.pathJoin(cfg.home, "/" + cfg.username) + } +} +const onUsernameChange = (value: string, cfg: VuepressConfig) => { + // sync site + if (StrUtil.isEmptyString(cfg.home) || StrUtil.isEmptyString(cfg.username)) { + cfg.site = "" + } else { + cfg.site = StrUtil.pathJoin(cfg.home, "/" + cfg.username) + } +}