feat: 为 Notion 导出添加可配置的页面名称 key
This commit is contained in:
parent
4add56ae6a
commit
95bbc70c93
@ -567,6 +567,8 @@
|
|||||||
"notion.api_key_placeholder": "Enter Notion API Key",
|
"notion.api_key_placeholder": "Enter Notion API Key",
|
||||||
"notion.database_id": "Notion Database ID",
|
"notion.database_id": "Notion Database ID",
|
||||||
"notion.database_id_placeholder": "Enter 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.title": "Notion Configuration",
|
||||||
"notion.help": "Notion Configuration Documentation",
|
"notion.help": "Notion Configuration Documentation",
|
||||||
"notion.check": {
|
"notion.check": {
|
||||||
|
|||||||
@ -567,6 +567,8 @@
|
|||||||
"notion.api_key_placeholder": "Notion APIキーを入力してください",
|
"notion.api_key_placeholder": "Notion APIキーを入力してください",
|
||||||
"notion.database_id": "Notion データベースID",
|
"notion.database_id": "Notion データベースID",
|
||||||
"notion.database_id_placeholder": "Notion データベースIDを入力してください",
|
"notion.database_id_placeholder": "Notion データベースIDを入力してください",
|
||||||
|
"notion.page_name_key": "ページタイトルフィールド名",
|
||||||
|
"notion.page_name_key_placeholder": "ページタイトルフィールド名を入力してください。デフォルトは Name です",
|
||||||
"notion.title": "Notion 設定",
|
"notion.title": "Notion 設定",
|
||||||
"notion.help": "Notion 設定ドキュメント",
|
"notion.help": "Notion 設定ドキュメント",
|
||||||
"notion.check": {
|
"notion.check": {
|
||||||
|
|||||||
@ -567,6 +567,8 @@
|
|||||||
"notion.api_key_placeholder": "Введите ключ API Notion",
|
"notion.api_key_placeholder": "Введите ключ API Notion",
|
||||||
"notion.database_id": "ID базы данных Notion",
|
"notion.database_id": "ID базы данных Notion",
|
||||||
"notion.database_id_placeholder": "Введите ID базы данных Notion",
|
"notion.database_id_placeholder": "Введите ID базы данных Notion",
|
||||||
|
"notion.page_name_key": "Название поля заголовка страницы",
|
||||||
|
"notion.page_name_key_placeholder": "Введите название поля заголовка страницы, по умолчанию Name",
|
||||||
"notion.title": "Настройки Notion",
|
"notion.title": "Настройки Notion",
|
||||||
"notion.help": "Документация по настройке Notion",
|
"notion.help": "Документация по настройке Notion",
|
||||||
"notion.check": {
|
"notion.check": {
|
||||||
|
|||||||
@ -567,8 +567,10 @@
|
|||||||
"notion.api_key_placeholder": "请输入Notion 密钥",
|
"notion.api_key_placeholder": "请输入Notion 密钥",
|
||||||
"notion.database_id": "Notion 数据库 ID",
|
"notion.database_id": "Notion 数据库 ID",
|
||||||
"notion.database_id_placeholder": "请输入Notion 数据库 ID",
|
"notion.database_id_placeholder": "请输入Notion 数据库 ID",
|
||||||
|
"notion.page_name_key": "页面标题字段名",
|
||||||
|
"notion.page_name_key_placeholder": "请输入页面标题字段名,默认为 Name",
|
||||||
"notion.title": "Notion 配置",
|
"notion.title": "Notion 配置",
|
||||||
"notion.help" : "Notion 配置文档",
|
"notion.help": "Notion 配置文档",
|
||||||
"notion.check": {
|
"notion.check": {
|
||||||
"button": "检查",
|
"button": "检查",
|
||||||
"fail": "连接失败,请检查网络及Api_key和Database_id是否正确",
|
"fail": "连接失败,请检查网络及Api_key和Database_id是否正确",
|
||||||
|
|||||||
@ -565,6 +565,8 @@
|
|||||||
"notion.api_key_placeholder": "請輸入Notion 密鑰",
|
"notion.api_key_placeholder": "請輸入Notion 密鑰",
|
||||||
"notion.database_id": "Notion 資料庫 ID",
|
"notion.database_id": "Notion 資料庫 ID",
|
||||||
"notion.database_id_placeholder": "請輸入Notion 資料庫 ID",
|
"notion.database_id_placeholder": "請輸入Notion 資料庫 ID",
|
||||||
|
"notion.page_name_key": "頁面標題欄位名稱",
|
||||||
|
"notion.page_name_key_placeholder": "請輸入頁面標題欄位名稱,預設為 Name",
|
||||||
"notion.title": "Notion 配置",
|
"notion.title": "Notion 配置",
|
||||||
"notion.help": "Notion 配置文檔",
|
"notion.help": "Notion 配置文檔",
|
||||||
"notion.check": {
|
"notion.check": {
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import MinApp from '@renderer/components/MinApp'
|
|||||||
import { useTheme } from '@renderer/context/ThemeProvider'
|
import { useTheme } from '@renderer/context/ThemeProvider'
|
||||||
import { backup, reset, restore } from '@renderer/services/BackupService'
|
import { backup, reset, restore } from '@renderer/services/BackupService'
|
||||||
import { RootState, useAppDispatch } from '@renderer/store'
|
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 { AppInfo } from '@renderer/types'
|
||||||
import { Button, Modal, Tooltip, Typography } from 'antd'
|
import { Button, Modal, Tooltip, Typography } from 'antd'
|
||||||
import Input from 'antd/es/input/Input'
|
import Input from 'antd/es/input/Input'
|
||||||
@ -23,10 +23,9 @@ const NotionSettings: FC = () => {
|
|||||||
const { theme } = useTheme()
|
const { theme } = useTheme()
|
||||||
const dispatch = useAppDispatch()
|
const dispatch = useAppDispatch()
|
||||||
|
|
||||||
// 这里可以添加 Notion 相关的状态和逻辑
|
|
||||||
// 例如:
|
|
||||||
const notionApiKey = useSelector((state: RootState) => state.settings.notionApiKey)
|
const notionApiKey = useSelector((state: RootState) => state.settings.notionApiKey)
|
||||||
const notionDatabaseID = useSelector((state: RootState) => state.settings.notionDatabaseID)
|
const notionDatabaseID = useSelector((state: RootState) => state.settings.notionDatabaseID)
|
||||||
|
const notionPageNameKey = useSelector((state: RootState) => state.settings.notionPageNameKey)
|
||||||
|
|
||||||
const handleNotionTokenChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleNotionTokenChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
dispatch(setNotionApiKey(e.target.value))
|
dispatch(setNotionApiKey(e.target.value))
|
||||||
@ -35,6 +34,11 @@ const NotionSettings: FC = () => {
|
|||||||
const handleNotionDatabaseIdChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleNotionDatabaseIdChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
dispatch(setNotionDatabaseID(e.target.value))
|
dispatch(setNotionDatabaseID(e.target.value))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleNotionPageNameKeyChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
dispatch(setNotionPageNameKey(e.target.value))
|
||||||
|
}
|
||||||
|
|
||||||
const handleNotionConnectionCheck = () => {
|
const handleNotionConnectionCheck = () => {
|
||||||
if (notionApiKey === null) {
|
if (notionApiKey === null) {
|
||||||
window.message.error(t('settings.data.notion.check.empty_api_key'))
|
window.message.error(t('settings.data.notion.check.empty_api_key'))
|
||||||
@ -95,6 +99,20 @@ const NotionSettings: FC = () => {
|
|||||||
</HStack>
|
</HStack>
|
||||||
</SettingRow>
|
</SettingRow>
|
||||||
<SettingDivider />
|
<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>
|
<SettingRow>
|
||||||
<SettingRowTitle>{t('settings.data.notion.api_key')}</SettingRowTitle>
|
<SettingRowTitle>{t('settings.data.notion.api_key')}</SettingRowTitle>
|
||||||
<HStack alignItems="center" gap="5px" style={{ width: 315 }}>
|
<HStack alignItems="center" gap="5px" style={{ width: 315 }}>
|
||||||
|
|||||||
@ -69,6 +69,7 @@ export interface SettingsState {
|
|||||||
multiModelMessageStyle: MultiModelMessageStyle
|
multiModelMessageStyle: MultiModelMessageStyle
|
||||||
notionDatabaseID: string | null
|
notionDatabaseID: string | null
|
||||||
notionApiKey: string | null
|
notionApiKey: string | null
|
||||||
|
notionPageNameKey: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export type MultiModelMessageStyle = 'horizontal' | 'vertical' | 'fold' | 'grid'
|
export type MultiModelMessageStyle = 'horizontal' | 'vertical' | 'fold' | 'grid'
|
||||||
@ -123,7 +124,8 @@ const initialState: SettingsState = {
|
|||||||
clickTrayToShowQuickAssistant: false,
|
clickTrayToShowQuickAssistant: false,
|
||||||
multiModelMessageStyle: 'fold',
|
multiModelMessageStyle: 'fold',
|
||||||
notionDatabaseID: '',
|
notionDatabaseID: '',
|
||||||
notionApiKey: ''
|
notionApiKey: '',
|
||||||
|
notionPageNameKey: 'Name'
|
||||||
}
|
}
|
||||||
|
|
||||||
const settingsSlice = createSlice({
|
const settingsSlice = createSlice({
|
||||||
@ -283,6 +285,9 @@ const settingsSlice = createSlice({
|
|||||||
},
|
},
|
||||||
setNotionApiKey: (state, action: PayloadAction<string>) => {
|
setNotionApiKey: (state, action: PayloadAction<string>) => {
|
||||||
state.notionApiKey = action.payload
|
state.notionApiKey = action.payload
|
||||||
|
},
|
||||||
|
setNotionPageNameKey: (state, action: PayloadAction<string>) => {
|
||||||
|
state.notionPageNameKey = action.payload
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -336,7 +341,8 @@ export const {
|
|||||||
setEnableQuickAssistant,
|
setEnableQuickAssistant,
|
||||||
setMultiModelMessageStyle,
|
setMultiModelMessageStyle,
|
||||||
setNotionDatabaseID,
|
setNotionDatabaseID,
|
||||||
setNotionApiKey
|
setNotionApiKey,
|
||||||
|
setNotionPageNameKey
|
||||||
} = settingsSlice.actions
|
} = settingsSlice.actions
|
||||||
|
|
||||||
export default settingsSlice.reducer
|
export default settingsSlice.reducer
|
||||||
|
|||||||
@ -67,7 +67,7 @@ export const exportTopicToNotion = async (topic: Topic) => {
|
|||||||
const response = await notion.pages.create({
|
const response = await notion.pages.create({
|
||||||
parent: { database_id: notionDatabaseID },
|
parent: { database_id: notionDatabaseID },
|
||||||
properties: {
|
properties: {
|
||||||
Name: {
|
[store.getState().settings.notionPageNameKey || 'Name']: {
|
||||||
title: [{ text: { content: topic.name } }]
|
title: [{ text: { content: topic.name } }]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user