feat: 为 Notion 导出添加可配置的页面名称 key

This commit is contained in:
jiangjiwei 2025-02-19 10:28:26 +08:00 committed by 亢奋猫
parent 4add56ae6a
commit 95bbc70c93
8 changed files with 41 additions and 7 deletions

View File

@ -567,6 +567,8 @@
"notion.api_key_placeholder": "Enter Notion API Key",
"notion.database_id": "Notion Database ID",
"notion.database_id_placeholder": "Enter Notion Database ID",
"notion.page_name_key": "Page Title Field Name",
"notion.page_name_key_placeholder": "Enter page title field name, default is Name",
"notion.title": "Notion Configuration",
"notion.help": "Notion Configuration Documentation",
"notion.check": {

View File

@ -567,6 +567,8 @@
"notion.api_key_placeholder": "Notion APIキーを入力してください",
"notion.database_id": "Notion データベースID",
"notion.database_id_placeholder": "Notion データベースIDを入力してください",
"notion.page_name_key": "ページタイトルフィールド名",
"notion.page_name_key_placeholder": "ページタイトルフィールド名を入力してください。デフォルトは Name です",
"notion.title": "Notion 設定",
"notion.help": "Notion 設定ドキュメント",
"notion.check": {

View File

@ -567,6 +567,8 @@
"notion.api_key_placeholder": "Введите ключ API Notion",
"notion.database_id": "ID базы данных Notion",
"notion.database_id_placeholder": "Введите ID базы данных Notion",
"notion.page_name_key": "Название поля заголовка страницы",
"notion.page_name_key_placeholder": "Введите название поля заголовка страницы, по умолчанию Name",
"notion.title": "Настройки Notion",
"notion.help": "Документация по настройке Notion",
"notion.check": {

View File

@ -567,8 +567,10 @@
"notion.api_key_placeholder": "请输入Notion 密钥",
"notion.database_id": "Notion 数据库 ID",
"notion.database_id_placeholder": "请输入Notion 数据库 ID",
"notion.page_name_key": "页面标题字段名",
"notion.page_name_key_placeholder": "请输入页面标题字段名,默认为 Name",
"notion.title": "Notion 配置",
"notion.help" : "Notion 配置文档",
"notion.help": "Notion 配置文档",
"notion.check": {
"button": "检查",
"fail": "连接失败请检查网络及Api_key和Database_id是否正确",

View File

@ -565,6 +565,8 @@
"notion.api_key_placeholder": "請輸入Notion 密鑰",
"notion.database_id": "Notion 資料庫 ID",
"notion.database_id_placeholder": "請輸入Notion 資料庫 ID",
"notion.page_name_key": "頁面標題欄位名稱",
"notion.page_name_key_placeholder": "請輸入頁面標題欄位名稱,預設為 Name",
"notion.title": "Notion 配置",
"notion.help": "Notion 配置文檔",
"notion.check": {

View File

@ -5,7 +5,7 @@ import MinApp from '@renderer/components/MinApp'
import { useTheme } from '@renderer/context/ThemeProvider'
import { backup, reset, restore } from '@renderer/services/BackupService'
import { RootState, useAppDispatch } from '@renderer/store'
import { setNotionApiKey, setNotionDatabaseID } from '@renderer/store/settings'
import { setNotionApiKey, setNotionDatabaseID, setNotionPageNameKey } from '@renderer/store/settings'
import { AppInfo } from '@renderer/types'
import { Button, Modal, Tooltip, Typography } from 'antd'
import Input from 'antd/es/input/Input'
@ -23,10 +23,9 @@ const NotionSettings: FC = () => {
const { theme } = useTheme()
const dispatch = useAppDispatch()
// 这里可以添加 Notion 相关的状态和逻辑
// 例如:
const notionApiKey = useSelector((state: RootState) => state.settings.notionApiKey)
const notionDatabaseID = useSelector((state: RootState) => state.settings.notionDatabaseID)
const notionPageNameKey = useSelector((state: RootState) => state.settings.notionPageNameKey)
const handleNotionTokenChange = (e: React.ChangeEvent<HTMLInputElement>) => {
dispatch(setNotionApiKey(e.target.value))
@ -35,6 +34,11 @@ const NotionSettings: FC = () => {
const handleNotionDatabaseIdChange = (e: React.ChangeEvent<HTMLInputElement>) => {
dispatch(setNotionDatabaseID(e.target.value))
}
const handleNotionPageNameKeyChange = (e: React.ChangeEvent<HTMLInputElement>) => {
dispatch(setNotionPageNameKey(e.target.value))
}
const handleNotionConnectionCheck = () => {
if (notionApiKey === null) {
window.message.error(t('settings.data.notion.check.empty_api_key'))
@ -95,6 +99,20 @@ const NotionSettings: FC = () => {
</HStack>
</SettingRow>
<SettingDivider />
<SettingRow>
<SettingRowTitle>{t('settings.data.notion.page_name_key')}</SettingRowTitle>
<HStack alignItems="center" gap="5px" style={{ width: 315 }}>
<Input
type="text"
value={notionPageNameKey || ''}
onChange={handleNotionPageNameKeyChange}
onBlur={handleNotionPageNameKeyChange}
style={{ width: 315 }}
placeholder={t('settings.data.notion.page_name_key_placeholder')}
/>
</HStack>
</SettingRow>
<SettingDivider />
<SettingRow>
<SettingRowTitle>{t('settings.data.notion.api_key')}</SettingRowTitle>
<HStack alignItems="center" gap="5px" style={{ width: 315 }}>

View File

@ -69,6 +69,7 @@ export interface SettingsState {
multiModelMessageStyle: MultiModelMessageStyle
notionDatabaseID: string | null
notionApiKey: string | null
notionPageNameKey: string | null
}
export type MultiModelMessageStyle = 'horizontal' | 'vertical' | 'fold' | 'grid'
@ -123,7 +124,8 @@ const initialState: SettingsState = {
clickTrayToShowQuickAssistant: false,
multiModelMessageStyle: 'fold',
notionDatabaseID: '',
notionApiKey: ''
notionApiKey: '',
notionPageNameKey: 'Name'
}
const settingsSlice = createSlice({
@ -283,6 +285,9 @@ const settingsSlice = createSlice({
},
setNotionApiKey: (state, action: PayloadAction<string>) => {
state.notionApiKey = action.payload
},
setNotionPageNameKey: (state, action: PayloadAction<string>) => {
state.notionPageNameKey = action.payload
}
}
})
@ -336,7 +341,8 @@ export const {
setEnableQuickAssistant,
setMultiModelMessageStyle,
setNotionDatabaseID,
setNotionApiKey
setNotionApiKey,
setNotionPageNameKey
} = settingsSlice.actions
export default settingsSlice.reducer

View File

@ -67,7 +67,7 @@ export const exportTopicToNotion = async (topic: Topic) => {
const response = await notion.pages.create({
parent: { database_id: notionDatabaseID },
properties: {
Name: {
[store.getState().settings.notionPageNameKey || 'Name']: {
title: [{ text: { content: topic.name } }]
}
},