qidian-shared 1.0.68 → 1.0.69
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/_virtual/___vite-browser-external.mjs +7 -0
- package/dist/_virtual/___vite-browser-external.mjs.map +1 -0
- package/dist/_virtual/__vite-browser-external.mjs +5 -0
- package/dist/_virtual/__vite-browser-external.mjs.map +1 -0
- package/dist/_virtual/_commonjs-dynamic-modules.mjs +7 -0
- package/dist/_virtual/_commonjs-dynamic-modules.mjs.map +1 -0
- package/dist/_virtual/_commonjsHelpers.mjs +39 -0
- package/dist/_virtual/_commonjsHelpers.mjs.map +1 -0
- package/dist/_virtual/aes.mjs +5 -0
- package/dist/_virtual/aes.mjs.map +1 -0
- package/dist/_virtual/blowfish.mjs +5 -0
- package/dist/_virtual/blowfish.mjs.map +1 -0
- package/dist/_virtual/cipher-core.mjs +5 -0
- package/dist/_virtual/cipher-core.mjs.map +1 -0
- package/dist/_virtual/core.mjs +5 -0
- package/dist/_virtual/core.mjs.map +1 -0
- package/dist/_virtual/enc-base64.mjs +5 -0
- package/dist/_virtual/enc-base64.mjs.map +1 -0
- package/dist/_virtual/enc-base64url.mjs +5 -0
- package/dist/_virtual/enc-base64url.mjs.map +1 -0
- package/dist/_virtual/enc-utf16.mjs +5 -0
- package/dist/_virtual/enc-utf16.mjs.map +1 -0
- package/dist/_virtual/evpkdf.mjs +5 -0
- package/dist/_virtual/evpkdf.mjs.map +1 -0
- package/dist/_virtual/format-hex.mjs +5 -0
- package/dist/_virtual/format-hex.mjs.map +1 -0
- package/dist/_virtual/hmac.mjs +5 -0
- package/dist/_virtual/hmac.mjs.map +1 -0
- package/dist/_virtual/index.mjs +8 -0
- package/dist/_virtual/index.mjs.map +1 -0
- package/dist/_virtual/index2.mjs +5 -0
- package/dist/_virtual/index2.mjs.map +1 -0
- package/dist/_virtual/lib-typedarrays.mjs +5 -0
- package/dist/_virtual/lib-typedarrays.mjs.map +1 -0
- package/dist/_virtual/md5.mjs +5 -0
- package/dist/_virtual/md5.mjs.map +1 -0
- package/dist/_virtual/mode-cfb.mjs +5 -0
- package/dist/_virtual/mode-cfb.mjs.map +1 -0
- package/dist/_virtual/mode-ctr-gladman.mjs +5 -0
- package/dist/_virtual/mode-ctr-gladman.mjs.map +1 -0
- package/dist/_virtual/mode-ctr.mjs +5 -0
- package/dist/_virtual/mode-ctr.mjs.map +1 -0
- package/dist/_virtual/mode-ecb.mjs +5 -0
- package/dist/_virtual/mode-ecb.mjs.map +1 -0
- package/dist/_virtual/mode-ofb.mjs +5 -0
- package/dist/_virtual/mode-ofb.mjs.map +1 -0
- package/dist/_virtual/pad-ansix923.mjs +5 -0
- package/dist/_virtual/pad-ansix923.mjs.map +1 -0
- package/dist/_virtual/pad-iso10126.mjs +5 -0
- package/dist/_virtual/pad-iso10126.mjs.map +1 -0
- package/dist/_virtual/pad-iso97971.mjs +5 -0
- package/dist/_virtual/pad-iso97971.mjs.map +1 -0
- package/dist/_virtual/pad-nopadding.mjs +5 -0
- package/dist/_virtual/pad-nopadding.mjs.map +1 -0
- package/dist/_virtual/pad-zeropadding.mjs +5 -0
- package/dist/_virtual/pad-zeropadding.mjs.map +1 -0
- package/dist/_virtual/pbkdf2.mjs +5 -0
- package/dist/_virtual/pbkdf2.mjs.map +1 -0
- package/dist/_virtual/rabbit-legacy.mjs +5 -0
- package/dist/_virtual/rabbit-legacy.mjs.map +1 -0
- package/dist/_virtual/rabbit.mjs +5 -0
- package/dist/_virtual/rabbit.mjs.map +1 -0
- package/dist/_virtual/rc4.mjs +5 -0
- package/dist/_virtual/rc4.mjs.map +1 -0
- package/dist/_virtual/ripemd160.mjs +5 -0
- package/dist/_virtual/ripemd160.mjs.map +1 -0
- package/dist/_virtual/sha1.mjs +5 -0
- package/dist/_virtual/sha1.mjs.map +1 -0
- package/dist/_virtual/sha224.mjs +5 -0
- package/dist/_virtual/sha224.mjs.map +1 -0
- package/dist/_virtual/sha256.mjs +5 -0
- package/dist/_virtual/sha256.mjs.map +1 -0
- package/dist/_virtual/sha3.mjs +5 -0
- package/dist/_virtual/sha3.mjs.map +1 -0
- package/dist/_virtual/sha384.mjs +5 -0
- package/dist/_virtual/sha384.mjs.map +1 -0
- package/dist/_virtual/sha512.mjs +5 -0
- package/dist/_virtual/sha512.mjs.map +1 -0
- package/dist/_virtual/tripledes.mjs +5 -0
- package/dist/_virtual/tripledes.mjs.map +1 -0
- package/dist/_virtual/x64-core.mjs +5 -0
- package/dist/_virtual/x64-core.mjs.map +1 -0
- package/dist/directive/index.d.ts +1 -0
- package/dist/directive/resize.d.ts +19 -0
- package/dist/directive/resize.mjs +42 -0
- package/dist/directive/resize.mjs.map +1 -0
- package/dist/hooks/index.d.ts +8 -0
- package/dist/hooks/useActivated.d.ts +3 -0
- package/dist/hooks/useActivated.mjs +17 -0
- package/dist/hooks/useActivated.mjs.map +1 -0
- package/dist/hooks/useAutoFocus.d.ts +3 -0
- package/dist/hooks/useAutoFocus.mjs +20 -0
- package/dist/hooks/useAutoFocus.mjs.map +1 -0
- package/dist/hooks/useCsl.d.ts +13 -0
- package/dist/hooks/useCsl.mjs +43 -0
- package/dist/hooks/useCsl.mjs.map +1 -0
- package/dist/hooks/useDoubleClick.d.ts +7 -0
- package/dist/hooks/useDoubleClick.mjs +41 -0
- package/dist/hooks/useDoubleClick.mjs.map +1 -0
- package/dist/hooks/useProxy.d.ts +1 -0
- package/dist/hooks/useProxy.mjs +12 -0
- package/dist/hooks/useProxy.mjs.map +1 -0
- package/dist/hooks/useService/index.d.ts +3 -0
- package/dist/hooks/useService/loadMore.d.ts +2 -0
- package/dist/hooks/useService/loadMore.mjs +133 -0
- package/dist/hooks/useService/loadMore.mjs.map +1 -0
- package/dist/hooks/useService/pagination.d.ts +2 -0
- package/dist/hooks/useService/pagination.mjs +167 -0
- package/dist/hooks/useService/pagination.mjs.map +1 -0
- package/dist/hooks/useService/types.d.ts +56 -0
- package/dist/hooks/useTimer.d.ts +22 -0
- package/dist/hooks/useTimer.mjs +31 -0
- package/dist/hooks/useTimer.mjs.map +1 -0
- package/dist/hooks/useTplRefsList.d.ts +5 -0
- package/dist/hooks/useTplRefsList.mjs +18 -0
- package/dist/hooks/useTplRefsList.mjs.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.mjs +105 -0
- package/dist/index.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/aes.mjs +163 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/aes.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/blowfish.mjs +1198 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/blowfish.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/cipher-core.mjs +650 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/cipher-core.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/core.mjs +615 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/core.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-base64.mjs +113 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-base64.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-base64url.mjs +124 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-base64url.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf16.mjs +123 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf16.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/evpkdf.mjs +98 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/evpkdf.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/format-hex.mjs +66 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/format-hex.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/hmac.mjs +112 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/hmac.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/index.mjs +56 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/index.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/lib-typedarrays.mjs +50 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/lib-typedarrays.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/md5.mjs +184 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/md5.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-cfb.mjs +58 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-cfb.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ctr-gladman.mjs +81 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ctr-gladman.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ctr.mjs +46 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ctr.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ecb.mjs +37 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ecb.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ofb.mjs +44 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ofb.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-ansix923.mjs +38 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-ansix923.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-iso10126.mjs +34 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-iso10126.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-iso97971.mjs +33 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-iso97971.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-nopadding.mjs +29 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-nopadding.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-zeropadding.mjs +40 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-zeropadding.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pbkdf2.mjs +105 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pbkdf2.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/rabbit-legacy.mjs +135 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/rabbit-legacy.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/rabbit.mjs +138 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/rabbit.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/rc4.mjs +92 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/rc4.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/ripemd160.mjs +476 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/ripemd160.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha1.mjs +96 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha1.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha224.mjs +51 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha224.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha256.mjs +126 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha256.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha3.mjs +208 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha3.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha384.mjs +53 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha384.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha512.mjs +288 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha512.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/tripledes.mjs +790 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/tripledes.mjs.map +1 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/x64-core.mjs +262 -0
- package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/x64-core.mjs.map +1 -0
- package/dist/node_modules/.pnpm/jsencrypt@3.5.4/node_modules/jsencrypt/lib/JSEncrypt.mjs +123 -0
- package/dist/node_modules/.pnpm/jsencrypt@3.5.4/node_modules/jsencrypt/lib/JSEncrypt.mjs.map +1 -0
- package/dist/node_modules/.pnpm/jsencrypt@3.5.4/node_modules/jsencrypt/lib/JSEncryptRSAKey.mjs +182 -0
- package/dist/node_modules/.pnpm/jsencrypt@3.5.4/node_modules/jsencrypt/lib/JSEncryptRSAKey.mjs.map +1 -0
- package/dist/node_modules/.pnpm/jsencrypt@3.5.4/node_modules/jsencrypt/lib/index.mjs +6 -0
- package/dist/node_modules/.pnpm/jsencrypt@3.5.4/node_modules/jsencrypt/lib/index.mjs.map +1 -0
- package/dist/node_modules/.pnpm/jsencrypt@3.5.4/node_modules/jsencrypt/lib/lib/asn1js/asn1.mjs +541 -0
- package/dist/node_modules/.pnpm/jsencrypt@3.5.4/node_modules/jsencrypt/lib/lib/asn1js/asn1.mjs.map +1 -0
- package/dist/node_modules/.pnpm/jsencrypt@3.5.4/node_modules/jsencrypt/lib/lib/asn1js/base64.mjs +75 -0
- package/dist/node_modules/.pnpm/jsencrypt@3.5.4/node_modules/jsencrypt/lib/lib/asn1js/base64.mjs.map +1 -0
- package/dist/node_modules/.pnpm/jsencrypt@3.5.4/node_modules/jsencrypt/lib/lib/asn1js/hex.mjs +53 -0
- package/dist/node_modules/.pnpm/jsencrypt@3.5.4/node_modules/jsencrypt/lib/lib/asn1js/hex.mjs.map +1 -0
- package/dist/node_modules/.pnpm/jsencrypt@3.5.4/node_modules/jsencrypt/lib/lib/asn1js/int10.mjs +75 -0
- package/dist/node_modules/.pnpm/jsencrypt@3.5.4/node_modules/jsencrypt/lib/lib/asn1js/int10.mjs.map +1 -0
- package/dist/node_modules/.pnpm/jsencrypt@3.5.4/node_modules/jsencrypt/lib/lib/jsbn/base64.mjs +65 -0
- package/dist/node_modules/.pnpm/jsencrypt@3.5.4/node_modules/jsencrypt/lib/lib/jsbn/base64.mjs.map +1 -0
- package/dist/node_modules/.pnpm/jsencrypt@3.5.4/node_modules/jsencrypt/lib/lib/jsbn/jsbn.mjs +1487 -0
- package/dist/node_modules/.pnpm/jsencrypt@3.5.4/node_modules/jsencrypt/lib/lib/jsbn/jsbn.mjs.map +1 -0
- package/dist/node_modules/.pnpm/jsencrypt@3.5.4/node_modules/jsencrypt/lib/lib/jsbn/prng4.mjs +47 -0
- package/dist/node_modules/.pnpm/jsencrypt@3.5.4/node_modules/jsencrypt/lib/lib/jsbn/prng4.mjs.map +1 -0
- package/dist/node_modules/.pnpm/jsencrypt@3.5.4/node_modules/jsencrypt/lib/lib/jsbn/rng.mjs +73 -0
- package/dist/node_modules/.pnpm/jsencrypt@3.5.4/node_modules/jsencrypt/lib/lib/jsbn/rng.mjs.map +1 -0
- package/dist/node_modules/.pnpm/jsencrypt@3.5.4/node_modules/jsencrypt/lib/lib/jsbn/rsa.mjs +357 -0
- package/dist/node_modules/.pnpm/jsencrypt@3.5.4/node_modules/jsencrypt/lib/lib/jsbn/rsa.mjs.map +1 -0
- package/dist/node_modules/.pnpm/jsencrypt@3.5.4/node_modules/jsencrypt/lib/lib/jsbn/sha256.mjs +104 -0
- package/dist/node_modules/.pnpm/jsencrypt@3.5.4/node_modules/jsencrypt/lib/lib/jsbn/sha256.mjs.map +1 -0
- package/dist/node_modules/.pnpm/jsencrypt@3.5.4/node_modules/jsencrypt/lib/lib/jsbn/util.mjs +60 -0
- package/dist/node_modules/.pnpm/jsencrypt@3.5.4/node_modules/jsencrypt/lib/lib/jsbn/util.mjs.map +1 -0
- package/dist/node_modules/.pnpm/jsencrypt@3.5.4/node_modules/jsencrypt/lib/lib/jsrsasign/asn1-1.0.mjs +746 -0
- package/dist/node_modules/.pnpm/jsencrypt@3.5.4/node_modules/jsencrypt/lib/lib/jsrsasign/asn1-1.0.mjs.map +1 -0
- package/dist/node_modules/.pnpm/jsonrepair@3.13.1/node_modules/jsonrepair/lib/esm/regular/jsonrepair.mjs +567 -0
- package/dist/node_modules/.pnpm/jsonrepair@3.13.1/node_modules/jsonrepair/lib/esm/regular/jsonrepair.mjs.map +1 -0
- package/dist/node_modules/.pnpm/jsonrepair@3.13.1/node_modules/jsonrepair/lib/esm/utils/JSONRepairError.mjs +10 -0
- package/dist/node_modules/.pnpm/jsonrepair@3.13.1/node_modules/jsonrepair/lib/esm/utils/JSONRepairError.mjs.map +1 -0
- package/dist/node_modules/.pnpm/jsonrepair@3.13.1/node_modules/jsonrepair/lib/esm/utils/stringUtils.mjs +114 -0
- package/dist/node_modules/.pnpm/jsonrepair@3.13.1/node_modules/jsonrepair/lib/esm/utils/stringUtils.mjs.map +1 -0
- package/dist/node_modules/.pnpm/vue-request@2.0.4_vue@3.5.26_typescript@5.9.3_/node_modules/vue-request/dist/index.es.mjs +1183 -0
- package/dist/node_modules/.pnpm/vue-request@2.0.4_vue@3.5.26_typescript@5.9.3_/node_modules/vue-request/dist/index.es.mjs.map +1 -0
- package/dist/utils/calc.d.ts +5 -0
- package/dist/utils/calc.mjs +54 -0
- package/dist/utils/calc.mjs.map +1 -0
- package/dist/utils/common.d.ts +48 -0
- package/dist/utils/common.mjs +125 -0
- package/dist/utils/common.mjs.map +1 -0
- package/dist/utils/conversion.d.ts +12 -0
- package/dist/utils/conversion.mjs +59 -0
- package/dist/utils/conversion.mjs.map +1 -0
- package/dist/utils/crypto.d.ts +7 -0
- package/dist/utils/crypto.mjs +39 -0
- package/dist/utils/crypto.mjs.map +1 -0
- package/dist/utils/dom.d.ts +4 -0
- package/dist/utils/dom.mjs +29 -0
- package/dist/utils/dom.mjs.map +1 -0
- package/dist/utils/download.d.ts +1 -0
- package/dist/utils/download.mjs +20 -0
- package/dist/utils/download.mjs.map +1 -0
- package/dist/utils/file.d.ts +7 -0
- package/dist/utils/file.mjs +48 -0
- package/dist/utils/file.mjs.map +1 -0
- package/dist/utils/glob.d.ts +1 -0
- package/dist/utils/glob.mjs +16 -0
- package/dist/utils/glob.mjs.map +1 -0
- package/dist/utils/index.d.ts +15 -0
- package/dist/utils/jsencrypt.d.ts +2 -0
- package/dist/utils/jsencrypt.mjs +16 -0
- package/dist/utils/jsencrypt.mjs.map +1 -0
- package/dist/utils/json.d.ts +3 -0
- package/dist/utils/json.mjs +24 -0
- package/dist/utils/json.mjs.map +1 -0
- package/dist/utils/platformInfo.d.ts +16 -0
- package/dist/utils/promise.d.ts +7 -0
- package/dist/utils/promise.mjs +38 -0
- package/dist/utils/promise.mjs.map +1 -0
- package/dist/utils/str.d.ts +8 -0
- package/dist/utils/str.mjs +78 -0
- package/dist/utils/str.mjs.map +1 -0
- package/dist/utils/type.d.ts +6 -0
- package/dist/utils/type.mjs +21 -0
- package/dist/utils/type.mjs.map +1 -0
- package/dist/utils/url.d.ts +4 -0
- package/dist/utils/url.mjs +75 -0
- package/dist/utils/url.mjs.map +1 -0
- package/dist/utils/validator.d.ts +14 -0
- package/dist/utils/validator.mjs +51 -0
- package/dist/utils/validator.mjs.map +1 -0
- package/dist/utils/vitePlugin.d.ts +8 -0
- package/dist/vite/qidian-vite-plugin.cjs.js +68 -0
- package/dist/vite/qidian-vite-plugin.cjs.js.map +1 -0
- package/dist/vite/qidian-vite-plugin.es.js +68 -0
- package/dist/vite/qidian-vite-plugin.es.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,1183 @@
|
|
|
1
|
+
import { shallowRef, computed, ref, inject, onUnmounted, watchEffect, watch, isRef } from "vue";
|
|
2
|
+
const GLOBAL_OPTIONS = {};
|
|
3
|
+
const GLOBAL_OPTIONS_PROVIDE_KEY = /* @__PURE__ */ Symbol("GLOBAL_OPTIONS_PROVIDE_KEY");
|
|
4
|
+
const getGlobalOptions = () => {
|
|
5
|
+
return GLOBAL_OPTIONS;
|
|
6
|
+
};
|
|
7
|
+
const definePlugin = (options) => {
|
|
8
|
+
return options;
|
|
9
|
+
};
|
|
10
|
+
const objectToString = Object.prototype.toString;
|
|
11
|
+
const toTypeString = (val) => objectToString.call(val);
|
|
12
|
+
const isPlainObject = (val) => toTypeString(val) === "[object Object]";
|
|
13
|
+
const isArray = (val) => Array.isArray(val);
|
|
14
|
+
const isObject = (val) => val !== null && typeof val === "object";
|
|
15
|
+
const isFunction = (fn) => fn instanceof Function;
|
|
16
|
+
const isNil = (val) => val === null || val === void 0;
|
|
17
|
+
const isServer = typeof window === "undefined";
|
|
18
|
+
const isDocumentVisibility = () => {
|
|
19
|
+
var _window$document;
|
|
20
|
+
if (isServer || isNil((_window$document = window.document) === null || _window$document === void 0 ? void 0 : _window$document.visibilityState)) return true;
|
|
21
|
+
return window.document.visibilityState === "visible";
|
|
22
|
+
};
|
|
23
|
+
const isOnline = () => {
|
|
24
|
+
var _ref, _window$navigator;
|
|
25
|
+
return (_ref = !isServer && ((_window$navigator = window.navigator) === null || _window$navigator === void 0 ? void 0 : _window$navigator.onLine)) !== null && _ref !== void 0 ? _ref : true;
|
|
26
|
+
};
|
|
27
|
+
const resolvedPromise = () => new Promise(() => {
|
|
28
|
+
});
|
|
29
|
+
const get = function(source, path) {
|
|
30
|
+
let defaultValue = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : void 0;
|
|
31
|
+
const paths = path.replace(/\[(\d+)\]/g, ".$1").split(".");
|
|
32
|
+
let result = source;
|
|
33
|
+
for (const p of paths) {
|
|
34
|
+
result = Object(result)[p];
|
|
35
|
+
if (result === void 0) {
|
|
36
|
+
return defaultValue;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
function omit(object, keys) {
|
|
42
|
+
const result = Object.assign({}, object);
|
|
43
|
+
for (const key of keys) {
|
|
44
|
+
delete result[key];
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
const warning = function(message) {
|
|
49
|
+
let throwError = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
50
|
+
const msg = `Warning: [vue-request] ${message}`;
|
|
51
|
+
if (throwError) {
|
|
52
|
+
return new Error(msg);
|
|
53
|
+
} else {
|
|
54
|
+
console.error(msg);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const refToRaw = (value) => {
|
|
58
|
+
return isRef(value) ? value.value : value;
|
|
59
|
+
};
|
|
60
|
+
const shallowCopy = (value) => {
|
|
61
|
+
if (isObject(value)) {
|
|
62
|
+
return Object.assign(isArray(value) ? [] : {}, value);
|
|
63
|
+
} else {
|
|
64
|
+
return value;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const CACHE_MAP = /* @__PURE__ */ new Map();
|
|
68
|
+
const getCache = (cacheKey) => {
|
|
69
|
+
if (isNil(cacheKey)) return;
|
|
70
|
+
const data = CACHE_MAP.get(cacheKey);
|
|
71
|
+
return data;
|
|
72
|
+
};
|
|
73
|
+
const setCache = (cacheKey, cacheTime, data) => {
|
|
74
|
+
const oldCache = CACHE_MAP.get(cacheKey);
|
|
75
|
+
if (oldCache !== null && oldCache !== void 0 && oldCache.timer) {
|
|
76
|
+
clearTimeout(oldCache.timer);
|
|
77
|
+
}
|
|
78
|
+
const timer = setTimeout(() => CACHE_MAP.delete(cacheKey), cacheTime);
|
|
79
|
+
CACHE_MAP.set(cacheKey, {
|
|
80
|
+
...data,
|
|
81
|
+
timer
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
function debounce(func, wait, options) {
|
|
85
|
+
let lastArgs, lastThis, maxWait, result, timerId, lastCallTime;
|
|
86
|
+
let lastInvokeTime = 0;
|
|
87
|
+
let leading = false;
|
|
88
|
+
let maxing = false;
|
|
89
|
+
let trailing = true;
|
|
90
|
+
const useRAF = !wait && wait !== 0 && typeof window.requestAnimationFrame === "function";
|
|
91
|
+
if (typeof func !== "function") {
|
|
92
|
+
throw new TypeError("Expected a function");
|
|
93
|
+
}
|
|
94
|
+
wait = +wait || 0;
|
|
95
|
+
if (isObject(options)) {
|
|
96
|
+
leading = !!options.leading;
|
|
97
|
+
maxing = "maxWait" in options;
|
|
98
|
+
maxWait = maxing ? Math.max(+options.maxWait || 0, wait) : maxWait;
|
|
99
|
+
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
100
|
+
}
|
|
101
|
+
function invokeFunc(time) {
|
|
102
|
+
const args = lastArgs;
|
|
103
|
+
const thisArg = lastThis;
|
|
104
|
+
lastArgs = lastThis = void 0;
|
|
105
|
+
lastInvokeTime = time;
|
|
106
|
+
result = func.apply(thisArg, args);
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
109
|
+
function startTimer(pendingFunc, wait2) {
|
|
110
|
+
if (useRAF) {
|
|
111
|
+
window.cancelAnimationFrame(timerId);
|
|
112
|
+
return window.requestAnimationFrame(pendingFunc);
|
|
113
|
+
}
|
|
114
|
+
return setTimeout(pendingFunc, wait2);
|
|
115
|
+
}
|
|
116
|
+
function cancelTimer(id) {
|
|
117
|
+
if (useRAF) {
|
|
118
|
+
return window.cancelAnimationFrame(id);
|
|
119
|
+
}
|
|
120
|
+
clearTimeout(id);
|
|
121
|
+
}
|
|
122
|
+
function leadingEdge(time) {
|
|
123
|
+
lastInvokeTime = time;
|
|
124
|
+
timerId = startTimer(timerExpired, wait);
|
|
125
|
+
return leading ? invokeFunc(time) : result;
|
|
126
|
+
}
|
|
127
|
+
function remainingWait(time) {
|
|
128
|
+
const timeSinceLastCall = time - lastCallTime;
|
|
129
|
+
const timeSinceLastInvoke = time - lastInvokeTime;
|
|
130
|
+
const timeWaiting = wait - timeSinceLastCall;
|
|
131
|
+
return maxing ? Math.min(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
|
|
132
|
+
}
|
|
133
|
+
function shouldInvoke(time) {
|
|
134
|
+
const timeSinceLastCall = time - lastCallTime;
|
|
135
|
+
const timeSinceLastInvoke = time - lastInvokeTime;
|
|
136
|
+
return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
|
|
137
|
+
}
|
|
138
|
+
function timerExpired() {
|
|
139
|
+
const time = Date.now();
|
|
140
|
+
if (shouldInvoke(time)) {
|
|
141
|
+
return trailingEdge(time);
|
|
142
|
+
}
|
|
143
|
+
timerId = startTimer(timerExpired, remainingWait(time));
|
|
144
|
+
}
|
|
145
|
+
function trailingEdge(time) {
|
|
146
|
+
timerId = void 0;
|
|
147
|
+
if (trailing && lastArgs) {
|
|
148
|
+
return invokeFunc(time);
|
|
149
|
+
}
|
|
150
|
+
lastArgs = lastThis = void 0;
|
|
151
|
+
return result;
|
|
152
|
+
}
|
|
153
|
+
function cancel() {
|
|
154
|
+
if (timerId !== void 0) {
|
|
155
|
+
cancelTimer(timerId);
|
|
156
|
+
}
|
|
157
|
+
lastInvokeTime = 0;
|
|
158
|
+
lastArgs = lastCallTime = lastThis = timerId = void 0;
|
|
159
|
+
}
|
|
160
|
+
function flush() {
|
|
161
|
+
return timerId === void 0 ? result : trailingEdge(Date.now());
|
|
162
|
+
}
|
|
163
|
+
function pending() {
|
|
164
|
+
return timerId !== void 0;
|
|
165
|
+
}
|
|
166
|
+
function debounced() {
|
|
167
|
+
const time = Date.now();
|
|
168
|
+
const isInvoking = shouldInvoke(time);
|
|
169
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
170
|
+
args[_key] = arguments[_key];
|
|
171
|
+
}
|
|
172
|
+
lastArgs = args;
|
|
173
|
+
lastThis = this;
|
|
174
|
+
lastCallTime = time;
|
|
175
|
+
if (isInvoking) {
|
|
176
|
+
if (timerId === void 0) {
|
|
177
|
+
return leadingEdge(lastCallTime);
|
|
178
|
+
}
|
|
179
|
+
if (maxing) {
|
|
180
|
+
timerId = startTimer(timerExpired, wait);
|
|
181
|
+
return invokeFunc(lastCallTime);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (timerId === void 0) {
|
|
185
|
+
timerId = startTimer(timerExpired, wait);
|
|
186
|
+
}
|
|
187
|
+
return result;
|
|
188
|
+
}
|
|
189
|
+
debounced.cancel = cancel;
|
|
190
|
+
debounced.flush = flush;
|
|
191
|
+
debounced.pending = pending;
|
|
192
|
+
return debounced;
|
|
193
|
+
}
|
|
194
|
+
function baseMerge(origin, target) {
|
|
195
|
+
for (const key in target) {
|
|
196
|
+
if (target[key] === void 0) {
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
if (!isObject(target[key]) || // `target[key]` is not an object
|
|
200
|
+
!isObject(origin[key]) || // `target[key]` is not an object
|
|
201
|
+
!(key in origin)) {
|
|
202
|
+
origin[key] = target[key];
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
if (isPlainObject(target[key]) || isArray(target[key])) {
|
|
206
|
+
baseMerge(origin[key], target[key]);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
function merge(origin) {
|
|
211
|
+
const result = Object.assign({}, origin);
|
|
212
|
+
for (var _len = arguments.length, others = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
213
|
+
others[_key - 1] = arguments[_key];
|
|
214
|
+
}
|
|
215
|
+
if (!others.length) return result;
|
|
216
|
+
for (const item of others) {
|
|
217
|
+
baseMerge(result, item);
|
|
218
|
+
}
|
|
219
|
+
return result;
|
|
220
|
+
}
|
|
221
|
+
function throttle(func, wait, options) {
|
|
222
|
+
let leading = true;
|
|
223
|
+
let trailing = true;
|
|
224
|
+
if (typeof func !== "function") {
|
|
225
|
+
throw new TypeError("Expected a function");
|
|
226
|
+
}
|
|
227
|
+
if (isObject(options)) {
|
|
228
|
+
leading = "leading" in options ? !!options.leading : leading;
|
|
229
|
+
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
230
|
+
}
|
|
231
|
+
return debounce(func, wait, {
|
|
232
|
+
leading,
|
|
233
|
+
trailing,
|
|
234
|
+
maxWait: wait
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
var useDebouncePlugin = definePlugin((queryInstance, _ref) => {
|
|
238
|
+
let {
|
|
239
|
+
debounceInterval,
|
|
240
|
+
debounceOptions,
|
|
241
|
+
manual
|
|
242
|
+
} = _ref;
|
|
243
|
+
const initialAutoRunFlag = ref(false);
|
|
244
|
+
const debouncedRun = ref();
|
|
245
|
+
const debounceOptionsRef = computed(() => debounceOptions);
|
|
246
|
+
const debounceIntervalRef = computed(() => refToRaw(debounceInterval));
|
|
247
|
+
const originRunRef = ref(queryInstance.context.runAsync);
|
|
248
|
+
if (!manual) {
|
|
249
|
+
initialAutoRunFlag.value = true;
|
|
250
|
+
}
|
|
251
|
+
watchEffect((onInvalidate) => {
|
|
252
|
+
if (isNil(debounceIntervalRef.value)) return;
|
|
253
|
+
debouncedRun.value = debounce((callback) => callback(), debounceIntervalRef.value, debounceOptionsRef.value);
|
|
254
|
+
queryInstance.context.runAsync = function() {
|
|
255
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
256
|
+
args[_key] = arguments[_key];
|
|
257
|
+
}
|
|
258
|
+
return new Promise((resolve, reject) => {
|
|
259
|
+
if (initialAutoRunFlag.value) {
|
|
260
|
+
initialAutoRunFlag.value = false;
|
|
261
|
+
originRunRef.value(...args).then(resolve).catch(reject);
|
|
262
|
+
} else {
|
|
263
|
+
debouncedRun.value(() => {
|
|
264
|
+
originRunRef.value(...args).then(resolve).catch(reject);
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
};
|
|
269
|
+
onInvalidate(() => {
|
|
270
|
+
var _debouncedRun$value;
|
|
271
|
+
(_debouncedRun$value = debouncedRun.value) === null || _debouncedRun$value === void 0 ? void 0 : _debouncedRun$value.cancel();
|
|
272
|
+
queryInstance.context.runAsync = originRunRef.value;
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
return {
|
|
276
|
+
onCancel() {
|
|
277
|
+
var _debouncedRun$value2;
|
|
278
|
+
(_debouncedRun$value2 = debouncedRun.value) === null || _debouncedRun$value2 === void 0 ? void 0 : _debouncedRun$value2.cancel();
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
});
|
|
282
|
+
var useErrorRetryPlugin = definePlugin((queryInstance, _ref) => {
|
|
283
|
+
let {
|
|
284
|
+
errorRetryCount = 0,
|
|
285
|
+
errorRetryInterval = 0
|
|
286
|
+
} = _ref;
|
|
287
|
+
const retryTimer = ref();
|
|
288
|
+
const retriedCount = ref(0);
|
|
289
|
+
const errorRetryCountRef = computed(() => refToRaw(errorRetryCount));
|
|
290
|
+
const errorRetryIntervalRef = computed(() => refToRaw(errorRetryInterval));
|
|
291
|
+
let isRetrying = false;
|
|
292
|
+
const resetRetriedCount = () => {
|
|
293
|
+
retriedCount.value = 0;
|
|
294
|
+
};
|
|
295
|
+
const actualErrorRetryInterval = computed(() => {
|
|
296
|
+
if (errorRetryIntervalRef.value) return errorRetryIntervalRef.value;
|
|
297
|
+
const baseTime = 1e3;
|
|
298
|
+
const minCoefficient = 1;
|
|
299
|
+
const maxCoefficient = 9;
|
|
300
|
+
const coefficient = Math.floor(Math.random() * 2 ** Math.min(retriedCount.value, maxCoefficient) + minCoefficient);
|
|
301
|
+
return baseTime * coefficient;
|
|
302
|
+
});
|
|
303
|
+
const errorRetryHooks = () => {
|
|
304
|
+
let timerId;
|
|
305
|
+
const isInfiniteRetry = errorRetryCountRef.value === -1;
|
|
306
|
+
const hasRetryCount = retriedCount.value < errorRetryCountRef.value;
|
|
307
|
+
if (isInfiniteRetry || hasRetryCount) {
|
|
308
|
+
if (!isInfiniteRetry) retriedCount.value += 1;
|
|
309
|
+
timerId = setTimeout(() => {
|
|
310
|
+
isRetrying = true;
|
|
311
|
+
queryInstance.context.refresh();
|
|
312
|
+
}, actualErrorRetryInterval.value);
|
|
313
|
+
}
|
|
314
|
+
return () => timerId && clearTimeout(timerId);
|
|
315
|
+
};
|
|
316
|
+
const clearTimer = () => {
|
|
317
|
+
if (retryTimer.value) {
|
|
318
|
+
retryTimer.value();
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
return {
|
|
322
|
+
onBefore() {
|
|
323
|
+
if (!isRetrying) {
|
|
324
|
+
resetRetriedCount();
|
|
325
|
+
}
|
|
326
|
+
isRetrying = false;
|
|
327
|
+
clearTimer();
|
|
328
|
+
},
|
|
329
|
+
onSuccess() {
|
|
330
|
+
resetRetriedCount();
|
|
331
|
+
},
|
|
332
|
+
onError() {
|
|
333
|
+
retryTimer.value = errorRetryHooks();
|
|
334
|
+
},
|
|
335
|
+
onCancel() {
|
|
336
|
+
resetRetriedCount();
|
|
337
|
+
clearTimer();
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
});
|
|
341
|
+
var useReadyPlugin = definePlugin((queryInstance, _ref) => {
|
|
342
|
+
let {
|
|
343
|
+
ready = ref(true),
|
|
344
|
+
manual,
|
|
345
|
+
defaultParams = []
|
|
346
|
+
} = _ref;
|
|
347
|
+
watch(ready, (val) => {
|
|
348
|
+
if (!manual && val) {
|
|
349
|
+
queryInstance.context.run(...defaultParams);
|
|
350
|
+
}
|
|
351
|
+
}, {
|
|
352
|
+
flush: "sync"
|
|
353
|
+
});
|
|
354
|
+
return {
|
|
355
|
+
onBefore() {
|
|
356
|
+
const readyFlag = isFunction(ready) ? ready() : ready.value;
|
|
357
|
+
if (!readyFlag) {
|
|
358
|
+
queryInstance.loading.value = false;
|
|
359
|
+
return {
|
|
360
|
+
isBreak: true
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
});
|
|
366
|
+
var useRefreshDepsPlugin = definePlugin((queryInstance, _ref) => {
|
|
367
|
+
let {
|
|
368
|
+
refreshDeps,
|
|
369
|
+
refreshDepsAction,
|
|
370
|
+
manual
|
|
371
|
+
} = _ref;
|
|
372
|
+
if (refreshDeps === void 0 || isArray(refreshDeps) && refreshDeps.length === 0) return {};
|
|
373
|
+
const deps = isArray(refreshDeps) ? refreshDeps : [refreshDeps];
|
|
374
|
+
watch(deps, () => {
|
|
375
|
+
if (refreshDepsAction) {
|
|
376
|
+
refreshDepsAction();
|
|
377
|
+
} else {
|
|
378
|
+
!manual && queryInstance.context.refresh();
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
return {};
|
|
382
|
+
});
|
|
383
|
+
var useThrottlePlugin = definePlugin((queryInstance, _ref) => {
|
|
384
|
+
let {
|
|
385
|
+
throttleInterval,
|
|
386
|
+
throttleOptions
|
|
387
|
+
} = _ref;
|
|
388
|
+
const throttledRun = ref();
|
|
389
|
+
const throttleIntervalRef = computed(() => refToRaw(throttleInterval));
|
|
390
|
+
const throttleOptionsRef = computed(() => throttleOptions);
|
|
391
|
+
const originRunRef = ref(queryInstance.context.runAsync);
|
|
392
|
+
watchEffect((onInvalidate) => {
|
|
393
|
+
if (isNil(throttleInterval)) return {};
|
|
394
|
+
throttledRun.value = throttle((callback) => callback(), throttleIntervalRef.value, throttleOptionsRef.value);
|
|
395
|
+
queryInstance.context.runAsync = function() {
|
|
396
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
397
|
+
args[_key] = arguments[_key];
|
|
398
|
+
}
|
|
399
|
+
return new Promise((resolve, reject) => {
|
|
400
|
+
throttledRun.value(() => {
|
|
401
|
+
originRunRef.value(...args).then(resolve).catch(reject);
|
|
402
|
+
});
|
|
403
|
+
});
|
|
404
|
+
};
|
|
405
|
+
onInvalidate(() => {
|
|
406
|
+
var _throttledRun$value;
|
|
407
|
+
(_throttledRun$value = throttledRun.value) === null || _throttledRun$value === void 0 ? void 0 : _throttledRun$value.cancel();
|
|
408
|
+
queryInstance.context.runAsync = originRunRef.value;
|
|
409
|
+
});
|
|
410
|
+
});
|
|
411
|
+
return {
|
|
412
|
+
onCancel() {
|
|
413
|
+
var _throttledRun$value2;
|
|
414
|
+
(_throttledRun$value2 = throttledRun.value) === null || _throttledRun$value2 === void 0 ? void 0 : _throttledRun$value2.cancel();
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
});
|
|
418
|
+
const setStateBind = (oldState, publicCb) => {
|
|
419
|
+
return (newState) => {
|
|
420
|
+
Object.keys(newState).forEach((key) => {
|
|
421
|
+
oldState[key].value = newState[key];
|
|
422
|
+
});
|
|
423
|
+
publicCb.forEach((fun) => fun(oldState));
|
|
424
|
+
};
|
|
425
|
+
};
|
|
426
|
+
const composeMiddleware = (middleArray, hook) => {
|
|
427
|
+
return () => {
|
|
428
|
+
let next = hook;
|
|
429
|
+
for (let i = middleArray.length; i-- > 0; ) {
|
|
430
|
+
next = middleArray[i](next);
|
|
431
|
+
}
|
|
432
|
+
return next();
|
|
433
|
+
};
|
|
434
|
+
};
|
|
435
|
+
const createQuery = (service, config, initialState) => {
|
|
436
|
+
var _initialState$loading, _initialState$data;
|
|
437
|
+
const {
|
|
438
|
+
initialData,
|
|
439
|
+
onSuccess,
|
|
440
|
+
onError,
|
|
441
|
+
onBefore,
|
|
442
|
+
onAfter
|
|
443
|
+
} = config;
|
|
444
|
+
const loading = ref((_initialState$loading = void 0) !== null && _initialState$loading !== void 0 ? _initialState$loading : false);
|
|
445
|
+
const data = shallowRef((_initialState$data = void 0) !== null && _initialState$data !== void 0 ? _initialState$data : initialData);
|
|
446
|
+
const error = shallowRef(void 0);
|
|
447
|
+
const params = ref(void 0);
|
|
448
|
+
const plugins = ref([]);
|
|
449
|
+
const status = shallowRef("pending");
|
|
450
|
+
const context = {};
|
|
451
|
+
const setState = setStateBind({
|
|
452
|
+
status,
|
|
453
|
+
loading,
|
|
454
|
+
data,
|
|
455
|
+
error,
|
|
456
|
+
params
|
|
457
|
+
}, []);
|
|
458
|
+
const emit = function(event) {
|
|
459
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
460
|
+
args[_key - 1] = arguments[_key];
|
|
461
|
+
}
|
|
462
|
+
if (event === "onQuery") {
|
|
463
|
+
const queryFn = plugins.value.map((i) => i.onQuery).filter(Boolean);
|
|
464
|
+
return {
|
|
465
|
+
servicePromise: composeMiddleware(queryFn, args[0])()
|
|
466
|
+
};
|
|
467
|
+
} else {
|
|
468
|
+
const res = plugins.value.map((i) => {
|
|
469
|
+
var _i$event;
|
|
470
|
+
return (_i$event = i[event]) === null || _i$event === void 0 ? void 0 : _i$event.call(i, ...args);
|
|
471
|
+
});
|
|
472
|
+
return Object.assign({}, ...res);
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
const count = ref(0);
|
|
476
|
+
context.runAsync = async function() {
|
|
477
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
478
|
+
args[_key2] = arguments[_key2];
|
|
479
|
+
}
|
|
480
|
+
setState({
|
|
481
|
+
loading: true,
|
|
482
|
+
params: args,
|
|
483
|
+
status: "pending"
|
|
484
|
+
});
|
|
485
|
+
count.value += 1;
|
|
486
|
+
const currentCount = count.value;
|
|
487
|
+
const {
|
|
488
|
+
isBreak,
|
|
489
|
+
breakResult = resolvedPromise()
|
|
490
|
+
} = emit("onBefore", args);
|
|
491
|
+
if (isBreak) {
|
|
492
|
+
setState({
|
|
493
|
+
status: "settled"
|
|
494
|
+
});
|
|
495
|
+
return breakResult;
|
|
496
|
+
}
|
|
497
|
+
onBefore === null || onBefore === void 0 ? void 0 : onBefore(args);
|
|
498
|
+
try {
|
|
499
|
+
const serviceWrapper = () => new Promise((resolve) => resolve(service(...params.value)));
|
|
500
|
+
let {
|
|
501
|
+
servicePromise
|
|
502
|
+
} = emit("onQuery", serviceWrapper);
|
|
503
|
+
if (!servicePromise) {
|
|
504
|
+
servicePromise = serviceWrapper();
|
|
505
|
+
}
|
|
506
|
+
const res = await servicePromise;
|
|
507
|
+
if (currentCount !== count.value) return resolvedPromise();
|
|
508
|
+
setState({
|
|
509
|
+
data: res,
|
|
510
|
+
loading: false,
|
|
511
|
+
error: void 0,
|
|
512
|
+
status: "settled"
|
|
513
|
+
});
|
|
514
|
+
emit("onSuccess", res, args);
|
|
515
|
+
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(res, args);
|
|
516
|
+
if (currentCount === count.value) {
|
|
517
|
+
emit("onAfter", args, res, void 0);
|
|
518
|
+
}
|
|
519
|
+
onAfter === null || onAfter === void 0 ? void 0 : onAfter(args);
|
|
520
|
+
return res;
|
|
521
|
+
} catch (error2) {
|
|
522
|
+
if (currentCount !== count.value) return resolvedPromise();
|
|
523
|
+
setState({
|
|
524
|
+
loading: false,
|
|
525
|
+
error: error2,
|
|
526
|
+
status: "settled"
|
|
527
|
+
});
|
|
528
|
+
emit("onError", error2, args);
|
|
529
|
+
onError === null || onError === void 0 ? void 0 : onError(error2, args);
|
|
530
|
+
if (currentCount === count.value) {
|
|
531
|
+
emit("onAfter", args, void 0, error2);
|
|
532
|
+
}
|
|
533
|
+
onAfter === null || onAfter === void 0 ? void 0 : onAfter(args);
|
|
534
|
+
throw error2;
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
context.run = function() {
|
|
538
|
+
context.runAsync(...arguments).catch((error2) => {
|
|
539
|
+
if (!onError) {
|
|
540
|
+
console.error(error2);
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
};
|
|
544
|
+
context.cancel = () => {
|
|
545
|
+
count.value += 1;
|
|
546
|
+
setState({
|
|
547
|
+
loading: false
|
|
548
|
+
});
|
|
549
|
+
emit("onCancel");
|
|
550
|
+
};
|
|
551
|
+
context.refresh = () => {
|
|
552
|
+
context.run(...params.value || []);
|
|
553
|
+
};
|
|
554
|
+
context.refreshAsync = () => {
|
|
555
|
+
return context.runAsync(...params.value || []);
|
|
556
|
+
};
|
|
557
|
+
context.mutate = (x) => {
|
|
558
|
+
const mutateData = isFunction(x) ? x(data.value) : x;
|
|
559
|
+
const _mutateData = shallowCopy(mutateData);
|
|
560
|
+
setState({
|
|
561
|
+
data: _mutateData
|
|
562
|
+
});
|
|
563
|
+
emit("onMutate", _mutateData);
|
|
564
|
+
};
|
|
565
|
+
return {
|
|
566
|
+
status,
|
|
567
|
+
loading,
|
|
568
|
+
data,
|
|
569
|
+
error,
|
|
570
|
+
params,
|
|
571
|
+
plugins,
|
|
572
|
+
context
|
|
573
|
+
};
|
|
574
|
+
};
|
|
575
|
+
function useQuery(service) {
|
|
576
|
+
let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
577
|
+
let plugins = arguments.length > 2 ? arguments[2] : void 0;
|
|
578
|
+
const injectedGlobalOptions = inject(GLOBAL_OPTIONS_PROVIDE_KEY, {});
|
|
579
|
+
const config = {
|
|
580
|
+
...getGlobalOptions(),
|
|
581
|
+
...injectedGlobalOptions,
|
|
582
|
+
...options
|
|
583
|
+
};
|
|
584
|
+
const {
|
|
585
|
+
manual = false,
|
|
586
|
+
defaultParams = []
|
|
587
|
+
} = config;
|
|
588
|
+
const queryInstance = createQuery(service, config);
|
|
589
|
+
queryInstance.plugins.value = plugins.map((i) => i(queryInstance, config));
|
|
590
|
+
if (!manual) {
|
|
591
|
+
const params = queryInstance.params.value || defaultParams;
|
|
592
|
+
queryInstance.context.run(...params);
|
|
593
|
+
}
|
|
594
|
+
onUnmounted(() => {
|
|
595
|
+
queryInstance.context.cancel();
|
|
596
|
+
});
|
|
597
|
+
return {
|
|
598
|
+
loading: queryInstance.loading,
|
|
599
|
+
data: queryInstance.data,
|
|
600
|
+
error: queryInstance.error,
|
|
601
|
+
params: queryInstance.params,
|
|
602
|
+
cancel: queryInstance.context.cancel,
|
|
603
|
+
refresh: queryInstance.context.refresh,
|
|
604
|
+
refreshAsync: queryInstance.context.refreshAsync,
|
|
605
|
+
mutate: queryInstance.context.mutate,
|
|
606
|
+
run: queryInstance.context.run,
|
|
607
|
+
runAsync: queryInstance.context.runAsync
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
function useLoadMore(service, options) {
|
|
611
|
+
const {
|
|
612
|
+
isNoMore,
|
|
613
|
+
...restOptions
|
|
614
|
+
} = options !== null && options !== void 0 ? options : {};
|
|
615
|
+
const data = shallowRef();
|
|
616
|
+
const dataList = computed(() => {
|
|
617
|
+
var _data$value;
|
|
618
|
+
return ((_data$value = data.value) === null || _data$value === void 0 ? void 0 : _data$value.list) || [];
|
|
619
|
+
});
|
|
620
|
+
const loadingMore = ref(false);
|
|
621
|
+
const isTriggerByLoadMore = ref(false);
|
|
622
|
+
const count = ref(0);
|
|
623
|
+
const {
|
|
624
|
+
runAsync,
|
|
625
|
+
run,
|
|
626
|
+
cancel: _cancel,
|
|
627
|
+
...rest
|
|
628
|
+
} = useQuery(async (lastData) => {
|
|
629
|
+
const currentCount = count.value;
|
|
630
|
+
const currentData = await service(lastData);
|
|
631
|
+
if (currentCount === count.value) {
|
|
632
|
+
if (lastData) {
|
|
633
|
+
data.value = {
|
|
634
|
+
...currentData,
|
|
635
|
+
list: [...lastData.list, ...currentData.list]
|
|
636
|
+
};
|
|
637
|
+
} else {
|
|
638
|
+
data.value = currentData;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
return currentData;
|
|
642
|
+
}, {
|
|
643
|
+
...restOptions,
|
|
644
|
+
defaultParams: [],
|
|
645
|
+
refreshDepsAction: () => {
|
|
646
|
+
if (restOptions !== null && restOptions !== void 0 && restOptions.refreshDepsAction) {
|
|
647
|
+
restOptions.refreshDepsAction();
|
|
648
|
+
} else {
|
|
649
|
+
refresh();
|
|
650
|
+
}
|
|
651
|
+
},
|
|
652
|
+
onError: (error) => {
|
|
653
|
+
var _restOptions$onError;
|
|
654
|
+
restOptions === null || restOptions === void 0 ? void 0 : (_restOptions$onError = restOptions.onError) === null || _restOptions$onError === void 0 ? void 0 : _restOptions$onError.call(restOptions, error);
|
|
655
|
+
},
|
|
656
|
+
onSuccess: (data2) => {
|
|
657
|
+
var _restOptions$onSucces;
|
|
658
|
+
restOptions === null || restOptions === void 0 ? void 0 : (_restOptions$onSucces = restOptions.onSuccess) === null || _restOptions$onSucces === void 0 ? void 0 : _restOptions$onSucces.call(restOptions, data2);
|
|
659
|
+
},
|
|
660
|
+
onBefore: () => {
|
|
661
|
+
var _restOptions$onBefore;
|
|
662
|
+
count.value += 1;
|
|
663
|
+
if (isTriggerByLoadMore.value) {
|
|
664
|
+
isTriggerByLoadMore.value = false;
|
|
665
|
+
loadingMore.value = true;
|
|
666
|
+
}
|
|
667
|
+
restOptions === null || restOptions === void 0 ? void 0 : (_restOptions$onBefore = restOptions.onBefore) === null || _restOptions$onBefore === void 0 ? void 0 : _restOptions$onBefore.call(restOptions);
|
|
668
|
+
},
|
|
669
|
+
onAfter: () => {
|
|
670
|
+
var _restOptions$onAfter;
|
|
671
|
+
loadingMore.value = false;
|
|
672
|
+
isTriggerByLoadMore.value = false;
|
|
673
|
+
restOptions === null || restOptions === void 0 ? void 0 : (_restOptions$onAfter = restOptions.onAfter) === null || _restOptions$onAfter === void 0 ? void 0 : _restOptions$onAfter.call(restOptions);
|
|
674
|
+
}
|
|
675
|
+
}, [useErrorRetryPlugin, useDebouncePlugin, useThrottlePlugin, useRefreshDepsPlugin, useReadyPlugin]);
|
|
676
|
+
const noMore = computed(() => {
|
|
677
|
+
return isNoMore && isFunction(isNoMore) ? isNoMore(data.value) : false;
|
|
678
|
+
});
|
|
679
|
+
const loadMore = () => {
|
|
680
|
+
loadMoreAsync().catch(() => {
|
|
681
|
+
});
|
|
682
|
+
};
|
|
683
|
+
const loadMoreAsync = () => {
|
|
684
|
+
if (noMore.value) {
|
|
685
|
+
return Promise.reject(warning("No more data. You need to ignore this error by checking if `noMore` is false before calling `loadMoreAsync`", true));
|
|
686
|
+
}
|
|
687
|
+
isTriggerByLoadMore.value = true;
|
|
688
|
+
return runAsync(data.value);
|
|
689
|
+
};
|
|
690
|
+
const refresh = () => run();
|
|
691
|
+
const refreshAsync = () => runAsync();
|
|
692
|
+
const cancel = () => {
|
|
693
|
+
count.value += 1;
|
|
694
|
+
_cancel();
|
|
695
|
+
loadingMore.value = false;
|
|
696
|
+
};
|
|
697
|
+
const mutate = (x) => {
|
|
698
|
+
const mutateData = isFunction(x) ? x(data.value) : x;
|
|
699
|
+
const _mutateData = shallowCopy(mutateData);
|
|
700
|
+
data.value = _mutateData;
|
|
701
|
+
};
|
|
702
|
+
return {
|
|
703
|
+
data,
|
|
704
|
+
dataList,
|
|
705
|
+
loadingMore,
|
|
706
|
+
noMore,
|
|
707
|
+
cancel,
|
|
708
|
+
mutate,
|
|
709
|
+
refresh,
|
|
710
|
+
refreshAsync,
|
|
711
|
+
loadMore,
|
|
712
|
+
loadMoreAsync,
|
|
713
|
+
...omit(rest, ["refresh", "refreshAsync", "mutate", "params", "data"])
|
|
714
|
+
};
|
|
715
|
+
}
|
|
716
|
+
const cacheQuery = /* @__PURE__ */ new Map();
|
|
717
|
+
const setCacheQuery = (cacheKey, query) => {
|
|
718
|
+
cacheQuery.set(cacheKey, query);
|
|
719
|
+
query.then((res) => {
|
|
720
|
+
cacheQuery.delete(cacheKey);
|
|
721
|
+
return res;
|
|
722
|
+
}).catch(() => {
|
|
723
|
+
cacheQuery.delete(cacheKey);
|
|
724
|
+
});
|
|
725
|
+
};
|
|
726
|
+
const getCacheQuery = (cacheKey) => {
|
|
727
|
+
return cacheQuery.get(cacheKey);
|
|
728
|
+
};
|
|
729
|
+
const listeners = /* @__PURE__ */ new Map();
|
|
730
|
+
const trigger = (key, data) => {
|
|
731
|
+
if (listeners.has(key)) {
|
|
732
|
+
listeners.get(key).forEach((item) => item(data));
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
const subscribe = (key, listener) => {
|
|
736
|
+
if (!listeners.has(key)) {
|
|
737
|
+
listeners.set(key, [listener]);
|
|
738
|
+
} else {
|
|
739
|
+
listeners.get(key).push(listener);
|
|
740
|
+
}
|
|
741
|
+
return () => {
|
|
742
|
+
const index = listeners.get(key).indexOf(listener);
|
|
743
|
+
listeners.get(key).splice(index, 1);
|
|
744
|
+
};
|
|
745
|
+
};
|
|
746
|
+
var useCachePlugin = definePlugin((queryInstance, _ref) => {
|
|
747
|
+
let {
|
|
748
|
+
cacheKey: customCacheKey,
|
|
749
|
+
cacheTime = 6e5,
|
|
750
|
+
staleTime = 0,
|
|
751
|
+
getCache: customGetCache,
|
|
752
|
+
setCache: customSetCache
|
|
753
|
+
} = _ref;
|
|
754
|
+
if (!customCacheKey) return {};
|
|
755
|
+
const cacheKey = isFunction(customCacheKey) ? customCacheKey : () => customCacheKey;
|
|
756
|
+
const unSubscribe = ref(() => {
|
|
757
|
+
});
|
|
758
|
+
let currentQuery;
|
|
759
|
+
const _getCache = (key) => {
|
|
760
|
+
if (customGetCache) {
|
|
761
|
+
return customGetCache(key);
|
|
762
|
+
} else {
|
|
763
|
+
return getCache(key);
|
|
764
|
+
}
|
|
765
|
+
};
|
|
766
|
+
const _setCache = (key, time, cacheData) => {
|
|
767
|
+
if (customSetCache) {
|
|
768
|
+
customSetCache(key, cacheData);
|
|
769
|
+
} else {
|
|
770
|
+
setCache(key, time, cacheData);
|
|
771
|
+
}
|
|
772
|
+
trigger(key, cacheData.data);
|
|
773
|
+
};
|
|
774
|
+
const isFresh = (time) => staleTime === -1 || time + staleTime > (/* @__PURE__ */ new Date()).getTime();
|
|
775
|
+
const hasProp = (object, prop) => Object.prototype.hasOwnProperty.call(object, prop);
|
|
776
|
+
const subscribeCache = (params) => {
|
|
777
|
+
const _cacheKey2 = cacheKey(params);
|
|
778
|
+
return subscribe(_cacheKey2, (data) => {
|
|
779
|
+
queryInstance.data.value = data;
|
|
780
|
+
});
|
|
781
|
+
};
|
|
782
|
+
const _cacheKey = cacheKey();
|
|
783
|
+
const cache = _getCache(_cacheKey);
|
|
784
|
+
if (cache && hasProp(cache, "data")) {
|
|
785
|
+
queryInstance.data.value = cache.data;
|
|
786
|
+
queryInstance.params.value = cache.params;
|
|
787
|
+
}
|
|
788
|
+
if (_cacheKey) {
|
|
789
|
+
unSubscribe.value = subscribeCache();
|
|
790
|
+
}
|
|
791
|
+
onUnmounted(() => {
|
|
792
|
+
unSubscribe.value();
|
|
793
|
+
});
|
|
794
|
+
return {
|
|
795
|
+
onBefore(params) {
|
|
796
|
+
const _cacheKey2 = cacheKey(params);
|
|
797
|
+
const cache2 = _getCache(_cacheKey2);
|
|
798
|
+
if (!cache2 || !hasProp(cache2, "data")) {
|
|
799
|
+
return {};
|
|
800
|
+
}
|
|
801
|
+
if (isFresh(cache2.time)) {
|
|
802
|
+
queryInstance.data.value = cache2.data;
|
|
803
|
+
queryInstance.loading.value = false;
|
|
804
|
+
return {
|
|
805
|
+
isBreak: true,
|
|
806
|
+
breakResult: cache2.data
|
|
807
|
+
};
|
|
808
|
+
} else {
|
|
809
|
+
queryInstance.data.value = cache2.data;
|
|
810
|
+
}
|
|
811
|
+
},
|
|
812
|
+
onQuery(service) {
|
|
813
|
+
const params = queryInstance.params.value;
|
|
814
|
+
const _cacheKey2 = cacheKey(params);
|
|
815
|
+
let servicePromise = getCacheQuery(_cacheKey2);
|
|
816
|
+
if (servicePromise && servicePromise !== currentQuery) {
|
|
817
|
+
return () => servicePromise;
|
|
818
|
+
}
|
|
819
|
+
servicePromise = service();
|
|
820
|
+
currentQuery = servicePromise;
|
|
821
|
+
setCacheQuery(_cacheKey2, servicePromise);
|
|
822
|
+
return () => servicePromise;
|
|
823
|
+
},
|
|
824
|
+
onSuccess(data, params) {
|
|
825
|
+
const _cacheKey2 = cacheKey(params);
|
|
826
|
+
if (_cacheKey2) {
|
|
827
|
+
unSubscribe.value();
|
|
828
|
+
_setCache(_cacheKey2, cacheTime, {
|
|
829
|
+
data,
|
|
830
|
+
params,
|
|
831
|
+
time: (/* @__PURE__ */ new Date()).getTime()
|
|
832
|
+
});
|
|
833
|
+
unSubscribe.value = subscribeCache(params);
|
|
834
|
+
}
|
|
835
|
+
},
|
|
836
|
+
onMutate(data) {
|
|
837
|
+
const _cacheKey2 = cacheKey(queryInstance.params.value);
|
|
838
|
+
if (_cacheKey2) {
|
|
839
|
+
unSubscribe.value();
|
|
840
|
+
_setCache(_cacheKey2, cacheTime, {
|
|
841
|
+
data,
|
|
842
|
+
params: queryInstance.params.value,
|
|
843
|
+
time: (/* @__PURE__ */ new Date()).getTime()
|
|
844
|
+
});
|
|
845
|
+
unSubscribe.value = subscribeCache(queryInstance.params.value);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
};
|
|
849
|
+
});
|
|
850
|
+
function setTimeoutPromise(duration) {
|
|
851
|
+
let timerId, stop;
|
|
852
|
+
class Timer extends Promise {
|
|
853
|
+
constructor(fn) {
|
|
854
|
+
super(fn);
|
|
855
|
+
this.cancel = () => {
|
|
856
|
+
stop();
|
|
857
|
+
clearTimeout(timerId);
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
return new Timer((resolve) => {
|
|
862
|
+
stop = resolve;
|
|
863
|
+
timerId = setTimeout(stop, duration);
|
|
864
|
+
});
|
|
865
|
+
}
|
|
866
|
+
function getCurrentTime() {
|
|
867
|
+
return (/* @__PURE__ */ new Date()).getTime();
|
|
868
|
+
}
|
|
869
|
+
var useLoadingDelayPlugin = definePlugin((queryInstance, _ref) => {
|
|
870
|
+
let {
|
|
871
|
+
loadingDelay = 0,
|
|
872
|
+
loadingKeep = 0
|
|
873
|
+
} = _ref;
|
|
874
|
+
const delayLoadingTimer = ref(() => {
|
|
875
|
+
});
|
|
876
|
+
const loadingDelayRef = computed(() => refToRaw(loadingDelay));
|
|
877
|
+
const loadingKeepRef = computed(() => refToRaw(loadingKeep));
|
|
878
|
+
let startTime = 0;
|
|
879
|
+
let timeoutPromise = {};
|
|
880
|
+
const delayLoading = () => {
|
|
881
|
+
let timerId;
|
|
882
|
+
if (loadingDelayRef.value) {
|
|
883
|
+
timerId = setTimeout(() => {
|
|
884
|
+
if (queryInstance.status.value === "pending") {
|
|
885
|
+
queryInstance.loading.value = true;
|
|
886
|
+
}
|
|
887
|
+
}, loadingDelayRef.value);
|
|
888
|
+
}
|
|
889
|
+
return () => timerId && clearTimeout(timerId);
|
|
890
|
+
};
|
|
891
|
+
return {
|
|
892
|
+
onBefore() {
|
|
893
|
+
queryInstance.loading.value = !loadingDelayRef.value;
|
|
894
|
+
delayLoadingTimer.value();
|
|
895
|
+
delayLoadingTimer.value = delayLoading();
|
|
896
|
+
startTime = getCurrentTime();
|
|
897
|
+
},
|
|
898
|
+
onQuery(service) {
|
|
899
|
+
if (!loadingKeepRef.value) return () => service();
|
|
900
|
+
timeoutPromise = setTimeoutPromise(loadingKeepRef.value + loadingDelayRef.value);
|
|
901
|
+
const _service = async () => {
|
|
902
|
+
try {
|
|
903
|
+
const res = await service();
|
|
904
|
+
if (getCurrentTime() - startTime <= loadingDelayRef.value) {
|
|
905
|
+
timeoutPromise.cancel();
|
|
906
|
+
}
|
|
907
|
+
return Promise.resolve(res);
|
|
908
|
+
} catch (error) {
|
|
909
|
+
if (getCurrentTime() - startTime <= loadingDelayRef.value) {
|
|
910
|
+
timeoutPromise.cancel();
|
|
911
|
+
}
|
|
912
|
+
return Promise.reject(error);
|
|
913
|
+
}
|
|
914
|
+
};
|
|
915
|
+
const servicePromise = Promise.allSettled([_service(), timeoutPromise]).then((res) => {
|
|
916
|
+
const result = res[0];
|
|
917
|
+
if (result.status === "fulfilled") {
|
|
918
|
+
return result.value;
|
|
919
|
+
} else {
|
|
920
|
+
return Promise.reject(result.reason);
|
|
921
|
+
}
|
|
922
|
+
});
|
|
923
|
+
return () => servicePromise;
|
|
924
|
+
},
|
|
925
|
+
onCancel() {
|
|
926
|
+
delayLoadingTimer.value();
|
|
927
|
+
},
|
|
928
|
+
onAfter() {
|
|
929
|
+
delayLoadingTimer.value();
|
|
930
|
+
}
|
|
931
|
+
};
|
|
932
|
+
});
|
|
933
|
+
var _window;
|
|
934
|
+
const FOCUS_LISTENER = /* @__PURE__ */ new Set();
|
|
935
|
+
const VISIBLE_LISTENER = /* @__PURE__ */ new Set();
|
|
936
|
+
const RECONNECT_LISTENER = /* @__PURE__ */ new Set();
|
|
937
|
+
const subscriber = (listenerType, event) => {
|
|
938
|
+
let listeners2;
|
|
939
|
+
switch (listenerType) {
|
|
940
|
+
case "FOCUS_LISTENER":
|
|
941
|
+
listeners2 = FOCUS_LISTENER;
|
|
942
|
+
break;
|
|
943
|
+
case "RECONNECT_LISTENER":
|
|
944
|
+
listeners2 = RECONNECT_LISTENER;
|
|
945
|
+
break;
|
|
946
|
+
case "VISIBLE_LISTENER":
|
|
947
|
+
listeners2 = VISIBLE_LISTENER;
|
|
948
|
+
break;
|
|
949
|
+
}
|
|
950
|
+
if (listeners2.has(event)) return;
|
|
951
|
+
listeners2.add(event);
|
|
952
|
+
return () => {
|
|
953
|
+
listeners2.delete(event);
|
|
954
|
+
};
|
|
955
|
+
};
|
|
956
|
+
const observer = (listeners2) => {
|
|
957
|
+
listeners2.forEach((event) => {
|
|
958
|
+
event();
|
|
959
|
+
});
|
|
960
|
+
};
|
|
961
|
+
if (!isServer && (_window = window) !== null && _window !== void 0 && _window.addEventListener) {
|
|
962
|
+
window.addEventListener("visibilitychange", () => {
|
|
963
|
+
if (isDocumentVisibility()) {
|
|
964
|
+
observer(VISIBLE_LISTENER);
|
|
965
|
+
}
|
|
966
|
+
}, false);
|
|
967
|
+
window.addEventListener("focus", () => observer(FOCUS_LISTENER), false);
|
|
968
|
+
window.addEventListener("online", () => observer(RECONNECT_LISTENER), false);
|
|
969
|
+
}
|
|
970
|
+
var usePollingPlugin = definePlugin((queryInstance, _ref) => {
|
|
971
|
+
let {
|
|
972
|
+
pollingInterval,
|
|
973
|
+
pollingWhenHidden = false,
|
|
974
|
+
pollingWhenOffline = false,
|
|
975
|
+
errorRetryCount = 0
|
|
976
|
+
} = _ref;
|
|
977
|
+
const pollingTimer = ref();
|
|
978
|
+
const stopPollingWhenHiddenOrOffline = ref(false);
|
|
979
|
+
const pollingIntervalRef = computed(() => refToRaw(pollingInterval));
|
|
980
|
+
const errorRetryCountRef = computed(() => refToRaw(errorRetryCount));
|
|
981
|
+
const unsubscribeList = [];
|
|
982
|
+
const addUnsubscribeList = (event) => {
|
|
983
|
+
event && unsubscribeList.push(event);
|
|
984
|
+
};
|
|
985
|
+
const isKeepPolling = () => {
|
|
986
|
+
return (
|
|
987
|
+
// pollingWhenHidden = true or pollingWhenHidden = false and document is visibility
|
|
988
|
+
(pollingWhenHidden || isDocumentVisibility()) && // pollingWhenOffline = true or pollingWhenOffline = false and is online
|
|
989
|
+
(pollingWhenOffline || isOnline())
|
|
990
|
+
);
|
|
991
|
+
};
|
|
992
|
+
const polling = (pollingFunc) => {
|
|
993
|
+
if (queryInstance.error.value && errorRetryCountRef.value !== 0) return;
|
|
994
|
+
let timerId;
|
|
995
|
+
if (!isNil(pollingIntervalRef.value) && pollingIntervalRef.value >= 0) {
|
|
996
|
+
if (isKeepPolling()) {
|
|
997
|
+
timerId = setTimeout(pollingFunc, pollingIntervalRef.value);
|
|
998
|
+
} else {
|
|
999
|
+
stopPollingWhenHiddenOrOffline.value = true;
|
|
1000
|
+
return;
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
return () => timerId && clearTimeout(timerId);
|
|
1004
|
+
};
|
|
1005
|
+
const rePolling = () => {
|
|
1006
|
+
if (stopPollingWhenHiddenOrOffline.value && isKeepPolling()) {
|
|
1007
|
+
queryInstance.context.refresh();
|
|
1008
|
+
stopPollingWhenHiddenOrOffline.value = false;
|
|
1009
|
+
}
|
|
1010
|
+
};
|
|
1011
|
+
watch(pollingIntervalRef, () => {
|
|
1012
|
+
if (pollingTimer.value) {
|
|
1013
|
+
pollingTimer.value();
|
|
1014
|
+
pollingTimer.value = polling(() => queryInstance.context.refresh());
|
|
1015
|
+
}
|
|
1016
|
+
});
|
|
1017
|
+
if (!pollingWhenHidden) {
|
|
1018
|
+
addUnsubscribeList(subscriber("VISIBLE_LISTENER", rePolling));
|
|
1019
|
+
}
|
|
1020
|
+
if (!pollingWhenOffline) {
|
|
1021
|
+
addUnsubscribeList(subscriber("RECONNECT_LISTENER", rePolling));
|
|
1022
|
+
}
|
|
1023
|
+
onUnmounted(() => {
|
|
1024
|
+
unsubscribeList.forEach((unsubscribe) => unsubscribe());
|
|
1025
|
+
});
|
|
1026
|
+
return {
|
|
1027
|
+
onBefore() {
|
|
1028
|
+
var _pollingTimer$value;
|
|
1029
|
+
(_pollingTimer$value = pollingTimer.value) === null || _pollingTimer$value === void 0 ? void 0 : _pollingTimer$value.call(pollingTimer);
|
|
1030
|
+
},
|
|
1031
|
+
onCancel() {
|
|
1032
|
+
var _pollingTimer$value2;
|
|
1033
|
+
(_pollingTimer$value2 = pollingTimer.value) === null || _pollingTimer$value2 === void 0 ? void 0 : _pollingTimer$value2.call(pollingTimer);
|
|
1034
|
+
},
|
|
1035
|
+
onAfter() {
|
|
1036
|
+
pollingTimer.value = polling(() => queryInstance.context.refresh());
|
|
1037
|
+
}
|
|
1038
|
+
};
|
|
1039
|
+
});
|
|
1040
|
+
const limitTrigger = (fn, timeInterval) => {
|
|
1041
|
+
let running = false;
|
|
1042
|
+
return function() {
|
|
1043
|
+
if (running) return;
|
|
1044
|
+
running = true;
|
|
1045
|
+
fn(...arguments);
|
|
1046
|
+
setTimeout(() => {
|
|
1047
|
+
running = false;
|
|
1048
|
+
}, timeInterval);
|
|
1049
|
+
};
|
|
1050
|
+
};
|
|
1051
|
+
var useRefreshOnWindowFocus = definePlugin((queryInstance, _ref) => {
|
|
1052
|
+
let {
|
|
1053
|
+
refreshOnWindowFocus = false,
|
|
1054
|
+
refocusTimespan = 5e3
|
|
1055
|
+
} = _ref;
|
|
1056
|
+
const refreshOnWindowFocusRef = computed(() => refToRaw(refreshOnWindowFocus));
|
|
1057
|
+
const refocusTimespanRef = computed(() => refToRaw(refocusTimespan));
|
|
1058
|
+
const unsubscribeList = [];
|
|
1059
|
+
const addUnsubscribeList = (event) => {
|
|
1060
|
+
event && unsubscribeList.push(event);
|
|
1061
|
+
};
|
|
1062
|
+
const unsubscribe = () => {
|
|
1063
|
+
unsubscribeList.forEach((fn) => fn());
|
|
1064
|
+
};
|
|
1065
|
+
watchEffect(() => {
|
|
1066
|
+
unsubscribe();
|
|
1067
|
+
if (refreshOnWindowFocusRef.value) {
|
|
1068
|
+
const limitRefresh = limitTrigger(queryInstance.context.refresh, refocusTimespanRef.value);
|
|
1069
|
+
addUnsubscribeList(subscriber("VISIBLE_LISTENER", limitRefresh));
|
|
1070
|
+
addUnsubscribeList(subscriber("FOCUS_LISTENER", limitRefresh));
|
|
1071
|
+
}
|
|
1072
|
+
});
|
|
1073
|
+
onUnmounted(() => {
|
|
1074
|
+
unsubscribe();
|
|
1075
|
+
});
|
|
1076
|
+
return {};
|
|
1077
|
+
});
|
|
1078
|
+
function useRequest(service, options, plugins) {
|
|
1079
|
+
return useQuery(service, options, [...[], useLoadingDelayPlugin, useErrorRetryPlugin, useDebouncePlugin, usePollingPlugin, useThrottlePlugin, useRefreshOnWindowFocus, useRefreshDepsPlugin, useReadyPlugin, useCachePlugin]);
|
|
1080
|
+
}
|
|
1081
|
+
function usePagination(service) {
|
|
1082
|
+
let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1083
|
+
const defaultPaginationOptions = {
|
|
1084
|
+
currentKey: "current",
|
|
1085
|
+
pageSizeKey: "pageSize",
|
|
1086
|
+
totalKey: "total",
|
|
1087
|
+
totalPageKey: "totalPage"
|
|
1088
|
+
};
|
|
1089
|
+
const injectedGlobalOptions = inject(GLOBAL_OPTIONS_PROVIDE_KEY, {});
|
|
1090
|
+
const {
|
|
1091
|
+
pagination,
|
|
1092
|
+
...restOptions
|
|
1093
|
+
} = options;
|
|
1094
|
+
const {
|
|
1095
|
+
currentKey,
|
|
1096
|
+
pageSizeKey,
|
|
1097
|
+
totalKey,
|
|
1098
|
+
totalPageKey
|
|
1099
|
+
} = merge(defaultPaginationOptions, getGlobalOptions().pagination || {}, injectedGlobalOptions.pagination || {}, pagination || {});
|
|
1100
|
+
const finallyOptions = merge({
|
|
1101
|
+
defaultParams: [{
|
|
1102
|
+
[currentKey]: 1,
|
|
1103
|
+
[pageSizeKey]: 10
|
|
1104
|
+
}]
|
|
1105
|
+
}, restOptions);
|
|
1106
|
+
const {
|
|
1107
|
+
data,
|
|
1108
|
+
params,
|
|
1109
|
+
run,
|
|
1110
|
+
...rest
|
|
1111
|
+
} = useRequest(service, finallyOptions);
|
|
1112
|
+
const paging = (paginationParams) => {
|
|
1113
|
+
const [oldPaginationParams, ...restParams] = params.value || [];
|
|
1114
|
+
const newPaginationParams = {
|
|
1115
|
+
...oldPaginationParams,
|
|
1116
|
+
...paginationParams
|
|
1117
|
+
};
|
|
1118
|
+
const mergerParams = [newPaginationParams, ...restParams];
|
|
1119
|
+
run(...mergerParams);
|
|
1120
|
+
};
|
|
1121
|
+
const changeCurrent = (current2) => {
|
|
1122
|
+
paging({
|
|
1123
|
+
[currentKey]: current2
|
|
1124
|
+
});
|
|
1125
|
+
};
|
|
1126
|
+
const changePageSize = (pageSize2) => {
|
|
1127
|
+
paging({
|
|
1128
|
+
[pageSizeKey]: pageSize2
|
|
1129
|
+
});
|
|
1130
|
+
};
|
|
1131
|
+
const changePagination = (current2, pageSize2) => {
|
|
1132
|
+
paging({
|
|
1133
|
+
[currentKey]: current2,
|
|
1134
|
+
[pageSizeKey]: pageSize2
|
|
1135
|
+
});
|
|
1136
|
+
};
|
|
1137
|
+
const total = computed(() => get(data.value, totalKey, 0));
|
|
1138
|
+
const current = computed({
|
|
1139
|
+
get: () => {
|
|
1140
|
+
var _params$value$0$curre, _params$value, _params$value$;
|
|
1141
|
+
return (
|
|
1142
|
+
// @ts-ignore
|
|
1143
|
+
(_params$value$0$curre = (_params$value = params.value) === null || _params$value === void 0 ? void 0 : (_params$value$ = _params$value[0]) === null || _params$value$ === void 0 ? void 0 : _params$value$[currentKey]) !== null && _params$value$0$curre !== void 0 ? _params$value$0$curre : finallyOptions.defaultParams[0][currentKey]
|
|
1144
|
+
);
|
|
1145
|
+
},
|
|
1146
|
+
set: (val) => {
|
|
1147
|
+
changeCurrent(val);
|
|
1148
|
+
}
|
|
1149
|
+
});
|
|
1150
|
+
const pageSize = computed({
|
|
1151
|
+
get: () => {
|
|
1152
|
+
var _params$value$0$pageS, _params$value2, _params$value2$;
|
|
1153
|
+
return (
|
|
1154
|
+
// @ts-ignore
|
|
1155
|
+
(_params$value$0$pageS = (_params$value2 = params.value) === null || _params$value2 === void 0 ? void 0 : (_params$value2$ = _params$value2[0]) === null || _params$value2$ === void 0 ? void 0 : _params$value2$[pageSizeKey]) !== null && _params$value$0$pageS !== void 0 ? _params$value$0$pageS : finallyOptions.defaultParams[0][pageSizeKey]
|
|
1156
|
+
);
|
|
1157
|
+
},
|
|
1158
|
+
set: (val) => {
|
|
1159
|
+
changePageSize(val);
|
|
1160
|
+
}
|
|
1161
|
+
});
|
|
1162
|
+
const totalPage = computed(() => get(data.value, totalPageKey, Math.ceil(total.value / pageSize.value)));
|
|
1163
|
+
return {
|
|
1164
|
+
data,
|
|
1165
|
+
params,
|
|
1166
|
+
current,
|
|
1167
|
+
pageSize,
|
|
1168
|
+
total,
|
|
1169
|
+
totalPage,
|
|
1170
|
+
run,
|
|
1171
|
+
changeCurrent,
|
|
1172
|
+
changePageSize,
|
|
1173
|
+
changePagination,
|
|
1174
|
+
...rest
|
|
1175
|
+
};
|
|
1176
|
+
}
|
|
1177
|
+
export {
|
|
1178
|
+
definePlugin,
|
|
1179
|
+
useLoadMore,
|
|
1180
|
+
usePagination,
|
|
1181
|
+
useRequest
|
|
1182
|
+
};
|
|
1183
|
+
//# sourceMappingURL=index.es.mjs.map
|