MacOS专区,系统管理新增系统音量、锁定屏幕、进入睡眠、设置Dock、隐藏菜单、深色模式

This commit is contained in:
fofolee 2025-01-11 19:11:57 +08:00
parent d6f5350425
commit f7165c9f2d
3 changed files with 32 additions and 104 deletions

View File

@ -1,26 +1,4 @@
module.exports = { module.exports = {
// 控制中心
controlCenter: async function () {
return await quickcommand.runAppleScript(`
tell application "System Events"
tell process "Control Center"
click menu bar item 1 of menu bar 1
end tell
end tell
`);
},
// 通知中心
notificationCenter: async function () {
return await quickcommand.runAppleScript(`
tell application "System Events"
tell process "NotificationCenter"
click menu bar item 1 of menu bar 1
end tell
end tell
`);
},
// 设置系统音量 // 设置系统音量
setVolume: async function (volume) { setVolume: async function (volume) {
return await quickcommand.runAppleScript(` return await quickcommand.runAppleScript(`
@ -28,17 +6,6 @@ module.exports = {
`); `);
}, },
// 设置屏幕亮度
setBrightness: async function (brightness) {
return await quickcommand.runAppleScript(`
tell application "System Events"
tell process "SystemUIServer"
set value of slider 1 of group 1 of window "Display" to ${brightness}
end tell
end tell
`);
},
// 锁定屏幕 // 锁定屏幕
lockScreen: async function () { lockScreen: async function () {
return await quickcommand.runAppleScript(` return await quickcommand.runAppleScript(`
@ -92,14 +59,6 @@ module.exports = {
`); `);
}, },
// 设置时钟格式
setClockFormat: async function (format) {
return await quickcommand.runAppleScript(`
do shell script "defaults write com.apple.menuextra.clock DateFormat -string '${format}'"
do shell script "killall SystemUIServer"
`);
},
// 切换深色模式 // 切换深色模式
toggleDarkMode: async function (enabled) { toggleDarkMode: async function (enabled) {
return await quickcommand.runAppleScript(` return await quickcommand.runAppleScript(`

View File

@ -43,7 +43,7 @@ export default defineComponent({
required: true, required: true,
}, },
modelValue: { modelValue: {
type: Object, type: [Object, String, Number, Array, Boolean],
required: true, required: true,
}, },
}, },

View File

@ -153,24 +153,12 @@ export const macosCommands = {
], ],
}, },
{ {
value: "quickcomposer.macos.system", value: "quickcomposer.macos.system.setVolume",
label: "系统管理", label: "系统管理",
desc: "系统级别的控制功能", desc: "系统级别的控制功能",
icon: "settings", icon: "settings",
isAsync: true, isAsync: true,
subCommands: [ subCommands: [
{
value: "quickcomposer.macos.system.controlCenter",
label: "控制中心",
desc: "打开或关闭控制中心",
icon: "toggle_on",
},
{
value: "quickcomposer.macos.system.notificationCenter",
label: "通知中心",
desc: "打开或关闭通知中心",
icon: "notifications",
},
{ {
value: "quickcomposer.macos.system.setVolume", value: "quickcomposer.macos.system.setVolume",
label: "系统音量", label: "系统音量",
@ -184,24 +172,7 @@ export const macosCommands = {
icon: "volume_up", icon: "volume_up",
min: 0, min: 0,
max: 100, max: 100,
defaultValue: 50, step: 10,
width: 12,
},
],
},
{
value: "quickcomposer.macos.system.setBrightness",
label: "屏幕亮度",
desc: "调整屏幕亮度",
icon: "brightness_medium",
config: [
{
key: "brightness",
label: "亮度",
component: "NumberInput",
icon: "brightness_medium",
min: 0,
max: 100,
defaultValue: 50, defaultValue: 50,
width: 12, width: 12,
}, },
@ -221,34 +192,44 @@ export const macosCommands = {
}, },
{ {
value: "quickcomposer.macos.system.setDockPosition", value: "quickcomposer.macos.system.setDockPosition",
label: "Dock位置", label: "设置Dock位置",
desc: "设置Dock栏位置", desc: "设置Dock栏的显示位置",
icon: "swap_horiz", icon: "dock",
config: [ config: [
{ {
key: "position", key: "position",
label: "位置", label: "位置",
component: "ButtonGroup", component: "ButtonGroup",
defaultValue: "bottom",
width: 12, width: 12,
options: [ options: [
{ label: "底部", value: "bottom" }, {
{ label: "左侧", value: "left" }, label: "底部",
{ label: "右侧", value: "right" }, value: "bottom",
},
{
label: "左侧",
value: "left",
},
{
label: "右侧",
value: "right",
},
], ],
defaultValue: "bottom",
}, },
], ],
}, },
{ {
value: "quickcomposer.macos.system.setDockSize", value: "quickcomposer.macos.system.setDockSize",
label: "Dock大小", label: "设置Dock大小",
desc: "设置Dock栏大小", desc: "设置Dock栏的图标大小",
icon: "aspect_ratio", icon: "dock",
config: [ config: [
{ {
key: "size", key: "size",
label: "大小", label: "大小",
component: "NumberInput", component: "NumberInput",
icon: "dock",
min: 16, min: 16,
max: 128, max: 128,
defaultValue: 48, defaultValue: 48,
@ -259,45 +240,32 @@ export const macosCommands = {
{ {
value: "quickcomposer.macos.system.toggleDockAutohide", value: "quickcomposer.macos.system.toggleDockAutohide",
label: "Dock自动隐藏", label: "Dock自动隐藏",
desc: "设置Dock栏自动隐藏", desc: "设置Dock栏是否自动隐藏",
icon: "visibility_off", icon: "dock",
config: [ config: [
{ {
key: "enabled", key: "enabled",
label: "启用", label: "启用",
component: "CheckButton", component: "CheckButton",
width: 12,
defaultValue: false, defaultValue: false,
icon: "dock",
width: 12,
}, },
], ],
}, },
{ {
value: "quickcomposer.macos.system.toggleMenuBarAutohide", value: "quickcomposer.macos.system.toggleMenuBarAutohide",
label: "菜单栏自动隐藏", label: "菜单栏自动隐藏",
desc: "设置菜单栏自动隐藏", desc: "设置菜单栏是否自动隐藏",
icon: "visibility_off", icon: "menu",
config: [ config: [
{ {
key: "enabled", key: "enabled",
label: "启用", label: "启用",
component: "CheckButton", component: "CheckButton",
width: 12,
defaultValue: false, defaultValue: false,
}, icon: "menu",
],
},
{
value: "quickcomposer.macos.system.setClockFormat",
label: "时钟格式",
desc: "设置菜单栏时钟显示格式",
icon: "schedule",
config: [
{
key: "format",
label: "格式",
component: "TextInput",
width: 12, width: 12,
placeholder: "EEE MMM d H:mm:ss",
}, },
], ],
}, },
@ -311,8 +279,9 @@ export const macosCommands = {
key: "enabled", key: "enabled",
label: "启用", label: "启用",
component: "CheckButton", component: "CheckButton",
defaultValue: true,
icon: "dark_mode",
width: 12, width: 12,
defaultValue: false,
}, },
], ],
}, },