Skip to content

Commit

Permalink
feat: 新版挂件-适配Yuque配置
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Jul 28, 2023
1 parent f41d464 commit e348d89
Show file tree
Hide file tree
Showing 23 changed files with 770 additions and 152 deletions.
2 changes: 2 additions & 0 deletions components.d.ts
Expand Up @@ -13,6 +13,7 @@ declare module '@vue/runtime-core' {
ChangeLocal: typeof import('./src/components/set/preference/ChangeLocal.vue')['default']
CnblogsSetting: typeof import('./src/components/set/publish/singleplatform/metaweblog/CnblogsSetting.vue')['default']
CnblogsTest: typeof import('./src/components/test/CnblogsTest.vue')['default']
CommonBlogSetting: typeof import('./src/components/set/publish/singleplatform/CommonBlogSetting.vue')['default']
ElAlert: typeof import('element-plus/es')['ElAlert']
ElBadge: typeof import('element-plus/es')['ElBadge']
ElButton: typeof import('element-plus/es')['ElButton']
Expand Down Expand Up @@ -63,6 +64,7 @@ declare module '@vue/runtime-core' {
VitepressTest: typeof import('./src/components/test/VitepressTest.vue')['default']
WordpressSetting: typeof import('./src/components/set/publish/singleplatform/metaweblog/WordpressSetting.vue')['default']
WordpressTest: typeof import('./src/components/test/WordpressTest.vue')['default']
YuqueSetting: typeof import('./src/components/set/publish/singleplatform/commonblog/YuqueSetting.vue')['default']
YuqueTest: typeof import('./src/components/test/YuqueTest.vue')['default']
ZhihuTest: typeof import('./src/components/test/ZhihuTest.vue')['default']
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -57,12 +57,12 @@
"vue-i18n": "^9.2.2",
"vue-router": "^4.2.4",
"xmlbuilder2": "^3.1.1",
"zhi-blog-api": "^1.15.0",
"zhi-blog-api": "^1.16.0",
"zhi-common": "^1.11.5",
"zhi-device": "^2.3.0",
"zhi-fetch-middleware": "^0.1.19",
"zhi-lib-base": "^0.4.2",
"zhi-siyuan-api": "^1.27.1",
"zhi-siyuan-api": "^1.27.2",
"zhi-xmlrpc-middleware": "^0.2.19"
}
}
18 changes: 9 additions & 9 deletions pnpm-lock.yaml

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

114 changes: 114 additions & 0 deletions src/adaptors/api/base/commonblog/config/CommonblogConfig.ts
@@ -0,0 +1,114 @@
import { BlogConfig, PageTypeEnum } from "zhi-blog-api"
import { MetaweblogPlaceholder } from "~/src/adaptors/api/base/metaweblog/config/MetaweblogPlaceholder.ts"
import { CommonblogPlaceholder } from "~/src/adaptors/api/base/commonblog/config/CommonblogPlaceholder.ts"

/*
* 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.
*/
export class CommonblogConfig extends BlogConfig {
/**
* 首页
*/
public override home = ""

/**
* API地址
*/
public override apiUrl = ""
/**
* 用户名
*/
public override username = ""
/**
* 密码
*/
public override password = ""

/**
* 是否发布
*/
public override apiStatus = false

/**
* 博客ID
*/
public override blogid = ""

/**
* 博客名(API获取)
*/
public override blogName = ""

/**
* 文章别名key
*/
public override posidKey = ""

/**
* 文章预览链接
*/
public override previewUrl = ""

/**
* 文章类型
*/
public override pageType = PageTypeEnum.Markdown

/**
* token设置地址
*/
public override tokenSettingUrl = ""

/**
* 操作提示
*/
public override placeholder = {} as CommonblogPlaceholder

/**
* 代理地址
*/
public override middlewareUrl = ""

/**
* 是否启用用户名
*/
public usernameEnabled = false

constructor(home: string, apiUrl: string, username: string, password: string, middlewareUrl?: string) {
super()
this.home = home
this.apiUrl = apiUrl
this.username = username
this.password = password
this.apiStatus = false
this.blogid = ""
this.blogName = ""
this.posidKey = ""
this.previewUrl = ""
this.pageType = PageTypeEnum.Markdown
this.placeholder = new MetaweblogPlaceholder()
this.middlewareUrl = middlewareUrl
this.usernameEnabled = false
}
}
80 changes: 80 additions & 0 deletions src/adaptors/api/base/commonblog/config/CommonblogPlaceholder.ts
@@ -0,0 +1,80 @@
/*
* 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 { BlogPlaceholder } from "zhi-blog-api"

/**
* Metaweblog 操作提示
*/
export class CommonblogPlaceholder extends BlogPlaceholder {
/**
* 首页操作提示
*/
public override homePlaceholder = ""

/**
* API 地址操作提示
*/
public override apiUrlPlaceholder = ""

/**
* 用户名操作提示
*/
public override usernamePlaceholder = ""

/**
* 密码操作提示
*/
public override passwordPlaceholder = ""

/**
* API状态是否正常操作提示
*/
public override apiStatusPlaceholder = false

/**
* 博客名(API获取)操作提示
*/
public override blogNamePlaceholder = ""

/**
* 文章别名key操作提示
*/
public override posidKeyPlaceholder = ""
/**
* 文章预览链接操作提示
*/
public override previewUrlPlaceholder = ""
/**
* 文章类型操作提示
*/
public override pageTypePlaceholder = ""

constructor() {
super()
}
}

