@kevisual/kv-login 0.1.1 → 0.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/dist/app.d.ts CHANGED
@@ -1,4 +1,63 @@
1
- declare const loginEmitter: any;
1
+ interface EventData<T = any> {
2
+ type: string;
3
+ data: T;
4
+ }
5
+ type EventHandler<T = any> = (event: EventData<T>) => void;
6
+ declare class EventEmitter {
7
+ private events;
8
+ /**
9
+ * 监听事件
10
+ * @param type 事件类型
11
+ * @param handler 事件处理函数
12
+ */
13
+ on<T = any>(type: string, handler: EventHandler<T>): void;
14
+ /**
15
+ * 移除事件监听器
16
+ * @param type 事件类型
17
+ * @param handler 事件处理函数 (可选,如果不提供则移除该类型的所有监听器)
18
+ */
19
+ off<T = any>(type: string, handler?: EventHandler<T>): void;
20
+ /**
21
+ * 触发事件
22
+ * @param event 事件对象,包含 type 和 data
23
+ */
24
+ emit<T = any>(event: EventData<T>): void;
25
+ /**
26
+ * 触发事件(简化版本,直接传递type和data)
27
+ * @param type 事件类型
28
+ * @param data 事件数据
29
+ */
30
+ emitSimple<T = any>(type: string, data: T): void;
31
+ /**
32
+ * 清空所有事件监听器
33
+ */
34
+ clear(): void;
35
+ /**
36
+ * 获取指定类型的监听器数量
37
+ * @param type 事件类型
38
+ * @returns 监听器数量
39
+ */
40
+ listenerCount(type: string): number;
41
+ /**
42
+ * 获取所有事件类型
43
+ * @returns 事件类型数组
44
+ */
45
+ eventNames(): string[];
46
+ /**
47
+ * 检查是否有指定类型的监听器
48
+ * @param type 事件类型
49
+ * @returns 是否有监听器
50
+ */
51
+ hasListeners(type: string): boolean;
52
+ /**
53
+ * 只监听一次事件
54
+ * @param type 事件类型
55
+ * @param handler 事件处理函数
56
+ */
57
+ once<T = any>(type: string, handler: EventHandler<T>): void;
58
+ }
59
+
60
+ declare const loginEmitter: EventEmitter;
2
61
 
3
62
  interface KvMessageOptions {
4
63
  type?: 'success' | 'error' | 'loading';
@@ -50,4 +109,7 @@ declare global {
50
109
  }
51
110
  }
52
111
 
53
- export { loginEmitter };
112
+ declare const clearCode: () => void;
113
+ declare const checkPluginLogin: () => Promise<void>;
114
+
115
+ export { checkPluginLogin, clearCode, loginEmitter };
package/dist/app.js CHANGED
@@ -16,14 +16,14 @@ var __toESM = (mod, isNodeMode, target) => {
16
16
  };
17
17
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
18
18
 
19
- // node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js
19
+ // ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js
20
20
  var require_can_promise = __commonJS((exports, module) => {
21
21
  module.exports = function() {
22
22
  return typeof Promise === "function" && Promise.prototype && Promise.prototype.then;
23
23
  };
24
24
  });
25
25
 
