fast-vue-multi-pages-vite 1.3.13 → 1.3.15

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.js CHANGED
@@ -1,16 +1,17 @@
1
1
  import _ from "lodash";
2
2
  import crypto from "crypto-js";
3
3
  import axios from "axios";
4
+ import * as rax from "retry-axios";
4
5
  import { clear, del, get, keys, set, update } from "idb-keyval";
5
6
  import CryptoJSMD5 from "crypto-js/md5";
6
7
  import * as uuid from "uuid";
7
- import { decompressSync } from "fflate";
8
+ import * as pako from "pako";
9
+ import moment from "moment";
10
+ import lz from "lz-string";
8
11
  import store from "store2";
9
12
  import cookies from "js-cookie";
10
13
  import copy from "copy-to-clipboard";
11
- import moment from "moment";
12
14
  import { animate } from "animejs";
13
- import lz from "lz-string";
14
15
 
15
16
  //#region src/vite/FastViteMultiConfig.ts
16
17
  var FastViteMultiConfig = class {
@@ -628,6 +629,161 @@ var FastVueMultiShortJsonParser = class {
628
629
  }
629
630
  };
630
631
 
632
+ //#endregion
633
+ //#region src/utils/FastVueMultiWindow.ts
634
+ var FastVueMultiWindow = class FastVueMultiWindow {
635
+ /**
636
+ * 添加window的onLoad事件,如果存在onLoad函数名则进行合并
637
+ * @param callBack
638
+ */
639
+ static addOnLoad(callBack) {
640
+ let oldOnload = window.onload;
641
+ if (_.isFunction(oldOnload)) window.onload = function() {
642
+ oldOnload();
643
+ callBack();
644
+ };
645
+ else window.onload = callBack;
646
+ }
647
+ /**
648
+ * 添加window的函数,如果存在相同的函数名则进行合并
649
+ * @param functionName 函数名
650
+ * @param functionBody 函数执行的代码
651
+ */
652
+ static addFunction(functionName, functionBody) {
653
+ let targetFunction = window[functionName];
654
+ if (_.isFunction(targetFunction)) window[functionName] = function() {
655
+ targetFunction.apply(this, arguments);
656
+ functionBody.apply(this, arguments);
657
+ };
658
+ else window[functionName] = functionBody;
659
+ }
660
+ /**
661
+ * 安全的获取窗口宽度,有的手机渲染后document.body.clientWidth 莫明会返回0
662
+ */
663
+ static safeGetClientWidth() {
664
+ return Math.max(document.documentElement.clientWidth, document.body.clientWidth);
665
+ }
666
+ /**
667
+ * 安全的获取窗口高度,有的手机渲染后document.body.clientHeight 莫明会返回0
668
+ */
669
+ static safeGetClientHeight() {
670
+ return Math.max(document.documentElement.clientHeight, document.body.clientHeight);
671
+ }
672
+ /**
673
+ * 获取实际访问的浏览器地址
674
+ */
675
+ static getRealWindowUrls() {
676
+ let urls = [];
677
+ if (window["__LOCATION_HREF"]) urls.push(window["__LOCATION_HREF"]);
678
+ urls.push(window.location.href);
679
+ return urls;
680
+ }
681
+ /**
682
+ * 设置当前window对象里实际的url地址
683
+ * @param url
684
+ */
685
+ static setRealWindowUrl(url) {
686
+ window["__LOCATION_HREF"] = url;
687
+ }
688
+ /**
689
+ * 获取地址栏携带的参数
690
+ * @param paramName 参数名
691
+ */
692
+ static getWindowUrlParam(paramName) {
693
+ let urls = FastVueMultiWindow.getRealWindowUrls();
694
+ for (let url of urls) {
695
+ let value = FastVueMultiHttp.Base.getUrlParam(url, paramName);
696
+ if (value !== null && value !== void 0) return value;
697
+ }
698
+ return null;
699
+ }
700
+ /**
701
+ * 获取地址栏携带的参数对象信息
702
+ */
703
+ static getWindowUrlInfo() {
704
+ let info = {};
705
+ let urls = FastVueMultiWindow.getRealWindowUrls();
706
+ for (let url of urls) {
707
+ let value = FastVueMultiHttp.Base.getUrlParamInfo(url);
708
+ if (value !== null && value !== void 0) for (let valueKey in value) info[valueKey] = value[valueKey];
709
+ }
710
+ return info;
711
+ }
712
+ /**
713
+ * 设置当前页面是否使用了vue-router
714
+ * @param router
715
+ */
716
+ static setVueRouter(router) {
717
+ window["__VUE_ROUTER"] = router;
718
+ }
719
+ /**
720
+ * 判断当前是否使用了vue-router
721
+ */
722
+ static isVueRouter() {
723
+ let val = window["__VUE_ROUTER"];
724
+ if (val === void 0 || val === null || val.length === 0 || val === "null" || val === "undefined") return false;
725
+ return val;
726
+ }
727
+ };
728
+
729
+ //#endregion
730
+ //#region src/utils/FastVueMultiLog.ts
731
+ var FastVueMultiLog = class FastVueMultiLog {
732
+ static _SystemLogKey = "FastVueMultiSystemLog";
733
+ /**
734
+ * 记录日志
735
+ */
736
+ static add(content) {
737
+ return update(FastVueMultiLog._SystemLogKey, (oldValue) => {
738
+ if (!oldValue) {
739
+ let projectConfig = { ...FastViteMultiConfig.getGlobalConfigObj() };
740
+ delete projectConfig.pages;
741
+ oldValue = [];
742
+ oldValue.push(lz.compress(navigator.userAgent));
743
+ oldValue.push(lz.compress(JSON.stringify(projectConfig)));
744
+ }
745
+ oldValue.push(lz.compress(moment().format("YYYY-MM-DD HH:mm:ss") + "\n" + content));
746
+ return oldValue;
747
+ });
748
+ }
749
+ /**
750
+ * 获取所有日志
751
+ */
752
+ static find() {
753
+ return get(FastVueMultiLog._SystemLogKey);
754
+ }
755
+ /**
756
+ * 清空日志
757
+ */
758
+ static clear() {
759
+ return del(FastVueMultiLog._SystemLogKey);
760
+ }
761
+ /**
762
+ * 记录异常日志
763
+ */
764
+ static error(error, ...moreInfo) {
765
+ if (!error) return;
766
+ let contents = [];
767
+ contents.push(JSON.stringify(FastVueMultiWindow.getRealWindowUrls()));
768
+ for (let info of moreInfo) contents.push(info);
769
+ contents.push(FastVueMultiObject.getErrorInfo(error.stack));
770
+ return FastVueMultiLog.add(contents.join("\n"));
771
+ }
772
+ /**
773
+ * 获取日志的blob对象
774
+ */
775
+ static blob() {
776
+ return new Promise((resolve, reject) => {
777
+ FastVueMultiLog.find().then((result) => {
778
+ if (!result) result = [];
779
+ let realData = [];
780
+ for (let item of result) realData.push(lz.decompress(item));
781
+ resolve(new Blob([realData.join("\n\n")], { type: "text/plain;charset=utf-8" }));
782
+ });
783
+ });
784
+ }
785
+ };
786
+
631
787
  //#endregion
