Merge pull request #27 from sijinhui/dev

合并分支
This commit is contained in:
sijinhui 2024-03-09 11:47:47 +08:00 committed by GitHub
commit 85328cb35b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 8 deletions

View File

@ -31,6 +31,9 @@ declare global {
// google only // google only
GOOGLE_API_KEY?: string; GOOGLE_API_KEY?: string;
GOOGLE_URL?: string; GOOGLE_URL?: string;
// google tag manager
GTM_ID?: string;
} }
} }
} }

1
app/global.d.ts vendored
View File

@ -19,6 +19,7 @@ declare interface Window {
}; };
fs: { fs: {
writeBinaryFile(path: string, data: Uint8Array): Promise<void>; writeBinaryFile(path: string, data: Uint8Array): Promise<void>;
writeTextFile(path: string, data: string): Promise<void>;
}; };
notification: { notification: {
requestPermission(): Promise<Permission>; requestPermission(): Promise<Permission>;

View File

@ -8,10 +8,12 @@ export function trimTopic(topic: string) {
// Fix an issue where double quotes still show in the Indonesian language // Fix an issue where double quotes still show in the Indonesian language
// This will remove the specified punctuation from the end of the string // This will remove the specified punctuation from the end of the string
// and also trim quotes from both the start and end if they exist. // and also trim quotes from both the start and end if they exist.
return topic return (
topic
// fix for gemini // fix for gemini
.replace(/^["“”*]+|["“”*]+$/g, "") .replace(/^["“”*]+|["“”*]+$/g, "")
.replace(/[,。!?”“"、,.!?*]*$/, ""); .replace(/[,。!?”“"、,.!?*]*$/, "")
);
} }
export async function copyToClipboard(text: string) { export async function copyToClipboard(text: string) {
@ -57,10 +59,7 @@ export async function downloadAs(text: string, filename: string) {
if (result !== null) { if (result !== null) {
try { try {
await window.__TAURI__.fs.writeBinaryFile( await window.__TAURI__.fs.writeTextFile(result, text);
result,
new Uint8Array([...text].map((c) => c.charCodeAt(0))),
);
showToast(Locale.Download.Success); showToast(Locale.Download.Success);
} catch (error) { } catch (error) {
showToast(Locale.Download.Failed); showToast(Locale.Download.Failed);