✨ set project title
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import { join } from 'path'
|
||||
import { join, basename } from 'path'
|
||||
import { homedir } from 'os'
|
||||
import { readFileSync, writeFileSync, mkdirSync } from 'fs'
|
||||
|
||||
export interface GlobalConfig {
|
||||
apiKey?: string
|
||||
projectPath?: string
|
||||
projectTitle?: string
|
||||
fontSize?: number
|
||||
theme?: 'dark' | 'light'
|
||||
}
|
||||
@@ -28,6 +29,9 @@ export const getDraftRoot = (): string =>
|
||||
export const getApiKey = (): string | undefined =>
|
||||
_config.apiKey ?? process.env.ANTHROPIC_API_KEY
|
||||
|
||||
export const getProjectTitle = (): string =>
|
||||
_config.projectTitle?.trim() || basename(getDraftRoot())
|
||||
|
||||
export function readGlobalConfig(): GlobalConfig {
|
||||
return { ..._config }
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { listDraftFiles, readMarkdownFile, writeMarkdownFile, getProjectWordCoun
|
||||
import type { SearchOptions } from './fileSystem'
|
||||
import { streamMessage, resetClient } from './aiService'
|
||||
import type { AIPayload, Attachment } from '../renderer/types/editor'
|
||||
import { readGlobalConfig, writeGlobalConfig, getDraftRoot } from './globalConfig'
|
||||
import { readGlobalConfig, writeGlobalConfig, getProjectTitle } from './globalConfig'
|
||||
import type { GlobalConfig } from './globalConfig'
|
||||
|
||||
export function registerIpcHandlers(): void {
|
||||
@@ -278,7 +278,7 @@ export function registerIpcHandlers(): void {
|
||||
|
||||
ipcMain.handle('export:projectPdf', async (event): Promise<void> => {
|
||||
const win = BrowserWindow.fromWebContents(event.sender)
|
||||
const projectName = basename(getDraftRoot())
|
||||
const projectName = getProjectTitle()
|
||||
|
||||
const result = await dialog.showSaveDialog(win!, {
|
||||
defaultPath: `${projectName}.pdf`,
|
||||
|
||||
Reference in New Issue
Block a user