mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-12-17 00:44:35 +08:00
编排新增文件/文件夹操作,获取文件图标
This commit is contained in:
@@ -49,3 +49,8 @@ export const SymmetricCryptoEditor = defineAsyncComponent(() =>
|
||||
export const AsymmetricCryptoEditor = defineAsyncComponent(() =>
|
||||
import("components/composer/crypto/AsymmetricCryptoEditor.vue")
|
||||
);
|
||||
|
||||
// File Components
|
||||
export const FileOperationEditor = defineAsyncComponent(() =>
|
||||
import("components/composer/file/FileOperationEditor.vue")
|
||||
);
|
||||
|
||||
@@ -4,8 +4,15 @@ export const fileCommands = {
|
||||
defaultOpened: true,
|
||||
commands: [
|
||||
{
|
||||
value: "open",
|
||||
label: "打开文件/文件夹/软件",
|
||||
value: "quickcomposer.file.operation",
|
||||
label: "文件/文件夹操作",
|
||||
component: "FileOperationEditor",
|
||||
desc: "文件和文件夹的读写、删除、重命名等操作",
|
||||
isAsync: true,
|
||||
},
|
||||
{
|
||||
value: "utools.shellOpenItem",
|
||||
label: "默认程序打开",
|
||||
config: [
|
||||
{
|
||||
key: "path",
|
||||
@@ -17,8 +24,8 @@ export const fileCommands = {
|
||||
],
|
||||
},
|
||||
{
|
||||
value: "locate",
|
||||
label: "在文件管理器中定位文件",
|
||||
value: "utools.shellShowItemInFolder",
|
||||
label: "文件管理器中显示",
|
||||
config: [
|
||||
{
|
||||
key: "path",
|
||||
@@ -29,5 +36,18 @@ export const fileCommands = {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
value: "utools.getFileIcon",
|
||||
label: "获取文件图标",
|
||||
config: [
|
||||
{
|
||||
key: "path",
|
||||
label: "文件或软件的绝对路径",
|
||||
type: "input",
|
||||
defaultValue: "",
|
||||
icon: "folder_open",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@ export const networkCommands = {
|
||||
commands: [
|
||||
{
|
||||
value: "visit",
|
||||
label: "用默认浏览器打开网址",
|
||||
label: "默认浏览器打开网址",
|
||||
config: [
|
||||
{
|
||||
key: "url",
|
||||
@@ -18,7 +18,7 @@ export const networkCommands = {
|
||||
},
|
||||
{
|
||||
value: "utools.ubrowser.goto",
|
||||
label: "用ubrowser打开网址",
|
||||
label: "ubrowser打开网址",
|
||||
config: [
|
||||
{
|
||||
key: "url",
|
||||
|
||||
133
src/js/composer/customComponentGuide.js
Normal file
133
src/js/composer/customComponentGuide.js
Normal file
@@ -0,0 +1,133 @@
|
||||
/**
|
||||
* Custom Component Creation Guide
|
||||
* 自定义组件创建指南
|
||||
*/
|
||||
const customComponentGuide = {
|
||||
description: "创建自定义命令组件的完整流程",
|
||||
steps: {
|
||||
"1. Backend Interface": {
|
||||
location: "plugin/lib/quickcomposer/xxx/yyy.js",
|
||||
description: "创建具体功能实现",
|
||||
requirements: {
|
||||
functionDefinition: "使用独立函数而非对象方法",
|
||||
asyncHandling: "使用 async/await 处理异步操作",
|
||||
errorHandling: "合理的错误捕获和提示",
|
||||
paramValidation: "检查必要参数是否存在",
|
||||
},
|
||||
},
|
||||
"2. Interface Export": {
|
||||
location: "plugin/lib/quickcomposer/xxx/index.js",
|
||||
description: "导出接口给quickcomposer使用",
|
||||
examples: {
|
||||
singleFunction: "module.exports = { operation }",
|
||||
multipleFunctions: "module.exports = { ...encoder, ...hash }",
|
||||
},
|
||||
},
|
||||
"3. Interface Registration": {
|
||||
location: "plugin/lib/quickcomposer.js",
|
||||
description: "将接口注册到quickcomposer对象",
|
||||
format: "quickcomposer.xxx = require('./quickcomposer/xxx')",
|
||||
},
|
||||
"4. Component Development": {
|
||||
location: "src/components/composer/xxx/YourComponent.vue",
|
||||
basicStructure: {
|
||||
template: "组件模板,使用quasar组件库",
|
||||
script: "组件逻辑,使用Vue3 defineComponent",
|
||||
style: "组件样式,建议使用scoped",
|
||||
},
|
||||
keyPoints: {
|
||||
variableInput: {
|
||||
scenarios: [
|
||||
"需要支持变量输入的文本框",
|
||||
"数字输入框(设置inputType='number')",
|
||||
"需要自动处理引号的输入",
|
||||
],
|
||||
props: {
|
||||
vModel: "双向绑定值",
|
||||
command: "配置图标和输入类型",
|
||||
label: "输入框标签",
|
||||
},
|
||||
events: {
|
||||
description: "需要监听的事件",
|
||||
list: ["@update:model-value='updateConfig' - 监听值变化并更新代码"],
|
||||
},
|
||||
},
|
||||
selectInput: {
|
||||
description: "选择框组件",
|
||||
component: "q-select",
|
||||
props: {
|
||||
"v-model": "双向绑定值",
|
||||
options: "选项列表",
|
||||
label: "标签文本",
|
||||
"emit-value": "true - 使用选项的value作为值",
|
||||
"map-options": "true - 启用选项映射",
|
||||
},
|
||||
events: {
|
||||
"@update:model-value": "必须监听此事件以触发代码更新",
|
||||
},
|
||||
tips: "所有影响代码生成的输入组件都必须在值变化时触发updateConfig",
|
||||
},
|
||||
codeGeneration: {
|
||||
tool: "使用formatJsonVariables处理变量",
|
||||
params: {
|
||||
config: "完整的配置对象",
|
||||
variableFields: "需要处理的字段列表",
|
||||
},
|
||||
formats: {
|
||||
objectParams: {
|
||||
description: "当参数是对象时的处理方式",
|
||||
example:
|
||||
"`quickcomposer.xxx.yyy(${formatJsonVariables(config, variableFields)})`",
|
||||
reference: "参考 AxiosConfigEditor.vue",
|
||||
},
|
||||
simpleParams: {
|
||||
description: "当参数是简单值时的处理方式",
|
||||
example: "`${functionName}(${args.join(',')})`",
|
||||
reference: "参考 MultiParams.vue",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"5. Component Registration": {
|
||||
location: "src/js/composer/cardComponents.js",
|
||||
description: "使用defineAsyncComponent注册组件",
|
||||
format:
|
||||
"export const YourComponent = defineAsyncComponent(() => import('path/to/component'))",
|
||||
},
|
||||
"6. Command Configuration": {
|
||||
location: "src/js/composer/commands/xxxCommands.js",
|
||||
requiredFields: {
|
||||
value: "quickcomposer.xxx.yyy",
|
||||
label: "显示名称",
|
||||
component: "组件名称",
|
||||
},
|
||||
optionalFields: {
|
||||
desc: "命令描述",
|
||||
isAsync: "是否异步命令",
|
||||
isControlFlow: "是否控制流命令",
|
||||
allowEmptyArgv: "是否允许空参数",
|
||||
},
|
||||
},
|
||||
},
|
||||
notes: {
|
||||
variableHandling: {
|
||||
description: "VariableInput 值的处理方式取决于参数类型",
|
||||
cases: {
|
||||
objectCase:
|
||||
"当值在对象中时,使用 formatJsonVariables 处理,如 AxiosConfigEditor",
|
||||
simpleCase: "当值是直接参数时,直接使用值本身,如 MultiParams",
|
||||
},
|
||||
tips: "formatJsonVariables 主要用于处理对象中的变量,避免对简单参数使用,以免产生不必要的引号",
|
||||
},
|
||||
asyncCommand: "后端使用异步函数时,命令配置需要设置isAsync: true",
|
||||
componentStructure: "参考现有组件的实现方式,保持一致的代码风格",
|
||||
errorHandling: "前后端都需要适当的错误处理和提示",
|
||||
typeChecking: "确保所有参数都有适当的类型检查",
|
||||
},
|
||||
examples: {
|
||||
simpleComponent: "RegexEditor - 单一功能的组件",
|
||||
complexComponent: "AxiosConfigEditor - 多功能、多配置的组件",
|
||||
controlComponent: "ConditionalJudgment - 流程控制组件",
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user