Skip to content

Commit

Permalink
fix: 对不支持标签的平台隐藏标签设置
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Sep 5, 2023
1 parent 8267742 commit 7ecfb23
Show file tree
Hide file tree
Showing 36 changed files with 464 additions and 55 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ Publish articles from siyuan-note to platforms such as Yuque, Notion, Cnblogs, W

Support features such as fast publishing, image bed management, platform expansion, smart labels, etc.

🎉 Version `1.12.0` of Publish Tool with the first CSDN support is now available!
> 🎉 The first version `1.13.0` of Publish Tool that supports WeChat Official Accounts released!
**Facing issues or have suggestions? Please join QQ group `895063267` for discussion. Alternatively, refer to the online documentation below:**
> Platform Limitations:
- **WeChat Official Accounts**: Publishing Tool now supports posting articles to the WeChat Official Accounts draft box in version `1.13.0` and beyond. However, due to limitations on the WeChat platform in Electron, normal login operations are not possible. Therefore, you will need to visit `https://mp.weixin.qq.com/` yourself, complete the login, copy the cookie, and then paste it into the configuration options.
- **Notion**: Since Notion is block-based, not a whole document, it is constrained by technology and does not support updates. To update, you can only delete and then repost it.

> [Click here](https://blog.terwer.space/s/20230810132040-nn4q7vs) to view the latest help documentation.
Expand Down
9 changes: 8 additions & 1 deletion README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@

将思源笔记的文章发布到语雀、Notion、Cnblogs、WordPress、Typecho、Hexo、知乎 等平台,支持极速发布、图床管理、平台扩展、智能标签等特色功能。

> 🎉 发布工具首个支持CSDN的版本 `1.12.0` 发布!
> 🎉 发布工具首个支持微信公众号的版本 `1.13.0` 发布!
> 平台限制说明
- 所有平台:发布工具每次都会获取思源笔记最新编辑的正文进行覆盖发布。每次发布都会覆盖正文,每次发布都会覆盖正文,每次发布都会覆盖正文。因此,请勿在平台自行修改正文。
- **微信公众号**:目前,发布工具在 `1.13.0+` 已经支持发布文章到微信公众号草稿箱。但是由于微信平台在 Electron 上有限制,无法正常进行登录操作。因此,只能自己访问 `https://mp.weixin.qq.com/` ,登录完成之后,复制cookie然后粘贴到配置选项。
- **Notion**: 由于Notion是基于块的,不是整篇文档,受限于技术,notion不支持更新。如需更新,目前只能删除后重新发布。


**遇到问题或者需求建议?请加QQ群 `895063267` 讨论。或者查看下面的在线文档:**

Expand Down
3 changes: 3 additions & 0 deletions src/adaptors/api/base/github/commonGithubConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ class CommonGithubConfig extends CommonBlogConfig {
this.passwordType = PasswordType.PasswordType_Token
this.tokenSettingUrl = "https://github.com/settings/tokens"
this.showTokenTip = true
this.tagEnabled = true
this.cateEnabled = true
this.knowledgeSpaceEnabled = false

this.githubRepo = githubRepo
this.githubBranch = githubBranch
Expand Down
2 changes: 1 addition & 1 deletion src/adaptors/api/base/metaweblog/metaweblogConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class MetaweblogConfig extends CommonBlogConfig {
this.usernameEnabled = true
this.showTokenTip = false
this.allowPreviewUrlChange = true
this.allowPreviewUrlChange = true
this.tagEnabled = true
this.cateEnabled = true
this.categoryType = CategoryTypeEnum.CategoryType_Multi
this.allowCateChange = true
Expand Down
1 change: 1 addition & 0 deletions src/adaptors/api/cnblogs/cnblogsConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class CnblogsConfig extends MetaweblogConfig {
this.passwordType = PasswordType.PasswordType_Token
this.showTokenTip = true
this.allowPreviewUrlChange = true
this.tagEnabled = true
this.cateEnabled = true
this.categoryType = CategoryTypeEnum.CategoryType_Multi
this.allowCateChange = true
Expand Down
1 change: 1 addition & 0 deletions src/adaptors/api/cnblogs/useCnblogsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export const useCnblogsApi = async (key?: string, newCfg?: CnblogsConfig) => {
}

// 博客园使用多选分类
cfg.tagEnabled = true
cfg.cateEnabled = true
cfg.categoryType = CategoryTypeEnum.CategoryType_Multi
cfg.allowCateChange = true
Expand Down
1 change: 1 addition & 0 deletions src/adaptors/api/gitlab-hexo/gitlabhexoConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class GitlabhexoConfig extends HexoConfig {
this.pageType = PageTypeEnum.Markdown
this.passwordType = PasswordType.PasswordType_Token
this.allowPreviewUrlChange = false
this.tagEnabled = true
this.cateEnabled = true
this.allowCateChange = true
this.categoryType = CategoryTypeEnum.CategoryType_Multi
Expand Down
2 changes: 2 additions & 0 deletions src/adaptors/api/gitlab-hexo/useGitlabhexoApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ const useGitlabhexoApi = async (key: string, newCfg?: GitlabhexoConfig) => {
}
}

// 标签
cfg.tagEnabled = true
// 分类
cfg.cateEnabled = true
cfg.allowCateChange = true
Expand Down
1 change: 1 addition & 0 deletions src/adaptors/api/hexo/hexoConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class HexoConfig extends CommonGithubConfig {
this.pageType = PageTypeEnum.Markdown
this.passwordType = PasswordType.PasswordType_Token
this.allowPreviewUrlChange = false
this.tagEnabled = true
this.cateEnabled = true
this.allowCateChange = true
this.categoryType = CategoryTypeEnum.CategoryType_Multi
Expand Down
2 changes: 2 additions & 0 deletions src/adaptors/api/hexo/useHexoApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ const useHexoApi = async (key: string, newCfg?: HexoConfig) => {
}
}

// 标签
cfg.tagEnabled = true
// 分类
cfg.cateEnabled = true
cfg.allowCateChange = true
Expand Down
1 change: 1 addition & 0 deletions src/adaptors/api/metaweblog/useMetaweblogApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export const useMetaweblogApi = async (key?: string, newCfg?: MetaweblogConfig)
}
}

cfg.tagEnabled = true
// Metaweblog 默认支持多选分类
cfg.cateEnabled = true
cfg.categoryType = CategoryTypeEnum.CategoryType_Multi
Expand Down
1 change: 1 addition & 0 deletions src/adaptors/api/notion/notionConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class NotionConfig extends CommonBlogConfig {
this.pageType = PageTypeEnum.Markdown
this.passwordType = PasswordType.PasswordType_Token
this.allowPreviewUrlChange = false
this.tagEnabled = false
this.cateEnabled = false
this.knowledgeSpaceEnabled = true
this.knowledgeSpaceTitle = "根页面"
Expand Down
2 changes: 2 additions & 0 deletions src/adaptors/api/notion/useNotionApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ const useNotionApi = async (key: string, newCfg?: NotionConfig) => {
}
}

// 标签
cfg.tagEnabled = false
// Notion 使用单选分类作为知识空间
cfg.cateEnabled = false
cfg.knowledgeSpaceEnabled = true
Expand Down
1 change: 1 addition & 0 deletions src/adaptors/api/typecho/typechoConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class TypechoConfig extends MetaweblogConfig {
this.pageType = PageTypeEnum.Html
this.showTokenTip = false
this.allowPreviewUrlChange = true
this.tagEnabled = true
this.cateEnabled = true
this.categoryType = CategoryTypeEnum.CategoryType_Multi
this.allowCateChange = true
Expand Down
2 changes: 2 additions & 0 deletions src/adaptors/api/typecho/useTypechoApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export const useTypechoApi = async (key?: string, newCfg?: TypechoConfig) => {
}
}

// 标签
cfg.tagEnabled = true
// Typecho使用多选分类
cfg.cateEnabled = true
cfg.categoryType = CategoryTypeEnum.CategoryType_Multi
Expand Down
2 changes: 2 additions & 0 deletions src/adaptors/api/wordpress/useWordpressApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export const useWordpressApi = async (key?: string, newCfg?: WordpressConfig) =>
}
}

