fast-vue-multi-pages-vite 1.3.6 → 1.3.7
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 +13 -0
- package/dist/index.js +47 -2
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -31,6 +31,18 @@ declare class FastVueMultiSimpleRequestConfig {
|
|
|
31
31
|
* 执行原生客户端http
|
|
32
32
|
*/
|
|
33
33
|
nativeHttp: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* 是否启用压缩
|
|
36
|
+
*/
|
|
37
|
+
outCompress: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* json字典
|
|
40
|
+
*/
|
|
41
|
+
shortJsonDictionary: any;
|
|
42
|
+
/**
|
|
43
|
+
* json字典版本
|
|
44
|
+
*/
|
|
45
|
+
shortJsonVersion: number;
|
|
34
46
|
}
|
|
35
47
|
//#endregion
|
|
36
48
|
//#region src/http/FastVueMultiSimpleJsonResponse.d.ts
|
|
@@ -231,6 +243,7 @@ declare namespace FastVueMultiHttp {
|
|
|
231
243
|
* @param callBack 请求接口回调函数,在使用alwaysBackRequest参数为true时,必须使用回调函数接收
|
|
232
244
|
*/
|
|
233
245
|
static request(method: string, url: string, params?: any, config?: FastVueMultiSimpleRequestConfig, callBack?: (result: FastVueMultiSimpleJsonResponse) => void): Promise<FastVueMultiSimpleJsonResponse>;
|
|
246
|
+
static parseShortResponse(config: FastVueMultiSimpleRequestConfig, responseJsonStringData: string): string;
|
|
234
247
|
/**
|
|
235
248
|
* post请求接口
|
|
236
249
|
* @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 { decompress } from "@structured-world/structured-zstd";
|
|
7
8
|
import store from "store2";
|
|
8
9
|
import cookies from "js-cookie";
|
|
9
10
|
import copy from "copy-to-clipboard";
|
|
@@ -93,6 +94,18 @@ var FastVueMultiSimpleRequestConfig = class {
|
|
|
93
94
|
* 执行原生客户端http
|
|
94
95
|
*/
|
|
95
96
|
nativeHttp = false;
|
|
97
|
+
/**
|
|
98
|
+
* 是否启用压缩
|
|
99
|
+
*/
|
|
100
|
+
outCompress = false;
|
|
101
|
+
/**
|
|
102
|
+
* json字典
|
|
103
|
+
*/
|
|
104
|
+
shortJsonDictionary;
|
|
105
|
+
/**
|
|
106
|
+
* json字典版本
|
|
107
|
+
*/
|
|
108
|
+
shortJsonVersion;
|
|
96
109
|
};
|
|
97
110
|
|
|
98
111
|
//#endregion
|
|
@@ -734,7 +747,13 @@ let FastVueMultiHttp;
|
|
|
734
747
|
let axiosConfig = {
|
|
735
748
|
headers: header,
|
|
736
749
|
method,
|
|
737
|
-
url
|
|
750
|
+
url,
|
|
751
|
+
adapter: [
|
|
752
|
+
"fetch",
|
|
753
|
+
"xhr",
|
|
754
|
+
"http"
|
|
755
|
+
],
|
|
756
|
+
responseType: "arraybuffer"
|
|
738
757
|
};
|
|
739
758
|
if (method === "post") if (_.isString(params)) axiosConfig.paramsSerializer = params;
|
|
740
759
|
else axiosConfig.data = this.convertToFormData(params);
|
|
@@ -923,6 +942,8 @@ let FastVueMultiHttp;
|
|
|
923
942
|
}
|
|
924
943
|
};
|
|
925
944
|
let headers = FastVueMultiHttp.Simple.getFinalHeaders();
|
|
945
|
+
if (config.outCompress) headers["out-compress"] = true;
|
|
946
|
+
if (config.shortJsonVersion > 0) headers["short-json"] = config.shortJsonVersion;
|
|
926
947
|
if ((config.nativeHttp || FastVueMultiTool.PageConfig.getConfig("nativeHttp").toString() === "true") && !justFormData && FastVueNative.isNativeApp() && !FastVueMultiHttp.Simple.hasFileParam(params) && !FastVueMultiHttp.Simple.hasArrayParam(params)) FastVueNative.execute("http", [
|
|
927
948
|
url,
|
|
928
949
|
JSON.stringify(FastVueMultiHttp.Base.convertToObject(params)),
|
|
@@ -933,7 +954,18 @@ let FastVueMultiHttp;
|
|
|
933
954
|
status: 200
|
|
934
955
|
});
|
|
935
956
|
});
|
|
936
|
-
else FastVueMultiHttp.Base.doRequest(method, url, params, headers).then(
|
|
957
|
+
else FastVueMultiHttp.Base.doRequest(method, url, params, headers).then((response) => {
|
|
958
|
+
let doReturn = (jsonStringData) => {
|
|
959
|
+
if (response.headers["short-json"]) response.data = JSON.parse(FastVueMultiHttp.Simple.parseShortResponse(config, jsonStringData));
|
|
960
|
+
else response.data = JSON.parse(jsonStringData);
|
|
961
|
+
requestThen(response);
|
|
962
|
+
};
|
|
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));
|
|
968
|
+
}).catch(function(error) {
|
|
937
969
|
console.error(error);
|
|
938
970
|
FastVueMultiDB.removeValue(cacheKey);
|
|
939
971
|
delete window[callingCode];
|
|
@@ -941,6 +973,19 @@ let FastVueMultiHttp;
|
|
|
941
973
|
});
|
|
942
974
|
});
|
|
943
975
|
}
|
|
976
|
+
static parseShortResponse(config, responseJsonStringData) {
|
|
977
|
+
if (config.shortJsonDictionary) {
|
|
978
|
+
let newJsonString = responseJsonStringData;
|
|
979
|
+
for (let key in config.shortJsonDictionary) {
|
|
980
|
+
let info = config.shortJsonDictionary[key];
|
|
981
|
+
if (!info.value) continue;
|
|
982
|
+
newJsonString = newJsonString.replaceAll(new RegExp(`"${info.value}"`, "g"), `"${key}"`);
|
|
983
|
+
newJsonString = newJsonString.replaceAll(new RegExp(`<${info.value}>`, "g"), key);
|
|
984
|
+
}
|
|
985
|
+
return newJsonString;
|
|
986
|
+
}
|
|
987
|
+
return responseJsonStringData;
|
|
988
|
+
}
|
|
944
989
|
/**
|
|
945
990
|
* post请求接口
|
|
946
991
|
* @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.7",
|
|
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
|
+
"@structured-world/structured-zstd": "^0.0.49"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
51
52
|
"@types/node": "^24.8.1",
|