Skip to content

Commit

Permalink
fix: 修复通用API请求错误
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Jan 10, 2023
1 parent c42c2b4 commit 45cea7e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion composables/picgo/picgoManageCom.ts
Expand Up @@ -82,7 +82,7 @@ export const usePicgoManage = (props, deps) => {

picgoCommonData.isUploadLoading = false
if (!hasLocalImages) {
ElMessage.error("未发现本地图片,不上传")
ElMessage.warning("未发现本地图片,不上传")
} else {
ElMessage.success("图片已经全部上传至图床,即将刷新页面")
reloadPage()
Expand Down
11 changes: 4 additions & 7 deletions utils/platform/commonblog/commonblogApi.ts
Expand Up @@ -30,12 +30,9 @@ import {
isInChromeExtension,
sendChromeMessage,
} from "~/utils/otherlib/ChromeUtil"
import {
getWidgetId,
isSiyuanOrSiyuanNewWin,
} from "~/utils/platform/siyuan/siyuanUtil"
import { getWidgetId } from "~/utils/platform/siyuan/siyuanUtil"
import { isEmptyString } from "~/utils/util"
import { isLocalhost } from "~/utils/browserUtil"
import { isElectron, isLocalhost } from "~/utils/browserUtil"

export class CommonblogApi {
protected logger: Logger
Expand Down Expand Up @@ -144,7 +141,7 @@ export class CommonblogApi {
this.logger.warn("检测到本地请求,直接fetch获取数据")
// 不解析了,直接fetch
result = await fetch(apiUrl, fetchOptions)
} else if (getWidgetId().isInSiyuan) {
} else if (isElectron) {
this.logger.warn("当前处于挂件模式,使用electron的fetch获取数据")
// 不解析了,直接使用Node兼容调用
result = await fetch(apiUrl, fetchOptions)
Expand Down Expand Up @@ -241,7 +238,7 @@ export class CommonblogApi {

if (isLocalhost(apiUrl)) {
resJson = await response.json()
} else if (isSiyuanOrSiyuanNewWin()) {
} else if (isElectron) {
resJson = await response.json()
} else {
const corsJson = await response.json()
Expand Down
2 changes: 1 addition & 1 deletion utils/platform/picgo/picgoPostApi.ts
Expand Up @@ -164,7 +164,7 @@ export class PicgoPostApi {
}

if (!hasLocalImages) {
ElMessage.error("未发现本地图片,不上传")
ElMessage.warning("未发现本地图片,不上传")
}

// 处理链接替换
Expand Down

0 comments on commit 45cea7e

Please sign in to comment.