11 changes: 11 additions & 0 deletions src/adaptors/api/base/metaweblog/config/MetaweblogConfig.ts
Expand Up @@ -53,6 +53,11 @@ export class MetaweblogConfig extends BlogConfig {
*/
public override apiStatus = false

/**
* 博客ID
*/
public override blogid = ""

/**
* 博客名(API获取)
*/
Expand Down Expand Up @@ -83,13 +88,19 @@ export class MetaweblogConfig extends BlogConfig {
*/
public override middlewareUrl = ""

/**
* 是否展示Token设置地址
*/
public showTokenTip = false

constructor(home: string, apiUrl: string, username: string, password: string, middlewareUrl?: string) {
super()
this.home = home
this.apiUrl = apiUrl
this.username = username
this.password = password
this.apiStatus = false
this.blogid = ""
this.blogName = ""
this.posidKey = ""
this.previewUrl = ""
Expand Down
3 changes: 3 additions & 0 deletions src/adaptors/api/cnblogs/config/cnblogsConfig.ts
Expand Up @@ -43,8 +43,11 @@ class CnblogsConfig extends MetaweblogConfig {
*/
constructor(apiUrl: string, username: string, password: string, middlewareUrl?: string) {
super("https://www.cnblogs.com/[your-blog-name]", apiUrl, username, password, middlewareUrl)

this.tokenSettingUrl = "https://i.cnblogs.com/settings"
this.previewUrl = "/p/[postid].html"
this.pageType = PageTypeEnum.Markdown
this.showTokenTip = true
}
}

Expand Down
44 changes: 11 additions & 33 deletions src/adaptors/api/yuque/config/yuqueConfig.ts
Expand Up @@ -23,43 +23,21 @@
* questions.
*/

import { BlogConfig } from "zhi-blog-api"
import { PageTypeEnum, PasswordType } from "zhi-blog-api"
import { CommonblogConfig } from "~/src/adaptors/api/base/commonblog/config/CommonblogConfig.ts"

/**
* Yuque 配置
*/
class YuqueConfig extends BlogConfig {
/**
* API 地址
*/
public override apiUrl = ""

/**
* 用户名
*/
public override username = ""

/**
* 密码
*/
public override password = ""

/**
* 标识
*/
public override blogid = ""

/**
* 代理地址
*/
public override middlewareUrl = ""

constructor(apiUrl: string, username: string, password: string, middlewareUrl?: string) {
super()
this.apiUrl = apiUrl
this.username = username
this.password = password
this.middlewareUrl = middlewareUrl
class YuqueConfig extends CommonblogConfig {
constructor(username: string, password: string, middlewareUrl?: string) {
super("https://www.yuque.com/", "https://www.yuque.com/api/v2", username, password, middlewareUrl)

this.tokenSettingUrl = "https://www.yuque.com/settings/tokens"
this.previewUrl = "/[notebook]/[postid]"
this.pageType = PageTypeEnum.Markdown
this.usernameEnabled = true
this.passwordType = PasswordType.PasswordType_Token
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/adaptors/api/yuque/config/yuquePlaceHolder.ts
Expand Up @@ -23,11 +23,11 @@
* questions.
*/

import { BlogPlaceholder } from "zhi-blog-api"
import { CommonblogPlaceholder } from "~/src/adaptors/api/base/commonblog/config/CommonblogPlaceholder.ts"

/**
* Yuque 配置提示
*/
class YuquePlaceHolder extends BlogPlaceholder {}
class YuquePlaceHolder extends CommonblogPlaceholder {}

export { YuquePlaceHolder }

0 comments on commit e348d89

Please sign in to comment.