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.body.classList.add(`platform-${config.platform}`);
|
||||
|
||||
// 根据类型设置不同的对话框内容
|
||||
switch (config.type) {
|
||||
case "message":
|
||||
|
@ -1,19 +1,25 @@
|
||||
const { ipcRenderer } = require("electron");
|
||||
const os = require("os");
|
||||
const { createBrowserWindow } = utools;
|
||||
/**
|
||||
* 创建对话框窗口
|
||||
* @param {object} config - 对话框配置
|
||||
* @param {object} [customOptions] - 自定义窗口选项
|
||||
* @param {object} [customDialogOptions] - 自定义窗口选项
|
||||
* @returns {Promise} 返回对话框结果
|
||||
*/
|
||||
const createDialog = (config, customOptions = {}) => {
|
||||
const createDialog = (config, customDialogOptions = {}) => {
|
||||
return new Promise((resolve) => {
|
||||
const dialogPath = "lib/dialog/view.html";
|
||||
const preloadPath = "lib/dialog/controller.js";
|
||||
|
||||
const platform = os.platform();
|
||||
|
||||
const dialogWidth =
|
||||
platform === "win32" && config.type !== "textarea" ? 370 : 470;
|
||||
|
||||
const dialogOptions = {
|
||||
title: config.title || "对话框",
|
||||
width: 470,
|
||||
width: dialogWidth,
|
||||
height: 80,
|
||||
resizable: false,
|
||||
minimizable: false,
|
||||
@ -27,7 +33,7 @@ const createDialog = (config, customOptions = {}) => {
|
||||
preload: preloadPath,
|
||||
devTools: utools.isDev(),
|
||||
},
|
||||
...customOptions, // 合并自定义选项
|
||||
...customDialogOptions, // 合并自定义选项
|
||||
};
|
||||
|
||||
// 创建窗口
|
||||
@ -48,7 +54,7 @@ const createDialog = (config, customOptions = {}) => {
|
||||
const newBounds = {
|
||||
x: Math.round(bounds.x),
|
||||
y: Math.max(0, y), // 确保不会超出屏幕顶部
|
||||
width: 470,
|
||||
width: dialogWidth,
|
||||
height: Math.round(height),
|
||||
};
|
||||
// 设置新的位置和大小
|
||||
@ -68,6 +74,7 @@ const createDialog = (config, customOptions = {}) => {
|
||||
ipcRenderer.sendTo(UBrowser.webContents.id, "dialog-config", {
|
||||
...config,
|
||||
isDark: utools.isDarkColors(),
|
||||
platform,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user