MCPcopy
hub / github.com/CopyTranslator/CopyTranslator / init

Method init

src/common/action.ts:122–606  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

120 }
121
122 init() {
123 const config = this.config;
124 //普通的按钮,执行一项操作
125 function normalAction(id: Identifier, cate?: Category): ActionInitOpt {
126 return {
127 type: "normal",
128 id,
129 cate,
130 };
131 }
132 //原生角色
133 function roleAction(role: Role): ActionInitOpt {
134 return {
135 role: role,
136 id: role,
137 type: "normal",
138 };
139 }
140 //设置常量
141 function constantAction(
142 identifier: Identifier,
143 cate?: Category
144 ): ActionInitOpt {
145 return {
146 actionType: "constant",
147 id: identifier,
148 cate,
149 };
150 }
151 this.append(constantAction("networkProxy"));
152 this.append(switchAction("enableNetworkProxy","advance"));
153
154 //切换状态的动作
155 function switchAction(
156 identifier: Identifier,
157 cate: Category = "basic"
158 ): ActionInitOpt {
159 return {
160 type: "checkbox",
161 id: identifier,
162 cate,
163 };
164 }
165
166 //列表类型,是select的一种特化
167 function listAction(
168 identifier: Identifier,
169 list: any,
170 cate?: Category,
171 needLocale: boolean = false,
172 postLocaleFunc?: PostLocaleFunc
173 ): ActionInitOpt {
174 if (!needLocale) {
175 return {
176 type: "submenu",
177 id: identifier,
178 submenu: subMenuGenerator(identifier, list, false),
179 cate,

Callers 1

constructorFunction · 0.45

Calls 3

appendMethod · 0.95
pushMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected