Vanessa 2022-06-05 00:48:29 +08:00
parent 64ae905921
commit ff3cd4d4e9
21 changed files with 117 additions and 85 deletions

View file

@ -166,6 +166,7 @@ export class Breadcrumb {
icon: "iconRecord",
label: this.mediaRecorder?.isRecording ? window.siyuan.languages.endRecord : window.siyuan.languages.startRecord,
click: () => {
let messageId = ''
if (!this.mediaRecorder) {
navigator.mediaDevices.getUserMedia({audio: true}).then((mediaStream: MediaStream) => {
this.mediaRecorder = new RecordMedia(mediaStream);
@ -180,7 +181,7 @@ export class Breadcrumb {
this.mediaRecorder.cloneChannelData(left, right);
};
this.mediaRecorder.startRecordingNewWavFile();
showMessage(window.siyuan.languages.recording, 86400000);
id = showMessage(window.siyuan.languages.recording, -1);
}).catch(() => {
showMessage(window.siyuan.languages["record-tip"]);
});
@ -189,12 +190,13 @@ export class Breadcrumb {
if (this.mediaRecorder.isRecording) {
this.mediaRecorder.stopRecording();
hideMessage();
hideMessage(messageId);
const file: File = new File([this.mediaRecorder.buildWavFileBlob()],
`record${(new Date()).getTime()}.wav`, {type: "video/webm"});
uploadFiles(protyle, [file]);
} else {
showMessage(window.siyuan.languages.recording, 86400000);
hideMessage(messageId);
messageId = showMessage(window.siyuan.languages.recording, -1);
this.mediaRecorder.startRecordingNewWavFile();
}
}

View file

@ -1,4 +1,4 @@
import {showMessage} from "../../dialog/message";
import {hideMessage, showMessage} from "../../dialog/message";
import {Constants} from "../../constants";
/// #if !BROWSER
import {PrintToPDFOptions, SaveDialogReturnValue} from "electron";
@ -126,7 +126,7 @@ const getExportPath = (option: { type: string, id: string }, pdfOption?: PrintTo
properties: ["showOverwriteConfirmation"],
}).then((result: SaveDialogReturnValue) => {
if (!result.canceled) {
showMessage(window.siyuan.languages.exporting, -1);
const id = showMessage(window.siyuan.languages.exporting, -1);
let url = "/api/export/exportHTML";
if (option.type === "htmlmd") {
url = "/api/export/exportMdHTML";
@ -138,6 +138,7 @@ const getExportPath = (option: { type: string, id: string }, pdfOption?: PrintTo
pdf: option.type === "pdf",
savePath: result.filePath
}, exportResponse => {
hideMessage(id);
if (option.type === "word") {
afterExport(result.filePath);
} else {

View file

@ -5,7 +5,7 @@ import {shell} from "electron";
import * as path from "path";
export const afterExport = (exportPath: string) => {
showMessage(`<div class="fn__flex">
const id = showMessage(`<div class="fn__flex">
<div class="fn__flex-center">${window.siyuan.languages.exported}${escapeHtml(exportPath)}</div>
<div class="fn__space"></div>
<div class="fn__space"></div>
@ -13,7 +13,7 @@ export const afterExport = (exportPath: string) => {
</div>`, 6000);
document.querySelector("#message button").addEventListener("click", () => {
shell.showItemInFolder(path.join(exportPath));
hideMessage();
hideMessage(id);
});
};
/// #endif

View file

@ -81,7 +81,6 @@ export class Background {
uploadFiles(protyle, event.target.files, event.target, (responseText) => {
const response = JSON.parse(responseText);
const style = `background-image:url(${response.data.succMap[Object.keys(response.data.succMap)[0]]})`;
hideMessage();
this.ial["title-img"] = Lute.EscapeHTMLStr(style);
this.render(this.ial, protyle.block.rootID);
fetchPost("/api/attr/setBlockAttrs", {

View file

@ -17,7 +17,6 @@ export class Upload {
}
const validateFile = (protyle: IProtyle, files: File[]) => {
hideMessage();
const uploadFileList = [];
let errorTip = "";
let uploadingStr = "";
@ -94,8 +93,6 @@ const genUploadedLabel = (responseText: string, protyle: IProtyle) => {
if (errorTip) {
showMessage(errorTip);
} else {
hideMessage();
}
let succFileText = "";