mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 16:40:13 +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/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
const {
|
const {
|
||||||
net, app, BrowserWindow, shell, Menu, screen, ipcMain, globalShortcut, Tray, dialog
|
net, app, BrowserWindow, shell, Menu, screen, ipcMain, globalShortcut, Tray, dialog, systemPreferences
|
||||||
} = require("electron");
|
} = require("electron");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
|
|
@ -674,6 +674,12 @@ app.whenReady().then(() => {
|
||||||
if (data.cmd === "isFullScreen") {
|
if (data.cmd === "isFullScreen") {
|
||||||
return getWindowByContentId(event.sender.id).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) => {
|
ipcMain.on("siyuan-cmd", (event, cmd) => {
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import {setEditMode} from "../util/setEditMode";
|
||||||
import {RecordMedia} from "../util/RecordMedia";
|
import {RecordMedia} from "../util/RecordMedia";
|
||||||
import {hideMessage, showMessage} from "../../dialog/message";
|
import {hideMessage, showMessage} from "../../dialog/message";
|
||||||
import {uploadFiles} from "../upload";
|
import {uploadFiles} from "../upload";
|
||||||
import {hasClosestBlock, hasClosestByAttribute, hasClosestByClassName} from "../util/hasClosest";
|
import {hasClosestBlock, hasClosestByAttribute} from "../util/hasClosest";
|
||||||
import {needSubscribe} from "../../util/needSubscribe";
|
import {needSubscribe} from "../../util/needSubscribe";
|
||||||
import {isMobile} from "../../util/functions";
|
import {isMobile} from "../../util/functions";
|
||||||
import {zoomOut} from "../../menus/protyle";
|
import {zoomOut} from "../../menus/protyle";
|
||||||
|
|
@ -18,7 +18,7 @@ import {openFileById} from "../../editor/util";
|
||||||
import {setPanelFocus} from "../../layout/util";
|
import {setPanelFocus} from "../../layout/util";
|
||||||
/// #endif
|
/// #endif
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
import {systemPreferences} from "@electron/remote";
|
import {ipcRenderer} from "electron";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {onGet} from "../util/onGet";
|
import {onGet} from "../util/onGet";
|
||||||
import {hideElements} from "../ui/hideElements";
|
import {hideElements} from "../ui/hideElements";
|
||||||
|
|
@ -271,12 +271,12 @@ export class Breadcrumb {
|
||||||
click: async () => {
|
click: async () => {
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
if (window.siyuan.config.system.os === "darwin") {
|
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)) {
|
if (["denied", "restricted", "unknown"].includes(status)) {
|
||||||
showMessage(window.siyuan.languages.microphoneDenied);
|
showMessage(window.siyuan.languages.microphoneDenied);
|
||||||
return;
|
return;
|
||||||
} else if (status === "not-determined") {
|
} else if (status === "not-determined") {
|
||||||
const isAccess = await systemPreferences.askForMediaAccess("microphone");
|
const isAccess = await ipcRenderer.invoke(Constants.SIYUAN_GET, {cmd: "askMicrophone"})
|
||||||
if (!isAccess) {
|
if (!isAccess) {
|
||||||
showMessage(window.siyuan.languages.microphoneNotAccess);
|
showMessage(window.siyuan.languages.microphoneNotAccess);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue