mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-30 04:42:45 +08:00
MacOS专区,新增访达管理,支持获取选中项,获取打开的路径,显示隐藏文件,获取窗口列表,激活窗口
This commit is contained in:
parent
f7165c9f2d
commit
b7af2bd1ff
@ -1,76 +1,47 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
// 获取选中项
|
// 获取选中项
|
||||||
getSelection: async function () {
|
getSelection: async function () {
|
||||||
return await quickcommand.runAppleScript(`
|
const result = await quickcommand.runAppleScript(`
|
||||||
tell application "Finder"
|
tell application "Finder"
|
||||||
set selectedItems to selection
|
set selectedItems to selection
|
||||||
set itemList to {}
|
set json to "["
|
||||||
repeat with theItem in selectedItems
|
repeat with i from 1 to count of selectedItems
|
||||||
set end of itemList to {
|
set theItem to item i of selectedItems
|
||||||
name: name of theItem,
|
set json to json & "{"
|
||||||
path: POSIX path of (theItem as alias),
|
set json to json & "\\"name\\":\\"" & name of theItem & "\\","
|
||||||
kind: kind of theItem,
|
set json to json & "\\"path\\":\\"" & POSIX path of (theItem as alias) & "\\","
|
||||||
size: size of theItem,
|
set json to json & "\\"kind\\":\\"" & kind of theItem & "\\","
|
||||||
created: creation date of theItem,
|
set json to json & "\\"size\\":" & size of theItem & ","
|
||||||
modified: modification date of theItem
|
set json to json & "\\"created\\":\\"" & creation date of theItem & "\\","
|
||||||
}
|
set json to json & "\\"modified\\":\\"" & modification date of theItem & "\\""
|
||||||
|
set json to json & "}"
|
||||||
|
if i < count of selectedItems then
|
||||||
|
set json to json & ","
|
||||||
|
end if
|
||||||
end repeat
|
end repeat
|
||||||
return itemList
|
set json to json & "]"
|
||||||
|
return json
|
||||||
end tell
|
end tell
|
||||||
`);
|
`);
|
||||||
|
return JSON.parse(result);
|
||||||
},
|
},
|
||||||
|
|
||||||
// 获取当前文件夹
|
// 获取当前文件夹
|
||||||
getCurrentFolder: async function () {
|
getCurrentFolder: async function () {
|
||||||
return await quickcommand.runAppleScript(`
|
const result = await quickcommand.runAppleScript(`
|
||||||
tell application "Finder"
|
tell application "Finder"
|
||||||
set currentFolder to (target of front window) as alias
|
set currentFolder to (target of front window) as alias
|
||||||
return {
|
set json to "{"
|
||||||
name: name of currentFolder,
|
set json to json & "\\"name\\":\\"" & name of currentFolder & "\\","
|
||||||
path: POSIX path of currentFolder,
|
set json to json & "\\"path\\":\\"" & POSIX path of currentFolder & "\\","
|
||||||
kind: kind of currentFolder,
|
set json to json & "\\"kind\\":\\"" & kind of currentFolder & "\\","
|
||||||
created: creation date of currentFolder,
|
set json to json & "\\"created\\":\\"" & creation date of currentFolder & "\\","
|
||||||
modified: modification date of currentFolder
|
set json to json & "\\"modified\\":\\"" & modification date of currentFolder & "\\""
|
||||||
}
|
set json to json & "}"
|
||||||
end tell
|
return json
|
||||||
`);
|
|
||||||
},
|
|
||||||
|
|
||||||
// 新建文件夹
|
|
||||||
newFolder: async function (name) {
|
|
||||||
return await quickcommand.runAppleScript(`
|
|
||||||
tell application "Finder"
|
|
||||||
set currentFolder to (target of front window) as alias
|
|
||||||
make new folder at currentFolder with properties {name:"${name}"}
|
|
||||||
end tell
|
|
||||||
`);
|
|
||||||
},
|
|
||||||
|
|
||||||
// 移到废纸篓
|
|
||||||
moveToTrash: async function () {
|
|
||||||
return await quickcommand.runAppleScript(`
|
|
||||||
tell application "Finder"
|
|
||||||
delete selection
|
|
||||||
end tell
|
|
||||||
`);
|
|
||||||
},
|
|
||||||
|
|
||||||
// 清空废纸篓
|
|
||||||
emptyTrash: async function () {
|
|
||||||
return await quickcommand.runAppleScript(`
|
|
||||||
tell application "Finder"
|
|
||||||
empty trash
|
|
||||||
end tell
|
|
||||||
`);
|
|
||||||
},
|
|
||||||
|
|
||||||
// 显示包内容
|
|
||||||
showPackageContents: async function (path) {
|
|
||||||
return await quickcommand.runAppleScript(`
|
|
||||||
tell application "Finder"
|
|
||||||
open package folder "${path}"
|
|
||||||
end tell
|
end tell
|
||||||
`);
|
`);
|
||||||
|
return JSON.parse(result);
|
||||||
},
|
},
|
||||||
|
|
||||||
// 设置显示隐藏文件
|
// 设置显示隐藏文件
|
||||||
@ -81,29 +52,38 @@ module.exports = {
|
|||||||
`);
|
`);
|
||||||
},
|
},
|
||||||
|
|
||||||
// 设置显示路径栏
|
// 获取窗口列表
|
||||||
setShowPathbar: async function (show) {
|
getWindows: async function () {
|
||||||
return await quickcommand.runAppleScript(`
|
const result = await quickcommand.runAppleScript(`
|
||||||
tell application "Finder"
|
tell application "Finder"
|
||||||
set ShowPathbar to ${show}
|
set windowList to every window
|
||||||
|
set json to "["
|
||||||
|
repeat with i from 1 to count of windowList
|
||||||
|
set theWindow to item i of windowList
|
||||||
|
set json to json & "{"
|
||||||
|
set json to json & "\\"name\\":\\"" & name of theWindow & "\\","
|
||||||
|
set json to json & "\\"index\\":" & index of theWindow & ","
|
||||||
|
set json to json & "\\"bounds\\":\\"" & bounds of theWindow & "\\","
|
||||||
|
set json to json & "\\"target\\":\\"" & POSIX path of (target of theWindow as alias) & "\\""
|
||||||
|
set json to json & "}"
|
||||||
|
if i < count of windowList then
|
||||||
|
set json to json & ","
|
||||||
|
end if
|
||||||
|
end repeat
|
||||||
|
set json to json & "]"
|
||||||
|
return json
|
||||||
end tell
|
end tell
|
||||||
`);
|
`);
|
||||||
|
return JSON.parse(result);
|
||||||
},
|
},
|
||||||
|
|
||||||
// 设置显示状态栏
|
// 激活指定窗口
|
||||||
setShowStatusBar: async function (show) {
|
activateWindow: async function (index) {
|
||||||
return await quickcommand.runAppleScript(`
|
return await quickcommand.runAppleScript(`
|
||||||
tell application "Finder"
|
tell application "Finder"
|
||||||
set StatusBar to ${show}
|
activate
|
||||||
end tell
|
set theWindow to window ${index}
|
||||||
`);
|
set index of theWindow to 1
|
||||||
},
|
|
||||||
|
|
||||||
// 设置显示预览面板
|
|
||||||
setShowPreviewPane: async function (show) {
|
|
||||||
return await quickcommand.runAppleScript(`
|
|
||||||
tell application "Finder"
|
|
||||||
set PreviewPaneIsVisible to ${show}
|
|
||||||
end tell
|
end tell
|
||||||
`);
|
`);
|
||||||
},
|
},
|
||||||
|
@ -43,7 +43,7 @@ export default defineComponent({
|
|||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: [Object, String, Number, Array, Boolean],
|
type: null,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -288,7 +288,7 @@ export const macosCommands = {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "quickcomposer.macos.finder",
|
value: "quickcomposer.macos.finder.getSelection",
|
||||||
label: "访达管理",
|
label: "访达管理",
|
||||||
desc: "访达操作和文件管理功能",
|
desc: "访达操作和文件管理功能",
|
||||||
icon: "folder",
|
icon: "folder",
|
||||||
@ -297,61 +297,16 @@ export const macosCommands = {
|
|||||||
{
|
{
|
||||||
value: "quickcomposer.macos.finder.getSelection",
|
value: "quickcomposer.macos.finder.getSelection",
|
||||||
label: "获取选中项",
|
label: "获取选中项",
|
||||||
desc: "获取访达中当前选中的项目",
|
|
||||||
icon: "select_all",
|
icon: "select_all",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "quickcomposer.macos.finder.getCurrentFolder",
|
value: "quickcomposer.macos.finder.getCurrentFolder",
|
||||||
label: "获取当前文件夹",
|
label: "获取打开的路径",
|
||||||
desc: "获取访达当前打开的文件夹路径",
|
|
||||||
icon: "folder_open",
|
icon: "folder_open",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
value: "quickcomposer.macos.finder.newFolder",
|
|
||||||
label: "新建文件夹",
|
|
||||||
desc: "在当前位置创建新文件夹",
|
|
||||||
icon: "create_new_folder",
|
|
||||||
config: [
|
|
||||||
{
|
|
||||||
key: "name",
|
|
||||||
label: "文件夹名称",
|
|
||||||
component: "TextInput",
|
|
||||||
width: 12,
|
|
||||||
placeholder: "新建文件夹",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: "quickcomposer.macos.finder.moveToTrash",
|
|
||||||
label: "移到废纸篓",
|
|
||||||
desc: "将选中项目移动到废纸篓",
|
|
||||||
icon: "delete",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: "quickcomposer.macos.finder.emptyTrash",
|
|
||||||
label: "清空废纸篓",
|
|
||||||
desc: "清空废纸篓",
|
|
||||||
icon: "delete_forever",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: "quickcomposer.macos.finder.showPackageContents",
|
|
||||||
label: "显示包内容",
|
|
||||||
desc: "显示应用程序包内容",
|
|
||||||
icon: "folder_zip",
|
|
||||||
config: [
|
|
||||||
{
|
|
||||||
key: "path",
|
|
||||||
label: "应用路径",
|
|
||||||
component: "FilePicker",
|
|
||||||
width: 12,
|
|
||||||
placeholder: "选择应用程序",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
value: "quickcomposer.macos.finder.setShowHiddenFiles",
|
value: "quickcomposer.macos.finder.setShowHiddenFiles",
|
||||||
label: "显示隐藏文件",
|
label: "显示隐藏文件",
|
||||||
desc: "设置是否显示隐藏文件",
|
|
||||||
icon: "visibility",
|
icon: "visibility",
|
||||||
config: [
|
config: [
|
||||||
{
|
{
|
||||||
@ -364,47 +319,25 @@ export const macosCommands = {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "quickcomposer.macos.finder.setShowPathbar",
|
value: "quickcomposer.macos.finder.getWindows",
|
||||||
label: "显示路径栏",
|
label: "获取窗口列表",
|
||||||
desc: "设置是否显示路径栏",
|
desc: "获取所有访达窗口信息",
|
||||||
icon: "wrap_text",
|
icon: "window",
|
||||||
config: [
|
|
||||||
{
|
|
||||||
key: "show",
|
|
||||||
label: "显示",
|
|
||||||
component: "CheckButton",
|
|
||||||
width: 12,
|
|
||||||
defaultValue: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "quickcomposer.macos.finder.setShowStatusBar",
|
value: "quickcomposer.macos.finder.activateWindow",
|
||||||
label: "显示状态栏",
|
label: "激活窗口",
|
||||||
desc: "设置是否显示状态栏",
|
desc: "激活指定的访达窗口",
|
||||||
icon: "info",
|
icon: "open_in_new",
|
||||||
config: [
|
config: [
|
||||||
{
|
{
|
||||||
key: "show",
|
key: "index",
|
||||||
label: "显示",
|
label: "窗口索引",
|
||||||
component: "CheckButton",
|
component: "NumberInput",
|
||||||
|
icon: "window",
|
||||||
|
min: 1,
|
||||||
|
defaultValue: 1,
|
||||||
width: 12,
|
width: 12,
|
||||||
defaultValue: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: "quickcomposer.macos.finder.setShowPreviewPane",
|
|
||||||
label: "显示预览面板",
|
|
||||||
desc: "设置是否显示预览面板",
|
|
||||||
icon: "preview",
|
|
||||||
config: [
|
|
||||||
{
|
|
||||||
key: "show",
|
|
||||||
label: "显示",
|
|
||||||
component: "CheckButton",
|
|
||||||
width: 12,
|
|
||||||
defaultValue: true,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user