mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +01:00
🎨 https://github.com/siyuan-note/siyuan/issues/9368 systemPreferences
This commit is contained in:
parent
b869fd1d9d
commit
2ca7253d1f
2 changed files with 12 additions and 6 deletions
|
|
@ -15,7 +15,7 @@
|
|||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
const {
|
||||
net, app, BrowserWindow, shell, Menu, screen, ipcMain, globalShortcut, Tray, dialog
|
||||
net, app, BrowserWindow, shell, Menu, screen, ipcMain, globalShortcut, Tray, dialog, systemPreferences
|
||||
} = require("electron");
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
|
|
@ -674,6 +674,12 @@ app.whenReady().then(() => {
|
|||
if (data.cmd === "isFullScreen") {
|
||||
return getWindowByContentId(event.sender.id).isFullScreen();
|
||||
}
|
||||
if (data.cmd === "getMicrophone") {
|
||||
return systemPreferences.getMediaAccessStatus("microphone");
|
||||
}
|
||||
if (data.cmd === "askMicrophone") {
|
||||
return systemPreferences.askForMediaAccess("microphone");
|
||||
}
|
||||
});
|
||||
ipcMain.on("siyuan-cmd", (event, cmd) => {
|
||||
switch (cmd) {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import {setEditMode} from "../util/setEditMode";
|
|||
import {RecordMedia} from "../util/RecordMedia";
|
||||
import {hideMessage, showMessage} from "../../dialog/message";
|
||||
import {uploadFiles} from "../upload";
|
||||
import {hasClosestBlock, hasClosestByAttribute, hasClosestByClassName} from "../util/hasClosest";
|
||||
import {hasClosestBlock, hasClosestByAttribute} from "../util/hasClosest";
|
||||
import {needSubscribe} from "../../util/needSubscribe";
|
||||
import {isMobile} from "../../util/functions";
|
||||
import {zoomOut} from "../../menus/protyle";
|
||||
|
|
@ -18,7 +18,7 @@ import {openFileById} from "../../editor/util";
|
|||
import {setPanelFocus} from "../../layout/util";
|
||||
/// #endif
|
||||
/// #if !BROWSER
|
||||
import {systemPreferences} from "@electron/remote";
|
||||
import {ipcRenderer} from "electron";
|
||||
/// #endif
|
||||
import {onGet} from "../util/onGet";
|
||||
import {hideElements} from "../ui/hideElements";
|
||||
|
|
@ -227,7 +227,7 @@ export class Breadcrumb {
|
|||
}
|
||||
}
|
||||
|
||||
public showMenu(protyle: IProtyle, position:IPosition) {
|
||||
public showMenu(protyle: IProtyle, position: IPosition) {
|
||||
if (!window.siyuan.menus.menu.element.classList.contains("fn__none") &&
|
||||
window.siyuan.menus.menu.element.getAttribute("data-name") === "breadcrumbMore") {
|
||||
window.siyuan.menus.menu.remove();
|
||||
|
|
@ -271,12 +271,12 @@ export class Breadcrumb {
|
|||
click: async () => {
|
||||
/// #if !BROWSER
|
||||
if (window.siyuan.config.system.os === "darwin") {
|
||||
const status = systemPreferences.getMediaAccessStatus("microphone");
|
||||
const status = await ipcRenderer.invoke(Constants.SIYUAN_GET, {cmd: "getMicrophone"})
|
||||
if (["denied", "restricted", "unknown"].includes(status)) {
|
||||
showMessage(window.siyuan.languages.microphoneDenied);
|
||||
return;
|
||||
} else if (status === "not-determined") {
|
||||
const isAccess = await systemPreferences.askForMediaAccess("microphone");
|
||||
const isAccess = await ipcRenderer.invoke(Constants.SIYUAN_GET, {cmd: "askMicrophone"})
|
||||
if (!isAccess) {
|
||||
showMessage(window.siyuan.languages.microphoneNotAccess);
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue