Skip to content

Commit

Permalink
Merge pull request #847 from terwer/dev
Browse files Browse the repository at this point in the history
fix: #838 保存各个平台的标签和分类
  • Loading branch information
terwer committed Oct 31, 2023
2 parents 032d7c6 + 0328355 commit 35ea6d4
Show file tree
Hide file tree
Showing 55 changed files with 431 additions and 133 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,18 @@ Support features such as fast publishing, image bed management, platform expansi
> Recent Update: 🎉 Publish Tool new version `1.18.0` released.
- `1.18.0` brings compatibility with multiple platforms and overall enhanced user experience.
- Key changes in `1.18.0` include:
- A clever workaround has been introduced to support document updates in Notion.
- `1.18.0` introduces the following important changes:
- Added a clever workaround to support document updates in Notion.
- Added support for external link conversion.
- Added the ability to manually set file rules in the publishing configuration.
- Integrated menu enhancements to focus on core functionality.
- Enabled automatic mapping of document paths to categories.
- Enhanced the platform list with hover tooltips, improved display of platform names, and added new platform prompts.
- Strengthened validation for GitHub and Gitlab platforms.
- Fixed compatibility issues with CSDN error prompts, reducing unnecessary disruptions.
- Fixed the problem of AI tab not being openable.
- Resolved formatting issues when publishing HTML content.
- Fixed the issue of formulas not displaying correctly in HTML publishing.
- Ahem, in addition, the author secretly developed an import feature after version `1.14.0`. You can easily import predefined platforms through the `Settings` -> `Publish Settings` -> `Import Predefined Platforms` function 😄

> Platform Limitations:
Expand Down
12 changes: 11 additions & 1 deletion README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@
- `1.18.0` 新适配多个平台,全方位优化体验。
- `1.18.0` 主要有以下重要变更:
- 曲线救国,支持 Notion 更新文档。
- 新增 曲线救国,支持 Notion 更新文档
- 新增 支持外链转换
- 新增 发布配置中的文件规则支持手动设置
- 新增 整合菜单,专注核心功能
- 新增 支持文档路径自动映射为分类
- 新增 平台列表新增 hover 提示,优化列表平台名称展示、新增新平台提示
- 新增 强化GitHub平台和Gitlab平台的校验
- 修复 兼容 CSDN 错误提示,减少上传提示打扰
- 修复 AI 标签无法打开的问题
- 修复 html发布的时候会出现有些格式没有转化
- 修复 html发布时公式无法显示
- 咳咳,另外,在 `1.14.0` 版本之后,作者还悄悄开发了导入功能。您可以使用 `设置` -> `发布设置` -> `导入预定义平台` 功能快速导入内置平台 😄

> 平台限制说明
Expand Down
12 changes: 10 additions & 2 deletions src/adaptors/api/base/baseBlogApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* questions.
*/

