fast-vue-multi-pages-vite 1.3.6 → 1.3.8
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 +17 -0
- package/dist/index.js +65 -2
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -31,6 +31,22 @@ declare class FastVueMultiSimpleRequestConfig {
|
|
|
31
31
|
* 执行原生客户端http
|
|
32
32
|
*/
|
|
33
33
|
nativeHttp: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* 启用压缩
|
|
36
|
+
*/
|
|
37
|
+
outCompress: string;
|
|
38
|
+
/**
|
|
39
|
+
* 解压缩密码
|
|
40
|
+
*/
|
|
41
|
+
outCompressPassword: string;
|
|
42
|
+
/**
|
|
43
|
+
* json字典
|
|
44
|
+
*/
|
|
45
|
+
shortJsonDictionary: any;
|
|
46
|
+
/**
|
|
47
|
+
* json字典版本
|
|
48
|
+
*/
|
|
49
|
+
shortJsonVersion: number;
|
|
34
50
|
}
|
|
35
51
|
//#endregion
|
|
36
52
|
//#region src/http/FastVueMultiSimpleJsonResponse.d.ts
|
|
@@ -231,6 +247,7 @@ declare namespace FastVueMultiHttp {
|
|
|
231
247
|
* @param callBack 请求接口回调函数,在使用alwaysBackRequest参数为true时,必须使用回调函数接收
|
|
232
248
|
*/
|
|
233
249
|
static request(method: string, url: string, params?: any, config?: FastVueMultiSimpleRequestConfig, callBack?: (result: FastVueMultiSimpleJsonResponse) => void): Promise<FastVueMultiSimpleJsonResponse>;
|
|
250
|
+
static parseShortResponse(config: FastVueMultiSimpleRequestConfig, responseJsonStringData: string): string;
|
|
234
251
|
/**
|
|
235
252
|
* post请求接口
|
|
236
253
|
* @param url 接口地址 完整的地址,例如:http://loalhost:8080/user/login
|
package/dist/index.js
CHANGED
|
@@ -4,6 +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 { ZSTDDecoder } from "zstddec";
|
|
7
8
|
import store from "store2";
|
|
8
9
|
import cookies from "js-cookie";
|
|
9
10
|
import copy from "copy-to-clipboard";
|
|
@@ -93,6 +94,22 @@ var FastVueMultiSimpleRequestConfig = class {
|
|
|
93
94
|
* 执行原生客户端http
|
|
94
95
|
*/
|
|
95
96
|
nativeHttp = false;
|
|
97
|
+
/**
|
|
98
|
+
* 启用压缩
|
|
99
|
+
*/
|
|
100
|
+
outCompress;
|
|
101
|
+
/**
|
|
102
|
+
* 解压缩密码
|
|
103
|
+
*/
|
|
104
|
+
outCompressPassword;
|
|
105
|
+
/**
|
|
106
|
+
* json字典
|
|
107
|
+
*/
|
|
108
|
+
shortJsonDictionary;
|
|
109
|
+
/**
|
|
110
|
+
* json字典版本
|
|
111
|
+
*/
|
|
112
|
+
shortJsonVersion;
|
|
96
113
|
};
|
|
97
114
|
|
|
98
115
|
//#endregion
|
|
@@ -734,7 +751,13 @@ let FastVueMultiHttp;
|
|
|
734
751
|
let axiosConfig = {
|
|
735
752
|
headers: header,
|
|
736
753
|
method,
|
|
737
|
-
url
|
|
754
|
+
url,
|
|
755
|
+
adapter: [
|
|
756
|
+
"fetch",
|
|
757
|
+
"xhr",
|
|
758
|
+
"http"
|
|
759
|
+
],
|
|
760
|
+
responseType: "arraybuffer"
|
|
738
761
|
};
|
|
739
762
|
if (method === "post") if (_.isString(params)) axiosConfig.paramsSerializer = params;
|
|
740
763
|
else axiosConfig.data = this.convertToFormData(params);
|
|
@@ -923,6 +946,11 @@ let FastVueMultiHttp;
|
|
|
923
946
|
}
|
|
924
947
|
};
|
|
925
948
|
let headers = FastVueMultiHttp.Simple.getFinalHeaders();
|
|
949
|
+
if (config.outCompress) {
|
|
950
|
+
headers["out-compress"] = config.outCompress;
|
|
951
|
+
headers["Accept-Encoding"] = "identity";
|
|
952
|
+
}
|
|
953
|
+
if (config.shortJsonVersion > 0) headers["short-json"] = config.shortJsonVersion;
|
|
926
954
|
if ((config.nativeHttp || FastVueMultiTool.PageConfig.getConfig("nativeHttp").toString() === "true") && !justFormData && FastVueNative.isNativeApp() && !FastVueMultiHttp.Simple.hasFileParam(params) && !FastVueMultiHttp.Simple.hasArrayParam(params)) FastVueNative.execute("http", [
|
|
927
955
|
url,
|
|
928
956
|
JSON.stringify(FastVueMultiHttp.Base.convertToObject(params)),
|
|
@@ -933,7 +961,29 @@ let FastVueMultiHttp;
|
|
|
933
961
|
status: 200
|
|
934
962
|
});
|
|
935
963
|
});
|
|
936
|
-
else FastVueMultiHttp.Base.doRequest(method, url, params, headers).then(
|
|
964
|
+
else FastVueMultiHttp.Base.doRequest(method, url, params, headers).then((response) => {
|
|
965
|
+
let doReturn = (jsonStringData) => {
|
|
966
|
+
if (response.headers["short-json"]) response.data = JSON.parse(FastVueMultiHttp.Simple.parseShortResponse(config, jsonStringData));
|
|
967
|
+
else response.data = JSON.parse(jsonStringData);
|
|
968
|
+
requestThen(response);
|
|
969
|
+
};
|
|
970
|
+
let uint8Data = new Uint8Array(response.data);
|
|
971
|
+
if (response.headers["fastchar-compress"] === "obfuscate") {
|
|
972
|
+
const unCompressData = new Uint8Array(uint8Data.length);
|
|
973
|
+
const password = new TextEncoder().encode(config.outCompressPassword);
|
|
974
|
+
const passwordLength = password.length;
|
|
975
|
+
for (let i = 0; i < uint8Data.length; i++) {
|
|
976
|
+
const k = password[i % passwordLength] & 255;
|
|
977
|
+
const posFactor = i & 255;
|
|
978
|
+
unCompressData[i] = (uint8Data[i] ^ k ^ posFactor) & 255;
|
|
979
|
+
}
|
|
980
|
+
const decoder = new ZSTDDecoder();
|
|
981
|
+
decoder.init().then(() => {
|
|
982
|
+
const decompressedArray = decoder.decode(unCompressData);
|
|
983
|
+
doReturn(new TextDecoder("utf-8").decode(decompressedArray));
|
|
984
|
+
}).catch(reject);
|
|
985
|
+
} else doReturn(new TextDecoder("utf-8").decode(uint8Data));
|
|
986
|
+
}).catch(function(error) {
|
|
937
987
|
console.error(error);
|
|
938
988
|
FastVueMultiDB.removeValue(cacheKey);
|
|
939
989
|
delete window[callingCode];
|
|
@@ -941,6 +991,19 @@ let FastVueMultiHttp;
|
|
|
941
991
|
});
|
|
942
992
|
});
|
|
943
993
|
}
|
|
994
|
+
static parseShortResponse(config, responseJsonStringData) {
|
|
995
|
+
if (config.shortJsonDictionary) {
|
|
996
|
+
let newJsonString = responseJsonStringData;
|
|
997
|
+
for (let key in config.shortJsonDictionary) {
|
|
998
|
+
let info = config.shortJsonDictionary[key];
|
|
999
|
+
if (!info.value) continue;
|
|
1000
|
+
newJsonString = newJsonString.replaceAll(`"${info.value}":`, `"${key}":`);
|
|
1001
|
+
newJsonString = newJsonString.replaceAll(`@${info.value}>`, key);
|
|
1002
|
+
}
|
|
1003
|
+
return newJsonString;
|
|
1004
|
+
}
|
|
1005
|
+
return responseJsonStringData;
|
|
1006
|
+
}
|
|
944
1007
|
/**
|
|
945
1008
|
* post请求接口
|
|
946
1009
|
* @param url 接口地址 完整的地址,例如:http://loalhost:8080/user/login
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fast-vue-multi-pages-vite",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.8",
|
|
4
4
|
"author": "janesen",
|
|
5
5
|
"description": "Vite-快速搭建VUE项目工具类的基本库,主要用于多个页面独立生成html",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -45,7 +45,8 @@
|
|
|
45
45
|
"uuid": "^11.1.0",
|
|
46
46
|
"vconsole": "^3.15.1",
|
|
47
47
|
"wavesurfer.js": "^7.9.4",
|
|
48
|
-
"lz-string": "^1.5.0"
|
|
48
|
+
"lz-string": "^1.5.0",
|
|
49
|
+
"zstddec": "^0.2.0"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
51
52
|
"@types/node": "^24.8.1",
|