-
Notifications
You must be signed in to change notification settings - Fork 310
二级菜单&分隔线 #785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
二级菜单&分隔线 #785
Changes from all commits
34e8098
b1311d8
b80def7
3abd3f9
fce7de8
b296cb6
af627e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -41,32 +41,60 @@ export class PopupService { | |||||
| private systemConfig: SystemConfig | ||||||
| ) {} | ||||||
|
|
||||||
| genScriptMenuByTabMap(menu: ScriptMenu[]) { | ||||||
| let n = 0; | ||||||
| genScriptMenuByTabMap(menuEntries: chrome.contextMenus.CreateProperties[], menu: ScriptMenu[]) { | ||||||
| for (const { uuid, name, menus } of menu) { | ||||||
| // 如果是带输入框的菜单则不在页面内注册 | ||||||
| const nonInputMenus = menus.filter((item) => !item.options?.inputType); | ||||||
| // 创建脚本菜单 | ||||||
| if (nonInputMenus.length) { | ||||||
| n += nonInputMenus.length; | ||||||
| chrome.contextMenus.create({ | ||||||
| id: `scriptMenu_${uuid}`, | ||||||
| title: name, | ||||||
| contexts: ["all"], | ||||||
| parentId: "scriptMenu", | ||||||
| }); | ||||||
| nonInputMenus.forEach((menu) => { | ||||||
| // 创建菜单 | ||||||
| chrome.contextMenus.create({ | ||||||
| id: `scriptMenu_menu_${uuid}_${menu.id}`, | ||||||
| title: menu.name, | ||||||
| const subMenuEntries = [] as chrome.contextMenus.CreateProperties[]; | ||||||
| let withMenuItem = false; | ||||||
| // eslint-disable-next-line prefer-const | ||||||
| for (let { id, name, options } of menus) { | ||||||
| // 如果是带输入框的菜单则不在页面内注册 | ||||||
| if (options?.inputType) continue; | ||||||
| let level = 3; | ||||||
| if (options?.nested === false) level = 2; | ||||||
| if (name[0] === "\xA7") { | ||||||
|
||||||
| if (name[0] === "\xA7") { | |
| if (name[0] === "§") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
避免build后脚本代码包括非通用ASCII字符
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -63,7 +63,8 @@ const MenuItem = React.memo(({ menu, uuid }: MenuItemProps) => { | |||||
| return null; | ||||||
| } | ||||||
| })(); | ||||||
|
|
||||||
| const menuName = menu.name.replace(/^\xA7+/, "").trim(); | ||||||
|
||||||
| const menuName = menu.name.replace(/^\xA7+/, "").trim(); | |
| const menuName = menu.name.replace(/^§+/, "").trim(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
避免build后脚本代码包括非通用ASCII字符
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
使用 eslint-disable 注释来绕过 prefer-const 规则不是最佳实践。既然需要修改
name变量,应该使用let声明并移除这个 eslint-disable 注释。There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不要