// 标签
cfg.tagEnabled = true
// WordPress使用多选分类
cfg.cateEnabled = true
cfg.categoryType = CategoryTypeEnum.CategoryType_Multi
Expand Down
1 change: 1 addition & 0 deletions src/adaptors/api/wordpress/wordpressConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class WordpressConfig extends MetaweblogConfig {
this.usernameEnabled = true
this.showTokenTip = false
this.allowPreviewUrlChange = true
this.tagEnabled = true
this.cateEnabled = true
this.categoryType = CategoryTypeEnum.CategoryType_Multi
this.allowCateChange = true
Expand Down
2 changes: 2 additions & 0 deletions src/adaptors/api/yuque/useYuqueApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ const useYuqueApi = async (key: string, newCfg?: YuqueConfig) => {
}
}

// 标签
cfg.tagEnabled = false
// Yuque 使用单选分类作为知识空间
cfg.cateEnabled = false
cfg.knowledgeSpaceEnabled = true
Expand Down
1 change: 1 addition & 0 deletions src/adaptors/api/yuque/yuqueConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class YuqueConfig extends CommonBlogConfig {
this.usernameEnabled = true
this.passwordType = PasswordType.PasswordType_Token
this.allowPreviewUrlChange = false
this.tagEnabled = false
this.cateEnabled = false
this.knowledgeSpaceEnabled = true
this.knowledgeSpaceTitle = "知识库"
Expand Down
5 changes: 2 additions & 3 deletions src/adaptors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* questions.
*/

import { BlogAdaptor, WebAdaptor, YamlConvertAdaptor } from "zhi-blog-api"
import { BlogAdaptor, BlogConfig, WebAdaptor, YamlConvertAdaptor } from "zhi-blog-api"
import { getSubPlatformTypeByKey, SubPlatformType } from "~/src/platforms/dynamicConfig.ts"
import { useCnblogsApi } from "~/src/adaptors/api/cnblogs/useCnblogsApi.ts"
import { createAppLogger } from "~/src/utils/appLogger.ts"
Expand All @@ -35,7 +35,6 @@ import { useSiyuanApi } from "~/src/composables/useSiyuanApi.ts"
import { useMetaweblogApi } from "~/src/adaptors/api/metaweblog/useMetaweblogApi.ts"
import { useNotionApi } from "~/src/adaptors/api/notion/useNotionApi.ts"
import { useHexoApi } from "~/src/adaptors/api/hexo/useHexoApi.ts"
import { CommonBlogConfig } from "~/src/adaptors/api/base/commonBlogConfig.ts"
import { useGitlabhexoApi } from "~/src/adaptors/api/gitlab-hexo/useGitlabhexoApi.ts"
import { useCsdnWeb } from "~/src/adaptors/web/csdn/useCsdnWeb.ts"
import { useWechatWeb } from "~/src/adaptors/web/wechat/useWechatWeb.ts"
Expand All @@ -55,7 +54,7 @@ class Adaptors {
* @param key
* @param newCfg
*/
public static async getCfg(key: string, newCfg?: any): Promise<CommonBlogConfig> {
public static async getCfg(key: string, newCfg?: any): Promise<BlogConfig> {
let conf = null
const type: SubPlatformType = getSubPlatformTypeByKey(key)

Expand Down
3 changes: 3 additions & 0 deletions src/adaptors/web/base/commonWebConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ export class CommonWebConfig extends WebConfig {
this.allowPreviewUrlChange = true
this.showTokenTip = false
this.yamlLinkEnabled = true
this.tagEnabled = false
this.cateEnabled = false
this.knowledgeSpaceEnabled = false
this.placeholder = new CommonWebPlaceholder()
}
}
1 change: 1 addition & 0 deletions src/adaptors/web/csdn/csdnConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class CsdnConfig extends CommonWebConfig {
this.pageType = PageTypeEnum.Markdown
this.usernameEnabled = false
this.passwordType = PasswordType.PasswordType_Cookie
this.tagEnabled = true
this.cateEnabled = true
this.categoryType = CategoryTypeEnum.CategoryType_Multi
this.allowCateChange = true
Expand Down
2 changes: 2 additions & 0 deletions src/adaptors/web/csdn/useCsdnWeb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ const useCsdnWeb = async (key?: string, newCfg?: CsdnConfig) => {
}
}

// 标签
cfg.tagEnabled = true
// CSDN使用多选分类作为专栏
cfg.cateEnabled = true
cfg.categoryType = CategoryTypeEnum.CategoryType_Multi
Expand Down
5 changes: 5 additions & 0 deletions src/adaptors/web/wechat/useWechatWeb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ const useWechatWeb = async (key?: string, newCfg?: WechatConfig) => {
}
}

// 微信公众号不支持标签、分类、知识空间
cfg.tagEnabled = false
cfg.cateEnabled = false
cfg.knowledgeSpaceEnabled = false

const webApi = new WechatWebAdaptor(appInstance, cfg)
return {
cfg,
Expand Down
12 changes: 11 additions & 1 deletion src/adaptors/web/wechat/wechatConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,22 @@
*/

import { CommonWebConfig } from "~/src/adaptors/web/base/commonWebConfig.ts"
import { PageTypeEnum, PasswordType } from "zhi-blog-api"

/**
* 微信公众号配置
*/
export class WechatConfig extends CommonWebConfig {
constructor(username: string, password: string, middlewareUrl?: string) {
super("", "", username, password, middlewareUrl)
super("https://mp.weixin.qq.com", "https://mp.weixin.qq.com/cgi-bin/appmsg", username, password, middlewareUrl)

this.previewUrl =
"/cgi-bin/appmsg?t=media/appmsg_edit&action=edit&type=77&appmsgid=[postid]&token=[token]&lang=zh_CN"
this.pageType = PageTypeEnum.Html
this.passwordType = PasswordType.PasswordType_Cookie
this.usernameEnabled = false
this.tagEnabled = false
this.cateEnabled = false
this.knowledgeSpaceEnabled = false
}
}
30 changes: 30 additions & 0 deletions src/adaptors/web/wechat/wechatPlaceholder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2023, Terwer . All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Terwer designates this
* particular file as subject to the "Classpath" exception as provided
* by Terwer in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com
* or visit www.terwer.space if you need additional information or have any
* questions.
*/

import { CommonWebPlaceholder } from "~/src/adaptors/web/base/commonWebPlaceholder.ts"

class WechatPlaceholder extends CommonWebPlaceholder {}

export { WechatPlaceholder }
Loading

0 comments on commit 7ecfb23

Please sign in to comment.