mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-30 21:13:02 +08:00
systemDialog样式根据操作系统改变
This commit is contained in:
parent
d64f00a8b4
commit
b71f47ec56
@ -25,6 +25,9 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||||||
document.getElementById("content").textContent = config.content;
|
document.getElementById("content").textContent = config.content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 添加平台类名
|
||||||
|
document.body.classList.add(`platform-${config.platform}`);
|
||||||
|
|
||||||
// 根据类型设置不同的对话框内容
|
// 根据类型设置不同的对话框内容
|
||||||
switch (config.type) {
|
switch (config.type) {
|
||||||
case "message":
|
case "message":
|
||||||
|
@ -1,19 +1,25 @@
|
|||||||
const { ipcRenderer } = require("electron");
|
const { ipcRenderer } = require("electron");
|
||||||
|
const os = require("os");
|
||||||
const { createBrowserWindow } = utools;
|
const { createBrowserWindow } = utools;
|
||||||
/**
|
/**
|
||||||
* 创建对话框窗口
|
* 创建对话框窗口
|
||||||
* @param {object} config - 对话框配置
|
* @param {object} config - 对话框配置
|
||||||
* @param {object} [customOptions] - 自定义窗口选项
|
* @param {object} [customDialogOptions] - 自定义窗口选项
|
||||||
* @returns {Promise} 返回对话框结果
|
* @returns {Promise} 返回对话框结果
|
||||||
*/
|
*/
|
||||||
const createDialog = (config, customOptions = {}) => {
|
const createDialog = (config, customDialogOptions = {}) => {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const dialogPath = "lib/dialog/view.html";
|
const dialogPath = "lib/dialog/view.html";
|
||||||
const preloadPath = "lib/dialog/controller.js";
|
const preloadPath = "lib/dialog/controller.js";
|
||||||
|
|
||||||
|
const platform = os.platform();
|
||||||
|
|
||||||
|
const dialogWidth =
|
||||||
|
platform === "win32" && config.type !== "textarea" ? 370 : 470;
|
||||||
|
|
||||||
const dialogOptions = {
|
const dialogOptions = {
|
||||||
title: config.title || "对话框",
|
title: config.title || "对话框",
|
||||||
width: 470,
|
width: dialogWidth,
|
||||||
height: 80,
|
height: 80,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
minimizable: false,
|
minimizable: false,
|
||||||
@ -27,7 +33,7 @@ const createDialog = (config, customOptions = {}) => {
|
|||||||
preload: preloadPath,
|
preload: preloadPath,
|
||||||
devTools: utools.isDev(),
|
devTools: utools.isDev(),
|
||||||
},
|
},
|
||||||
...customOptions, // 合并自定义选项
|
...customDialogOptions, // 合并自定义选项
|
||||||
};
|
};
|
||||||
|
|
||||||
// 创建窗口
|
// 创建窗口
|
||||||
@ -48,7 +54,7 @@ const createDialog = (config, customOptions = {}) => {
|
|||||||
const newBounds = {
|
const newBounds = {
|
||||||
x: Math.round(bounds.x),
|
x: Math.round(bounds.x),
|
||||||
y: Math.max(0, y), // 确保不会超出屏幕顶部
|
y: Math.max(0, y), // 确保不会超出屏幕顶部
|
||||||
width: 470,
|
width: dialogWidth,
|
||||||
height: Math.round(height),
|
height: Math.round(height),
|
||||||
};
|
};
|
||||||
// 设置新的位置和大小
|
// 设置新的位置和大小
|
||||||
@ -68,6 +74,7 @@ const createDialog = (config, customOptions = {}) => {
|
|||||||
ipcRenderer.sendTo(UBrowser.webContents.id, "dialog-config", {
|
ipcRenderer.sendTo(UBrowser.webContents.id, "dialog-config", {
|
||||||
...config,
|
...config,
|
||||||
isDark: utools.isDarkColors(),
|
isDark: utools.isDarkColors(),
|
||||||
|
platform,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user