632
788
  //#region src/http/FastVueMultiHttp.ts
633
789
  let FastVueMultiHttp;
@@ -780,6 +936,7 @@ let FastVueMultiHttp;
780
936
  "xhr",
781
937
  "http"
782
938
  ],
939
+ timeout: 5e3,
783
940
  responseType: "arraybuffer"
784
941
  };
785
942
  if (method === "post") if (_.isString(params)) axiosConfig.paramsSerializer = params;
@@ -797,6 +954,20 @@ let FastVueMultiHttp;
797
954
  }, function(error) {
798
955
  return Promise.reject(error);
799
956
  });
957
+ _request.defaults.raxConfig = {
958
+ backoffType: "exponential",
959
+ retryDelay: 500,
960
+ retry: 5,
961
+ shouldRetry: (err) => {
962
+ if (!err.response || err.code === "ERR_NAME_NOT_RESOLVED") return true;
963
+ return rax.shouldRetryRequest(err);
964
+ },
965
+ onRetryAttempt: async (err) => {
966
+ const cfg = rax.getConfig(err);
967
+ FastVueMultiLog.error(err, `axios请求重试中!${cfg.currentRetryAttempt}`, url).then(() => {});
968
+ }
969
+ };
970
+ rax.attach(_request);
800
971
  return _request(axiosConfig);
801
972
  }
