mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
修复新版Notion中附件文件无法打开的问题
This commit is contained in:
@@ -63,6 +63,7 @@ export async function getPageWithRetry(id, from, retryAttempts = 3) {
|
||||
|
||||
/**
|
||||
* 获取到的blockMap删除不需要的字段
|
||||
* 并且对于页面内容进行特殊处理,比如文件url格式化
|
||||
* @param {*} id 页面ID
|
||||
* @param {*} pageBlock 页面元素
|
||||
* @param {*} slice 截取数量
|
||||
@@ -72,6 +73,7 @@ function filterPostBlocks(id, pageBlock, slice) {
|
||||
const clonePageBlock = deepClone(pageBlock)
|
||||
let count = 0
|
||||
|
||||
// 循环遍历文档的每个block
|
||||
for (const i in clonePageBlock?.block) {
|
||||
const b = clonePageBlock?.block[i]
|
||||
if (slice && slice > 0 && count > slice) {
|
||||
@@ -99,6 +101,13 @@ function filterPostBlocks(id, pageBlock, slice) {
|
||||
}
|
||||
}
|
||||
|
||||
// 如果是文件,需要重新加密签名
|
||||
if (b?.value?.type === 'file' && b?.value?.properties?.source?.[0][0]) {
|
||||
const oldUrl = b?.value?.properties?.source?.[0][0]
|
||||
const newUrl = `https://notion.so/signed/${encodeURIComponent(oldUrl)}?table=block&id=${b?.value?.id}`
|
||||
b.value.properties.source[0][0] = newUrl
|
||||
}
|
||||
|
||||
delete b?.role
|
||||
delete b?.value?.version
|
||||
delete b?.value?.created_by_table
|
||||
|
||||
Reference in New Issue
Block a user