mirror of
https://github.com/Yidadaa/ChatGPT-Next-Web.git
synced 2025-08-08 21:44:59 +08:00
feat: close #887 import masks
This commit is contained in:
20
app/utils.ts
20
app/utils.ts
@@ -42,6 +42,26 @@ export function downloadAs(text: string, filename: string) {
|
||||
document.body.removeChild(element);
|
||||
}
|
||||
|
||||
export function readFromFile() {
|
||||
return new Promise<string>((res, rej) => {
|
||||
const fileInput = document.createElement("input");
|
||||
fileInput.type = "file";
|
||||
fileInput.accept = "application/json";
|
||||
|
||||
fileInput.onchange = (event: any) => {
|
||||
const file = event.target.files[0];
|
||||
const fileReader = new FileReader();
|
||||
fileReader.onload = (e: any) => {
|
||||
res(e.target.result);
|
||||
};
|
||||
fileReader.onerror = (e) => rej(e);
|
||||
fileReader.readAsText(file);
|
||||
};
|
||||
|
||||
fileInput.click();
|
||||
});
|
||||
}
|
||||
|
||||
export function isIOS() {
|
||||
const userAgent = navigator.userAgent.toLowerCase();
|
||||
return /iphone|ipad|ipod/.test(userAgent);
|
||||
|
Reference in New Issue
Block a user