mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
feat(支持复杂格式的config表格式配置):
(cherry picked from commit 13dfb9a9078fedaac94da15ae3ee44a32ea6cdf0)
This commit is contained in:
@@ -157,19 +157,12 @@ export async function getConfigMapFromConfigPage(allPages) {
|
||||
// 只导入生效的配置
|
||||
if (config.enable) {
|
||||
// console.log('[Notion配置]', config.key, config.value)
|
||||
notionConfig[config.key] = config.value || null
|
||||
notionConfig[config.key] = parseTextToJson(config.value) || config.value || null
|
||||
// 配置不能是undefined,至少是null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 最后检查Notion_Config页面的INLINE_CONFIG,是否是一个js对象
|
||||
const combine = Object.assign(
|
||||
{},
|
||||
deepClone(notionConfig),
|
||||
parseConfig(notionConfig?.INLINE_CONFIG)
|
||||
)
|
||||
return combine
|
||||
return notionConfig
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -191,3 +184,16 @@ export function parseConfig(configString) {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析文本为JSON
|
||||
* @param text
|
||||
* @returns {any|null}
|
||||
*/
|
||||
export function parseTextToJson(text) {
|
||||
try {
|
||||
return JSON.parse(text);
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user