Skip to content

Commit

Permalink
fix: 修复Github平台发布状态bug
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Jan 7, 2023
1 parent 511a9f5 commit 45b9264
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -10,7 +10,7 @@
![](https://img.shields.io/badge/license-GPL-blue.svg?style=popout-square)

[![](https://img.shields.io/badge/%E9%A1%B9%E7%9B%AE%E6%BA%90%E7%A0%81-code-brightgreen)](https://github.com/terwer/src-sy-post-publisher)
[![](https://img.shields.io/badge/%E5%B8%AE%E5%8A%A9%E6%96%87%E6%A1%A3-doc-blue)](https://www.terwer.space/post/readme-1j4ltp.html)
[![](https://img.shields.io/badge/%E5%B8%AE%E5%8A%A9%E6%96%87%E6%A1%A3-doc-blue)](https://docs.publish.terwer.space)
[![](https://img.shields.io/badge/%E6%96%B0%E6%89%8B%E5%B0%8F%E7%99%BD%E7%BA%A7%E8%A7%86%E9%A2%91%E6%95%99%E7%A8%8B-video-red)](https://www.terwer.space/post/configure-entry-video-brpm9.html)

![](https://img1.terwer.space/api/public/202212181127124.png)
Expand Down
26 changes: 11 additions & 15 deletions components/publish/tab/main/GithubMain.vue
@@ -1,5 +1,5 @@
<!--
- Copyright (c) 2022, Terwer . All rights reserved.
- Copyright (c) 2022-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
Expand Down Expand Up @@ -262,32 +262,26 @@
<!-- Github pages -->
<div class="form-github-pages">
<!-- 启用Github发布 -->
<el-form-item
v-if="pageModeData.etype !== PageEditMode.EditMode_simple"
:label="$t('main.publish.github')"
>
<el-form-item :label="$t('main.publish.github')">
<el-switch
v-model="githubPagesData.githubEnabled"
@change="githubPagesMethods.githubOnChange"
/>
</el-form-item>
<el-form-item v-if="!githubPagesData.githubEnabled">
<el-alert
v-if="!githubPagesData.githubEnabled"
:closable="false"
:title="$t('main.publish.github.no.tip')"
type="warning"
/>
</el-form-item>

<div
v-if="githubPagesData.githubEnabled"
class="form-github-pages-items"
>
<!-- 是否使用默认目录 -->
<el-form-item
v-if="
pageModeData.etype !== PageEditMode.EditMode_simple &&
!initPublishData.isPublished
"
v-if="!initPublishData.isPublished"
:label="$t('main.publish.github.choose.path.use.default')"
>
<el-switch
Expand Down Expand Up @@ -332,6 +326,7 @@
>
<el-input
v-model="githubPagesData.mdTitle"
@change="githubPagesMethods.onFilenameChange"
:disabled="slugMethods.isSlugEmpty()"
/>
</el-form-item>
Expand All @@ -341,9 +336,7 @@
>
<el-input
v-model="githubPagesData.publishPath"
:disabled="
slugMethods.isSlugEmpty() || initPublishData.isPublished
"
:disabled="true"
/>
</el-form-item>
</div>
Expand Down Expand Up @@ -428,7 +421,10 @@

<!-- 发布状态 -->
<div
v-if="pageModeData.etype !== PageEditMode.EditMode_source"
v-if="
pageModeData.etype !== PageEditMode.EditMode_source &&
initPublishData.apiStatus
"
class="publish-status"
>
<!-- 文章状态 -->
Expand Down
2 changes: 1 addition & 1 deletion components/publish/tab/main/MetaweblogMain.vue
Expand Up @@ -475,7 +475,7 @@ const initPage = async () => {
formData.postid = meta[metaweblogCfg.posidKey]
// 路径组合
previewUrl.value = await api.getPreviewUrl(formData.postid.toString())
previewUrl.value = await api.getPreviewUrl(formData?.postid?.toString())
try {
// 如果文章选择了分类,初始化分类
Expand Down
12 changes: 10 additions & 2 deletions composables/publish/githubPagesCom.ts
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Terwer . All rights reserved.
* Copyright (c) 2022-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
Expand All @@ -23,7 +23,7 @@
* questions.
*/

import { reactive } from "vue"
import { reactive, ref } from "vue"
import { LogFactory } from "~/utils/logUtil"
import { getJSONConf } from "~/utils/configUtil"
import { IGithubCfg } from "~/utils/platform/github/githubCfg"
Expand Down Expand Up @@ -132,6 +132,14 @@ export const useGithubPages = (props, deps) => {
fname: githubPagesData.mdTitle,
})
},
onFilenameChange: () => {
if (githubPagesData.customPath === "") {
return
}
const val = ref(githubPagesData.customPath)
githubPagesMethods.onSelectChange(val)
logger.info("触发文件名修改,同步发布路径.")
},

getGithubPagesData: () => {
return githubPagesData
Expand Down
4 changes: 2 additions & 2 deletions composables/publish/initPublishCom.ts
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Terwer . All rights reserved.
* Copyright (c) 2022-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
Expand Down Expand Up @@ -337,7 +337,7 @@ export const useInitPublish = (props, deps, otherArgs?) => {
initPublishMethods.convertAttrToYAML(true)

// 预览链接
if (initPublishData.isPublished) {
if (initPublishData.apiStatus && initPublishData.isPublished) {
// 预览链接
const baseUrl = githubCfg.baseUrl ?? "https://terwer.space/"
const home = githubCfg.home ?? "https://terwer.space/"
Expand Down
2 changes: 1 addition & 1 deletion public/lib/siyuanhook.js
Expand Up @@ -280,7 +280,7 @@ window.terwer.renderPublishHelper = (pageId, pageUrl) => {
(response) => {
window.siyuan.printWin.loadURL(response.data.url)
// 打开开发者工具
window.siyuan.printWin.webContents.openDevTools()
// window.siyuan.printWin.webContents.openDevTools()
}
)
})
Expand Down
2 changes: 1 addition & 1 deletion utils/publishUtil.ts
Expand Up @@ -136,7 +136,7 @@ export const getPublishStatus = (apiType: string, meta: any): boolean => {
logger.debug("postidKey的值=>", postId)
}

return isEmptyString(postId)
return !isEmptyString(postId)
}

/**
Expand Down

0 comments on commit 45b9264

Please sign in to comment.