fast-vue-multi-pages-vite 1.3.7 → 1.3.9

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.d.ts CHANGED
@@ -32,9 +32,9 @@ declare class FastVueMultiSimpleRequestConfig {
32
32
  */
33
33
  nativeHttp: boolean;
34
34
  /**
35
- * 是否启用压缩
35
+ * 启用安全响应
36
36
  */
37
- outCompress: boolean;
37
+ securityResponse: string;
38
38
  /**
39
39
  * json字典
40
40
  */
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import axios from "axios";
4
4
  import { clear, del, get, keys, set, update } from "idb-keyval";
5
5
  import CryptoJSMD5 from "crypto-js/md5";
6
6
  import * as uuid from "uuid";
7
- import { decompress } from "@structured-world/structured-zstd";
7
+ import { ZSTDDecoder } from "zstddec";
8
8
  import store from "store2";
9
9
  import cookies from "js-cookie";
10
10
  import copy from "copy-to-clipboard";
@@ -95,9 +95,9 @@ var FastVueMultiSimpleRequestConfig = class {
95
95
  */
96
96
  nativeHttp = false;
97
97
  /**
98
- * 是否启用压缩
98
+ * 启用安全响应
99
99
  */
100
- outCompress = false;
100
+ securityResponse;
101
101
  /**
102
102
  * json字典
103
103
  */
@@ -942,7 +942,7 @@ let FastVueMultiHttp;
942
942
  }
943
943
  };
944
944
  let headers = FastVueMultiHttp.Simple.getFinalHeaders();
945
- if (config.outCompress) headers["out-compress"] = true;
945
+ if (config.securityResponse) headers["security-type"] = "obfuscate";
946
946
  if (config.shortJsonVersion > 0) headers["short-json"] = config.shortJsonVersion;
947
947
  if ((config.nativeHttp || FastVueMultiTool.PageConfig.getConfig("nativeHttp").toString() === "true") && !justFormData && FastVueNative.isNativeApp() && !FastVueMultiHttp.Simple.hasFileParam(params) && !FastVueMultiHttp.Simple.hasArrayParam(params)) FastVueNative.execute("http", [
948
948
  url,
@@ -961,10 +961,21 @@ let FastVueMultiHttp;
961
961
  requestThen(response);
962
962
  };
963
963
  let uint8Data = new Uint8Array(response.data);
964
- if (response.headers["fastchar-compress"] === "zstd") decompress(uint8Data).then((data) => {
965
- doReturn(new TextDecoder("utf-8").decode(data));
966
- }).catch(reject);
967
- else doReturn(new TextDecoder("utf-8").decode(uint8Data));
964
+ if (response.headers["security-response"]) {
965
+ const unCompressData = new Uint8Array(uint8Data.length);
966
+ const password = new TextEncoder().encode(config.securityResponse);
967
+ const passwordLength = password.length;
968
+ for (let i = 0; i < uint8Data.length; i++) {
969
+ const k = password[i % passwordLength] & 255;
970
+ const posFactor = i & 255;
971
+ unCompressData[i] = (uint8Data[i] ^ k ^ posFactor) & 255;
972
+ }
973
+ const decoder = new ZSTDDecoder();
974
+ decoder.init().then(() => {
975
+ const decompressedArray = decoder.decode(unCompressData);
976
+ doReturn(new TextDecoder("utf-8").decode(decompressedArray));
977
+ }).catch(reject);
978
+ } else doReturn(new TextDecoder("utf-8").decode(uint8Data));
968
979
  }).catch(function(error) {
969
980
  console.error(error);
970
981
  FastVueMultiDB.removeValue(cacheKey);
@@ -976,11 +987,10 @@ let FastVueMultiHttp;
976
987
  static parseShortResponse(config, responseJsonStringData) {
977
988
  if (config.shortJsonDictionary) {
978
989
  let newJsonString = responseJsonStringData;
979
- for (let key in config.shortJsonDictionary) {
980
- let info = config.shortJsonDictionary[key];
990
+ for (let info of config.shortJsonDictionary) {
981
991
  if (!info.value) continue;
982
- newJsonString = newJsonString.replaceAll(new RegExp(`"${info.value}"`, "g"), `"${key}"`);
983
- newJsonString = newJsonString.replaceAll(new RegExp(`<${info.value}>`, "g"), key);
992
+ newJsonString = newJsonString.replaceAll(`"${info.value}":`, `"${info.key}":`);
993
+ newJsonString = newJsonString.replaceAll(`@${info.value}>`, info.key);
984
994
  }
985
995
  return newJsonString;
986
996
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fast-vue-multi-pages-vite",
3
- "version": "1.3.7",
3
+ "version": "1.3.9",
4
4
  "author": "janesen",
5
5
  "description": "Vite-快速搭建VUE项目工具类的基本库,主要用于多个页面独立生成html",
6
6
  "main": "./dist/index.js",
@@ -46,7 +46,7 @@
46
46
  "vconsole": "^3.15.1",
47
47
  "wavesurfer.js": "^7.9.4",
48
48
  "lz-string": "^1.5.0",
49
- "@structured-world/structured-zstd": "^0.0.49"
49
+ "zstddec": "^0.2.0"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@types/node": "^24.8.1",