Skip to content

实现 CAT_registerMenuInput 支持快捷输入交互#411

Merged
CodFrm merged 7 commits intoscriptscat:mainfrom
DreamNya:mv3
Jun 14, 2025
Merged

实现 CAT_registerMenuInput 支持快捷输入交互#411
CodFrm merged 7 commits intoscriptscat:mainfrom
DreamNya:mv3

Conversation

@DreamNya
Copy link
Contributor

@DreamNya DreamNya commented Jun 1, 2025

改动

  • 实现 用户可通过 CAT_registerMenuInput 方法在 popup 页面与脚本快捷输入交互
    (CAT_registerMenuInput实际作为GM_registerMenuCommand别名,逻辑复用)
    • 支持 "text" | "number" | "boolean" 三种交互方式
    • 新增4个脚本猫独有的CAT_registerMenuInput.options可选字段 inputType inputLabel inputDefaultValue inputPlaceholder 用于控制 popup 交互界面
  • 修复 GM_registerMenuCommand.options.autoClose 字段不生效的bug

预览

image

测试脚本

example\cat_bg_input_menu.js

TODO

  • 支持更多输入方式 如selcet radio checkbox
    - [x] 输入内容存储
  • 样式优化

DreamNya added 3 commits June 2, 2025 03:19
 - 实现 用户可通过
`GM_registerMenuCommand` 方法在 `popup 页面`与脚本快捷输入交互
   - 支持 `"text" | "number" | "boolean"` 三种交互方式
   - 新增4个脚本猫独有的options可选字段 `inputType` `inputLabel` `inputDefaultValue` `inputPlaceholder` 用于控制 `popup` 交互界面
 - 修复 `autoClose` 字段不生效的bug
@CodFrm
Copy link
Member

CodFrm commented Jun 2, 2025

菜单感觉不应该这么复杂

@DreamNya
Copy link
Contributor Author

DreamNya commented Jun 2, 2025

菜单感觉不应该这么复杂

后台脚本没有可动态交互的方式,只能靠CAT_userConfig实现一些机械的静态的交互,用户体验不是很好
popup菜单是最便捷的入口,只要预定义一个输入范围,即可实现动态交互,满足更多的用户需求

@CodFrm
Copy link
Member

CodFrm commented Jun 3, 2025

@DreamNya 相比这个,我觉得为CAT_userConfig加入一些动态交互更好,userConfig也是为了后台脚本配置诞生的

菜单这个我觉得有点难以接受,变得太复杂了,而且popup页面也很小,页面输入也受限制

@CodFrm
Copy link
Member

CodFrm commented Jun 3, 2025

我觉得还是开新API或者userConfig mini化放这里吧,这个UI和交互感觉有点不太好,还得再点击一下菜单才触发事件

另外把所有的选项放在一起会不会好点(userConfig第一个tab/新API),像下面这样(随便画的):

b9baee3596f910b700b1d89ab9fe17d6

@DreamNya
Copy link
Contributor Author

DreamNya commented Jun 3, 2025

userConfig和这个不冲突吧 userConfig是详细配置
这个popupMenu可以作为简单的快速交互使用

另外如果userConfig只能显示第一个tab,个人感觉不如不改变,还是点开跳转到option.html比较好

@CodFrm
Copy link
Member

CodFrm commented Jun 3, 2025

那就开一个新的API,例如:CAT_registerMenuInput,现在GM_registerMenuCommand变得复杂了,而且一个input就占用一个菜单位置,感觉ui也不好做(而且他和chrrome的菜单也是联动的)

另外这个 inputValue 记忆,提供一个输入值的参数(默认值),让用户/开发者使用GM_value或者其它去实现这个记忆更好吧

@DreamNya DreamNya changed the title 实现 GM_registerMenuCommand 支持快捷输入交互 实现 CAT_registerMenuInput 支持快捷输入交互 Jun 3, 2025
@CodFrm CodFrm merged commit 79cb27c into scriptscat:main Jun 14, 2025
1 check passed
htmlType="submit"
icon={<IconMenu />}
title={menu.options?.title}
style={{ display: "block", width: "100%", borderTopColor: "#E5E6EB" }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么要加borderTopColor

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QQ_1749868140142

是为了区分input和菜单么?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants