Skip to content

Commit

Permalink
feat: #133 支持Github系列-Hexo适配
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Dec 1, 2022
1 parent 1f3ea54 commit ef417b4
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 18 deletions.
8 changes: 6 additions & 2 deletions src/components/publish/tab/setting/GithubSetting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const formData = reactive({
githubRepo: "",
githubToken: "",
defaultBranch: "main",
defaultPath: "docs/_posts/",
defaultPath: "docs/_posts",
msg: "auto published by sy-post-publisher",
author: "terwer",
email: "youweics@163.com",
Expand Down Expand Up @@ -252,7 +252,7 @@ const valiConf = async () => {
logUtil.logError(e)
}
// 验证通过刷新状态
// 刷新状态
setJSONConf(props.apiType, cfg)
if (!apiStatus.value) {
Expand Down Expand Up @@ -280,6 +280,8 @@ const saveConf = (hideTip?: boolean) => {
cfg.email = formData.email
cfg.previewUrl = formData.previewUrl
cfg.apiStatus = apiStatus.value
setJSONConf(props.apiType, cfg)
if (hideTip != true) {
Expand All @@ -304,6 +306,8 @@ const initConf = () => {
formData.author = conf.author
formData.email = conf.email
formData.previewUrl = conf.previewUrl
apiStatus.value = conf.apiStatus
}
}
Expand Down
19 changes: 9 additions & 10 deletions src/components/publish/tab/setting/MetaweblogSetting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,18 @@ const valiConf = async () => {
if (usersBlogs && usersBlogs.length > 0) {
const userBlog = usersBlogs[0]
cfg.apiStatus = true
apiStatus.value = true
cfg.blogName = userBlog.blogName
blogName.value = userBlog.blogName
// 验证通过刷新状态
setJSONConf(props.apiType, cfg)
cfg.apiStatus = true
apiStatus.value = true
} else {
cfg.apiStatus = false
apiStatus.value = false
// 验证失败刷新状态
setJSONConf(props.apiType, cfg)
}
// 刷新状态
setJSONConf(props.apiType, cfg)
} catch (e) {
console.error(e)
}
Expand All @@ -142,10 +139,11 @@ const saveConf = (hideTip?: boolean) => {
cfg.password = password.value
cfg.apiUrl = apiUrl.value
cfg.previewUrl = previewUrl.value
cfg.apiStatus = apiStatus.value
cfg.blogName = blogName.value
cfg.pageType = ptype.value
cfg.apiStatus = apiStatus.value
setJSONConf(props.apiType, cfg)
if (hideTip != true) {
Expand All @@ -168,9 +166,10 @@ const initConf = () => {
previewUrl.value = conf.previewUrl
username.value = conf.username
password.value = conf.password
apiStatus.value = conf.apiStatus
blogName.value = conf.blogName
ptype.value = conf.pageType
apiStatus.value = conf.apiStatus
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/locales/en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default {
"setting.blog.type.github.token.tip": "Github token, eg:ghp_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"setting.blog.type.github.token.gen": "Generate Github Personal Token",
"setting.blog.type.github.default.path": "Doc path",
"setting.blog.type.github.default.path.tip": "Doc path, eg:docs/_posts/",
"setting.blog.type.github.default.path.tip": "Doc path, eg:docs/_posts",
"setting.blog.type.github.msg": "Commit msg",
"setting.blog.type.github.msg.tip": "Commit msg, eg:auto published by sy-post-publisher",
"setting.blog.type.github.author": "Author",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default {
"setting.blog.type.github.default.branch": "默认分支",
"setting.blog.type.github.default.branch.tip": "默认分支(旧版仓库为master,新版仓库默认为main),例如:main",
"setting.blog.type.github.default.path": "存储目录",
"setting.blog.type.github.default.path.tip": "存储目录(相对于仓库根目录的相对路径,默认所有文章都发布在这里),例如:docs/_posts/",
"setting.blog.type.github.default.path.tip": "存储目录(相对于仓库根目录的相对路径,默认所有文章都发布在这里),例如:docs/_posts",
"setting.blog.type.github.msg": "提交信息",
"setting.blog.type.github.msg.tip": "提交信息,例如:auto published by sy-post-publisher",
"setting.blog.type.github.author": "作者",
Expand Down
3 changes: 2 additions & 1 deletion src/utils/platform/github/DynamicGCfg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export class DynamicGCfg extends GithubCfg {
this.defaultPath = "content/post"
break
case SubPlantformType.Github_Hexo:
this.defaultPath = "hexo"
this.defaultPath = "source/_posts"
this.previewUrl = "/[date]/[postid]/"
break
case SubPlantformType.Github_Jekyll:
this.defaultPath = "_posts"
Expand Down
2 changes: 1 addition & 1 deletion src/utils/platform/github/githubCfg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class GithubCfg implements IGithubCfg {
this.githubRepo = "";
this.githubToken = "";
this.defaultBranch = "main";
this.defaultPath = "docs/_posts/";
this.defaultPath = "docs/_posts";
this.defaultMsg = "auto published by sy-post-publisher";
this.author = "terwer";
this.email = "youweics@163.com"
Expand Down
4 changes: 2 additions & 2 deletions src/utils/platform/github/hexo/hexoCfg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export class HexoCfg extends GithubCfg{
constructor() {
super();

this.defaultPath = "hexo"
this.defaultPath = "source/_posts"
this.posidKey = POSTID_KEY_CONSTANTS.HEXO_POSTID_KEY
this.previewUrl = "/post/[postid].html"
this.previewUrl = "/[date]/[postid]/"
}
}

0 comments on commit ef417b4

Please sign in to comment.