802
973
  /**
@@ -997,7 +1168,7 @@ let FastVueMultiHttp;
997
1168
  const posFactor = i & 255;
998
1169
  unCompressData[i] = (uint8Data[i] ^ k ^ posFactor) & 255;
999
1170
  }
1000
- const decompressedData = decompressSync(unCompressData);
1171
+ const decompressedData = pako.ungzip(unCompressData);
1001
1172
  doReturn(new TextDecoder("utf-8").decode(decompressedData));
1002
1173
  } else doReturn(new TextDecoder("utf-8").decode(uint8Data));
1003
1174
  }).catch(function(error) {
@@ -1648,103 +1819,6 @@ var FastVueMultiElement = class {
1648
1819
  }
1649
1820
  };
1650
1821
 
1651
- //#endregion
1652
- //#region src/utils/FastVueMultiWindow.ts
1653
- var FastVueMultiWindow = class FastVueMultiWindow {
1654
- /**
1655
- * 添加window的onLoad事件,如果存在onLoad函数名则进行合并
1656
- * @param callBack
1657
- */
1658
- static addOnLoad(callBack) {
1659
- let oldOnload = window.onload;
1660
- if (_.isFunction(oldOnload)) window.onload = function() {
1661
- oldOnload();
1662
- callBack();
1663
- };
1664
- else window.onload = callBack;
1665
- }
1666
- /**
1667
- * 添加window的函数,如果存在相同的函数名则进行合并
1668
- * @param functionName 函数名
1669
- * @param functionBody 函数执行的代码
1670
- */
1671
- static addFunction(functionName, functionBody) {
1672
- let targetFunction = window[functionName];
1673
- if (_.isFunction(targetFunction)) window[functionName] = function() {
1674
- targetFunction.apply(this, arguments);
1675
- functionBody.apply(this, arguments);
1676
- };
1677
- else window[functionName] = functionBody;
1678
- }
1679
- /**
1680
- * 安全的获取窗口宽度,有的手机渲染后document.body.clientWidth 莫明会返回0
1681
- */
1682
- static safeGetClientWidth() {
1683
- return Math.max(document.documentElement.clientWidth, document.body.clientWidth);
1684
- }
1685
- /**
1686
- * 安全的获取窗口高度,有的手机渲染后document.body.clientHeight 莫明会返回0
1687
- */
1688
- static safeGetClientHeight() {
1689
- return Math.max(document.documentElement.clientHeight, document.body.clientHeight);
1690
- }
1691
- /**
1692
- * 获取实际访问的浏览器地址
1693
- */
1694
- static getRealWindowUrls() {
1695
- let urls = [];
1696
- if (window["__LOCATION_HREF"]) urls.push(window["__LOCATION_HREF"]);
1697
- urls.push(window.location.href);
1698
- return urls;
1699
- }
1700
- /**
1701
- * 设置当前window对象里实际的url地址
1702
- * @param url
1703
- */
1704
- static setRealWindowUrl(url) {
1705
- window["__LOCATION_HREF"] = url;
1706
- }
1707
- /**
1708
- * 获取地址栏携带的参数
1709
- * @param paramName 参数名
1710
- */
1711
- static getWindowUrlParam(paramName) {
1712
- let urls = FastVueMultiWindow.getRealWindowUrls();
1713
- for (let url of urls) {
1714
- let value = FastVueMultiHttp.Base.getUrlParam(url, paramName);
1715
- if (value !== null && value !== void 0) return value;
1716
- }
1717
- return null;
1718
- }
1719
- /**
1720
- * 获取地址栏携带的参数对象信息
1721
- */
1722
- static getWindowUrlInfo() {
1723
- let info = {};
1724
- let urls = FastVueMultiWindow.getRealWindowUrls();
1725
- for (let url of urls) {
1726
- let value = FastVueMultiHttp.Base.getUrlParamInfo(url);
1727
- if (value !== null && value !== void 0) for (let valueKey in value) info[valueKey] = value[valueKey];
1728
- }
1729
- return info;
1730
- }
1731
- /**
1732
- * 设置当前页面是否使用了vue-router
1733
- * @param router
1734
- */
1735
- static setVueRouter(router) {
1736
- window["__VUE_ROUTER"] = router;
1737
- }
1738
- /**
1739
- * 判断当前是否使用了vue-router
1740
- */
1741
- static isVueRouter() {
1742
- let val = window["__VUE_ROUTER"];
1743
- if (val === void 0 || val === null || val.length === 0 || val === "null" || val === "undefined") return false;
1744
- return val;
1745
- }
1746
- };
1747
-
1748
1822
  //#endregion
1749
1823
  //#region src/utils/FastVueMultiFile.ts
