diff --git a/src/adaptors/base/baseExtendApi.ts b/src/adaptors/base/baseExtendApi.ts
index 034e3813..71f415e5 100644
--- a/src/adaptors/base/baseExtendApi.ts
+++ b/src/adaptors/base/baseExtendApi.ts
@@ -644,8 +644,11 @@ class BaseExtendApi extends WebApi implements IBlogApi, IWebApi {
// eslint-disable-next-line no-prototype-builtins
if (!postMeta.hasOwnProperty(posidKey)) {
outerLink = `siyuan://blocks/${id}`
- this.logger.error("引用的文档尚未发布,您可以删除此外链再发布,或者先发布外链文章 =>", id)
- throw new Error(`引用的文档 ${id} 尚未发布,您可以删除此外链再发布,或者先发布外链文章`)
+ // 包括未配置和未勾选
+ if (pref.value.ignoreBlockRef !== true) {
+ this.logger.error("引用的文档尚未发布,您可以删除此外链再发布,或者先发布外链文章 =>", id)
+ throw new Error(`引用的文档 ${id} 尚未发布,您可以删除此外链再发布,或者先发布外链文章`)
+ }
} else {
let previewUrl: string
const postid = postMeta[posidKey]
diff --git a/src/components/set/preference/PreferenceSetting.vue b/src/components/set/preference/PreferenceSetting.vue
index 3065cb0b..21fb2a3c 100644
--- a/src/components/set/preference/PreferenceSetting.vue
+++ b/src/components/set/preference/PreferenceSetting.vue
@@ -80,6 +80,9 @@ const isSiyuanPlugin = isInSiyuanWin() || (isInSiyuanWidget() && StrUtil.isEmpty
+
+
+
diff --git a/src/locales/en_US.ts b/src/locales/en_US.ts
index be69be52..0be2bcd5 100644
--- a/src/locales/en_US.ts
+++ b/src/locales/en_US.ts
@@ -654,6 +654,7 @@ export default {
"distri.type.merge.warn":
"Note: In merge mode, the title and abstract changes are not valid, and the labels and categories are merged with the selected platform data.",
"preference.setting.keepTitle": "Do not update the original title",
+ "preference.setting.ignoreBlockRef": "Ignore block ref",
"setting.blog.gitlab.url.tip": "GitLab homepage, e.g., http://localhost:8002",
"setting.blog.type.gitlab.user.tip": "Username for GitLab",
diff --git a/src/locales/zh_CN.ts b/src/locales/zh_CN.ts
index f518cac4..e0decb3a 100644
--- a/src/locales/zh_CN.ts
+++ b/src/locales/zh_CN.ts
@@ -647,6 +647,7 @@ export default {
"preference.setting.showAIMenu": "显示AI菜单",
"preference.setting.showExtendMenu": "显示扩展菜单",
"preference.setting.showArticleManageMenu": "显示文章管理菜单",
+ "preference.setting.ignoreBlockRef": "忽略块引用",
"message.publish.notShared": "文章尚未分享,无法在外部查看。请分享文章或者在PC 客户端内部通过插件菜单进行预览。",
diff --git a/src/models/publishPreferenceCfg.ts b/src/models/publishPreferenceCfg.ts
index 36d3ea50..76b7e665 100644
--- a/src/models/publishPreferenceCfg.ts
+++ b/src/models/publishPreferenceCfg.ts
@@ -89,6 +89,9 @@ class PublishPreferenceCfg extends PreferenceConfig {
// 文章管理
public showArticleManageMenu?: boolean
+ // 是否忽略块引用
+ public ignoreBlockRef?: boolean
+
constructor() {
super()
this.experimentalUseSiyuanNoteAIConfig = true
@@ -103,6 +106,7 @@ class PublishPreferenceCfg extends PreferenceConfig {
this.showExtendMenu = true
this.showArticleManageMenu = true
+ this.ignoreBlockRef = false
}
}
diff --git a/src/stores/useSiyuanSettingStore.ts b/src/stores/useSiyuanSettingStore.ts
index 43b2e292..87d35f82 100644
--- a/src/stores/useSiyuanSettingStore.ts
+++ b/src/stores/useSiyuanSettingStore.ts
@@ -27,9 +27,10 @@ import { SiyuanConfig } from "zhi-siyuan-api"
import { RemovableRef, StorageSerializers } from "@vueuse/core"
import { readonly } from "vue"
import { SiyuanDevice } from "zhi-device"
-import { useSiyuanDevice } from "~/src/composables/useSiyuanDevice.ts"
import useCommonLocalStorage from "~/src/stores/common/useCommonLocalStorage.ts"
import { LEGENCY_SHARED_PROXT_MIDDLEWARE } from "~/src/utils/constants.ts"
+import { Utils } from "~/src/utils/utils.ts"
+import { StrUtil } from "zhi-common"
/**
* 思源笔记设置
@@ -57,15 +58,21 @@ const useSiyuanSettingStore = () => {
const win = SiyuanDevice.siyuanWindow()
origin = win?.location.origin
- const initialValue = new SiyuanConfig(origin ?? baseUrl, token)
+ // 顺序
+ // 1、环境变量
+ // 2、origin
+ // 3、默认值
+ const envSiyuanApiUrl = Utils.emptyOrDefault(process.env.VITE_SIYUAN_API_URL, origin)
+ const siyuanApiUrl = Utils.emptyOrDefault(envSiyuanApiUrl, baseUrl)
+ const initialValue = new SiyuanConfig(siyuanApiUrl, token)
initialValue.middlewareUrl = middlewareUrl
const siyuanConfig = useCommonLocalStorage(filePath, storageKey, initialValue, {
serializer: StorageSerializers.object,
})
- // 更新apiUrl
- if (origin) {
- siyuanConfig.value.apiUrl = origin
+ // 更新apiUrl,兼容旧数据的情况
+ if (!StrUtil.isEmptyString(siyuanApiUrl)) {
+ siyuanConfig.value.apiUrl = siyuanApiUrl
}
return siyuanConfig
}