karin-plugin-kkk 1.1.2 → 1.1.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.1.3](https://github.com/ikenxuan/karin-plugin-kkk/compare/v1.1.2...v1.1.3) (2025-02-28)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * add type ([65c9710](https://github.com/ikenxuan/karin-plugin-kkk/commit/65c9710f6691a4a105c1a3e5b356e95429785647))
9
+ * avatar ([f4bd7a6](https://github.com/ikenxuan/karin-plugin-kkk/commit/f4bd7a61afe9a0146bf2fd8f1d27aa96cfcf7a5e))
10
+ * web.config.ts ([e939cd5](https://github.com/ikenxuan/karin-plugin-kkk/commit/e939cd5efb0d581ebd8510ff4ae5f18acb2c9c3e))
11
+
3
12
  ## [1.1.2](https://github.com/ikenxuan/karin-plugin-kkk/compare/v1.1.1...v1.1.2) (2025-02-25)
4
13
 
5
14
 
@@ -1,12 +1,23 @@
1
1
  import { LocalApiResponse } from 'node-karin';
2
2
  import { ConfigType } from './types/index.js';
3
+ /** 基础配置的类型 */
4
+ type BaseConfigType = {
5
+ [key in keyof Omit<ConfigType, 'pushlist'>]: ConfigType[key];
6
+ };
7
+ /** 推送列表配置的类型,要单独处理 */
8
+ type PushConfigType = {
9
+ 'pushlist:douyin': ConfigType['pushlist']['douyin'];
10
+ 'pushlist:bilibili': ConfigType['pushlist']['bilibili'];
11
+ };
12
+ /** 前端传回来新配置的类型 */
13
+ type newConfigType = BaseConfigType & PushConfigType;
3
14
  declare const _default: {
4
15
  info: LocalApiResponse;
5
16
  /** 动态渲染的组件 */
6
17
  components: () => (import("node-karin").DividerProps | import("node-karin").AccordionProps | import("node-karin").AccordionProProps)[];
7
18
  /** 前端点击保存之后调用的方法 */
8
- save: (config: any) => {
9
- fullData: ConfigType;
19
+ save: (config: newConfigType) => {
20
+ mergeCfg: ConfigType;
10
21
  formatCfg: ConfigType;
11
22
  success: boolean;
12
23
  message: string;
package/lib/web.config.js CHANGED
@@ -9,7 +9,14 @@ export default {
9
9
  icon: {
10
10
  name: 'tag',
11
11
  color: '#EAC452'
12
- }
12
+ },
13
+ author: [
14
+ {
15
+ name: 'ikenxuan',
16
+ home: 'https://github.com/ikenxuan',
17
+ avatar: 'https://avatars.githubusercontent.com/u/112480306'
18
+ }
19
+ ]
13
20
  },
14
21
  /** 动态渲染的组件 */
15
22
  components: () => [
@@ -17,9 +24,9 @@ export default {
17
24
  description: 'Cookies 相关',
18
25
  descPosition: 20
19
26
  }),
20
- components.accordion.create('cfg.cookies', {
27
+ components.accordion.create('cookies', {
21
28
  children: [
22
- components.accordion.createItem('cookies', {
29
+ components.accordion.createItem('cfg:cookies', {
23
30
  title: 'Cookies 相关',
24
31
  className: 'ml-4 mr-4',
25
32
  subtitle: '建议配置,否则大部分功能无法使用',
@@ -59,9 +66,9 @@ export default {
59
66
  description: '插件应用相关',
60
67
  descPosition: 20
61
68
  }),
62
- components.accordion.create('cfg.app', {
69
+ components.accordion.create('app', {
63
70
  children: [
64
- components.accordion.createItem('app', {
71
+ components.accordion.createItem('cfg:app', {
65
72
  title: '插件应用相关',
66
73
  className: 'ml-4 mr-4',
67
74
  subtitle: '此处用于管理插件的基本设置',
@@ -148,9 +155,9 @@ export default {
148
155
  description: '抖音相关',
149
156
  descPosition: 20
150
157
  }),
151
- components.accordion.create('cfg.douyin', {
158
+ components.accordion.create('douyin', {
152
159
  children: [
153
- components.accordion.createItem('douyin', {
160
+ components.accordion.createItem('cfg:douyin', {
154
161
  title: '抖音相关',
155
162
  className: 'ml-4 mr-4',
156
163
  subtitle: '此处为抖音相关的用户偏好设置',
@@ -184,84 +191,84 @@ export default {
184
191
  description: '抖音推送相关',
185
192
  descPosition: 20
186
193
  }),
187
- components.switch.create('push.switch', {
194
+ components.switch.create('push:switch', {
188
195
  startText: '推送开关',
189
196
  description: '推送开关,开启后需重启;使用「#设置抖音推送 + 抖音号」配置推送列表',
190
197
  defaultSelected: all.douyin.push.switch
191
198
  }),
192
- components.input.group('push.banWords', {
199
+ components.input.group('push:banWords', {
193
200
  label: '作品中有以下指定关键词时,不推送',
194
201
  maxRows: 2,
195
202
  itemsPerRow: 4,
196
203
  data: all.douyin.push.banWords,
197
- template: components.input.string('push.banWords', {
204
+ template: components.input.string('push:banWords', {
198
205
  placeholder: '',
199
206
  label: '',
200
207
  color: 'success'
201
208
  })
202
209
  }),
203
- components.input.group('push.banTags', {
210
+ components.input.group('push:banTags', {
204
211
  label: '作品中有指定标签时,不推送',
205
212
  maxRows: 2,
206
213
  itemsPerRow: 4,
207
214
  data: all.douyin.push.banWords,
208
- template: components.input.string('push.banTags', {
215
+ template: components.input.string('push:banTags', {
209
216
  placeholder: '',
210
217
  label: '',
211
218
  color: 'success'
212
219
  })
213
220
  }),
214
- components.radio.group('push.permission', {
221
+ components.radio.group('push:permission', {
215
222
  label: '谁可以设置推送',
216
223
  orientation: 'horizontal',
217
224
  defaultValue: all.douyin.push.permission,
218
225
  radio: [
219
- components.radio.create('push.permission.radio-1', {
226
+ components.radio.create('push:permission:radio-1', {
220
227
  label: '所有人',
221
228
  value: 'all'
222
229
  }),
223
- components.radio.create('push.permission.radio-2', {
230
+ components.radio.create('push:permission:radio-2', {
224
231
  label: '管理员',
225
232
  value: 'admin'
226
233
  }),
227
- components.radio.create('push.permission.radio-3', {
234
+ components.radio.create('push:permission:radio-3', {
228
235
  label: '主人',
229
236
  value: 'master'
230
237
  }),
231
- components.radio.create('push.permission.radio-4', {
238
+ components.radio.create('push:permission:radio-4', {
232
239
  label: '群主',
233
240
  value: 'group.owner'
234
241
  }),
235
- components.radio.create('push.permission.radio-5', {
242
+ components.radio.create('push:permission:radio-5', {
236
243
  label: '群管理员',
237
244
  value: 'group.admin'
238
245
  })
239
246
  ]
240
247
  }),
241
- components.input.string('push.cron', {
248
+ components.input.string('push:cron', {
242
249
  label: '定时任务表达式',
243
250
  defaultValue: all.douyin.push.cron
244
251
  }),
245
- components.switch.create('push.parsedynamic', {
252
+ components.switch.create('push:parsedynamic', {
246
253
  startText: '作品解析',
247
254
  description: '触发推送时是否一同解析该作品',
248
255
  defaultSelected: all.douyin.push.parsedynamic
249
256
  }),
250
- components.switch.create('push.log', {
257
+ components.switch.create('push:log', {
251
258
  startText: '推送日志',
252
259
  description: '是否打印推送日志(修改后需重启)',
253
260
  defaultSelected: all.douyin.push.log
254
261
  }),
255
- components.radio.group('push.shareType', {
262
+ components.radio.group('push:shareType', {
256
263
  label: '分享链接二维码的类型',
257
264
  orientation: 'horizontal',
258
265
  defaultValue: all.douyin.push.shareType,
259
266
  radio: [
260
- components.radio.create('push.shareType.radio-1', {
267
+ components.radio.create('push:shareType.radio-1', {
261
268
  label: '网页链接',
262
269
  value: 'web'
263
270
  }),
264
- components.radio.create('push.shareType.radio-2', {
271
+ components.radio.create('push:shareType.radio-2', {
265
272
  label: '下载链接',
266
273
  value: 'download'
267
274
  })
@@ -275,9 +282,9 @@ export default {
275
282
  description: 'B站相关',
276
283
  descPosition: 20
277
284
  }),
278
- components.accordion.create('cfg.bilibili', {
285
+ components.accordion.create('bilibili', {
279
286
  children: [
280
- components.accordion.createItem('bilibili', {
287
+ components.accordion.createItem('cfg:bilibili', {
281
288
  title: 'B站相关',
282
289
  className: 'ml-4 mr-4',
283
290
  subtitle: '此处为B站相关的用户偏好设置',
@@ -316,70 +323,70 @@ export default {
316
323
  description: 'B站推送相关',
317
324
  descPosition: 20
318
325
  }),
319
- components.switch.create('push.switch', {
326
+ components.switch.create('push:switch', {
320
327
  startText: '推送开关',
321
328
  description: '推送开关,开启后需重启;使用「#设置B站推送 + UID」配置推送列表',
322
329
  defaultSelected: all.bilibili.push.switch
323
330
  }),
324
- components.input.group('push.banWords', {
331
+ components.input.group('push:banWords', {
325
332
  label: '动态中有以下指定关键词时,不推送',
326
333
  maxRows: 2,
327
334
  itemsPerRow: 4,
328
335
  data: all.bilibili.push.banWords,
329
- template: components.input.string('push.banWords', {
336
+ template: components.input.string('push:banWords', {
330
337
  placeholder: '',
331
338
  label: '',
332
339
  color: 'success'
333
340
  })
334
341
  }),
335
- components.input.group('push.banTags', {
342
+ components.input.group('push:banTags', {
336
343
  label: '动态中有指定标签时,不推送',
337
344
  maxRows: 2,
338
345
  itemsPerRow: 4,
339
346
  data: all.bilibili.push.banWords,
340
- template: components.input.string('push.banTags', {
347
+ template: components.input.string('push:banTags', {
341
348
  placeholder: '',
342
349
  label: '',
343
350
  color: 'success'
344
351
  })
345
352
  }),
346
- components.radio.group('push.permission', {
353
+ components.radio.group('push:permission', {
347
354
  label: '谁可以设置推送',
348
355
  orientation: 'horizontal',
349
356
  defaultValue: all.bilibili.push.permission,
350
357
  radio: [
351
- components.radio.create('push.permission.radio-1', {
358
+ components.radio.create('push:permission:radio-1', {
352
359
  label: '所有人',
353
360
  value: 'all'
354
361
  }),
355
- components.radio.create('push.permission.radio-2', {
362
+ components.radio.create('push:permission:radio-2', {
356
363
  label: '管理员',
357
364
  value: 'admin'
358
365
  }),
359
- components.radio.create('push.permission.radio-3', {
366
+ components.radio.create('push:permission:radio-3', {
360
367
  label: '主人',
361
368
  value: 'master'
362
369
  }),
363
- components.radio.create('push.permission.radio-4', {
370
+ components.radio.create('push:permission:radio-4', {
364
371
  label: '群主',
365
372
  value: 'group.owner'
366
373
  }),
367
- components.radio.create('push.permission.radio-5', {
374
+ components.radio.create('push:permission:radio-5', {
368
375
  label: '群管理员',
369
376
  value: 'group.admin'
370
377
  })
371
378
  ]
372
379
  }),
373
- components.input.string('push.cron', {
380
+ components.input.string('push:cron', {
374
381
  label: '定时任务表达式',
375
382
  defaultValue: all.bilibili.push.cron
376
383
  }),
377
- components.switch.create('push.parsedynamic', {
384
+ components.switch.create('push:parsedynamic', {
378
385
  startText: '作品解析',
379
386
  description: '触发推送时是否一同解析该作品',
380
387
  defaultSelected: all.bilibili.push.parsedynamic
381
388
  }),
382
- components.switch.create('push.log', {
389
+ components.switch.create('push:log', {
383
390
  startText: '推送日志',
384
391
  description: '是否打印推送日志(修改后需重启)',
385
392
  defaultSelected: all.bilibili.push.log
@@ -392,9 +399,9 @@ export default {
392
399
  description: '快手相关',
393
400
  descPosition: 20
394
401
  }),
395
- components.accordion.create('cfg.kuaishou', {
402
+ components.accordion.create('kuaishou', {
396
403
  children: [
397
- components.accordion.createItem('kuaishou', {
404
+ components.accordion.createItem('cfg:kuaishou', {
398
405
  title: '快手相关',
399
406
  className: 'ml-4 mr-4',
400
407
  subtitle: '此处为快手相关的用户偏好设置',
@@ -427,9 +434,9 @@ export default {
427
434
  description: '上传相关',
428
435
  descPosition: 20
429
436
  }),
430
- components.accordion.create('cfg.upload', {
437
+ components.accordion.create('upload', {
431
438
  children: [
432
- components.accordion.createItem('upload', {
439
+ components.accordion.createItem('cfg:upload', {
433
440
  title: '上传相关',
434
441
  className: 'ml-4 mr-4',
435
442
  subtitle: '此处为上传相关的用户偏好设置',
@@ -490,7 +497,7 @@ export default {
490
497
  description: '抖音推送列表相关',
491
498
  descPosition: 20
492
499
  }),
493
- components.accordionPro.create('cfg.pushlist.douyin', all.pushlist.douyin.map((item) => {
500
+ components.accordionPro.create('pushlist:douyin', all.pushlist.douyin.map((item) => {
494
501
  return {
495
502
  ...item,
496
503
  title: item.remark,
@@ -510,7 +517,7 @@ export default {
510
517
  label: '推送群号和机器人账号',
511
518
  maxRows: 2,
512
519
  data: [],
513
- template: components.input.string('accordion-item-douyin.banTags', {
520
+ template: components.input.string('accordion-item-douyin:push:douyin:group_id', {
514
521
  placeholder: '',
515
522
  label: '',
516
523
  color: 'success'
@@ -535,7 +542,7 @@ export default {
535
542
  description: 'B站推送列表相关',
536
543
  descPosition: 20
537
544
  }),
538
- components.accordionPro.create('cfg.pushlist.bilibili', all.pushlist.bilibili.map((item) => {
545
+ components.accordionPro.create('pushlist:bilibili', all.pushlist.bilibili.map((item) => {
539
546
  return {
540
547
  ...item,
541
548
  title: item.remark,
@@ -556,7 +563,7 @@ export default {
556
563
  label: '推送群号和机器人账号',
557
564
  maxRows: 2,
558
565
  data: [],
559
- template: components.input.string('accordion-item-bilibili.banTags', {
566
+ template: components.input.string('accordion-item-bilibili:push:bilibili:group_id', {
560
567
  placeholder: '',
561
568
  label: '',
562
569
  color: 'success'
@@ -577,17 +584,17 @@ export default {
577
584
  const formatCfg = processFrontendData(config);
578
585
  const oldAllCfg = Config.All();
579
586
  /** 合并旧新配置 */
580
- const fullData = _.mergeWith({}, oldAllCfg, formatCfg, customizer);
587
+ const mergeCfg = _.mergeWith({}, oldAllCfg, formatCfg, customizer);
581
588
  let success = false;
582
589
  let isChange = false;
583
- Object.keys(fullData).forEach((key) => {
584
- isChange = deepEqual(fullData[key], oldAllCfg[key]);
590
+ Object.keys(mergeCfg).forEach((key) => {
591
+ isChange = deepEqual(mergeCfg[key], oldAllCfg[key]);
585
592
  if (isChange) {
586
- success = Config.ModifyPro(key, fullData[key]);
593
+ success = Config.ModifyPro(key, mergeCfg[key]);
587
594
  }
588
595
  });
589
596
  return {
590
- fullData,
597
+ mergeCfg,
591
598
  formatCfg,
592
599
  success,
593
600
  message: success ? '保存成功 Ciallo~(∠・ω< )⌒☆' : '配置无变化,无需保存'
@@ -701,34 +708,32 @@ function getFirstObject(arr) {
701
708
  */
702
709
  function processFrontendData(data) {
703
710
  const result = {};
704
- // 处理普通配置项
705
- // const configKeys = ['app', 'bilibili', 'douyin', 'cookies', 'kuaishou', 'upload']
706
- const configKeys = Object.keys(data).filter(key => !key.includes('pushlist'));
711
+ const configKeys = Object.keys(data).filter((key) => {
712
+ return !key.includes('pushlist') && key in data;
713
+ });
707
714
  for (const key of configKeys) {
708
- const firstObj = getFirstObject(data[key] || []);
715
+ const value = data[key];
716
+ const firstObj = Array.isArray(value) ? getFirstObject(value) : {};
717
+ // 使用类型断言,确保 result[key] 的类型正确
709
718
  result[key] = {};
710
719
  for (const prop in firstObj) {
711
720
  let value = firstObj[prop];
712
- // 尝试将值转换为数字
713
721
  value = convertToNumber(value);
714
- if (prop.includes('.')) {
715
- // 处理嵌套属性
716
- const [parent, child] = prop.split('.');
722
+ if (prop.includes(':')) {
723
+ const [parent, child] = prop.split(':');
717
724
  if (!result[key][parent]) {
718
725
  result[key][parent] = {};
719
726
  }
720
727
  result[key][parent][child] = value;
721
728
  }
722
729
  else {
723
- // 处理普通属性
724
730
  result[key][prop] = value;
725
731
  }
726
732
  }
727
733
  }
728
- // 处理 pushlist 配置项
729
734
  result.pushlist = {
730
- douyin: data['cfg.pushlist.douyin'] || [],
731
- bilibili: data['cfg.pushlist.bilibili'] || []
735
+ douyin: data['pushlist:douyin'] || [],
736
+ bilibili: data['pushlist:bilibili'] || []
732
737
  };
733
738
  return result;
734
739
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "karin-plugin-kkk",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "a Karin video parsing tool",
5
5
  "keywords": [
6
6
  "karin-plugin",
@@ -27,9 +27,7 @@
27
27
  <body {{@sys.scale}}>
28
28
  <div class="container" id="container">
29
29
  {{block 'main'}}{{/block}}
30
- {{if copyright}}
31
30
  <div class="copyright">{{@copyright}}</div>
32
- {{/if}}
33
31
  <script>
34
32
  // 获取当前时间并自动设置主题
35
33
  function setThemeBasedOnTime () {