forked from XiaoMo/ChatGPT-Next-Web
commit
8874c687d8
@ -152,71 +152,64 @@ export function MessageExporter() {
|
|||||||
index={currentStepIndex}
|
index={currentStepIndex}
|
||||||
onStepChange={setCurrentStepIndex}
|
onStepChange={setCurrentStepIndex}
|
||||||
/>
|
/>
|
||||||
|
<div
|
||||||
<div className={styles["message-exporter-body"]}>
|
className={styles["message-exporter-body"]}
|
||||||
{currentStep.value === "select" && (
|
style={currentStep.value !== "select" ? { display: "none" } : {}}
|
||||||
<>
|
>
|
||||||
<List>
|
<List>
|
||||||
<ListItem
|
<ListItem
|
||||||
title={Locale.Export.Format.Title}
|
title={Locale.Export.Format.Title}
|
||||||
subTitle={Locale.Export.Format.SubTitle}
|
subTitle={Locale.Export.Format.SubTitle}
|
||||||
>
|
>
|
||||||
<Select
|
<Select
|
||||||
value={exportConfig.format}
|
value={exportConfig.format}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
updateExportConfig(
|
updateExportConfig(
|
||||||
(config) =>
|
(config) =>
|
||||||
(config.format = e.currentTarget.value as ExportFormat),
|
(config.format = e.currentTarget.value as ExportFormat),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{formats.map((f) => (
|
{formats.map((f) => (
|
||||||
<option key={f} value={f}>
|
<option key={f} value={f}>
|
||||||
{f}
|
{f}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
<ListItem
|
<ListItem
|
||||||
title={Locale.Export.IncludeContext.Title}
|
title={Locale.Export.IncludeContext.Title}
|
||||||
subTitle={Locale.Export.IncludeContext.SubTitle}
|
subTitle={Locale.Export.IncludeContext.SubTitle}
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
checked={exportConfig.includeContext}
|
checked={exportConfig.includeContext}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
updateExportConfig(
|
updateExportConfig(
|
||||||
(config) =>
|
(config) => (config.includeContext = e.currentTarget.checked),
|
||||||
(config.includeContext = e.currentTarget.checked),
|
);
|
||||||
);
|
}}
|
||||||
}}
|
></input>
|
||||||
></input>
|
</ListItem>
|
||||||
</ListItem>
|
</List>
|
||||||
</List>
|
<MessageSelector
|
||||||
<MessageSelector
|
selection={selection}
|
||||||
selection={selection}
|
updateSelection={updateSelection}
|
||||||
updateSelection={updateSelection}
|
defaultSelectAll
|
||||||
defaultSelectAll
|
/>
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{currentStep.value === "preview" && (
|
|
||||||
<>
|
|
||||||
{exportConfig.format === "text" ? (
|
|
||||||
<MarkdownPreviewer
|
|
||||||
messages={selectedMessages}
|
|
||||||
topic={session.topic}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<ImagePreviewer
|
|
||||||
messages={selectedMessages}
|
|
||||||
topic={session.topic}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
{currentStep.value === "preview" && (
|
||||||
|
<div className={styles["message-exporter-body"]}>
|
||||||
|
{exportConfig.format === "text" ? (
|
||||||
|
<MarkdownPreviewer
|
||||||
|
messages={selectedMessages}
|
||||||
|
topic={session.topic}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<ImagePreviewer messages={selectedMessages} topic={session.topic} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ export function MessageSelector(props: {
|
|||||||
const isValid = (m: ChatMessage) => m.content && !m.isError && !m.streaming;
|
const isValid = (m: ChatMessage) => m.content && !m.isError && !m.streaming;
|
||||||
const messages = session.messages.filter(
|
const messages = session.messages.filter(
|
||||||
(m, i) =>
|
(m, i) =>
|
||||||
m.id && // messsage must has id
|
m.id && // message must have id
|
||||||
isValid(m) &&
|
isValid(m) &&
|
||||||
(i >= session.messages.length - 1 || isValid(session.messages[i + 1])),
|
(i >= session.messages.length - 1 || isValid(session.messages[i + 1])),
|
||||||
);
|
);
|
||||||
@ -88,13 +88,13 @@ export function MessageSelector(props: {
|
|||||||
return searchInput.length === 0 || searchIds.has(id);
|
return searchInput.length === 0 || searchIds.has(id);
|
||||||
};
|
};
|
||||||
const doSearch = (text: string) => {
|
const doSearch = (text: string) => {
|
||||||
const searchResuts = new Set<number>();
|
const searchResults = new Set<number>();
|
||||||
if (text.length > 0) {
|
if (text.length > 0) {
|
||||||
messages.forEach((m) =>
|
messages.forEach((m) =>
|
||||||
m.content.includes(text) ? searchResuts.add(m.id!) : null,
|
m.content.includes(text) ? searchResults.add(m.id!) : null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
setSearchIds(searchResuts);
|
setSearchIds(searchResults);
|
||||||
};
|
};
|
||||||
|
|
||||||
// for range selection
|
// for range selection
|
||||||
|
Loading…
Reference in New Issue
Block a user