diff --git a/src/lib/components/settings/BugReporter.svelte b/src/lib/components/settings/BugReporter.svelte index e4d1d95..b0b9647 100644 --- a/src/lib/components/settings/BugReporter.svelte +++ b/src/lib/components/settings/BugReporter.svelte @@ -10,6 +10,8 @@ buildSettingsBlock, buildIssueUrl, type ReportType, + type BugFields, + type FeatureFields, } from './lib/bugReport' interface Props { onClose: () => void } @@ -92,7 +94,10 @@ async function handleOpen() { const settingsBlock = buildSettingsBlock([...selectedKeys]) - const url = buildIssueUrl(reportType, settingsBlock, title, serverVersion) + const fields: BugFields | FeatureFields = reportType === 'bug' + ? { description, steps, expected, actual } + : { problem, solution, alternatives } + const url = buildIssueUrl(reportType, settingsBlock, title, fields, serverVersion) await platformService.openExternal(url) } diff --git a/src/lib/components/settings/lib/bugReport.ts b/src/lib/components/settings/lib/bugReport.ts index b0815fa..b88dd0e 100644 --- a/src/lib/components/settings/lib/bugReport.ts +++ b/src/lib/components/settings/lib/bugReport.ts @@ -107,13 +107,48 @@ export function buildSettingsBlock(keys: (keyof Settings)[]): string { .join('\n') } -export function buildIssueUrl(type: ReportType, settingsBlock: string, title: string, serverVersion?: string): string { - const base = 'https://github.com/moku-project/Moku/issues/new' - const params = new URLSearchParams({ +export interface BugFields { + description: string + steps: string + expected: string + actual: string +} + +export interface FeatureFields { + problem: string + solution: string + alternatives: string +} + +export function buildIssueUrl( + type: ReportType, + settingsBlock: string, + title: string, + fields: BugFields | FeatureFields, + serverVersion?: string, +): string { + const base = 'https://github.com/moku-project/Moku/issues/new' + + const common = { template: type === 'bug' ? 'bug_report.yml' : 'feature_request.yml', title, environment: buildEnvironmentBlock(serverVersion), - settings: settingsBlock, - }) + } + + const specific = type === 'bug' + ? { + description: (fields as BugFields).description, + steps: (fields as BugFields).steps, + expected: (fields as BugFields).expected, + actual: (fields as BugFields).actual, + settings: settingsBlock, + } + : { + problem: (fields as FeatureFields).problem, + solution: (fields as FeatureFields).solution, + alternatives: (fields as FeatureFields).alternatives, + } + + const params = new URLSearchParams({ ...common, ...specific }) return `${base}?${params.toString()}` } \ No newline at end of file