node-karin 1.3.5 → 1.3.6-pr.260.041eab9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -10122,6 +10122,47 @@ var init_admin2 = __esm({
10122
10122
  }
10123
10123
  });
10124
10124
 
10125
+ // src/server/api/plugins/cache.ts
10126
+ var CACHE_KEY, CACHE_EXPIRE, getPluginListCache, setPluginListCache, deletePluginListCache, paginatePlugins;
10127
+ var init_cache2 = __esm({
10128
+ "src/server/api/plugins/cache.ts"() {
10129
+ "use strict";
10130
+ init_esm_shims();
10131
+ init_index();
10132
+ CACHE_KEY = "karin:web:plugin:list";
10133
+ CACHE_EXPIRE = 300;
10134
+ getPluginListCache = async () => {
10135
+ try {
10136
+ const cached = await redis2.get(CACHE_KEY);
10137
+ if (!cached) return null;
10138
+ return JSON.parse(cached);
10139
+ } catch (error) {
10140
+ logger.error("\u83B7\u53D6\u63D2\u4EF6\u5217\u8868\u7F13\u5B58\u5931\u8D25:", error);
10141
+ return null;
10142
+ }
10143
+ };
10144
+ setPluginListCache = async (plugins) => {
10145
+ try {
10146
+ await redis2.setEx(CACHE_KEY, CACHE_EXPIRE, JSON.stringify(plugins));
10147
+ } catch (error) {
10148
+ logger.error("\u8BBE\u7F6E\u63D2\u4EF6\u5217\u8868\u7F13\u5B58\u5931\u8D25:", error);
10149
+ }
10150
+ };
10151
+ deletePluginListCache = async () => {
10152
+ try {
10153
+ await redis2.del(CACHE_KEY);
10154
+ } catch (error) {
10155
+ logger.error("\u5220\u9664\u63D2\u4EF6\u5217\u8868\u7F13\u5B58\u5931\u8D25:", error);
10156
+ }
10157
+ };
10158
+ paginatePlugins = (plugins, page, pageSize) => {
10159
+ const start3 = (page - 1) * pageSize;
10160
+ const end = start3 + pageSize;
10161
+ return plugins.slice(start3, end);
10162
+ };
10163
+ }
10164
+ });
10165
+
10125
10166
  // src/server/api/plugins/install.ts
10126
10167
  import { spawn } from "child_process";
10127
10168
  import path16 from "path";
