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 = {
// 控制中心
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) {
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 () {
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) {
return await quickcommand.runAppleScript(`

View File

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

View File

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