Skip to content
4 changes: 4 additions & 0 deletions src/renderer/src/i18n/locales/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -3829,6 +3829,10 @@
"help": "When enabled, citation markers will be converted to standard Markdown footnote format [^1] and citation lists will be formatted.",
"title": "Standardize Citation Format"
},
"show_timestamp": {
"title": "Show message timestamps on export",
"help": "When enabled, the creation time of each message will be appended to its heading in the format YYYY-MM-DD HH:mm."
},
"title": "Markdown Export"
},
"message_title": {
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/src/i18n/locales/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -3829,6 +3829,10 @@
"help": "开启后,导出 Markdown 时会将引用标记转换为标准 Markdown 脚注格式 [^1],并格式化引用列表",
"title": "标准化引用格式"
},
"show_timestamp": {
"title": "导出时显示消息时间戳",
"help": "开启后,导出 Markdown 时每条消息标题后会附加发送时间,格式为 YYYY-MM-DD HH:mm"
},
"title": "Markdown 导出"
},
"message_title": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DeleteOutlined, FolderOpenOutlined } from '@ant-design/icons'

Check failure on line 1 in src/renderer/src/pages/settings/DataSettings/MarkdownExportSettings.tsx

View workflow job for this annotation

GitHub Actions / basic-checks

Run autofix to sort these imports!
import { HStack } from '@renderer/components/Layout'
import { useTheme } from '@renderer/context/ThemeProvider'
import type { RootState } from '@renderer/store'
Expand All @@ -10,6 +10,7 @@
setShowModelNameInMarkdown,
setShowModelProviderInMarkdown,
setStandardizeCitationsInExport,
setShowTimestampInMarkdown,
setUseTopicNamingForMessageTitle
} from '@renderer/store/settings'
import { Button, Switch } from 'antd'
Expand All @@ -30,6 +31,7 @@
const useTopicNamingForMessageTitle = useSelector((state: RootState) => state.settings.useTopicNamingForMessageTitle)
const showModelNameInExport = useSelector((state: RootState) => state.settings.showModelNameInMarkdown)
const showModelProviderInMarkdown = useSelector((state: RootState) => state.settings.showModelProviderInMarkdown)
const showTimestampInMarkdown = useSelector((state: RootState) => state.settings.showTimestampInMarkdown)
const excludeCitationsInExport = useSelector((state: RootState) => state.settings.excludeCitationsInExport)
const standardizeCitationsInExport = useSelector((state: RootState) => state.settings.standardizeCitationsInExport)

Expand Down Expand Up @@ -59,7 +61,11 @@
const handleToggleShowModelProvider = (checked: boolean) => {
dispatch(setShowModelProviderInMarkdown(checked))
}


const handleToggleShowTimestamp = (checked: boolean) => {
dispatch(setShowTimestampInMarkdown(checked))
}

const handleToggleExcludeCitations = (checked: boolean) => {
dispatch(setExcludeCitationsInExport(checked))
}
Expand Down Expand Up @@ -127,6 +133,14 @@
<SettingRow>
<SettingHelpText>{t('settings.data.markdown_export.show_model_provider.help')}</SettingHelpText>
</SettingRow>
<SettingDivider />
<SettingRow>
<SettingRowTitle>{t('settings.data.markdown_export.show_timestamp.title')}</SettingRowTitle>
<Switch checked={showTimestampInMarkdown} onChange={handleToggleShowTimestamp} />
</SettingRow>
<SettingRow>
<SettingHelpText>{t('settings.data.markdown_export.show_timestamp.help')}</SettingHelpText>
</SettingRow>
<SettingDivider />
<SettingRow>
<SettingRowTitle>{t('settings.data.markdown_export.exclude_citations.title')}</SettingRowTitle>
Expand Down
6 changes: 6 additions & 0 deletions src/renderer/src/store/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ export interface SettingsState {
notionExportReasoning: boolean
excludeCitationsInExport: boolean
standardizeCitationsInExport: boolean
showTimestampInMarkdown: boolean
yuqueToken: string | null
yuqueUrl: string | null
yuqueRepoId: string | null
Expand Down Expand Up @@ -361,6 +362,7 @@ export const initialState: SettingsState = {
thoughtAutoCollapse: true,
notionExportReasoning: false,
excludeCitationsInExport: false,
showTimestampInMarkdown: false,
standardizeCitationsInExport: false,
yuqueToken: '',
yuqueUrl: '',
Expand Down Expand Up @@ -739,6 +741,9 @@ const settingsSlice = createSlice({
setShowModelProviderInMarkdown: (state, action: PayloadAction<boolean>) => {
state.showModelProviderInMarkdown = action.payload
},
setShowTimestampInMarkdown: (state, action: PayloadAction<boolean>) => {
state.showTimestampInMarkdown = action.payload
},
setThoughtAutoCollapse: (state, action: PayloadAction<boolean>) => {
state.thoughtAutoCollapse = action.payload
},
Expand Down Expand Up @@ -904,6 +909,7 @@ const settingsSlice = createSlice({
})

export const {
setShowTimestampInMarkdown,
setShowModelNameInMarkdown,
setShowModelProviderInMarkdown,
setShowAssistants,
Expand Down
7 changes: 4 additions & 3 deletions src/renderer/src/utils/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,10 @@ const createBaseMarkdown = (
excludeCitations: boolean = false,
normalizeCitations: boolean = true
): { titleSection: string; reasoningSection: string; contentSection: string; citation: string } => {
const { forceDollarMathInMarkdown } = store.getState().settings
const roleText = getRoleText(message.role, message.model?.name, message.model?.provider)
const titleSection = `## ${roleText}`
const { forceDollarMathInMarkdown, showTimestampInMarkdown } = store.getState().settings
const roleText = getRoleText(message.role, message.model?.name, message.model?.provider)
const timestamp = showTimestampInMarkdown ? ` (${dayjs(message.createdAt).format('YYYY-MM-DD HH:mm')})` : ''
const titleSection = `## ${roleText}${timestamp}`
let reasoningSection = ''

if (includeReasoning) {
Expand Down
Loading