Skip to content

Commit

Permalink
#1054 新增文章管理功能
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Feb 27, 2024
1 parent 4ceeae9 commit 8843b89
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/utils/siyuanUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { useRoute } from "vue-router"
import { createAppLogger } from "~/src/utils/appLogger.ts"
import { useSiyuanDevice } from "~/src/composables/useSiyuanDevice.ts"
import { BrowserUtil } from "zhi-device"
import { useSiyuanApi } from "~/src/composables/useSiyuanApi.ts"

const route = useRoute()
const logger = createAppLogger("siyuan-util")
Expand Down Expand Up @@ -56,7 +57,7 @@ export const isFileExists = async (kernelApi: SiyuanKernelApi, p: string, type:
/**
* 获取挂件所在的块ID
*/
export const getSiyuanWidgetId = () => {
const getSiyuanWidgetId = () => {
if (
window.frameElement == null ||
window.frameElement.parentElement == null ||
Expand All @@ -79,7 +80,7 @@ export const getSiyuanWidgetId = () => {
}

// 如果是思源新窗口
export const getSiyuanNewWinPageId = () => {
const getSiyuanNewWinPageId = () => {
let pageId: string
const win = window as any
if (win && win.terwer && win.terwer.pageId) {
Expand All @@ -101,7 +102,10 @@ export const getSiyuanPageId = async (pageId?: string, force?: boolean) => {
// 尝试读取挂件的ID
const widgetPageId = getSiyuanWidgetId()
if (!StrUtil.isEmptyString(widgetPageId)) {
return widgetPageId
const { kernelApi } = useSiyuanApi()
const widgetAttrs = await kernelApi.getBlockByID(widgetPageId)
const docPageId = widgetAttrs.root_id
return docPageId
}
}

Expand Down

0 comments on commit 8843b89

Please sign in to comment.