import { BlogApi, BlogConfig, Post, YamlConvertAdaptor } from "zhi-blog-api"
import { BlogApi, BlogConfig, CategoryInfo, Post, TagInfo, YamlConvertAdaptor } from "zhi-blog-api"
import { PublisherAppInstance } from "~/src/publisherAppInstance.ts"
import { createAppLogger, ILogger } from "~/src/utils/appLogger.ts"
import { useProxy } from "~/src/composables/useProxy.ts"
Expand Down Expand Up @@ -56,7 +56,7 @@ export class BaseBlogApi extends BlogApi {
this.appInstance = appInstance
this.cfg = cfg
this.logger = createAppLogger("base-blog-api")
this.baseExtendApi = new BaseExtendApi(this)
this.baseExtendApi = new BaseExtendApi(this, cfg)

const { proxyFetch } = useProxy(cfg.middlewareUrl)
this.proxyFetch = proxyFetch
Expand All @@ -78,6 +78,14 @@ export class BaseBlogApi extends BlogApi {
return await this.baseExtendApi.preEditPost(post, id, publishCfg)
}

public async getCategories(keyword?: string): Promise<CategoryInfo[]> {
return this.baseExtendApi.getCategories(keyword)
}

public async getTags(): Promise<TagInfo[]> {
return this.baseExtendApi.getTags()
}

public async apiFormFetch(url: string, headers: any[], formData: FormData) {
const win = this.appInstance.win
const doFetch = win.require(`${this.appInstance.moduleBase}libs/zhi-formdata-fetch/index.cjs`)
Expand Down
4 changes: 0 additions & 4 deletions src/adaptors/api/base/github/commonGithubApiAdaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,6 @@ class CommonGithubApiAdaptor extends BaseBlogApi {
return true
}

public async getCategories(): Promise<CategoryInfo[]> {
return Promise.resolve([])
}

public async getCategoryTreeNodes(docPath: string): Promise<any[]> {
const res = await this.githubClient.getGithubPageTreeNode(docPath)
return res
Expand Down
4 changes: 0 additions & 4 deletions src/adaptors/api/base/gitlab/commonGitlabApiAdaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,6 @@ class CommonGitlabApiAdaptor extends BaseBlogApi {
return true
}

public async getCategories(): Promise<CategoryInfo[]> {
return Promise.resolve([])
}

public async getCategoryTreeNodes(docPath: string): Promise<any[]> {
const res = await this.gitlabClient.getRepositoryTree(docPath)
return res
Expand Down
4 changes: 2 additions & 2 deletions src/adaptors/api/cnblogs/useCnblogsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { Utils } from "~/src/utils/utils.ts"
import { CnblogsConfig } from "~/src/adaptors/api/cnblogs/cnblogsConfig.ts"
import { CnblogsApiAdaptor } from "~/src/adaptors/api/cnblogs/cnblogsApiAdaptor.ts"
import { PublisherAppInstance } from "~/src/publisherAppInstance.ts"
import { useSettingStore } from "~/src/stores/useSettingStore.ts"
import { usePublishSettingStore } from "~/src/stores/usePublishSettingStore.ts"
import { JsonUtil, ObjectUtil, StrUtil } from "zhi-common"
import { getDynPostidKey } from "~/src/platforms/dynamicConfig.ts"
import { CategoryTypeEnum } from "zhi-blog-api"
Expand Down Expand Up @@ -58,7 +58,7 @@ export const useCnblogsApi = async (key?: string, newCfg?: CnblogsConfig) => {
cfg = newCfg
} else {
// 从配置中获取数据
const { getSetting } = useSettingStore()
const { getSetting } = usePublishSettingStore()
const setting = await getSetting()
cfg = JsonUtil.safeParse<CnblogsConfig>(setting[key], {} as CnblogsConfig)
// 如果配置为空,则使用默认的环境变量值,并记录日志
Expand Down
4 changes: 2 additions & 2 deletions src/adaptors/api/gitlab-hexo/useGitlabhexoApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import { createAppLogger } from "~/src/utils/appLogger.ts"
import { PublisherAppInstance } from "~/src/publisherAppInstance.ts"
import { useSettingStore } from "~/src/stores/useSettingStore.ts"
import { usePublishSettingStore } from "~/src/stores/usePublishSettingStore.ts"
import { JsonUtil, ObjectUtil, StrUtil } from "zhi-common"
import { Utils } from "~/src/utils/utils.ts"
import { getDynPostidKey } from "~/src/platforms/dynamicConfig.ts"
Expand All @@ -50,7 +50,7 @@ const useGitlabhexoApi = async (key: string, newCfg?: GitlabhexoConfig) => {
cfg = newCfg
} else {
// 从配置中获取数据
const { getSetting } = useSettingStore()
const { getSetting } = usePublishSettingStore()
const setting = await getSetting()
cfg = JsonUtil.safeParse<GitlabhexoConfig>(setting[key], {} as GitlabhexoConfig)

Expand Down
4 changes: 2 additions & 2 deletions src/adaptors/api/gitlab-hugo/useGitlabhugoApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import { createAppLogger } from "~/src/utils/appLogger.ts"
import { PublisherAppInstance } from "~/src/publisherAppInstance.ts"
import { useSettingStore } from "~/src/stores/useSettingStore.ts"
import { usePublishSettingStore } from "~/src/stores/usePublishSettingStore.ts"
import { JsonUtil, ObjectUtil, StrUtil } from "zhi-common"
import { Utils } from "~/src/utils/utils.ts"
import { getDynPostidKey } from "~/src/platforms/dynamicConfig.ts"
Expand All @@ -50,7 +50,7 @@ const useGitlabhugoApi = async (key: string, newCfg?: GitlabhugoConfig) => {
cfg = newCfg
} else {
// 从配置中获取数据
const { getSetting } = useSettingStore()
const { getSetting } = usePublishSettingStore()
const setting = await getSetting()
cfg = JsonUtil.safeParse<GitlabhugoConfig>(setting[key], {} as GitlabhugoConfig)

Expand Down
4 changes: 2 additions & 2 deletions src/adaptors/api/gitlab-jekyll/useGitlabjekyllApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import { createAppLogger } from "~/src/utils/appLogger.ts"
import { PublisherAppInstance } from "~/src/publisherAppInstance.ts"
import { useSettingStore } from "~/src/stores/useSettingStore.ts"
import { usePublishSettingStore } from "~/src/stores/usePublishSettingStore.ts"
import { JsonUtil, ObjectUtil, StrUtil } from "zhi-common"
import { Utils } from "~/src/utils/utils.ts"
import { getDynPostidKey } from "~/src/platforms/dynamicConfig.ts"
Expand All @@ -50,7 +50,7 @@ const useGitlabjekyllApi = async (key: string, newCfg?: GitlabjekyllConfig) => {
cfg = newCfg
} else {
// 从配置中获取数据
const { getSetting } = useSettingStore()
const { getSetting } = usePublishSettingStore()
const setting = await getSetting()
cfg = JsonUtil.safeParse<GitlabjekyllConfig>(setting[key], {} as GitlabjekyllConfig)

Expand Down
4 changes: 2 additions & 2 deletions src/adaptors/api/gitlab-vitepress/useGitlabvitepressApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import { createAppLogger } from "~/src/utils/appLogger.ts"
import { PublisherAppInstance } from "~/src/publisherAppInstance.ts"
import { useSettingStore } from "~/src/stores/useSettingStore.ts"
import { usePublishSettingStore } from "~/src/stores/usePublishSettingStore.ts"
import { JsonUtil, ObjectUtil, StrUtil } from "zhi-common"
import { Utils } from "~/src/utils/utils.ts"
import { getDynPostidKey } from "~/src/platforms/dynamicConfig.ts"
Expand All @@ -50,7 +50,7 @@ const useGitlabvitepressApi = async (key: string, newCfg?: GitlabvitepressConfig
cfg = newCfg
} else {
// 从配置中获取数据
const { getSetting } = useSettingStore()
const { getSetting } = usePublishSettingStore()
const setting = await getSetting()
cfg = JsonUtil.safeParse<GitlabvitepressConfig>(setting[key], {} as GitlabvitepressConfig)

Expand Down
4 changes: 2 additions & 2 deletions src/adaptors/api/gitlab-vuepress/useGitlabvuepressApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import { createAppLogger } from "~/src/utils/appLogger.ts"
import { PublisherAppInstance } from "~/src/publisherAppInstance.ts"
import { useSettingStore } from "~/src/stores/useSettingStore.ts"
import { usePublishSettingStore } from "~/src/stores/usePublishSettingStore.ts"
import { JsonUtil, ObjectUtil, StrUtil } from "zhi-common"
import { Utils } from "~/src/utils/utils.ts"
import { getDynPostidKey } from "~/src/platforms/dynamicConfig.ts"
Expand All @@ -50,7 +50,7 @@ const useGitlabvuepressApi = async (key: string, newCfg?: GitlabvuepressConfig)
cfg = newCfg
} else {
// 从配置中获取数据
const { getSetting } = useSettingStore()
const { getSetting } = usePublishSettingStore()
const setting = await getSetting()
cfg = JsonUtil.safeParse<GitlabvuepressConfig>(setting[key], {} as GitlabvuepressConfig)

Expand Down
4 changes: 2 additions & 2 deletions src/adaptors/api/gitlab-vuepress2/useGitlabvuepress2Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import { createAppLogger } from "~/src/utils/appLogger.ts"
import { PublisherAppInstance } from "~/src/publisherAppInstance.ts"
import { useSettingStore } from "~/src/stores/useSettingStore.ts"
import { usePublishSettingStore } from "~/src/stores/usePublishSettingStore.ts"
import { JsonUtil, ObjectUtil, StrUtil } from "zhi-common"
import { Utils } from "~/src/utils/utils.ts"
import { getDynPostidKey } from "~/src/platforms/dynamicConfig.ts"
Expand All @@ -50,7 +50,7 @@ const useGitlabvuepress2Api = async (key: string, newCfg?: Gitlabvuepress2Config
cfg = newCfg
} else {
// 从配置中获取数据
const { getSetting } = useSettingStore()
const { getSetting } = usePublishSettingStore()
const setting = await getSetting()
cfg = JsonUtil.safeParse<Gitlabvuepress2Config>(setting[key], {} as Gitlabvuepress2Config)

Expand Down
4 changes: 2 additions & 2 deletions src/adaptors/api/halo/useHaloApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import { HaloConfig } from "~/src/adaptors/api/halo/HaloConfig.ts"
import { createAppLogger } from "~/src/utils/appLogger.ts"
import { PublisherAppInstance } from "~/src/publisherAppInstance.ts"
import { useSettingStore } from "~/src/stores/useSettingStore.ts"
import { usePublishSettingStore } from "~/src/stores/usePublishSettingStore.ts"
import { JsonUtil, ObjectUtil, StrUtil } from "zhi-common"
import { Utils } from "~/src/utils/utils.ts"
import { getDynPostidKey } from "~/src/platforms/dynamicConfig.ts"
Expand All @@ -49,7 +49,7 @@ const useHaloApi = async (key: string, newCfg?: HaloConfig) => {
cfg = newCfg
} else {
// 从配置中获取数据
const { getSetting } = useSettingStore()
const { getSetting } = usePublishSettingStore()
const setting = await getSetting()
cfg = JsonUtil.safeParse<HaloConfig>(setting[key], {} as HaloConfig)

Expand Down
4 changes: 2 additions & 2 deletions src/adaptors/api/hexo/useHexoApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import { createAppLogger } from "~/src/utils/appLogger.ts"
import { PublisherAppInstance } from "~/src/publisherAppInstance.ts"
import { useSettingStore } from "~/src/stores/useSettingStore.ts"
import { usePublishSettingStore } from "~/src/stores/usePublishSettingStore.ts"
import { JsonUtil, ObjectUtil, StrUtil } from "zhi-common"
import { Utils } from "~/src/utils/utils.ts"
import { getDynPostidKey } from "~/src/platforms/dynamicConfig.ts"
Expand All @@ -50,7 +50,7 @@ const useHexoApi = async (key: string, newCfg?: HexoConfig) => {
cfg = newCfg
} else {
// 从配置中获取数据
const { getSetting } = useSettingStore()
const { getSetting } = usePublishSettingStore()
const setting = await getSetting()
cfg = JsonUtil.safeParse<HexoConfig>(setting[key], {} as HexoConfig)

Expand Down
4 changes: 2 additions & 2 deletions src/adaptors/api/hugo/useHugoApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import { createAppLogger } from "~/src/utils/appLogger.ts"
import { PublisherAppInstance } from "~/src/publisherAppInstance.ts"
import { useSettingStore } from "~/src/stores/useSettingStore.ts"
import { usePublishSettingStore } from "~/src/stores/usePublishSettingStore.ts"
import { JsonUtil, ObjectUtil, StrUtil } from "zhi-common"
import { Utils } from "~/src/utils/utils.ts"
import { getDynPostidKey } from "~/src/platforms/dynamicConfig.ts"
Expand All @@ -50,7 +50,7 @@ const useHugoApi = async (key: string, newCfg?: HugoConfig) => {
cfg = newCfg
} else {
// 从配置中获取数据
const { getSetting } = useSettingStore()
const { getSetting } = usePublishSettingStore()
const setting = await getSetting()
cfg = JsonUtil.safeParse<HugoConfig>(setting[key], {} as HugoConfig)

Expand Down
4 changes: 2 additions & 2 deletions src/adaptors/api/jekyll/useJekyllApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import { createAppLogger } from "~/src/utils/appLogger.ts"
import { PublisherAppInstance } from "~/src/publisherAppInstance.ts"
import { useSettingStore } from "~/src/stores/useSettingStore.ts"
import { usePublishSettingStore } from "~/src/stores/usePublishSettingStore.ts"
import { JsonUtil, ObjectUtil, StrUtil } from "zhi-common"
import { Utils } from "~/src/utils/utils.ts"
import { getDynPostidKey } from "~/src/platforms/dynamicConfig.ts"
Expand All @@ -50,7 +50,7 @@ const useJekyllApi = async (key: string, newCfg?: JekyllConfig) => {
cfg = newCfg
} else {
// 从配置中获取数据
const { getSetting } = useSettingStore()
const { getSetting } = usePublishSettingStore()
const setting = await getSetting()
cfg = JsonUtil.safeParse<JekyllConfig>(setting[key], {} as JekyllConfig)

Expand Down
4 changes: 2 additions & 2 deletions src/adaptors/api/metaweblog/useMetaweblogApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import { MetaweblogConfig } from "~/src/adaptors/api/base/metaweblog/metaweblogConfig.ts"
import { createAppLogger } from "~/src/utils/appLogger.ts"
import { PublisherAppInstance } from "~/src/publisherAppInstance.ts"
import { useSettingStore } from "~/src/stores/useSettingStore.ts"
import { usePublishSettingStore } from "~/src/stores/usePublishSettingStore.ts"
import { JsonUtil, ObjectUtil, StrUtil } from "zhi-common"
import { Utils } from "~/src/utils/utils.ts"
import { getDynPostidKey } from "~/src/platforms/dynamicConfig.ts"
Expand Down Expand Up @@ -58,7 +58,7 @@ export const useMetaweblogApi = async (key?: string, newCfg?: MetaweblogConfig)
cfg = newCfg
} else {
// 从配置中获取数据
const { getSetting } = useSettingStore()
const { getSetting } = usePublishSettingStore()
const setting = await getSetting()
cfg = JsonUtil.safeParse<MetaweblogConfig>(setting[key], {} as MetaweblogConfig)
// 如果配置为空,则使用默认的环境变量值,并记录日志
Expand Down
4 changes: 2 additions & 2 deletions src/adaptors/api/notion/notionApiAdaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { NotionConfig } from "~/src/adaptors/api/notion/notionConfig.ts"
import { createAppLogger } from "~/src/utils/appLogger.ts"
import { ObjectUtil } from "zhi-common"
import { NotionMarkdownConverter } from "zhi-notion-markdown"
import { useSettingStore } from "~/src/stores/useSettingStore.ts"
import { usePublishSettingStore } from "~/src/stores/usePublishSettingStore.ts"

/**
* Notion API 适配器
Expand Down Expand Up @@ -69,7 +69,7 @@ class NotionApiAdaptor extends BaseBlogApi {
// ================================
// 下面这一段是更新postid,需要注意适配
// 写入属性到配置
const { getSetting, updateSetting } = useSettingStore()
const { getSetting, updateSetting } = usePublishSettingStore()
const setting = await getSetting()
const posidKey = this.cfg.posidKey
const id = post.originalId
Expand Down
4 changes: 2 additions & 2 deletions src/adaptors/api/notion/useNotionApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { createAppLogger } from "~/src/utils/appLogger.ts"
import { PublisherAppInstance } from "~/src/publisherAppInstance.ts"
import { Utils } from "~/src/utils/utils.ts"
import { NotionConfig } from "~/src/adaptors/api/notion/notionConfig.ts"
import { useSettingStore } from "~/src/stores/useSettingStore.ts"
import { usePublishSettingStore } from "~/src/stores/usePublishSettingStore.ts"
import { JsonUtil, ObjectUtil, StrUtil } from "zhi-common"
import { getDynPostidKey } from "~/src/platforms/dynamicConfig.ts"
import { NotionApiAdaptor } from "~/src/adaptors/api/notion/notionApiAdaptor.ts"
Expand All @@ -49,7 +49,7 @@ const useNotionApi = async (key: string, newCfg?: NotionConfig) => {
cfg = newCfg
} else {
// 从配置中获取数据
const { getSetting } = useSettingStore()
const { getSetting } = usePublishSettingStore()
const setting = await getSetting()
cfg = JsonUtil.safeParse<NotionConfig>(setting[key], {} as NotionConfig)

Expand Down
4 changes: 2 additions & 2 deletions src/adaptors/api/typecho/useTypechoApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import { createAppLogger } from "~/src/utils/appLogger.ts"
import { PublisherAppInstance } from "~/src/publisherAppInstance.ts"
import { Utils } from "~/src/utils/utils.ts"
import { useSettingStore } from "~/src/stores/useSettingStore.ts"
import { usePublishSettingStore } from "~/src/stores/usePublishSettingStore.ts"
import { TypechoConfig } from "~/src/adaptors/api/typecho/typechoConfig.ts"
import { JsonUtil, ObjectUtil, StrUtil } from "zhi-common"
import { getDynPostidKey } from "~/src/platforms/dynamicConfig.ts"
Expand Down Expand Up @@ -58,7 +58,7 @@ export const useTypechoApi = async (key?: string, newCfg?: TypechoConfig) => {
cfg = newCfg
} else {
// 从配置中获取数据
const { getSetting } = useSettingStore()
const { getSetting } = usePublishSettingStore()
const setting = await getSetting()
cfg = JsonUtil.safeParse<TypechoConfig>(setting[key], {} as TypechoConfig)
// 如果配置为空,则使用默认的环境变量值,并记录日志
Expand Down
4 changes: 2 additions & 2 deletions src/adaptors/api/vitepress/useVitepressApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import { createAppLogger } from "~/src/utils/appLogger.ts"
import { PublisherAppInstance } from "~/src/publisherAppInstance.ts"
import { useSettingStore } from "~/src/stores/useSettingStore.ts"
import { usePublishSettingStore } from "~/src/stores/usePublishSettingStore.ts"
import { JsonUtil, ObjectUtil, StrUtil } from "zhi-common"
import { Utils } from "~/src/utils/utils.ts"
import { getDynPostidKey } from "~/src/platforms/dynamicConfig.ts"
Expand All @@ -50,7 +50,7 @@ const useVitepressApi = async (key: string, newCfg?: VitepressConfig) => {
cfg = newCfg
} else {
// 从配置中获取数据
const { getSetting } = useSettingStore()
const { getSetting } = usePublishSettingStore()
const setting = await getSetting()
cfg = JsonUtil.safeParse<VitepressConfig>(setting[key], {} as VitepressConfig)

Expand Down
Loading

0 comments on commit 35ea6d4

Please sign in to comment.