@@ -10221,6 +10262,7 @@ async function installPluginTask(task2, url) {
10221
10262
  task2.logs.push("-------------------");
10222
10263
  task2.logs.push("\u{1F389} \u5B89\u88C5\u5B8C\u6210!");
10223
10264
  task2.status = "completed";
10265
+ await deletePluginListCache();
10224
10266
  } catch (error) {
10225
10267
  task2.status = "failed";
10226
10268
  task2.error = error.message;
@@ -10261,6 +10303,7 @@ async function uninstallPluginTask(task2) {
10261
10303
  task2.logs.push("\u{1F389} \u5378\u8F7D\u5B8C\u6210!");
10262
10304
  task2.logs.push("\u26A0\uFE0F \u5EFA\u8BAE\u91CD\u542F Bot \u4EE5\u4F7F\u66F4\u6539\u751F\u6548");
10263
10305
  task2.status = "completed";
10306
+ await deletePluginListCache();
10264
10307
  } catch (error) {
10265
10308
  task2.status = "failed";
10266
10309
  task2.error = error.message;
@@ -10284,6 +10327,7 @@ var init_install = __esm({
10284
10327
  init_esm_shims();
10285
10328
  init_router();
10286
10329
  init_response();
10330
+ init_cache2();
10287
10331
  taskQueue = /* @__PURE__ */ new Map();
10288
10332
  installPlugin = async (req, res) => {
10289
10333
  try {
@@ -11016,7 +11060,7 @@ var init_info2 = __esm({
11016
11060
 
11017
11061
  // src/server/api/plugins/index.ts
11018
11062
  import path18 from "node:path";
11019
- var getOnlinePluginList, str, getPluginListRouter, getPluginApps, checkNodeKarinUpdate, getUpdatablePlugins, batchUpdatePlugins;
11063
+ var getFullPluginList, getOnlinePluginList, str, getPluginListRouter, getPluginApps, checkNodeKarinUpdate, getUpdatablePlugins, batchUpdatePlugins;
11020
11064
  var init_plugins = __esm({
11021
11065
  "src/server/api/plugins/index.ts"() {
11022
11066
  "use strict";
@@ -11032,112 +11076,131 @@ var init_plugins = __esm({
11032
11076
  init_response();
11033
11077
  init_update();
11034
11078
  init_info2();
11035
- getOnlinePluginList = async (_req, res) => {
11036
- try {
11037
- const [list2, createUrl, localPlugins] = await Promise.all([
11038
- fetchPluginList(),
11039
- testGithub(),
11040
- getPlugins("all", true, true)
11041
- ]);
11042
- const pluginMap = /* @__PURE__ */ new Map();
11043
- await Promise.all(localPlugins.map(async (plugin) => {
11044
- const { version, description, homepage, time: time2, license, author } = (plugin == null ? void 0 : plugin.pkgData) || {};
11045
- pluginMap.set(plugin.name, {
11046
- installed: true,
11047
- version: str(version),
11048
- type: plugin.type,
11049
- name: plugin.name,
11050
- description: str(description),
11051
- home: str(homepage),
11052
- time: str(time2),
11053
- license: {
11054
- name: str(license),
11055
- url: ""
11056
- },
11057
- author: [
11058
- {
11059
- name: str(author),
11060
- home: "",
11061
- avatar: ""
11062
- }
11063
- ],
11064
- repo: [],
11065
- downloads: 0,
11066
- size: 0,
11067
- updated: ""
11068
- });
11069
- }));
11070
- await Promise.all(list2.plugins.map(async (plugin) => {
11071
- let info = null;
11072
- switch (plugin.type) {
11073
- case "npm":
11074
- info = await handleNpmPlugin(plugin);
11075
- break;
11076
- case "git":
11077
- info = await handleGitPlugin(plugin, createUrl);
11078
- break;
11079
- case "app":
11080
- info = await handleAppPlugin(plugin);
11081
- break;
11082
- }
11083
- if (!info) return;
11084
- const existingPlugin = pluginMap.get(info.name);
11085
- if (existingPlugin) {
11086
- pluginMap.set(info.name, {
11087
- ...info,
11088
- installed: existingPlugin.installed,
11089
- version: existingPlugin.installed ? existingPlugin.version : info.version,
11090
- latestVersion: info.version,
11091
- downloads: existingPlugin.downloads,
11092
- size: existingPlugin.size,
11093
- updated: existingPlugin.updated
11094
- });
11095
- return;
11096
- }
11079
+ init_cache2();
11080
+ getFullPluginList = async () => {
11081
+ const [list2, createUrl, localPlugins] = await Promise.all([
11082
+ fetchPluginList(),
11083
+ testGithub(),
11084
+ getPlugins("all", true, true)
11085
+ ]);
11086
+ const pluginMap = /* @__PURE__ */ new Map();
11087
+ await Promise.all(localPlugins.map(async (plugin) => {
11088
+ const { version, description, homepage, time: time2, license, author } = (plugin == null ? void 0 : plugin.pkgData) || {};
11089
+ pluginMap.set(plugin.name, {
11090
+ installed: true,
11091
+ version: str(version),
11092
+ type: plugin.type,
11093
+ name: plugin.name,
11094
+ description: str(description),
11095
+ home: str(homepage),
11096
+ time: str(time2),
11097
+ license: {
11098
+ name: str(license),
11099
+ url: ""
11100
+ },
11101
+ author: [
11102
+ {
11103
+ name: str(author),
11104
+ home: "",
11105
+ avatar: ""
11106
+ }
11107
+ ],
11108
+ repo: [],
11109
+ downloads: 0,
11110
+ size: 0,
11111
+ updated: ""
11112
+ });
11113
+ }));
11114
+ await Promise.all(list2.plugins.map(async (plugin) => {
11115
+ let info = null;
11116
+ switch (plugin.type) {
11117
+ case "npm":
11118
+ info = await handleNpmPlugin(plugin);
11119
+ break;
11120
+ case "git":
11121
+ info = await handleGitPlugin(plugin, createUrl);
11122
+ break;
11123
+ case "app":
11124
+ info = await handleAppPlugin(plugin);
11125
+ break;
11126
+ }
11127
+ if (!info) return;
11128
+ const existingPlugin = pluginMap.get(info.name);
11129
+ if (existingPlugin) {
11097
11130
  pluginMap.set(info.name, {
11098
11131
  ...info,
11132
+ installed: existingPlugin.installed,
11133
+ version: existingPlugin.installed ? existingPlugin.version : info.version,
11099
11134
  latestVersion: info.version,
11100
- downloads: 0,
11101
- size: 0,
11102
- updated: ""
11135
+ downloads: existingPlugin.downloads,
11136
+ size: existingPlugin.size,
11137
+ updated: existingPlugin.updated
11103
11138
  });
11104
- }));
11105
- await Promise.all(
11106
- Array.from(pluginMap.values()).map(async (plugin) => {
11107
- await Promise.all([
11108
- // 并发处理作者头像
11109
- Promise.all(
11110
- plugin.author.map(async (item) => {
11111
- item.avatar = getAuthorAvatar(item.home, item.avatar);
11112
- })
11113
- ),
11114
- // 并发获取插件信息
11115
- (async () => {
11116
- var _a;
11117
- if (plugin.type === "npm") {
11118
- const info = await getNpmInfo2(plugin.name);
11139
+ return;
11140
+ }
11141
+ pluginMap.set(info.name, {
11142
+ ...info,
11143
+ latestVersion: info.version,
11144
+ downloads: 0,
11145
+ size: 0,
11146
+ updated: ""
11147
+ });
11148
+ }));
11149
+ await Promise.all(
11150
+ Array.from(pluginMap.values()).map(async (plugin) => {
11151
+ await Promise.all([
11152
+ // 并发处理作者头像
11153
+ Promise.all(
11154
+ plugin.author.map(async (item) => {
11155
+ item.avatar = getAuthorAvatar(item.home, item.avatar);
11156
+ })
11157
+ ),
11158
+ // 并发获取插件信息
11159
+ (async () => {
11160
+ var _a;
11161
+ if (plugin.type === "npm") {
11162
+ const info = await getNpmInfo2(plugin.name);
11163
+ plugin.downloads = info.downloads;
11164
+ plugin.size = info.size;
11165
+ plugin.updated = info.updated;
11166
+ } else if (plugin.type === "git" && !plugin.installed) {
11167
+ const repoUrl = ((_a = plugin.repo[0]) == null ? void 0 : _a.url) || "";
11168
+ if (repoUrl) {
11169
+ const info = await getGitInfo2(repoUrl);
11119
11170
  plugin.downloads = info.downloads;
11120
- plugin.size = info.size;
11121
11171
  plugin.updated = info.updated;
11122
- } else if (plugin.type === "git" && !plugin.installed) {
11123
- const repoUrl = ((_a = plugin.repo[0]) == null ? void 0 : _a.url) || "";
11124
- if (repoUrl) {
11125
- const info = await getGitInfo2(repoUrl);
11126
- plugin.downloads = info.downloads;
11127
- plugin.updated = info.updated;
11128
- }
11129
11172
  }
11130
- })()
11131
- ]);
11132
- })
11133
- );
11134
- const result = Array.from(pluginMap.values());
11135
- result.sort((a, b) => {
11136
- if (a.installed && !b.installed) return -1;
11137
- if (!a.installed && b.installed) return 1;
11138
- return a.name.localeCompare(b.name);
11173
+ }
11174
+ })()
11175
+ ]);
11176
+ })
11177
+ );
11178
+ const result = Array.from(pluginMap.values());
11179
+ result.sort((a, b) => {
11180
+ if (a.installed && !b.installed) return -1;
11181
+ if (!a.installed && b.installed) return 1;
11182
+ return a.name.localeCompare(b.name);
11183
+ });
11184
+ return result;
11185
+ };
11186
+ getOnlinePluginList = async (req, res) => {
11187
+ try {
11188
+ const { page = 1, pageSize = 16, refresh = false } = req.body;
11189
+ let plugins = null;
11190
+ if (!refresh) {
11191
+ plugins = await getPluginListCache();
11192
+ }
11193
+ if (!plugins) {
11194
+ plugins = await getFullPluginList();
11195
+ await setPluginListCache(plugins);
11196
+ }
11197
+ const paginatedPlugins = paginatePlugins(plugins, page, pageSize);
11198
+ createSuccessResponse(res, {
11199
+ list: paginatedPlugins,
11200
+ total: plugins.length,
11201
+ page,
11202
+ pageSize
11139
11203
  });
11140
- createSuccessResponse(res, result);
11141
11204
  } catch (error) {
11142
11205
  createServerErrorResponse(res, error.message);
11143
11206
  logger.error(error);
@@ -12825,7 +12888,7 @@ var init_db2 = __esm({
12825
12888
 
12826
12889
  // src/adapter/render/admin/cache.ts
12827
12890
  var index2, cache10, registerRender, unregisterRender, getRender, callRender, getRenderCount, getRenderList, renderHtml, renderMultiHtml, RenderCache, render2, Renderer;
12828
- var init_cache2 = __esm({
12891
+ var init_cache3 = __esm({
12829
12892
  "src/adapter/render/admin/cache.ts"() {
12830
12893
  "use strict";
12831
12894
  init_esm_shims();
@@ -12958,7 +13021,7 @@ var init_http = __esm({
12958
13021
  "src/adapter/render/connect/http.ts"() {
12959
13022
  "use strict";
12960
13023
  init_esm_shims();
12961
- init_cache2();
13024
+ init_cache3();
12962
13025
  init_render();
12963
13026
  createHttpRenderClient = () => {
12964
13027
  const cfg = render();
@@ -13101,7 +13164,7 @@ var init_ws2 = __esm({
13101
13164
  "use strict";
13102
13165
  init_esm_shims();
13103
13166
  init_template();
13104
- init_cache2();
13167
+ init_cache3();
13105
13168
  init_static();
13106
13169
  WebSocketRender = class {
13107
13170
  /** websocket实例 */
@@ -16184,7 +16247,7 @@ var init_render3 = __esm({
16184
16247
  "src/core/karin/render.ts"() {
16185
16248
  "use strict";
16186
16249
  init_esm_shims();
16187
- init_cache2();
16250
+ init_cache3();
16188
16251
  render3 = (options, multiPageOrId, id) => {
16189
16252
  if (options === "opt") {
16190
16253
  return callRender(multiPageOrId, id);
@@ -16548,684 +16611,248 @@ var init_types2 = __esm({
16548
16611
  }
16549
16612
  });
16550
16613
 
16551
- // src/components/base.ts
16552
- var Component;
16553
- var init_base5 = __esm({
16554
- "src/components/base.ts"() {
16555
- "use strict";
16556
- init_esm_shims();
16557
- Component = class {
16558
- _config;
16559
- _componentType;
16560
- constructor(componentType) {
16561
- this._componentType = componentType;
16562
- }
16563
- /**
16564
- * 转换为JSON字符串
16565
- */
16566
- toString() {
16567
- return JSON.stringify(this.toJSON());
16568
- }
16569
- /**
16570
- * 转换为JSON对象
16571
- */
16572
- toJSON() {
16573
- return { componentType: this._componentType, ...this._config };
16574
- }
16575
- };
16576
- }
16577
- });
16578
-
16579
16614
  // src/components/accordion.ts
16580
- var AccordionBase, Accordion, AccordionPro, AccordionItem, accordion, accordionPro, accordionItem;
16615
+ var createAccordion, createAccordionPro, createAccordionItem, accordion, accordionPro, accordionItem;
16581
16616
  var init_accordion = __esm({
16582
16617
  "src/components/accordion.ts"() {
16583
16618
  "use strict";
16584
16619
  init_esm_shims();
16585
- init_base5();
16586
- AccordionBase = class extends Component {
16587
- _config;
16588
- constructor(key, componentType) {
16589
- super(componentType);
16590
- this._config = { key, componentType };
16591
- }
16592
- /**
16593
- * 设置标题
16594
- * @param title - 标题文本
16595
- */
16596
- title = (title) => {
16597
- this._config.title = title;
16598
- return this;
16599
- };
16600
- /**
16601
- * 设置子组件
16602
- * @param children - 子组件数组
16603
- */
16604
- children = (children) => {
16605
- const childrens = [];
16606
- for (const child of children) {
16607
- if (typeof (child == null ? void 0 : child.toJSON) === "function") {
16608
- childrens.push(child.toJSON());
16609
- continue;
16610
- }
16611
- if (typeof child === "object" && child !== null) {
16612
- childrens.push(child);
16613
- continue;
16614
- }
16615
- }
16616
- this._config.children = childrens;
16617
- return this;
16618
- };
16619
- /**
16620
- * 设置样式变体
16621
- * @param variant - 样式类型
16622
- */
16623
- variant = (variant) => {
16624
- this._config.variant = variant;
16625
- return this;
16626
- };
16627
- /**
16628
- * 设置选择模式
16629
- * @param mode - 选择模式
16630
- * - none: 无
16631
- * - single: 单选
16632
- * - multiple: 多选
16633
- */
16634
- selectionMode = (mode) => {
16635
- this._config.selectionMode = mode;
16636
- return this;
16637
- };
16638
- /**
16639
- * 设置选择行为
16640
- * @param behavior - 选择行为
16641
- * - toggle: 切换
16642
- * - replace: 替换
16643
- */
16644
- selectionBehavior = (behavior) => {
16645
- this._config.selectionBehavior = behavior;
16646
- return this;
16647
- };
16648
- /**
16649
- * 设置是否紧凑模式
16650
- * @param isCompact - 是否紧凑
16651
- */
16652
- compact = (isCompact = true) => {
16653
- this._config.isCompact = isCompact;
16654
- return this;
16655
- };
16656
- /**
16657
- * 设置是否禁用
16658
- * @param isDisabled - 是否禁用
16659
- */
16660
- disabled = (isDisabled = true) => {
16661
- this._config.isDisabled = isDisabled;
16662
- return this;
16663
- };
16664
- /**
16665
- * 设置是否显示分隔线
16666
- * @param show - 是否显示
16667
- */
16668
- showDivider = (show = true) => {
16669
- this._config.showDivider = show;
16670
- return this;
16671
- };
16672
- /**
16673
- * 设置是否隐藏指示器
16674
- * @param hide - 是否隐藏
16675
- */
16676
- hideIndicator = (hide = true) => {
16677
- this._config.hideIndicator = hide;
16678
- return this;
16679
- };
16680
- /**
16681
- * 设置是否禁用动画
16682
- * @param disable - 是否禁用
16683
- */
16684
- disableAnimation = (disable = true) => {
16685
- this._config.disableAnimation = disable;
16686
- return this;
16687
- };
16688
- /**
16689
- * 设置是否禁用指示器动画
16690
- * @param disable - 是否禁用
16691
- */
16692
- disableIndicatorAnimation = (disable = true) => {
16693
- this._config.disableIndicatorAnimation = disable;
16694
- return this;
16695
- };
16696
- /**
16697
- * 设置是否不允许空选择
16698
- * @param disallow - 是否不允许
16699
- */
16700
- disallowEmptySelection = (disallow = true) => {
16701
- this._config.disallowEmptySelection = disallow;
16702
- return this;
16703
- };
16704
- /**
16705
- * 设置是否保持内容挂载
16706
- * @param keep - 是否保持
16707
- */
16708
- keepContentMounted = (keep = true) => {
16709
- this._config.keepContentMounted = keep;
16710
- return this;
16711
- };
16712
- /**
16713
- * 设置是否全宽
16714
- * @param full - 是否全宽
16715
- */
16716
- fullWidth = (full = true) => {
16717
- this._config.fullWidth = full;
16718
- return this;
16719
- };
16720
- /**
16721
- * 设置禁用的键
16722
- * @param keys - 禁用的键数组
16723
- */
16724
- disabledKeys = (keys) => {
16725
- this._config.disabledKeys = keys;
16726
- return this;
16727
- };
16728
- /**
16729
- * 设置选中项
16730
- * @param keys - 选中的键数组
16731
- */
16732
- selectedKeys = (keys) => {
16733
- this._config.selectedKeys = keys;
16734
- return this;
16735
- };
16736
- /**
16737
- * 设置默认选中项
16738
- * @param keys - 默认选中的键数组
16739
- */
16740
- defaultSelectedKeys = (keys) => {
16741
- this._config.defaultSelectedKeys = keys;
16742
- return this;
16743
- };
16744
- /**
16745
- * 自定义配置
16746
- * @param options - 配置选项
16747
- */
16748
- options = (options) => {
16749
- this._config = { ...this._config, ...options };
16750
- return this;
16751
- };
16752
- /**
16753
- * 转换为JSON对象
16754
- * @description 手风琴比较特殊 需要子组件也进行转换
16755
- */
16756
- toJSON = () => {
16757
- if (!this._config.children) this._config.children = [];
16758
- return this._config;
16759
- };
16760
- };
16761
- Accordion = class extends AccordionBase {
16762
- constructor(key) {
16763
- super(key, "accordion");
16764
- }
16765
- };
16766
- AccordionPro = class extends AccordionBase {
16767
- constructor(key) {
16768
- super(key, "accordion-pro");
16769
- }
16770
- /**
16771
- * 设置渲染数据
16772
- * @param data - 渲染数据
16773
- */
16774
- data = (data) => {
16775
- this._config.data = data;
16776
- return this;
16620
+ createAccordion = (key, config2) => ({
16621
+ key,
16622
+ ...config2,
16623
+ componentType: "accordion"
16624
+ });
16625
+ createAccordionPro = (key, config2) => {
16626
+ const result = {
16627
+ key,
16628
+ ...config2,
16629
+ componentType: "accordion-pro"
16777
16630
  };
16631
+ console.log("createAccordionPro:", JSON.stringify(result));
16632
+ return result;
16778
16633
  };
16779
- AccordionItem = class extends Component {
16780
- _config = { key: "", componentType: "accordion-item" };
16781
- constructor(key) {
16782
- super("accordion-item");
16783
- this._config.key = key;
16784
- }
16785
- /**
16786
- * 设置子组件
16787
- * @param children - 子组件数组
16788
- */
16789
- children = (children) => {
16790
- if (!Array.isArray(children)) children = [children];
16791
- const childrens = [];
16792
- children.forEach((child) => {
16793
- if (typeof (child == null ? void 0 : child.toJSON) === "function") {
16794
- childrens.push(child.toJSON());
16795
- return;
16796
- }
16797
- if (typeof child === "object" && child !== null) {
16798
- childrens.push(child);
16799
- }
16800
- });
16801
- this._config.children = childrens;
16802
- return this;
16803
- };
16804
- /**
16805
- * 设置标题
16806
- * @param title - 标题文本
16807
- */
16808
- title = (title) => {
16809
- this._config.title = title;
16810
- return this;
16811
- };
16812
- /**
16813
- * 设置副标题
16814
- * @param subtitle - 副标题文本
16815
- */
16816
- subtitle = (subtitle) => {
16817
- this._config.subtitle = subtitle;
16818
- return this;
16819
- };
16820
- /**
16821
- * 设置是否显示指示器
16822
- * @param hide - 是否隐藏
16823
- */
16824
- hideIndicator = (hide = true) => {
16825
- this._config.hideIndicator = hide;
16826
- return this;
16827
- };
16828
- // /**
16829
- // * 设置开始内容
16830
- // * @param content - 开始内容组件
16831
- // */
16832
- // startContent = (content: Component) => {
16833
- // this.config.startContent = content
16834
- // return this
16835
- // }
16836
- // /**
16837
- // * 设置结束内容
16838
- // * @param content - 结束内容组件
16839
- // */
16840
- // endContent = (content: Component) => {
16841
- // this.config.endContent = content
16842
- // return this
16843
- // }
16844
- /**
16845
- * 设置是否紧凑模式
16846
- * @param isCompact - 是否紧凑
16847
- */
16848
- compact = (isCompact = true) => {
16849
- this._config.isCompact = isCompact;
16850
- return this;
16851
- };
16852
- /**
16853
- * 设置是否禁用
16854
- * @param isDisabled - 是否禁用
16855
- */
16856
- disabled = (isDisabled = true) => {
16857
- this._config.isDisabled = isDisabled;
16858
- return this;
16859
- };
16860
- /**
16861
- * 设置是否保持内容挂载
16862
- * @param keep - 是否保持
16863
- */
16864
- keepContentMounted = (keep = true) => {
16865
- this._config.keepContentMounted = keep;
16866
- return this;
16867
- };
16868
- /**
16869
- * 设置是否禁用动画
16870
- * @param disable - 是否禁用
16871
- */
16872
- disableAnimation = (disable = true) => {
16873
- this._config.disableAnimation = disable;
16874
- return this;
16875
- };
16876
- /**
16877
- * 设置是否禁用指示器动画
16878
- * @param disable - 是否禁用
16879
- */
16880
- disableIndicatorAnimation = (disable = true) => {
16881
- this._config.disableIndicatorAnimation = disable;
16882
- return this;
16883
- };
16884
- // /**
16885
- // * 设置标题组件
16886
- // * @param component - 标题组件
16887
- // */
16888
- // headingComponent = (component: string) => {
16889
- // this.config.headingComponent = component
16890
- // return this
16891
- // }
16892
- /**
16893
- * 自定义配置
16894
- * @param options - 配置选项
16895
- */
16896
- options = (options) => {
16897
- this._config = { ...this._config, ...options };
16898
- return this;
16899
- };
16900
- /**
16901
- * 转换为JSON对象
16902
- * @description 手风琴比较特殊 需要子组件也进行转换
16903
- */
16904
- toJSON = () => {
16905
- return this._config;
16634
+ createAccordionItem = (key, config2) => {
16635
+ const result = {
16636
+ key,
16637
+ ...config2,
16638
+ componentType: "accordion-item"
16906
16639
  };
16640
+ console.log("createAccordionItem:", JSON.stringify(result));
16641
+ return result;
16907
16642
  };
16908
16643
  accordion = {
16909
16644
  /**
16910
16645
  * 创建基础手风琴组件
16911
- * @param key - 唯一标识符
16646
+ * @param key 唯一标识符
16647
+ * @param options 手风琴配置
16912
16648
  */
16913
- create: (key) => new Accordion(key),
16649
+ create: (key, options) => createAccordion(key, options),
16914
16650
  /**
16915
16651
  * 创建默认配置的手风琴组件
16916
- * @param key - 唯一标识符
16917
- */
16918
- default: (key) => {
16919
- return new Accordion(key).title("\u6298\u53E0\u9762\u677F").variant("bordered").selectionMode("single").selectionBehavior("toggle").showDivider().fullWidth();
16920
- },
16921
- /**
16922
- * 使用自定义配置创建手风琴组件
16923
- * @param key - 唯一标识符
16924
- * @param options - 配置选项
16652
+ * @param key 唯一标识符
16925
16653
  */
16926
- options: (key, options) => new Accordion(key).options(options),
16654
+ default: (key) => createAccordion(key, {
16655
+ title: "\u6298\u53E0\u9762\u677F",
16656
+ variant: "bordered",
16657
+ selectionMode: "single",
16658
+ selectionBehavior: "toggle",
16659
+ showDivider: true,
16660
+ fullWidth: true
16661
+ }),
16927
16662
  /**
16928
16663
  * 创建手风琴子项
16929
- * @param key - 唯一标识符
16664
+ * @param key 唯一标识符
16665
+ * @param options 手风琴子项配置
16930
16666
  */
16931
- createItem: (key) => new AccordionItem(key)
16667
+ createItem: (key, options) => createAccordionItem(key, options)
16932
16668
  };
16933
16669
  accordionPro = {
16934
16670
  /**
16935
- * 创建基础手风琴组件
16936
- * @param key - 唯一标识符
16937
- */
16938
- create: (key, data) => new AccordionPro(key).data(data),
16939
- /**
16940
- * 创建默认配置的手风琴组件
16941
- * @param key - 唯一标识符
16942
- */
16943
- default: (key) => {
16944
- return new AccordionPro(key).title("\u6298\u53E0\u9762\u677FPro").variant("bordered").selectionMode("single").selectionBehavior("toggle").showDivider().fullWidth();
16945
- },
16946
- /**
16947
- * 使用自定义配置创建手风琴组件
16948
- * @param key - 唯一标识符
16949
- * @param options - 配置选项
16671
+ * 创建基础手风琴Pro组件
16672
+ * @param key 唯一标识符
16673
+ * @param data 渲染数据
16674
+ * @param options 手风琴Pro配置
16950
16675
  */
16951
- options: (key, options) => new AccordionPro(key).options(options)
16676
+ create: (key, data, options) => createAccordionPro(key, {
16677
+ ...options,
16678
+ data
16679
+ })
16952
16680
  };
16953
16681
  accordionItem = {
16954
16682
  /**
16955
16683
  * 创建手风琴子项
16956
- * @param key - 唯一标识符
16684
+ * @param key 唯一标识符
16685
+ * @param options 手风琴子项配置
16957
16686
  */
16958
- create: (key) => new AccordionItem(key)
16687
+ create: (key, options) => createAccordionItem(key, options),
16688
+ /**
16689
+ * 创建默认配置的手风琴子项
16690
+ * @param key 唯一标识符
16691
+ * @param title 标题
16692
+ * @param children 子组件
16693
+ */
16694
+ default: (key, title, children) => createAccordionItem(key, {
16695
+ title,
16696
+ children,
16697
+ isCompact: false,
16698
+ hideIndicator: false,
16699
+ disableAnimation: false,
16700
+ disableIndicatorAnimation: false
16701
+ })
16959
16702
  };
16960
16703
  }
16961
16704
  });
16962
16705
 
16963
- // src/types/components/types.ts
16964
- var init_types3 = __esm({
16965
- "src/types/components/types.ts"() {
16966
- "use strict";
16967
- init_esm_shims();
16968
- }
16969
- });
16970
-
16971
- // src/types/components/base.ts
16972
- var init_base6 = __esm({
16973
- "src/types/components/base.ts"() {
16974
- "use strict";
16975
- init_esm_shims();
16976
- }
16977
- });
16978
-
16979
- // src/types/components/input.ts
16980
- var init_input = __esm({
16981
- "src/types/components/input.ts"() {
16982
- "use strict";
16983
- init_esm_shims();
16984
- }
16985
- });
16986
-
16987
- // src/types/components/divider.ts
16988
- var init_divider = __esm({
16989
- "src/types/components/divider.ts"() {
16990
- "use strict";
16991
- init_esm_shims();
16992
- }
16993
- });
16994
-
16995
- // src/types/components/switch.ts
16996
- var init_switch = __esm({
16997
- "src/types/components/switch.ts"() {
16998
- "use strict";
16999
- init_esm_shims();
17000
- }
17001
- });
17002
-
17003
- // src/types/components/accordion.ts
17004
- var init_accordion2 = __esm({
17005
- "src/types/components/accordion.ts"() {
17006
- "use strict";
17007
- init_esm_shims();
17008
- }
17009
- });
17010
-
17011
- // src/types/components/all.ts
17012
- var init_all = __esm({
17013
- "src/types/components/all.ts"() {
17014
- "use strict";
17015
- init_esm_shims();
17016
- }
17017
- });
17018
-
17019
- // src/types/components/index.ts
17020
- var init_components = __esm({
17021
- "src/types/components/index.ts"() {
17022
- "use strict";
17023
- init_esm_shims();
17024
- init_types3();
17025
- init_base6();
17026
- init_input();
17027
- init_divider();
17028
- init_switch();
17029
- init_accordion2();
17030
- init_all();
17031
- }
17032
- });
17033
-
17034
16706
  // src/components/input.ts
17035
- var Input, input;
17036
- var init_input2 = __esm({
16707
+ var createInput, input;
16708
+ var init_input = __esm({
17037
16709
  "src/components/input.ts"() {
17038
16710
  "use strict";
17039
16711
  init_esm_shims();
17040
- init_base5();
17041
- init_components();
17042
- Input = class extends Component {
17043
- _config = { key: "", type: "text", componentType: "input" };
17044
- constructor(key) {
17045
- super("input");
17046
- this._config.key = key;
17047
- }
17048
- /**
17049
- * 内部属性 仅在`options`中可手动设置,其他方法请不要调用
17050
- */
17051
- _type(dataType) {
17052
- const typeMap = {
17053
- ["string" /* STRING */]: "text",
17054
- ["number" /* NUMBER */]: "number",
17055
- ["boolean" /* BOOLEAN */]: "text",
17056
- ["date" /* DATE */]: "text",
17057
- ["time" /* TIME */]: "text",
17058
- ["datetime" /* DATETIME */]: "text",
17059
- ["email" /* EMAIL */]: "email",
17060
- ["url" /* URL */]: "url",
17061
- ["tel" /* TEL */]: "tel",
17062
- ["password" /* PASSWORD */]: "password",
17063
- ["color" /* COLOR */]: "text",
17064
- ["json" /* JSON */]: "text"
17065
- };
17066
- if (!typeMap[dataType]) return this;
17067
- this._config.type = typeMap[dataType];
17068
- return this;
17069
- }
17070
- /**
17071
- * 设置标签
17072
- */
17073
- label(label) {
17074
- this._config.label = label;
17075
- return this;
17076
- }
17077
- /**
17078
- * 设置占位符
17079
- */
17080
- placeholder(placeholder) {
17081
- this._config.placeholder = placeholder;
17082
- return this;
17083
- }
17084
- /**
17085
- * 设置验证规则
17086
- */
17087
- validate(rules) {
17088
- if (!Array.isArray(rules)) rules = [rules];
17089
- rules.forEach((rule) => {
17090
- if (rule.regex && rule.regex instanceof RegExp) {
17091
- rule.regex = rule.regex.toString();
17092
- }
17093
- });
17094
- this._config.rules = rules;
17095
- return this;
17096
- }
17097
- /**
17098
- * 设置大小
17099
- * @param size 大小
17100
- * @returns 输入框构建器
17101
- */
17102
- size(size) {
17103
- this._config.size = size;
17104
- return this;
17105
- }
17106
- /**
17107
- * 设置颜色
17108
- */
17109
- color(color) {
17110
- this._config.color = color;
17111
- return this;
17112
- }
17113
- /**
17114
- * 设置是否必填
17115
- */
17116
- required(required = true) {
17117
- this._config.isRequired = required;
17118
- return this;
17119
- }
17120
- /**
17121
- * 设置清除按钮
17122
- */
17123
- clearable(clearable = true) {
17124
- this._config.isClearable = clearable;
17125
- return this;
17126
- }
17127
- /**
17128
- * 设置描述
17129
- */
17130
- description(description) {
17131
- this._config.description = description;
17132
- return this;
17133
- }
17134
- /**
17135
- * 自定义参数
17136
- */
17137
- options(options) {
17138
- this._config = options;
17139
- return this;
17140
- }
16712
+ createInput = (key, config2) => {
16713
+ const result = {
16714
+ key,
16715
+ type: "text",
16716
+ ...config2,
16717
+ componentType: "input"
16718
+ };
16719
+ return result;
17141
16720
  };
17142
16721
  input = {
17143
16722
  /**
17144
16723
  * 创建基础输入框
17145
16724
  * @param key 唯一标识符
16725
+ * @param options 输入框配置
17146
16726
  */
17147
- create: (key) => new Input(key),
16727
+ create: (key, options) => createInput(key, options),
17148
16728
  /**
17149
- * 字符串
16729
+ * 字符串输入框
17150
16730
  * @param key 唯一标识符
17151
- */
17152
- string: (key) => {
17153
- const fnc2 = new Input(key)._type("string" /* STRING */);
17154
- return fnc2.label("\u5B57\u7B26\u4E32").placeholder("\u8BF7\u8F93\u5165\u5B57\u7B26\u4E32").required().clearable().color("primary");
17155
- },
17156
- /**
17157
- * 数字
16731
+ * @param config 输入框配置
16732
+ */
16733
+ string: (key, config2 = {}) => createInput(key, {
16734
+ type: "text",
16735
+ label: "\u5B57\u7B26\u4E32",
16736
+ placeholder: "\u8BF7\u8F93\u5165\u5B57\u7B26\u4E32",
16737
+ isRequired: true,
16738
+ isClearable: true,
16739
+ color: "primary",
16740
+ ...config2
16741
+ }),
16742
+ /**
16743
+ * 数字输入框
17158
16744
  * @param key 唯一标识符
17159
- */
17160
- number: (key) => {
17161
- const fnc2 = new Input(key)._type("number" /* NUMBER */);
17162
- return fnc2.label("\u6570\u5B57").placeholder("\u8BF7\u8F93\u5165\u6570\u5B57").required().clearable().color("primary").validate([
16745
+ * @param config 输入框配置
16746
+ */
16747
+ number: (key, config2 = {}) => createInput(key, {
16748
+ type: "number",
16749
+ label: "\u6570\u5B57",
16750
+ placeholder: "\u8BF7\u8F93\u5165\u6570\u5B57",
16751
+ isRequired: true,
16752
+ isClearable: true,
16753
+ color: "primary",
16754
+ rules: [
17163
16755
  {
17164
16756
  min: 0,
17165
16757
  max: 100,
17166
16758
  error: "\u6570\u5B57\u5E94\u57280-100\u4E4B\u95F4"
17167
16759
  }
17168
- ]);
17169
- },
16760
+ ],
16761
+ ...config2
16762
+ }),
17170
16763
  /**
17171
- * 布尔值
16764
+ * 布尔值输入框
17172
16765
  * @param key 唯一标识符
17173
- */
17174
- boolean: (key) => {
17175
- const fnc2 = new Input(key)._type("boolean" /* BOOLEAN */);
17176
- return fnc2.label("\u5E03\u5C14\u503C").placeholder("\u8BF7\u8F93\u5165\u5E03\u5C14\u503C").required().clearable().color("primary").validate([
16766
+ * @param config 输入框配置
16767
+ */
16768
+ boolean: (key, config2 = {}) => createInput(key, {
16769
+ type: "text",
16770
+ label: "\u5E03\u5C14\u503C",
16771
+ placeholder: "\u8BF7\u8F93\u5165\u5E03\u5C14\u503C",
16772
+ isRequired: true,
16773
+ isClearable: true,
16774
+ color: "primary",
16775
+ rules: [
17177
16776
  {
17178
16777
  regex: /^(true|false)$/,
17179
16778
  error: "\u8BF7\u8F93\u5165\u6709\u6548\u7684\u5E03\u5C14\u503C"
17180
16779
  }
17181
- ]);
17182
- },
16780
+ ],
16781
+ ...config2
16782
+ }),
17183
16783
  /**
17184
- * 日期
16784
+ * 日期输入框
17185
16785
  * @param key 唯一标识符
17186
- */
17187
- date: (key) => {
17188
- const fnc2 = new Input(key)._type("date" /* DATE */);
17189
- return fnc2.label("\u65E5\u671F").placeholder("\u8BF7\u8F93\u5165\u65E5\u671F").required().clearable().color("primary").validate([
16786
+ * @param config 输入框配置
16787
+ */
16788
+ date: (key, config2 = {}) => createInput(key, {
16789
+ type: "text",
16790
+ label: "\u65E5\u671F",
16791
+ placeholder: "\u8BF7\u8F93\u5165\u65E5\u671F",
16792
+ isRequired: true,
16793
+ isClearable: true,
16794
+ color: "primary",
16795
+ rules: [
17190
16796
  {
17191
16797
  regex: /^\d{4}-\d{2}-\d{2}$/,
17192
16798
  error: "\u8BF7\u8F93\u5165\u6709\u6548\u7684\u65E5\u671F\u683C\u5F0F"
17193
16799
  }
17194
- ]);
17195
- },
16800
+ ],
16801
+ ...config2
16802
+ }),
17196
16803
  /**
17197
- * 时间
16804
+ * 时间输入框
17198
16805
  * @param key 唯一标识符
17199
- */
17200
- time: (key) => {
17201
- const fnc2 = new Input(key)._type("time" /* TIME */);
17202
- return fnc2.label("\u65F6\u95F4").placeholder("\u8BF7\u8F93\u5165\u65F6\u95F4").required().clearable().color("primary").validate([
16806
+ * @param config 输入框配置
16807
+ */
16808
+ time: (key, config2 = {}) => createInput(key, {
16809
+ type: "text",
16810
+ label: "\u65F6\u95F4",
16811
+ placeholder: "\u8BF7\u8F93\u5165\u65F6\u95F4",
16812
+ isRequired: true,
16813
+ isClearable: true,
16814
+ color: "primary",
16815
+ rules: [
17203
16816
  {
17204
16817
  regex: /^\d{2}:\d{2}:\d{2}$/,
17205
16818
  error: "\u8BF7\u8F93\u5165\u6709\u6548\u7684\u65F6\u95F4\u683C\u5F0F"
17206
16819
  }
17207
- ]);
17208
- },
16820
+ ],
16821
+ ...config2
16822
+ }),
17209
16823
  /**
17210
- * 日期时间
16824
+ * 日期时间输入框
17211
16825
  * @param key 唯一标识符
17212
- */
17213
- datetime: (key) => {
17214
- const fnc2 = new Input(key)._type("datetime" /* DATETIME */);
17215
- return fnc2.label("\u65E5\u671F\u65F6\u95F4").placeholder("\u8BF7\u8F93\u5165\u65E5\u671F\u65F6\u95F4").required().clearable().color("primary").validate([
16826
+ * @param config 输入框配置
16827
+ */
16828
+ datetime: (key, config2 = {}) => createInput(key, {
16829
+ type: "text",
16830
+ label: "\u65E5\u671F\u65F6\u95F4",
16831
+ placeholder: "\u8BF7\u8F93\u5165\u65E5\u671F\u65F6\u95F4",
16832
+ isRequired: true,
16833
+ isClearable: true,
16834
+ color: "primary",
16835
+ rules: [
17216
16836
  {
17217
16837
  regex: /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/,
17218
16838
  error: "\u8BF7\u8F93\u5165\u6709\u6548\u7684\u65E5\u671F\u65F6\u95F4\u683C\u5F0F"
17219
16839
  }
17220
- ]);
17221
- },
16840
+ ],
16841
+ ...config2
16842
+ }),
17222
16843
  /**
17223
- * 邮箱
16844
+ * 邮箱输入框
17224
16845
  * @param key 唯一标识符
17225
- */
17226
- email: (key) => {
17227
- const fnc2 = new Input(key)._type("email" /* EMAIL */);
17228
- return fnc2.label("\u90AE\u7BB1").placeholder("\u8BF7\u8F93\u5165\u90AE\u7BB1").required().clearable().color("primary").validate([
16846
+ * @param config 输入框配置
16847
+ */
16848
+ email: (key, config2 = {}) => createInput(key, {
16849
+ type: "email",
16850
+ label: "\u90AE\u7BB1",
16851
+ placeholder: "\u8BF7\u8F93\u5165\u90AE\u7BB1",
16852
+ isRequired: true,
16853
+ isClearable: true,
16854
+ color: "primary",
16855
+ rules: [
17229
16856
  {
17230
16857
  regex: "^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$",
17231
16858
  error: "\u8BF7\u8F93\u5165\u6709\u6548\u7684\u90AE\u7BB1\u5730\u5740"
@@ -17235,274 +16862,207 @@ var init_input2 = __esm({
17235
16862
  maxLength: 50,
17236
16863
  error: "\u90AE\u7BB1\u957F\u5EA6\u5E94\u57285-50\u4E2A\u5B57\u7B26\u4E4B\u95F4"
17237
16864
  }
17238
- ]);
17239
- },
16865
+ ],
16866
+ ...config2
16867
+ }),
17240
16868
  /**
17241
- * URL
16869
+ * URL输入框
17242
16870
  * @param key 唯一标识符
17243
- */
17244
- url: (key) => {
17245
- const fnc2 = new Input(key)._type("url" /* URL */);
17246
- return fnc2.label("URL").placeholder("\u8BF7\u8F93\u5165URL").required().clearable().color("primary").validate([
16871
+ * @param config 输入框配置
16872
+ */
16873
+ url: (key, config2 = {}) => createInput(key, {
16874
+ type: "url",
16875
+ label: "URL",
16876
+ placeholder: "\u8BF7\u8F93\u5165URL",
16877
+ isRequired: true,
16878
+ isClearable: true,
16879
+ color: "primary",
16880
+ rules: [
17247
16881
  {
17248
16882
  regex: /^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/,
17249
16883
  error: "\u8BF7\u8F93\u5165\u6709\u6548\u7684URL\u5730\u5740"
17250
16884
  }
17251
- ]);
17252
- },
16885
+ ],
16886
+ ...config2
16887
+ }),
17253
16888
  /**
17254
- * 电话
16889
+ * 电话输入框
17255
16890
  * @param key 唯一标识符
17256
- */
17257
- tel: (key) => {
17258
- const fnc2 = new Input(key)._type("tel" /* TEL */);
17259
- return fnc2.label("\u7535\u8BDD").placeholder("\u8BF7\u8F93\u5165\u7535\u8BDD").required().clearable().color("primary").validate([
16891
+ * @param config 输入框配置
16892
+ */
16893
+ tel: (key, config2 = {}) => createInput(key, {
16894
+ type: "tel",
16895
+ label: "\u7535\u8BDD",
16896
+ placeholder: "\u8BF7\u8F93\u5165\u7535\u8BDD",
16897
+ isRequired: true,
16898
+ isClearable: true,
16899
+ color: "primary",
16900
+ rules: [
17260
16901
  {
17261
16902
  regex: /^1[3-9]\d{9}$/,
17262
16903
  error: "\u8BF7\u8F93\u5165\u6709\u6548\u7684\u624B\u673A\u53F7\u7801"
17263
16904
  }
17264
- ]);
17265
- },
16905
+ ],
16906
+ ...config2
16907
+ }),
17266
16908
  /**
17267
- * 密码
16909
+ * 密码输入框
17268
16910
  * @param key 唯一标识符
17269
- */
17270
- password: (key) => {
17271
- const fnc2 = new Input(key)._type("password" /* PASSWORD */);
17272
- return fnc2.label("\u5BC6\u7801").placeholder("\u8BF7\u8F93\u5165\u5BC6\u7801").required().clearable().color("primary").validate({
17273
- minLength: 1,
17274
- error: "\u5BC6\u7801\u957F\u5EA6\u4E0D\u80FD\u5C0F\u4E8E1\u4F4D"
17275
- });
17276
- },
16911
+ * @param config 输入框配置
16912
+ */
16913
+ password: (key, config2 = {}) => createInput(key, {
16914
+ type: "password",
16915
+ label: "\u5BC6\u7801",
16916
+ placeholder: "\u8BF7\u8F93\u5165\u5BC6\u7801",
16917
+ isRequired: true,
16918
+ isClearable: true,
16919
+ color: "primary",
16920
+ rules: [
16921
+ {
16922
+ minLength: 1,
16923
+ error: "\u5BC6\u7801\u957F\u5EA6\u4E0D\u80FD\u5C0F\u4E8E1\u4F4D"
16924
+ }
16925
+ ],
16926
+ ...config2
16927
+ }),
17277
16928
  /**
17278
- * 颜色
16929
+ * 颜色输入框
17279
16930
  * @param key 唯一标识符
17280
- */
17281
- color: (key) => {
17282
- const fnc2 = new Input(key)._type("color" /* COLOR */);
17283
- return fnc2.label("\u989C\u8272").placeholder("\u8BF7\u8F93\u5165\u989C\u8272").required().clearable().color("primary").validate([
16931
+ * @param config 输入框配置
16932
+ */
16933
+ color: (key, config2 = {}) => createInput(key, {
16934
+ type: "text",
16935
+ label: "\u989C\u8272",
16936
+ placeholder: "\u8BF7\u8F93\u5165\u989C\u8272",
16937
+ isRequired: true,
16938
+ isClearable: true,
16939
+ color: "primary",
16940
+ rules: [
17284
16941
  {
17285
16942
  regex: /^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/,
17286
16943
  error: "\u8BF7\u8F93\u5165\u6709\u6548\u7684\u989C\u8272\u683C\u5F0F"
17287
16944
  }
17288
- ]);
17289
- },
16945
+ ],
16946
+ ...config2
16947
+ }),
17290
16948
  /**
17291
- * JSON
16949
+ * JSON输入框
17292
16950
  * @param key 唯一标识符
17293
- */
17294
- json: (key) => {
17295
- const fnc2 = new Input(key)._type("json" /* JSON */);
17296
- return fnc2.label("JSON").placeholder("\u8BF7\u8F93\u5165JSON").required().clearable().color("primary").validate([
16951
+ * @param config 输入框配置
16952
+ */
16953
+ json: (key, config2 = {}) => createInput(key, {
16954
+ type: "text",
16955
+ label: "JSON",
16956
+ placeholder: "\u8BF7\u8F93\u5165JSON",
16957
+ isRequired: true,
16958
+ isClearable: true,
16959
+ color: "primary",
16960
+ rules: [
17297
16961
  {
17298
16962
  regex: /^[^{}]*$/,
17299
16963
  error: "\u8BF7\u8F93\u5165\u6709\u6548\u7684JSON\u683C\u5F0F"
17300
16964
  }
17301
- ]);
17302
- },
17303
- /**
17304
- * 自定义参数
17305
- * @param key 键
17306
- * @param options 参数
17307
- * @returns 输入框构建器
17308
- */
17309
- options: (key, options) => new Input(key).options(options)
16965
+ ],
16966
+ ...config2
16967
+ })
17310
16968
  };
17311
16969
  }
17312
16970
  });
17313
16971
 
17314
16972
  // src/components/switch.ts
17315
- var Switch, switchComponent;
17316
- var init_switch2 = __esm({
16973
+ var createSwitch, switchComponent;
16974
+ var init_switch = __esm({
17317
16975
  "src/components/switch.ts"() {
17318
16976
  "use strict";
17319
16977
  init_esm_shims();
17320
- init_base5();
17321
- Switch = class extends Component {
17322
- _config = { key: "", componentType: "switch" };
17323
- constructor(key) {
17324
- super("switch");
17325
- this._config.key = key;
17326
- }
17327
- /**
17328
- * 设置开始文本
17329
- * @param text 开始文本
17330
- */
17331
- startText = (text2) => {
17332
- this._config.startText = text2;
17333
- return this;
17334
- };
17335
- /**
17336
- * 设置结束文本
17337
- * @param text 结束文本
17338
- */
17339
- endText = (text2) => {
17340
- this._config.endText = text2;
17341
- return this;
17342
- };
17343
- /**
17344
- * 设置大小
17345
- * @param size 大小
17346
- */
17347
- size = (size) => {
17348
- this._config.size = size;
17349
- return this;
17350
- };
17351
- /**
17352
- * 设置颜色
17353
- * @param color 颜色
17354
- */
17355
- color = (color) => {
17356
- this._config.color = color;
17357
- return this;
17358
- };
17359
- /**
17360
- * 设置开关图标
17361
- * @param icon 图标
17362
- */
17363
- thumbIcon = (icon) => {
17364
- this._config.thumbIcon = icon;
17365
- return this;
17366
- };
17367
- /**
17368
- * 设置开始内容图标
17369
- * @param icon 图标
17370
- */
17371
- startContent = (icon) => {
17372
- this._config.startContent = icon;
17373
- return this;
17374
- };
17375
- /**
17376
- * 设置结束内容图标
17377
- * @param icon 图标
17378
- */
17379
- endContent = (icon) => {
17380
- this._config.endContent = icon;
17381
- return this;
17382
- };
17383
- /**
17384
- * 设置是否被选中(只读)
17385
- * @param selected 是否被选中
17386
- */
17387
- selected = (selected = true) => {
17388
- this._config.isSelected = selected;
17389
- return this;
17390
- };
17391
- /**
17392
- * 设置默认选中状态
17393
- * @param selected 是否默认选中
17394
- */
17395
- defaultSelected = (selected = true) => {
17396
- this._config.defaultSelected = selected;
17397
- return this;
17398
- };
17399
- /**
17400
- * 设置是否只读
17401
- * @param readonly 是否只读
17402
- */
17403
- readonly = (readonly = true) => {
17404
- this._config.isReadOnly = readonly;
17405
- return this;
17406
- };
17407
- /**
17408
- * 设置是否禁用
17409
- * @param disabled 是否禁用
17410
- */
17411
- disabled = (disabled = true) => {
17412
- this._config.isDisabled = disabled;
17413
- return this;
17414
- };
17415
- /**
17416
- * 设置是否禁用动画
17417
- * @param disable 是否禁用动画
17418
- */
17419
- disableAnimation = (disable = true) => {
17420
- this._config.disableAnimation = disable;
17421
- return this;
17422
- };
17423
- /**
17424
- * 自定义参数
17425
- * @param options 参数
17426
- */
17427
- options = (options) => {
17428
- this._config = options;
17429
- return this;
16978
+ createSwitch = (key, config2 = {}) => {
16979
+ const result = {
16980
+ key,
16981
+ ...config2,
16982
+ componentType: "switch"
17430
16983
  };
16984
+ console.log("createSwitch:", JSON.stringify(result));
16985
+ return result;
17431
16986
  };
17432
16987
  switchComponent = {
17433
16988
  /**
17434
16989
  * 创建基础开关
17435
16990
  * @param key 唯一标识符
16991
+ * @param options 开关配置
17436
16992
  */
17437
- create: (key) => new Switch(key),
16993
+ create: (key, options = {}) => createSwitch(key, options),
17438
16994
  /**
17439
- * 自定义参数
16995
+ * 自定义开关
17440
16996
  * @param key 唯一标识符
17441
- * @param options 参数
17442
- */
17443
- options: (key, options) => new Switch(key).options(options)
16997
+ * @param config 开关配置
16998
+ */
16999
+ options: (key, config2 = {}) => createSwitch(key, {
17000
+ startText: "\u5F00\u542F",
17001
+ endText: "\u5173\u95ED",
17002
+ size: "md",
17003
+ color: "primary",
17004
+ isSelected: false,
17005
+ defaultSelected: false,
17006
+ isReadOnly: false,
17007
+ isDisabled: false,
17008
+ disableAnimation: false,
17009
+ ...config2
17010
+ })
17444
17011
  };
17445
17012
  }
17446
17013
  });
17447
17014
 
17448
17015
  // src/components/divider.ts
17449
- var Divider, divider;
17450
- var init_divider2 = __esm({
17016
+ var createDivider, divider;
17017
+ var init_divider = __esm({
17451
17018
  "src/components/divider.ts"() {
17452
17019
  "use strict";
17453
17020
  init_esm_shims();
17454
- init_base5();
17455
- Divider = class _Divider extends Component {
17456
- _config;
17457
- constructor() {
17458
- super("divider");
17459
- this._config = {
17460
- key: "",
17461
- componentType: "divider",
17462
- transparent: false,
17463
- orientation: "horizontal"
17464
- };
17465
- }
17021
+ createDivider = (key, config2) => ({
17022
+ key,
17023
+ componentType: "divider",
17024
+ transparent: false,
17025
+ orientation: "horizontal",
17026
+ ...config2
17027
+ });
17028
+ divider = {
17466
17029
  /**
17467
- * 设置透明
17468
- * @param transparent 是否透明 默认不透明
17030
+ * 创建基础分隔线
17031
+ * @param key 唯一标识符
17032
+ * @param options 分隔线配置
17469
17033
  */
17470
- transparent(transparent) {
17471
- this._config.transparent = transparent;
17472
- return this;
17473
- }
17034
+ create: (key, options) => createDivider(key, options),
17474
17035
  /**
17475
- * 设置竖向分隔线
17476
- * @param orientation 是否使用竖向分隔线 默认使用横向
17036
+ * 创建水平分隔线
17037
+ * @param key 唯一标识符
17038
+ * @param config 分隔线配置
17477
17039
  */
17478
- vertical(orientation) {
17479
- this._config.orientation = orientation ? "vertical" : "horizontal";
17480
- return this;
17481
- }
17040
+ horizontal: (key, config2 = {}) => createDivider(key, {
17041
+ orientation: "horizontal",
17042
+ ...config2
17043
+ }),
17482
17044
  /**
17483
- * 转换为 JSON 对象
17484
- * @returns JSON 对象
17045
+ * 创建垂直分隔线
17046
+ * @param key 唯一标识符
17047
+ * @param config 分隔线配置
17485
17048
  */
17486
- toJSON() {
17487
- const data = new _Divider();
17488
- const key = Math.random().toString(36).substring(2, 15);
17489
- data._config = { ...this._config, key };
17490
- return data._config;
17491
- }
17049
+ vertical: (key, config2 = {}) => createDivider(key, {
17050
+ orientation: "vertical",
17051
+ ...config2
17052
+ })
17492
17053
  };
17493
- divider = new Divider();
17494
17054
  }
17495
17055
  });
17496
17056
 
17497
17057
  // src/components/all.ts
17498
17058
  var components;
17499
- var init_all2 = __esm({
17059
+ var init_all = __esm({
17500
17060
  "src/components/all.ts"() {
17501
17061
  "use strict";
17502
17062
  init_esm_shims();
17503
- init_input2();
17504
- init_divider2();
17505
- init_switch2();
17063
+ init_input();
17064
+ init_divider();
17065
+ init_switch();
17506
17066
  init_accordion();
17507
17067
  components = {
17508
17068
  /** 分隔线 */
@@ -17522,15 +17082,15 @@ var init_all2 = __esm({
17522
17082
  });
17523
17083
 
17524
17084
  // src/components/index.ts
17525
- var init_components2 = __esm({
17085
+ var init_components = __esm({
17526
17086
  "src/components/index.ts"() {
17527
17087
  "use strict";
17528
17088
  init_esm_shims();
17529
17089
  init_accordion();
17530
- init_input2();
17531
- init_switch2();
17532
- init_divider2();
17533
- init_all2();
17090
+ init_input();
17091
+ init_switch();
17092
+ init_divider();
17093
+ init_all();
17534
17094
  }
17535
17095
  });
17536
17096
 
@@ -17585,7 +17145,7 @@ var init_class2 = __esm({
17585
17145
  import fs30 from "node:fs";
17586
17146
  import path23 from "node:path";
17587
17147
  var index3, botID, AdapterConsole, adapter3;
17588
- var init_input3 = __esm({
17148
+ var init_input2 = __esm({
17589
17149
  "src/adapter/input/index.ts"() {
17590
17150
  "use strict";
17591
17151
  init_esm_shims();
@@ -17734,7 +17294,7 @@ var init_adapter3 = __esm({
17734
17294
  "src/adapter/index.ts"() {
17735
17295
  "use strict";
17736
17296
  init_esm_shims();
17737
- init_input3();
17297
+ init_input2();
17738
17298
  init_adapter2();
17739
17299
  init_base();
17740
17300
  init_render2();
@@ -17744,7 +17304,6 @@ var init_adapter3 = __esm({
17744
17304
  // src/index.ts
17745
17305
  var index_exports = {};
17746
17306
  __export(index_exports, {
17747
- AccordionItem: () => AccordionItem,
17748
17307
  AdapterBase: () => AdapterBase,
17749
17308
  BaseEvent: () => BaseEvent,
17750
17309
  Bot: () => Bot,
@@ -18029,9 +17588,9 @@ var init_index = __esm({
18029
17588
  init_server3();
18030
17589
  init_onebot();
18031
17590
  init_event2();
18032
- init_cache2();
17591
+ init_cache3();
18033
17592
  init_types2();
18034
- init_components2();
17593
+ init_components();
18035
17594
  init_base();
18036
17595
  init_list();
18037
17596
  init_class2();
@@ -18055,7 +17614,6 @@ var init_index = __esm({
18055
17614
  });
18056
17615
  init_index();
18057
17616
  export {
18058
- AccordionItem,
18059
17617
  AdapterBase,
18060
17618
  BaseEvent,
18061
17619
  Bot,