1750
1824
  var FastVueMultiFile = class FastVueMultiFile {
@@ -2001,64 +2075,6 @@ var ValueAnimateConfig = class ValueAnimateConfig {
2001
2075
  onComplete = function(anim) {};
2002
2076
  };
2003
2077
 
2004
- //#endregion
2005
- //#region src/utils/FastVueMultiLog.ts
2006
- var FastVueMultiLog = class FastVueMultiLog {
2007
- static _SystemLogKey = "FastVueMultiSystemLog";
2008
- /**
2009
- * 记录日志
2010
- */
2011
- static add(content) {
2012
- return update(FastVueMultiLog._SystemLogKey, (oldValue) => {
2013
- if (!oldValue) {
2014
- let projectConfig = { ...FastViteMultiConfig.getGlobalConfigObj() };
2015
- delete projectConfig.pages;
2016
- oldValue = [];
2017
- oldValue.push(lz.compress(navigator.userAgent));
2018
- oldValue.push(lz.compress(JSON.stringify(projectConfig)));
2019
- }
2020
- oldValue.push(lz.compress(moment().format("YYYY-MM-DD HH:mm:ss") + "\n" + content));
2021
- return oldValue;
2022
- });
2023
- }
2024
- /**
2025
- * 获取所有日志
2026
- */
2027
- static find() {
2028
- return get(FastVueMultiLog._SystemLogKey);
2029
- }
2030
- /**
2031
- * 清空日志
2032
- */
2033
- static clear() {
2034
- return del(FastVueMultiLog._SystemLogKey);
2035
- }
2036
- /**
2037
- * 记录异常日志
2038
- */
2039
- static error(error, ...moreInfo) {
2040
- if (!error) return;
2041
- let contents = [];
2042
- contents.push(JSON.stringify(FastVueMultiWindow.getRealWindowUrls()));
2043
- for (let info of moreInfo) contents.push(info);
2044
- contents.push(FastVueMultiObject.getErrorInfo(error.stack));
2045
- return FastVueMultiLog.add(contents.join("\n"));
2046
- }
2047
- /**
2048
- * 获取日志的blob对象
2049
- */
2050
- static blob() {
2051
- return new Promise((resolve, reject) => {
2052
- FastVueMultiLog.find().then((result) => {
2053
- if (!result) result = [];
2054
- let realData = [];
2055
- for (let item of result) realData.push(lz.decompress(item));
2056
- resolve(new Blob([realData.join("\n\n")], { type: "text/plain;charset=utf-8" }));
2057
- });
2058
- });
2059
- }
2060
- };
2061
-
2062
2078
  //#endregion
2063
2079
  //#region src/FastVueMultiTool.ts
2064
2080
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fast-vue-multi-pages-vite",
3
- "version": "1.3.13",
3
+ "version": "1.3.15",
4
4
  "author": "janesen",
5
5
  "description": "Vite-快速搭建VUE项目工具类的基本库,主要用于多个页面独立生成html",
6
6
  "main": "./dist/index.js",
@@ -22,8 +22,8 @@
22
22
  "dependencies": {
23
23
  "@types/lodash": "^4.17.24",
24
24
  "animejs": "^4.0.2",
25
- "axios": "^1.15.2",
26
- "axios-retry": "^4.5.0",
25
+ "axios": "^1.19.0",
26
+ "retry-axios": "^4.0.3",
27
27
  "cac": "^6.7.14",
28
28
  "cheerio": "^1.0.0",
29
29
  "colors": "^1.4.0",
@@ -47,7 +47,7 @@
47
47
  "wavesurfer.js": "^7.9.4",
48
48
  "lz-string": "^1.5.0",
49
49
  "zstddec": "^0.2.0",
50
- "fflate": "^0.8.3"
50
+ "pako": "^3.0.1"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/node": "^24.8.1",
package/vite/index.d.ts CHANGED
@@ -233,7 +233,10 @@ declare class FastViteMultiTool {
233
233
  }: any): void;
234
234
  configResolved(resolvedConfig: any): void;
235
235
  configureServer(server: any): void;
236
- transform(source: string, id: string): any;
236
+ transform(source: string, id: string): {
237
+ code: any;
238
+ map: any;
239
+ };
237
240
  transformIndexHtml: {
238
241
  order: string;
239
242
  handler(html: string, ctx: any): {
package/vite/index.js CHANGED
@@ -915,13 +915,22 @@ var FastViteMultiTool = class FastViteMultiTool {
915
915
  transform(source, id) {
916
916
  source = FastViteTransformText.transform(id, source, option);
917
917
  if (id.includes(".vue") || id.includes("/src/") && id.includes(".js")) source = FastViteTransformResources.transform(source, option);
918
- if (id.includes(".vue")) return FastViteTransformVue.transform(source, option);
918
+ if (id.includes(".vue")) return {
919
+ code: FastViteTransformVue.transform(source, option),
920
+ map: null
921
+ };
919
922
  if (FastViteMultiTool._viteConfig.command === "build") {
920
923
  if (option.safeCodeJsFileName) {
921
- for (let fileName of option.safeCodeJsFileName) if (id.includes(fileName)) return FastJavascriptObfuscator.getObfuscateCode(source);
924
+ for (let fileName of option.safeCodeJsFileName) if (id.includes(fileName)) return {
925
+ code: FastJavascriptObfuscator.getObfuscateCode(source),
926
+ map: null
927
+ };
922
928
  }
923
929
  }
924
- return source;
930
+ return {
931
+ code: source,
932
+ map: null
933
+ };
925
934
  },
926
935
  transformIndexHtml: {
927
936
  order: "pre",