xctc-utils 1.6.25 → 1.6.27

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.
@@ -21,4 +21,11 @@ interface GetOptions {
21
21
  }
22
22
  export declare const get: (options: GetOptions) => any;
23
23
  export declare const urlStateParams: (cacheKey?: string, key?: string, iv?: string) => void;
24
+ /**
25
+ * dyb 2024-5-30
26
+ * 将 data 对象 拼接为地址,根据拼接地址执行页面跳转
27
+ * @param data 需要处理的 data 对象
28
+ * @returns
29
+ */
30
+ export declare const formatDataToUrl: (data: any) => string;
24
31
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.urlStateParams = exports.get = exports.set = void 0;
3
+ exports.formatDataToUrl = exports.urlStateParams = exports.get = exports.set = void 0;
4
4
  var crypto_1 = require("../crypto");
5
5
  var storage_1 = require("../storage");
6
6
  var defaultKey = "5uMz4R8r0926DkC8";
@@ -126,3 +126,39 @@ var urlStateParams = function (cacheKey, key, iv) {
126
126
  }
127
127
  };
128
128
  exports.urlStateParams = urlStateParams;
129
+ /**
130
+ * dyb 2024-5-30
131
+ * 将 data 对象 拼接为地址,根据拼接地址执行页面跳转
132
+ * @param data 需要处理的 data 对象
133
+ * @returns
134
+ */
135
+ var formatDataToUrl = function (data) {
136
+ var url = loc.origin;
137
+ var str = "";
138
+ var hashVal = loc.hash;
139
+ if ((0, is_1.isObject)(data)) {
140
+ for (var key in data) {
141
+ if (key == "path") {
142
+ if (data[key][0] == "/") {
143
+ url = "".concat(url, "/#").concat(data.path);
144
+ }
145
+ else {
146
+ url = "".concat(url, "/#/").concat(data.path);
147
+ }
148
+ }
149
+ else {
150
+ str += "".concat(key, "=").concat(data[key], "&");
151
+ }
152
+ }
153
+ if (data === null || data === void 0 ? void 0 : data.path) {
154
+ if (str) {
155
+ url = "".concat(url, "?").concat(str);
156
+ }
157
+ }
158
+ }
159
+ else if (hashVal) {
160
+ url = "".concat(url, "/").concat(hashVal);
161
+ }
162
+ return url;
163
+ };
164
+ exports.formatDataToUrl = formatDataToUrl;
@@ -216,7 +216,7 @@ function login(code) {
216
216
  }
217
217
  }
218
218
  }
219
- else {
219
+ else if (hashVal) {
220
220
  url = "".concat(url, "/").concat(hashVal);
221
221
  }
222
222
  if (weixinConfig['isPassLogin']) {
@@ -321,7 +321,7 @@ var isContinue = function () {
321
321
  if (search) {
322
322
  codeIndex = search.indexOf("code=");
323
323
  }
324
- if (localCodeData && localCodeData.hasOwnProperty("code") && codeIndex == -1) {
324
+ if (localCodeData && localCodeData.hasOwnProperty("code")) {
325
325
  return true;
326
326
  }
327
327
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xctc-utils",
3
- "version": "1.6.25",
3
+ "version": "1.6.27",
4
4
  "description": "localStorage存储\r ```\r sessionStorage存储\r ```\r crypto-js加密、解密\r ```\r 微信授权登录、微信分享\r ```\r 设备环境获取\r ```\r 是否是微信浏览器\r ```\r 时间戳转时间,字符串转时间戳",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",