26
- // node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js
26
+ // ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js
27
27
  var require_utils = __commonJS((exports) => {
28
28
  var toSJISFunction;
29
29
  var CODEWORDS_COUNT = [
@@ -101,7 +101,7 @@ var require_utils = __commonJS((exports) => {
101
101
  };
102
102
  });
103
103
 
104
- // node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js
104
+ // ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js
105
105
  var require_error_correction_level = __commonJS((exports) => {
106
106
  exports.L = { bit: 1 };
107
107
  exports.M = { bit: 0 };
@@ -144,7 +144,7 @@ var require_error_correction_level = __commonJS((exports) => {
144
144
  };
145
145
  });
146
146
 
147
- // node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js
147
+ // ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js
148
148
  var require_bit_buffer = __commonJS((exports, module) => {
149
149
  function BitBuffer() {
150
150
  this.buffer = [];
@@ -177,7 +177,7 @@ var require_bit_buffer = __commonJS((exports, module) => {
177
177
  module.exports = BitBuffer;
178
178
  });
179
179
 
180
- // node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js
180
+ // ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js
181
181
  var require_bit_matrix = __commonJS((exports, module) => {
182
182
  function BitMatrix(size) {
183
183
  if (!size || size < 1) {
@@ -205,7 +205,7 @@ var require_bit_matrix = __commonJS((exports, module) => {
205
205
  module.exports = BitMatrix;
206
206
  });
207
207
 
208
- // node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js
208
+ // ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js
209
209
  var require_alignment_pattern = __commonJS((exports) => {
210
210
  var getSymbolSize = require_utils().getSymbolSize;
211
211
  exports.getRowColCoords = function getRowColCoords(version) {
@@ -237,7 +237,7 @@ var require_alignment_pattern = __commonJS((exports) => {
237
237
  };
238
238
  });
239
239
 
240
- // node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js
240
+ // ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js
241
241
  var require_finder_pattern = __commonJS((exports) => {
242
242
  var getSymbolSize = require_utils().getSymbolSize;
243
243
  var FINDER_PATTERN_SIZE = 7;
@@ -251,7 +251,7 @@ var require_finder_pattern = __commonJS((exports) => {
251
251
  };
252
252
  });
253
253
 
254
- // node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js
254
+ // ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js
255
255
  var require_mask_pattern = __commonJS((exports) => {
256
256
  exports.Patterns = {
257
257
  PATTERN000: 0,
@@ -400,7 +400,7 @@ var require_mask_pattern = __commonJS((exports) => {
400
400
  };
401
401
  });
402
402
 
403
- // node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js
403
+ // ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js
404
404
  var require_error_correction_code = __commonJS((exports) => {
405
405
  var ECLevel = require_error_correction_level();
406
406
  var EC_BLOCKS_TABLE = [
@@ -757,7 +757,7 @@ var require_error_correction_code = __commonJS((exports) => {
757
757
  };
758
758
  });
759
759
 
760
- // node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.js
760
+ // ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.js
761
761
  var require_galois_field = __commonJS((exports) => {
762
762
  var EXP_TABLE = new Uint8Array(512);
763
763
  var LOG_TABLE = new Uint8Array(256);
@@ -790,7 +790,7 @@ var require_galois_field = __commonJS((exports) => {
790
790
  };
791
791
  });
792
792
 
793
- // node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.js
793
+ // ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.js
794
794
  var require_polynomial = __commonJS((exports) => {
795
795
  var GF = require_galois_field();
796
796
  exports.mul = function mul(p1, p2) {
@@ -825,7 +825,7 @@ var require_polynomial = __commonJS((exports) => {
825
825
  };
826
826
  });
827
827
 
828
- // node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.js
828
+ // ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.js
829
829
  var require_reed_solomon_encoder = __commonJS((exports, module) => {
830
830
  var Polynomial = require_polynomial();
831
831
  function ReedSolomonEncoder(degree) {
@@ -856,14 +856,14 @@ var require_reed_solomon_encoder = __commonJS((exports, module) => {
856
856
  module.exports = ReedSolomonEncoder;
857
857
  });
858
858
 
859
- // node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js
859
+ // ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js
860
860
  var require_version_check = __commonJS((exports) => {
861
861
  exports.isValid = function isValid(version) {
862
862
  return !isNaN(version) && version >= 1 && version <= 40;
863
863
  };
864
864
  });
865
865
 
866
- // node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js
866
+ // ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js
867
867
  var require_regex = __commonJS((exports) => {
868
868
  var numeric = "[0-9]+";
869
869
  var alphanumeric = "[A-Z $%*+\\-./:]+";
@@ -890,7 +890,7 @@ var require_regex = __commonJS((exports) => {
890
890
  };
891
891
  });
892
892
 
893
- // node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js
893
+ // ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js
894
894
  var require_mode = __commonJS((exports) => {
895
895
  var VersionCheck = require_version_check();
896
896
  var Regex = require_regex();
@@ -977,7 +977,7 @@ var require_mode = __commonJS((exports) => {
977
977
  };
978
978
  });
979
979
 
980
- // node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.js
980
+ // ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.js
981
981
  var require_version = __commonJS((exports) => {
982
982
  var Utils = require_utils();
983
983
  var ECCode = require_error_correction_code();
@@ -1072,7 +1072,7 @@ var require_version = __commonJS((exports) => {
1072
1072
  };
1073
1073
  });
1074
1074
 
1075
- // node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.js
1075
+ // ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.js
1076
1076
  var require_format_info = __commonJS((exports) => {
1077
1077
  var Utils = require_utils();
1078
1078
  var G15 = 1 << 10 | 1 << 8 | 1 << 5 | 1 << 4 | 1 << 2 | 1 << 1 | 1 << 0;
@@ -1088,7 +1088,7 @@ var require_format_info = __commonJS((exports) => {
1088
1088
  };
1089
1089
  });
1090
1090
 
1091
- // node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.js
1091
+ // ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.js
1092
1092
  var require_numeric_data = __commonJS((exports, module) => {
1093
1093
  var Mode = require_mode();
1094
1094
  function NumericData(data) {
@@ -1121,7 +1121,7 @@ var require_numeric_data = __commonJS((exports, module) => {
1121
1121
  module.exports = NumericData;
1122
1122
  });
1123
1123
 
1124
- // node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.js
1124
+ // ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.js
1125
1125
  var require_alphanumeric_data = __commonJS((exports, module) => {
1126
1126
  var Mode = require_mode();
1127
1127
  var ALPHA_NUM_CHARS = [
@@ -1198,7 +1198,7 @@ var require_alphanumeric_data = __commonJS((exports, module) => {
1198
1198
  module.exports = AlphanumericData;
1199
1199
  });
1200
1200
 
1201
- // node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.js
1201
+ // ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.js
1202
1202
  var require_byte_data = __commonJS((exports, module) => {
1203
1203
  var Mode = require_mode();
1204
1204
  function ByteData(data) {
@@ -1226,7 +1226,7 @@ var require_byte_data = __commonJS((exports, module) => {
1226
1226
  module.exports = ByteData;
1227
1227
  });
1228
1228
 
1229
- // node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.js
1229
+ // ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.js
1230
1230
  var require_kanji_data = __commonJS((exports, module) => {
1231
1231
  var Mode = require_mode();
1232
1232
  var Utils = require_utils();
@@ -1262,7 +1262,7 @@ var require_kanji_data = __commonJS((exports, module) => {
1262
1262
  module.exports = KanjiData;
1263
1263
  });
1264
1264
 
1265
- // node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.js
1265
+ // ../../node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.js
1266
1266
  var require_dijkstra = __commonJS((exports, module) => {
1267
1267
  var dijkstra = {
1268
1268
  single_source_shortest_paths: function(graph, s, d2) {
@@ -1347,7 +1347,7 @@ var require_dijkstra = __commonJS((exports, module) => {
1347
1347
  }
1348
1348
  });
1349
1349
 
1350
- // node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.js
1350
+ // ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.js
1351
1351
  var require_segments = __commonJS((exports) => {
1352
1352
  var Mode = require_mode();
1353
1353
  var NumericData = require_numeric_data();
@@ -1531,7 +1531,7 @@ var require_segments = __commonJS((exports) => {
1531
1531
  };
1532
1532
  });
1533
1533
 
1534
- // node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.js
1534
+ // ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.js
1535
1535
  var require_qrcode = __commonJS((exports) => {
1536
1536
  var Utils = require_utils();
1537
1537
  var ECLevel = require_error_correction_level();
@@ -1791,7 +1791,7 @@ var require_qrcode = __commonJS((exports) => {
1791
1791
  };
1792
1792
  });
1793
1793
 
1794
- // node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js
1794
+ // ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js
1795
1795
  var require_utils2 = __commonJS((exports) => {
1796
1796
  function hex2rgba(hex) {
1797
1797
  if (typeof hex === "number") {
@@ -1872,7 +1872,7 @@ var require_utils2 = __commonJS((exports) => {
1872
1872
  };
1873
1873
  });
1874
1874
 
1875
- // node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/canvas.js
1875
+ // ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/canvas.js
1876
1876
  var require_canvas = __commonJS((exports) => {
1877
1877
  var Utils = require_utils2();
1878
1878
  function clearCanvas(ctx, canvas, size) {
@@ -1925,7 +1925,7 @@ var require_canvas = __commonJS((exports) => {
1925
1925
  };
1926
1926
  });
1927
1927
 
1928
- // node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg-tag.js
1928
+ // ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg-tag.js
1929
1929
  var require_svg_tag = __commonJS((exports) => {
1930
1930
  var Utils = require_utils2();
1931
1931
  function getColorAttrib(color, attrib) {
@@ -1984,7 +1984,7 @@ var require_svg_tag = __commonJS((exports) => {
1984
1984
  };
1985
1985
  });
1986
1986
 
1987
- // node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/browser.js
1987
+ // ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/browser.js
1988
1988
  var require_browser = __commonJS((exports) => {
1989
1989
  var canPromise = require_can_promise();
1990
1990
  var QRCode = require_qrcode();
@@ -2052,7 +2052,7 @@ var require_browser = __commonJS((exports) => {
2052
2052
  });
2053
2053
  });
2054
2054
 
2055
- // node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/development/lit-html.js
2055
+ // ../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/development/lit-html.js
2056
2056
  var DEV_MODE = true;
2057
2057
  var ENABLE_EXTRA_SECURITY_HOOKS = true;
2058
2058
  var ENABLE_SHADYDOM_NOPATCH = true;
@@ -2901,7 +2901,7 @@ if (ENABLE_EXTRA_SECURITY_HOOKS) {
2901
2901
  }
2902
2902
  }
2903
2903
 
2904
- // node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/development/directive.js
2904
+ // ../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/development/directive.js
2905
2905
  var PartType = {
2906
2906
  ATTRIBUTE: 1,
2907
2907
  CHILD: 2,
@@ -2933,7 +2933,7 @@ class Directive {
2933
2933
  }
2934
2934
  }
2935
2935
 
2936
- // node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/development/directives/unsafe-html.js
2936
+ // ../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/development/directives/unsafe-html.js
2937
2937
  var HTML_RESULT2 = 1;
2938
2938
 
2939
2939
  class UnsafeHTMLDirective extends Directive {
@@ -2972,7 +2972,7 @@ UnsafeHTMLDirective.directiveName = "unsafeHTML";
2972
2972
  UnsafeHTMLDirective.resultType = HTML_RESULT2;
2973
2973
  var unsafeHTML = directive(UnsafeHTMLDirective);
2974
2974
 
2975
- // node_modules/.pnpm/@kevisual+query@0.0.32/node_modules/@kevisual/query/dist/query-browser.js
2975
+ // ../../node_modules/.pnpm/@kevisual+query@0.0.33/node_modules/@kevisual/query/dist/query-browser.js
2976
2976
  var isTextForContentType = (contentType) => {
2977
2977
  if (!contentType)
2978
2978
  return false;
@@ -3039,7 +3039,7 @@ var adapter = async (opts = {}, overloadOpts) => {
3039
3039
  return await response.json();
3040
3040
  } else if (isTextForContentType(contentType)) {
3041
3041
  return {
3042
- code: 200,
3042
+ code: response.status,
3043
3043
  status: response.status,
3044
3044
  data: await response.text()
3045
3045
  };
@@ -3078,9 +3078,11 @@ class Query {
3078
3078
  timeout;
3079
3079
  stop;
3080
3080
  qws;
3081
+ isClient = false;
3081
3082
  constructor(opts) {
3082
3083
  this.adapter = opts?.adapter || adapter;
3083
- this.url = opts?.url || "/api/router";
3084
+ const defaultURL = opts?.isClient ? "/client/router" : "/api/router";
3085
+ this.url = opts?.url || defaultURL;
3084
3086
  this.headers = opts?.headers || {
3085
3087
  "Content-Type": "application/json"
3086
3088
  };
@@ -3220,7 +3222,7 @@ class BaseQuery {
3220
3222
  }
3221
3223
  }
3222
3224
 
3223
- // node_modules/.pnpm/@kevisual+query@0.0.32/node_modules/@kevisual/query/dist/query.js
3225
+ // ../../node_modules/.pnpm/@kevisual+query@0.0.33/node_modules/@kevisual/query/dist/query.js
3224
3226
  var setBaseResponse = (res) => {
3225
3227
  res.success = res.code === 200;
3226
3228
  res.showError = (fn) => {
@@ -3231,7 +3233,7 @@ var setBaseResponse = (res) => {
3231
3233
  return res;
3232
3234
  };
3233
3235
 
3234
- // node_modules/.pnpm/@kevisual+cache@0.0.3/node_modules/@kevisual/cache/dist/cache.js
3236
+ // ../../node_modules/.pnpm/@kevisual+cache@0.0.3/node_modules/@kevisual/cache/dist/cache.js
3235
3237
  function promisifyRequest(request) {
3236
3238
  return new Promise((resolve, reject) => {
3237
3239
  request.oncomplete = request.onsuccess = () => resolve(request.result);
@@ -3411,7 +3413,7 @@ class MyCache extends CacheWorkspace {
3411
3413
  }
3412
3414
  }
3413
3415
 
3414
- // node_modules/.pnpm/@kevisual+query-login@0.0.7_@kevisual+query@0.0.32/node_modules/@kevisual/query-login/dist/query-login-browser.js
3416
+ // ../../node_modules/.pnpm/@kevisual+query-login@0.0.7_@kevisual+query@0.0.33/node_modules/@kevisual/query-login/dist/query-login-browser.js
3415
3417
  var LoginCacheStore = class {
3416
3418
  cache;
3417
3419
  name;
@@ -4242,6 +4244,8 @@ var clearCode = () => {
4242
4244
  const url = new URL(window.location.href);
4243
4245
  url.searchParams.delete("code");
4244
4246
  url.searchParams.delete("state");
4247
+ url.searchParams.delete("user-check");
4248
+ url.searchParams.delete("redirect");
4245
4249
  window.history.replaceState({}, document.title, url.toString());
4246
4250
  };
4247
4251
  var checkWechat = async () => {
@@ -4286,6 +4290,27 @@ var checkMpWechat = async () => {
4286
4290
  closePage();
4287
4291
  }
4288
4292
  };
4293
+ var checkPluginLogin = async () => {
4294
+ const userCheck = "user-check";
4295
+ const url = new URL(location.href);
4296
+ const redirect = url.searchParams.get("redirect");
4297
+ const redirectUrl = redirect ? decodeURIComponent(redirect) : "";
4298
+ const checkKey = url.searchParams.get(userCheck);
4299
+ if (redirect && checkKey) {
4300
+ const me = await query.getMe();
4301
+ if (me.code === 200) {
4302
+ message.success("登录插件中...");
4303
+ const token = await query.cacheStore.getAccessToken();
4304
+ const newRedirectUrl = new URL(redirectUrl);
4305
+ newRedirectUrl.searchParams.set("token", token + "");
4306
+ setTimeout(() => {
4307
+ window.open(newRedirectUrl.toString(), "_blank");
4308
+ }, 2000);
4309
+ return;
4310
+ }
4311
+ }
4312
+ console.log("checkKey", checkKey, redirectUrl);
4313
+ };
4289
4314
  var isWechat = () => {
4290
4315
  const ua = navigator.userAgent.toLowerCase();
4291
4316
  return /micromessenger/i.test(ua);
@@ -4480,7 +4505,7 @@ var useCreateLoginQRCode = (el) => {
4480
4505
  return { createQrcode, clear: clear2 };
4481
4506
  };
4482
4507
 
4483
- // node_modules/.pnpm/@kevisual+context@0.0.4/node_modules/@kevisual/context/dist/app.js
4508
+ // ../../node_modules/.pnpm/@kevisual+context@0.0.4/node_modules/@kevisual/context/dist/app.js
4484
4509
  var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
4485
4510
  function getDefaultExportFromCjs(x) {
4486
4511
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
@@ -5102,7 +5127,6 @@ class KvLogin extends HTMLElement {
5102
5127
  if (loginMethods.length > 0) {
5103
5128
  this.loginMethods = getLoginMethod(loginMethods);
5104
5129
  this.selectedMethod = loginMethods[0];
5105
- this.setLoginMethods(this.loginMethods);
5106
5130
  return;
5107
5131
  }
5108
5132
  }
@@ -5320,20 +5344,9 @@ class KvLogin extends HTMLElement {
5320
5344
  return this.renderPasswordForm();
5321
5345
  }
5322
5346
  }
5323
- createWeixinEl() {
5324
- const id = "weixinLogin";
5325
- let el = this.querySelector("#" + id);
5326
- if (el)
5327
- return el;
5328
- const weixinEl = document.createElement("div");
5329
- weixinEl.id = "weixinLogin";
5330
- this.appendChild(weixinEl);
5331
- return weixinEl;
5332
- }
5333
5347
  render() {
5334
5348
  if (!this.shadowRoot)
5335
5349
  return;
5336
- this.createWeixinEl();
5337
5350
  const renderIcon = (icon) => {
5338
5351
  if (typeof icon === "string" && !icons[icon]) {
5339
5352
  return html`<span class="method-icon-emoji">${icon}</span>`;
@@ -5579,5 +5592,7 @@ class KvLogin extends HTMLElement {
5579
5592
  }
5580
5593
  customElements.define("kv-login", KvLogin);
5581
5594
  export {
5582
- loginEmitter
5595
+ loginEmitter,
5596
+ clearCode,
5597
+ checkPluginLogin
5583
5598
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevisual/kv-login",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "",
5
5
  "main": "src/main.ts",
6
6
  "scripts": {
@@ -12,20 +12,20 @@
12
12
  "pub": "ev deploy ./dist -k kv-login-test -v 0.0.6 -u -y yes"
13
13
  },
14
14
  "keywords": [],
15
+ "files": [
16
+ "types",
17
+ "src",
18
+ "dist"
19
+ ],
15
20
  "author": "abearxiong <xiongxiao@xiongxiao.me> (https://www.xiongxiao.me)",
16
21
  "license": "MIT",
17
- "packageManager": "pnpm@10.26.0",
22
+ "packageManager": "pnpm@10.24.0",
18
23
  "publishConfig": {
19
24
  "access": "public"
20
25
  },
21
26
  "type": "module",
22
- "files": [
23
- "types",
24
- "dist"
25
- ],
26
27
  "dependencies": {
27
28
  "@kevisual/context": "^0.0.4",
28
- "@kevisual/query": "^0.0.32",
29
29
  "@kevisual/query-login": "^0.0.7",
30
30
  "lit-html": "^3.3.1",
31
31
  "qrcode": "^1.5.4"
@@ -36,8 +36,6 @@
36
36
  },
37
37
  "types": "./types/index.d.ts",
38
38
  "devDependencies": {
39
- "@types/bun": "^1.3.4",
40
- "@types/qrcode": "^1.5.6",
41
- "vite": "^7.3.0"
39
+ "@types/bun": "^1.3.5"
42
40
  }
43
41
  }
package/readme.md CHANGED
@@ -4,24 +4,9 @@
4
4
 
5
5
  黑白
6
6
 
7
- ```html
8
- <kv-login>
9
- </kv-login>
10
- ```
11
-
12
- ## 网页
13
7
 
14
8
  ```html
15
- <script type="importmap">
16
- {
17
- "imports": {
18
- "@kevisual/kv-login": "https://esm.kevisual.cn/@kevisual/kv-login"
19
- }
20
- }
21
- </script>
22
- <script type="module">
23
- import '@kevisual/kv-login';
24
- </script>
25
- <kv-login method="password,wechat,wechat-mp">
9
+ <kv-login>
10
+ <div id="weixinLogin"></div>
26
11
  </kv-login>
27
- ```
12
+ ```
package/src/main.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import './pages/kv-login'
2
2
  import './pages/kv-message'
3
3
 
4
- export { loginEmitter } from './pages/kv-login'
4
+ export { loginEmitter } from './pages/kv-login'
5
+
6
+ export { checkPluginLogin, clearCode } from './modules/login-handle';