Skip to content

Commit

Permalink
feat: #1076 #1077 优化发布配置、平台导入、插件商店使用体验 - 优化文章绑定
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Mar 7, 2024
1 parent bf2d8e2 commit 03f6793
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 17 deletions.
60 changes: 44 additions & 16 deletions src/components/set/preference/PostBind.vue
Expand Up @@ -34,6 +34,8 @@ 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 { Utils } from "~/src/utils/utils.ts"
const logger = createAppLogger("post-bind")
Expand All @@ -44,11 +46,12 @@ const { getPublishCfg } = usePublishConfig()
const { updateSetting } = usePublishSettingStore()
// datas
const id = (query.id ?? getWidgetId()) as string
const id = Utils.emptyOrDefault(query.id ?? getWidgetId(), getSiyuanWidgetId()) as string
const ruleFormRef = ref()
const ruleForm = reactive({})
const rules = reactive<FormRules>({})
const formData = reactive({
pageId: id,
dynamicConfigArray: [] as DynamicConfig[],
postIdMap: {} as any,
})
Expand Down Expand Up @@ -89,13 +92,13 @@ onMounted(async () => {
const publishCfg = await getPublishCfg()
const setting = publishCfg.setting
formData.dynamicConfigArray = publishCfg.dynamicConfigArray
const postMeta = ObjectUtil.getProperty(setting, id, {})
const postMeta = ObjectUtil.getProperty(setting, formData.pageId, {})
formData.dynamicConfigArray.forEach((item: DynamicConfig) => {
let postid = ""
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)) {
postid = ObjectUtil.getProperty(postMeta, posidKey)
}
formData.postIdMap[item.platformKey] = postid
Expand All @@ -104,22 +107,47 @@ onMounted(async () => {
</script>

<template>
<el-form label-width="85px" class="post-bind-form" ref="ruleFormRef" :model="ruleForm" :rules="rules" status-icon>
<div>
<el-alert class="top-tip" :title="t('post.bind.auto.tips')" type="error" :closable="false" />
<!-- 动态配置 -->
<el-form-item
v-for="(cfg, index) in formData.dynamicConfigArray"
:key="index"
:label="cfg.platformName"
v-show="cfg.isEnabled && cfg.isEnabled"
>
<el-input v-model="formData.postIdMap[cfg.platformKey]" />
</el-form-item>

<el-form-item>
<el-button type="primary" @click="submitForm(ruleFormRef)">{{ t("post.bind.conf.save") }} </el-button>
<el-input v-model="formData.pageId" placeholder="请输入需要修复的文档根 ID"/>
</el-form-item>
</el-form>
<el-divider border-style="dashed" />

<div v-if="StrUtil.isEmptyString(formData.pageId)">
<el-alert class="top-tip" :title="t('post.bind.auto.error')" type="warning" :closable="false" />
</div>
<el-form
v-else
label-width="85px"
class="post-bind-form"
ref="ruleFormRef"
:model="ruleForm"
:rules="rules"
status-icon
>
<el-alert
class="top-tip"
:title="'将为文章「' + formData.pageId + '」进行修复'"
type="warning"
:closable="false"
/>
<!-- 动态配置 -->
<el-form-item
v-for="(cfg, index) in formData.dynamicConfigArray"
:key="index"
:label="cfg.platformName"
v-show="cfg.isEnabled && cfg.isEnabled"
>
<el-input v-model="formData.postIdMap[cfg.platformKey]" />
</el-form-item>

<el-form-item>
<el-button type="primary" @click="submitForm(ruleFormRef)">{{ t("post.bind.conf.save") }}</el-button>
<el-button type="warning">{{ t("post.bind.conf.v081") }}</el-button>
</el-form-item>
</el-form>
</div>
</template>

<style scoped lang="stylus">
Expand Down
2 changes: 2 additions & 0 deletions src/locales/en_US.ts
Expand Up @@ -225,6 +225,8 @@ 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.cancel": "Cancel",
"form.validate.name.required": "Please input name",
"form.validate.name.length": "Length should be 0 to 1",
Expand Down
5 changes: 4 additions & 1 deletion src/locales/zh_CN.ts
Expand Up @@ -225,6 +225,8 @@ 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.auto.error": "未检测到ID,请手动输入文档根 ID ,然后再进行修复",
"post.bind.conf.cancel": "取消",
"form.validate.name.required": "请输入名称",
"form.validate.name.length": "长度必须在0到1之间",
Expand Down Expand Up @@ -655,5 +657,6 @@ export default {
"setting.blog.middlewareUrl.my.warn.tip":
"⚠️特别提醒:请求限制为 「10万次/天」、「1000次/10分钟」,频次为「所有人共享」,因此资源十分珍贵。为了大家的利益,请勿恶意请求,否则,我们会关闭此共享代理。",

"platform.new.platform": "检测到还有 [count] 个内置平台 [platform] 尚未导入,您可以使用平台导入批量导入,或者去插件商店自行添加。",
"platform.new.platform":
"检测到还有 [count] 个内置平台 [platform] 尚未导入,您可以使用平台导入批量导入,或者去插件商店自行添加。",
}

0 comments on commit 03f6793

Please sign in to comment.