From e2e134ca3d626e1f44680bab34512615eaca7f5b Mon Sep 17 00:00:00 2001 From: terwer Date: Thu, 7 Mar 2024 18:33:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20#1076=20#1077=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E9=85=8D=E7=BD=AE=E3=80=81=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E3=80=81=E6=8F=92=E4=BB=B6=E5=95=86=E5=BA=97?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E4=BD=93=E9=AA=8C=20-=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=96=87=E7=AB=A0=E7=BB=91=E5=AE=9A=EF=BC=8C=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E5=85=83=E6=95=B0=E6=8D=AE=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/set/preference/PostBind.vue | 40 +++++++++++++--------- src/locales/en_US.ts | 9 ++--- src/locales/zh_CN.ts | 3 +- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/components/set/preference/PostBind.vue b/src/components/set/preference/PostBind.vue index 9fd2a61e..cea37129 100644 --- a/src/components/set/preference/PostBind.vue +++ b/src/components/set/preference/PostBind.vue @@ -34,7 +34,7 @@ import { useRoute } from "vue-router" import { getWidgetId } from "~/src/utils/widgetUtils.ts" import { usePublishSettingStore } from "~/src/stores/usePublishSettingStore.ts" import { createAppLogger } from "~/src/utils/appLogger.ts" -import { getSiyuanWidgetId } from "~/src/utils/siyuanUtils.ts" +import { getSiyuanPageId } from "~/src/utils/siyuanUtils.ts" import { Utils } from "~/src/utils/utils.ts" const logger = createAppLogger("post-bind") @@ -46,19 +46,18 @@ const { getPublishCfg } = usePublishConfig() const { updateSetting } = usePublishSettingStore() // datas -const id = Utils.emptyOrDefault(query.id ?? getWidgetId(), getSiyuanWidgetId()) as string const ruleFormRef = ref() const ruleForm = reactive({}) const rules = reactive({}) const formData = reactive({ - pageId: id, + pageId: "", dynamicConfigArray: [] as DynamicConfig[], postIdMap: {} as any, }) // methods const submitForm = async (formEl: any) => { - if (StrUtil.isEmptyString(id)) { + if (StrUtil.isEmptyString(formData.pageId)) { ElMessage.error("") return } @@ -66,18 +65,18 @@ const submitForm = async (formEl: any) => { try { const publishCfg = await getPublishCfg() const setting = publishCfg.setting - const postMeta = ObjectUtil.getProperty(setting, id, {}) + const postMeta = ObjectUtil.getProperty(setting, formData.pageId, {}) formData.dynamicConfigArray = formData.dynamicConfigArray.map((item: DynamicConfig) => { const postid = formData.postIdMap[item.platformKey] const cfg = ObjectUtil.getProperty(setting, item.platformKey, {}) const posidKey = cfg?.posidKey - if (!StrUtil.isEmptyString(posidKey) && !StrUtil.isEmptyString(id)) { + if (!StrUtil.isEmptyString(posidKey) && !StrUtil.isEmptyString(formData.pageId)) { postMeta[posidKey] = postid } return item }) - setting[id] = postMeta + setting[formData.pageId] = postMeta logger.debug("prepare to save setting =>", { setting: toRaw(setting) }) await updateSetting(setting) ElMessage.success(t("main.opt.success")) @@ -89,6 +88,10 @@ const submitForm = async (formEl: any) => { // lifecycles onMounted(async () => { + const id = Utils.emptyOrDefault(query.id as string, getWidgetId()) + const siyuanPageId = await getSiyuanPageId(id) + formData.pageId = siyuanPageId + const publishCfg = await getPublishCfg() const setting = publishCfg.setting formData.dynamicConfigArray = publishCfg.dynamicConfigArray @@ -110,7 +113,7 @@ onMounted(async () => {
- + @@ -133,14 +136,19 @@ onMounted(async () => { :closable="false" /> - - - +
+ + + +
+
+ +
{{ t("post.bind.conf.save") }} diff --git a/src/locales/en_US.ts b/src/locales/en_US.ts index 4db51e02..14b59f6c 100644 --- a/src/locales/en_US.ts +++ b/src/locales/en_US.ts @@ -24,7 +24,7 @@ */ export default { - "lang.choose": "Choose lang", + "lang.choose": "Language", "lang.choose.placeholder": "Please select language", "theme.mode.choose": "Mode", "theme.mode.dark": "Dark mode", @@ -225,8 +225,9 @@ export default { "post.bind.yuque.postid": "Yuque ID", "post.bind.kms.postid": "KMS ID", "post.bind.conf.save": "Save", - "post.bind.conf.v081": "检测 v0.8.1 元数据并导入", - "post.bind.auto.":"未检测到ID,请手动输入文档根 ID ,然后再进行修复", + "post.bind.conf.v081": "Examine the v0.8.1 metadata and import it", + "post.bind.auto.error": "No ID detected, kindly input the document root ID manually, before proceeding with the repair.", + "post.bind.auto.empty": "This document has never been published, hence no repair is necessary", "post.bind.conf.cancel": "Cancel", "form.validate.name.required": "Please input name", "form.validate.name.length": "Length should be 0 to 1", @@ -607,7 +608,7 @@ export default { "post.bind.auto.tips": "The ID here is automatically saved by the publishing tool, if you are not clear about the principle, please do not modify it", "siyuan.config.setting": "Source settings", - "setting.blog.siyuan.apiurl": "Siyuan API address", + "setting.blog.siyuan.apiurl": "Siyuan API", "setting.blog.siyuan.apiurl.tip": "The API address of Siyuan Note, including ports, The default address of Siyuan API is: http://127.0.0.1;6806", "setting.blog.siyuan.password": "Siyuan Token", diff --git a/src/locales/zh_CN.ts b/src/locales/zh_CN.ts index baa864a1..fdce2e28 100644 --- a/src/locales/zh_CN.ts +++ b/src/locales/zh_CN.ts @@ -225,8 +225,9 @@ export default { "post.bind.yuque.postid": "语雀的ID", "post.bind.kms.postid": "KMS的ID", "post.bind.conf.save": "保存", - "post.bind.conf.v081": "Examine the v0.8.1 metadata and import it", + "post.bind.conf.v081": "检测 v0.8.1 元数据并导入", "post.bind.auto.error": "未检测到ID,请手动输入文档根 ID ,然后再进行修复", + "post.bind.auto.empty": "该文档未发布过,无需修复", "post.bind.conf.cancel": "取消", "form.validate.name.required": "请输入名称", "form.validate.name.length": "长度必须在0到1之间",