Skip to content

Commit

Permalink
feat: 支持细粒度控制发布属性-支持修改发布时间和更新时间
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Aug 16, 2023
1 parent 141732c commit f866652
Show file tree
Hide file tree
Showing 10 changed files with 200 additions and 75 deletions.
Binary file modified icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"zhi-github-middleware": "^0.2.8",
"zhi-lib-base": "^0.4.4",
"zhi-notion-markdown": "^0.1.4",
"zhi-siyuan-api": "^2.1.5",
"zhi-siyuan-api": "^2.1.6",
"zhi-xmlrpc-middleware": "^0.4.22"
}
}
100 changes: 50 additions & 50 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion src/adaptors/api/hexo/hexoYamlConverterAdaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class HexoYamlConverterAdaptor extends YamlConvertAdaptor {
yamlFormatObj.yamlObj.date = DateUtil.formatIsoToZh(post.dateCreated.toISOString(), true)

// updated
yamlFormatObj.yamlObj.updated = DateUtil.formatIsoToZh(new Date().toISOString(), true)
yamlFormatObj.yamlObj.updated = DateUtil.formatIsoToZh(post.dateUpdated.toISOString(), true)

// excerpt
yamlFormatObj.yamlObj.excerpt = post.shortDesc
Expand Down Expand Up @@ -108,7 +108,14 @@ export class HexoYamlConverterAdaptor extends YamlConvertAdaptor {

convertToAttr(post: Post, yamlFormatObj: YamlFormatObj, cfg?: CommonBlogConfig): Post {
this.logger.debug("开始转换YAML到Post", yamlFormatObj)

// 标题
post.title = yamlFormatObj.yamlObj.title

// 发布时间
post.dateCreated = DateUtil.convertStringToDate(yamlFormatObj.yamlObj.date)
post.dateUpdated = DateUtil.convertStringToDate(yamlFormatObj.yamlObj.updated)

// 其他属性
// ...

Expand Down
31 changes: 23 additions & 8 deletions src/components/publish/BatchPublishIndex.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
import { createAppLogger } from "~/src/utils/appLogger.ts"
import PublishTips from "~/src/components/publish/form/PublishTips.vue"
import PublishPlatform from "~/src/components/publish/form/PublishPlatform.vue"
import { markRaw, onMounted, reactive } from "vue"
import { markRaw, onMounted, reactive, ref } from "vue"
import { usePublish } from "~/src/composables/usePublish.ts"
import { useSiyuanApi } from "~/src/composables/useSiyuanApi.ts"
import { useVueI18n } from "~/src/composables/useVueI18n.ts"
import { ElMessage, ElMessageBox } from "element-plus"
import { StrUtil } from "zhi-common"
import { DateUtil, StrUtil } from "zhi-common"
import { pre } from "~/src/utils/import/pre.ts"
import { Delete } from "@element-plus/icons-vue"
import { BrowserUtil } from "zhi-device"
Expand All @@ -41,6 +41,7 @@ import { Post } from "zhi-blog-api"
import { IPublishCfg } from "~/src/types/IPublishCfg.ts"
import { PageEditMode } from "~/src/models/pageEditMode.ts"
import EditModeSelect from "~/src/components/publish/form/EditModeSelect.vue"
import PublishTime from "~/src/components/publish/form/PublishTime.vue"
const logger = createAppLogger("publisher-index")
Expand Down Expand Up @@ -210,6 +211,12 @@ const syncDynList = (selectedKeys: string[]) => {
logger.debug("syncDynList in batch publish")
}
const syncPublishTime = (val1: Date, val2: Date) => {
formData.siyuanPost.dateCreated = val1
formData.siyuanPost.dateUpdated = val2
logger.debug("syncPublishTime in batch publish")
}
const handleRefresh = () => {
BrowserUtil.reloadPage()
}
Expand Down Expand Up @@ -275,12 +282,20 @@ onMounted(async () => {
</div>
<el-divider border-style="dashed" />

<!--
----------------------------------------------------------------------
-->
<!-- 标签
<publish-tags />
-->
<div v-if="formData.editType === PageEditMode.EditMode_complex" class="complex-mode">
<!-- 别名字段 -->
<el-form-item :label="t('main.slug')">
<el-input v-model="formData.siyuanPost.wp_slug" :disabled="true" />
</el-form-item>

<!-- 标签 -->
<publish-tags />

<!-- 发布时间 -->
<publish-time v-model="formData.siyuanPost" @emitSyncPublishTime="syncPublishTime" />

<el-divider border-style="dashed" />
</div>
</div>
<!--
--------------------------------------
Expand Down
Loading

0 comments on commit f866652

Please sign in to comment.