diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index c582dc71..3f13a2ac 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -43,8 +43,8 @@ jobs: run: | echo "${{ secrets.ENV_FILE }}" > .env - - name: Lint project - run: pnpm lint + - name: Lint and check type + run: pnpm lint && pnpm typecheck - name: Build Taro weapp run: pnpm build:weapp diff --git a/package.json b/package.json index dfd0f7d0..9cb0542a 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "author": "ZJUTJH", "scripts": { "lint": "eslint", + "typecheck": "vue-tsc --noEmit", "dev:weapp": "npm run build:weapp -- --watch", "build:weapp": "taro build --type weapp" }, @@ -49,6 +50,7 @@ "stylelint": "^14.4.0", "terser": "^5.30.4", "typescript": "^5.4.5", - "vite": "^4.2.0" + "vite": "^4.2.0", + "vue-tsc": "^2.1.10" } } \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8edd95e9..0ca28005 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -114,6 +114,9 @@ importers: vite: specifier: ^4.2.0 version: 4.5.5(@types/node@22.7.5)(less@4.2.0)(lightningcss@1.27.0)(sass@1.79.5)(stylus@0.55.0)(terser@5.34.1) + vue-tsc: + specifier: ^2.1.10 + version: 2.1.10(typescript@5.6.3) packages: @@ -1312,30 +1315,35 @@ packages: engines: {node: '>= 10.0.0'} cpu: [arm] os: [linux] + libc: [glibc] '@parcel/watcher-linux-arm64-glibc@2.4.1': resolution: {integrity: sha512-BJ7mH985OADVLpbrzCLgrJ3TOpiZggE9FMblfO65PlOCdG++xJpKUJ0Aol74ZUIYfb8WsRlUdgrZxKkz3zXWYA==} engines: {node: '>= 10.0.0'} cpu: [arm64] os: [linux] + libc: [glibc] '@parcel/watcher-linux-arm64-musl@2.4.1': resolution: {integrity: sha512-p4Xb7JGq3MLgAfYhslU2SjoV9G0kI0Xry0kuxeG/41UfpjHGOhv7UoUDAz/jb1u2elbhazy4rRBL8PegPJFBhA==} engines: {node: '>= 10.0.0'} cpu: [arm64] os: [linux] + libc: [musl] '@parcel/watcher-linux-x64-glibc@2.4.1': resolution: {integrity: sha512-s9O3fByZ/2pyYDPoLM6zt92yu6P4E39a03zvO0qCHOTjxmt3GHRMLuRZEWhWLASTMSrrnVNWdVI/+pUElJBBBg==} engines: {node: '>= 10.0.0'} cpu: [x64] os: [linux] + libc: [glibc] '@parcel/watcher-linux-x64-musl@2.4.1': resolution: {integrity: sha512-L2nZTYR1myLNST0O632g0Dx9LyMNHrn6TOt76sYxWLdff3cB22/GZX2UPtJnaqQPdCRoszoY5rcOj4oMTtp5fQ==} engines: {node: '>= 10.0.0'} cpu: [x64] os: [linux] + libc: [musl] '@parcel/watcher-win32-arm64@2.4.1': resolution: {integrity: sha512-Uq2BPp5GWhrq/lcuItCHoqxjULU1QYEcyjSO5jqqOK8RNFDBQnenMMx4gAl3v8GiWa59E9+uDM7yZ6LxwUIfRg==} @@ -1480,24 +1488,28 @@ packages: engines: {node: '>=10'} cpu: [arm64] os: [linux] + libc: [glibc] '@swc/core-linux-arm64-musl@1.3.96': resolution: {integrity: sha512-i5/UTUwmJLri7zhtF6SAo/4QDQJDH2fhYJaBIUhrICmIkRO/ltURmpejqxsM/ye9Jqv5zG7VszMC0v/GYn/7BQ==} engines: {node: '>=10'} cpu: [arm64] os: [linux] + libc: [musl] '@swc/core-linux-x64-gnu@1.3.96': resolution: {integrity: sha512-USdaZu8lTIkm4Yf9cogct/j5eqtdZqTgcTib4I+NloUW0E/hySou3eSyp3V2UAA1qyuC72ld1otXuyKBna0YKQ==} engines: {node: '>=10'} cpu: [x64] os: [linux] + libc: [glibc] '@swc/core-linux-x64-musl@1.3.96': resolution: {integrity: sha512-QYErutd+G2SNaCinUVobfL7jWWjGTI0QEoQ6hqTp7PxCJS/dmKmj3C5ZkvxRYcq7XcZt7ovrYCTwPTHzt6lZBg==} engines: {node: '>=10'} cpu: [x64] os: [linux] + libc: [musl] '@swc/core-win32-arm64-msvc@1.3.96': resolution: {integrity: sha512-hjGvvAduA3Un2cZ9iNP4xvTXOO4jL3G9iakhFsgVhpkU73SGmK7+LN8ZVBEu4oq2SUcHO6caWvnZ881cxGuSpg==} @@ -1567,6 +1579,7 @@ packages: engines: {node: '>= 18'} cpu: [x64] os: [linux] + libc: [glibc] '@tarojs/binding-win32-x64-msvc@4.0.6': resolution: {integrity: sha512-yvBL+x7V7wz3eBG7Tf3SuYc7YkZY3sGDNJbOUVUZ9nGPubok94b5qLxPh/BD2dbZgz8dMtcED/6QhrBdFOsQLw==} @@ -1652,24 +1665,28 @@ packages: engines: {node: '>= 10'} cpu: [arm64] os: [linux] + libc: [glibc] '@tarojs/parse-css-to-stylesheet-linux-arm64-musl@0.0.69': resolution: {integrity: sha512-bYODGCEx1Ni4EMNuZU95IUPqVZAXsY9gIc5CPSfKQ2j167Vbeo/gskQk/uNVjmnYJ69PplgJ9npylINgLIPIrA==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] + libc: [musl] '@tarojs/parse-css-to-stylesheet-linux-x64-gnu@0.0.69': resolution: {integrity: sha512-89f03s+txGJ1c8Zc6Ib4qTAP4YhfFbVFq29XExqbC7eGvpQl5DeOtwonO5DBwMc7lA+LG4b1Q4CMXE3qodn2eA==} engines: {node: '>= 10'} cpu: [x64] os: [linux] + libc: [glibc] '@tarojs/parse-css-to-stylesheet-linux-x64-musl@0.0.69': resolution: {integrity: sha512-vyewIf1KysXYNIJdkzc9JSPguTG9zD65Belk3H186mLR18KtsvrqNqlWnP8kKfduF4ixh6qt0F2PkKbeI9PZvg==} engines: {node: '>= 10'} cpu: [x64] os: [linux] + libc: [musl] '@tarojs/parse-css-to-stylesheet-win32-x64-msvc@0.0.69': resolution: {integrity: sha512-CHKlVjAiSAZTFNV8GkfXV88Jy9yyFSvKBAO3++l2KSQUBUWmPX775FbH+god2BOLf5SfAXRPd0HVAEK9qNeHXQ==} @@ -1709,24 +1726,28 @@ packages: engines: {node: '>= 10'} cpu: [arm64] os: [linux] + libc: [glibc] '@tarojs/plugin-doctor-linux-arm64-musl@0.0.13': resolution: {integrity: sha512-V1HnFITOLgHVyQ+OCa1oPFKOtGFRtP91vlbUGfOwMA4GeOVw9g28W/hfTyucTCkfZWlrssLehgW6L2AGAMXh2w==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] + libc: [musl] '@tarojs/plugin-doctor-linux-x64-gnu@0.0.13': resolution: {integrity: sha512-oetfzBW60uenPBBF4/NE6Mf0Iwkw1YGqIIBiN++aVQynbWrmMzWBsW8kleZ5vN1npxI9aud9EfRU1uM37DrG2A==} engines: {node: '>= 10'} cpu: [x64] os: [linux] + libc: [glibc] '@tarojs/plugin-doctor-linux-x64-musl@0.0.13': resolution: {integrity: sha512-OdIF/kFwwM0kQPDnpkanhvfWRaAI6EtDmpM9rQA/Lu2QcJq86w5d7X/WSN0U2xF1nialAUrfl79NyIaEzp4Fcw==} engines: {node: '>= 10'} cpu: [x64] os: [linux] + libc: [musl] '@tarojs/plugin-doctor-win32-ia32-msvc@0.0.13': resolution: {integrity: sha512-nIbG2SliRhRwACLa1kNMskcfjsihp+3tZQMAxl+LoYUq6JRaWgP3vH2nHkDyZHTCheBTDtAaupqXWrYF3w+U6g==} @@ -2038,6 +2059,15 @@ packages: vite: ^5.0.0 vue: ^3.2.25 + '@volar/language-core@2.4.10': + resolution: {integrity: sha512-hG3Z13+nJmGaT+fnQzAkS0hjJRa2FCeqZt6Bd+oGNhUkQ+mTFsDETg5rqUTxyzIh5pSOGY7FHCWUS8G82AzLCA==} + + '@volar/source-map@2.4.10': + resolution: {integrity: sha512-OCV+b5ihV0RF3A7vEvNyHPi4G4kFa6ukPmyVocmqm5QzOd8r5yAtiNvaPEjl8dNvgC/lj4JPryeeHLdXd62rWA==} + + '@volar/typescript@2.4.10': + resolution: {integrity: sha512-F8ZtBMhSXyYKuBfGpYwqA5rsONnOwAVvjyE7KPYJ7wgZqo2roASqNWUnianOomJX5u1cxeRooHV59N0PhvEOgw==} + '@vue/babel-helper-vue-transform-on@1.2.5': resolution: {integrity: sha512-lOz4t39ZdmU4DJAa2hwPYmKc8EsuGa2U0L9KaZaOJUt0UwQNjNA3AZTq6uEivhOKhhG1Wvy96SvYBoFmCg3uuw==} @@ -2066,6 +2096,9 @@ packages: '@vue/compiler-ssr@3.5.11': resolution: {integrity: sha512-P4+GPjOuC2aFTk1Z4WANvEhyOykcvEd5bIj2KVNGKGfM745LaXGr++5njpdBTzVz5pZifdlR1kpYSJJpIlSePA==} + '@vue/compiler-vue2@2.7.16': + resolution: {integrity: sha512-qYC3Psj9S/mfu9uVi5WvNZIzq+xnXMhOwbTFKKDD7b1lhpnn71jXSFdTQ+WsIEk0ONCd7VV2IMm7ONl6tbQ86A==} + '@vue/devtools-api@6.6.4': resolution: {integrity: sha512-sGhTPMuXqZ1rVOk32RylztWkfXTRhuS7vgAKv0zjqk8gbsHkJ7xfFf+jbySxt7tWObEJwyKaHMikV/WGDiQm8g==} @@ -2080,6 +2113,14 @@ packages: typescript: optional: true + '@vue/language-core@2.1.10': + resolution: {integrity: sha512-DAI289d0K3AB5TUG3xDp9OuQ71CnrujQwJrQnfuZDwo6eGNf0UoRlPuaVNO+Zrn65PC3j0oB2i7mNmVPggeGeQ==} + peerDependencies: + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + '@vue/reactivity@3.5.11': resolution: {integrity: sha512-Nqo5VZEn8MJWlCce8XoyVqHZbd5P2NH+yuAaFzuNSR96I+y1cnuUiq7xfSG+kyvLSiWmaHTKP1r3OZY4mMD50w==} @@ -2212,6 +2253,9 @@ packages: ajv@8.17.1: resolution: {integrity: sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==} + alien-signals@0.2.1: + resolution: {integrity: sha512-FlEQrDJe9r2RI4cDlnK2zYqJezvx1uJaWEuwxsnlFqnPwvJbgitNBRumWrLDv8lA+7cCikpMxfJD2TTHiaTklA==} + ansi-escapes@4.3.2: resolution: {integrity: sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==} engines: {node: '>=8'} @@ -2757,6 +2801,9 @@ packages: dayjs@1.11.13: resolution: {integrity: sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg==} + de-indent@1.0.2: + resolution: {integrity: sha512-e/1zu3xH5MQryN2zdVaF0OrdNLUbvWxzMbi+iNA6Bky7l1RoP8a2fIbRocyHclXt/arDrrR6lL3TqFD9pMQTsg==} + debug@2.6.9: resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==} peerDependencies: @@ -4093,24 +4140,28 @@ packages: engines: {node: '>= 12.0.0'} cpu: [arm64] os: [linux] + libc: [glibc] lightningcss-linux-arm64-musl@1.27.0: resolution: {integrity: sha512-rCGBm2ax7kQ9pBSeITfCW9XSVF69VX+fm5DIpvDZQl4NnQoMQyRwhZQm9pd59m8leZ1IesRqWk2v/DntMo26lg==} engines: {node: '>= 12.0.0'} cpu: [arm64] os: [linux] + libc: [musl] lightningcss-linux-x64-gnu@1.27.0: resolution: {integrity: sha512-Dk/jovSI7qqhJDiUibvaikNKI2x6kWPN79AQiD/E/KeQWMjdGe9kw51RAgoWFDi0coP4jinaH14Nrt/J8z3U4A==} engines: {node: '>= 12.0.0'} cpu: [x64] os: [linux] + libc: [glibc] lightningcss-linux-x64-musl@1.27.0: resolution: {integrity: sha512-QKjTxXm8A9s6v9Tg3Fk0gscCQA1t/HMoF7Woy1u68wCk5kS4fR+q3vXa1p3++REW784cRAtkYKrPy6JKibrEZA==} engines: {node: '>= 12.0.0'} cpu: [x64] os: [linux] + libc: [musl] lightningcss-win32-arm64-msvc@1.27.0: resolution: {integrity: sha512-/wXegPS1hnhkeG4OXQKEMQeJd48RDC3qdh+OA8pCuOPCyvnm/yEayrJdJVqzBsqpy1aJklRCVxscpFur80o6iQ==} @@ -4374,6 +4425,9 @@ packages: ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} + muggle-string@0.4.1: + resolution: {integrity: sha512-VNTrAak/KhO2i8dqqnqnAHOa3cYBwXEZe9h+D5h/1ZqFSTEFHdM65lR7RoIqq3tBBYavsOXV84NoHXZ0AkPyqQ==} + multicast-dns-service-types@1.1.0: resolution: {integrity: sha512-cnAsSVxIDsYt0v7HmC0hWZFwwXSh+E6PgCrREDuN/EsjgLwA5XRmlMHhSiDPrt6HxY1gTivEa/Zh7GtODoLevQ==} @@ -4632,6 +4686,9 @@ packages: pascal-case@3.1.2: resolution: {integrity: sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==} + path-browserify@1.0.1: + resolution: {integrity: sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==} + path-exists@4.0.0: resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} engines: {node: '>=8'} @@ -5710,6 +5767,9 @@ packages: terser: optional: true + vscode-uri@3.0.8: + resolution: {integrity: sha512-AyFQ0EVmsOZOlAnxoFOGOq1SQDWAB7C6aqMGS23svWAllfOaxbuFvcT8D1i8z3Gyn8fraVeZNNmN6e9bxxXkKw==} + vue-demi@0.14.10: resolution: {integrity: sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg==} engines: {node: '>=12'} @@ -5739,6 +5799,12 @@ packages: vue: optional: true + vue-tsc@2.1.10: + resolution: {integrity: sha512-RBNSfaaRHcN5uqVqJSZh++Gy/YUzryuv9u1aFWhsammDJXNtUiJMNoJ747lZcQ68wUQFx6E73y4FY3D8E7FGMA==} + hasBin: true + peerDependencies: + typescript: '>=5.0.0' + vue@3.5.11: resolution: {integrity: sha512-/8Wurrd9J3lb72FTQS7gRMNQD4nztTtKPmuDuPuhqXmmpD6+skVjAeahNpVzsuky6Sy9gy7wn8UadqPtt9SQIg==} peerDependencies: @@ -8045,6 +8111,18 @@ snapshots: vite: 4.5.5(@types/node@22.7.5)(less@4.2.0)(lightningcss@1.27.0)(sass@1.79.5)(stylus@0.55.0)(terser@5.34.1) vue: 3.5.11(typescript@5.6.3) + '@volar/language-core@2.4.10': + dependencies: + '@volar/source-map': 2.4.10 + + '@volar/source-map@2.4.10': {} + + '@volar/typescript@2.4.10': + dependencies: + '@volar/language-core': 2.4.10 + path-browserify: 1.0.1 + vscode-uri: 3.0.8 + '@vue/babel-helper-vue-transform-on@1.2.5': {} '@vue/babel-plugin-jsx@1.2.5(@babel/core@7.25.7)': @@ -8105,6 +8183,11 @@ snapshots: '@vue/compiler-dom': 3.5.11 '@vue/shared': 3.5.11 + '@vue/compiler-vue2@2.7.16': + dependencies: + de-indent: 1.0.2 + he: 1.2.0 + '@vue/devtools-api@6.6.4': {} '@vue/eslint-config-typescript@14.0.0(eslint-plugin-vue@9.28.0(eslint@9.12.0(jiti@2.3.3)))(eslint@9.12.0(jiti@2.3.3))(typescript@5.6.3)': @@ -8120,6 +8203,19 @@ snapshots: transitivePeerDependencies: - supports-color + '@vue/language-core@2.1.10(typescript@5.6.3)': + dependencies: + '@volar/language-core': 2.4.10 + '@vue/compiler-dom': 3.5.11 + '@vue/compiler-vue2': 2.7.16 + '@vue/shared': 3.5.11 + alien-signals: 0.2.1 + minimatch: 9.0.5 + muggle-string: 0.4.1 + path-browserify: 1.0.1 + optionalDependencies: + typescript: 5.6.3 + '@vue/reactivity@3.5.11': dependencies: '@vue/shared': 3.5.11 @@ -8300,6 +8396,8 @@ snapshots: json-schema-traverse: 1.0.0 require-from-string: 2.0.2 + alien-signals@0.2.1: {} + ansi-escapes@4.3.2: dependencies: type-fest: 0.21.3 @@ -8957,6 +9055,8 @@ snapshots: dayjs@1.11.13: {} + de-indent@1.0.2: {} + debug@2.6.9: dependencies: ms: 2.0.0 @@ -10844,6 +10944,8 @@ snapshots: ms@2.1.3: {} + muggle-string@0.4.1: {} + multicast-dns-service-types@1.1.0: optional: true @@ -11134,6 +11236,8 @@ snapshots: tslib: 2.7.0 optional: true + path-browserify@1.0.1: {} + path-exists@4.0.0: {} path-is-absolute@1.0.1: {} @@ -12353,6 +12457,8 @@ snapshots: stylus: 0.55.0 terser: 5.34.1 + vscode-uri@3.0.8: {} + vue-demi@0.14.10(vue@3.5.11(typescript@5.6.3)): dependencies: vue: 3.5.11(typescript@5.6.3) @@ -12379,6 +12485,13 @@ snapshots: optionalDependencies: vue: 3.5.11(typescript@5.6.3) + vue-tsc@2.1.10(typescript@5.6.3): + dependencies: + '@volar/typescript': 2.4.10 + '@vue/language-core': 2.1.10(typescript@5.6.3) + semver: 7.6.3 + typescript: 5.6.3 + vue@3.5.11(typescript@5.6.3): dependencies: '@vue/compiler-dom': 3.5.11 diff --git a/src/utils/cookie.ts b/src/utils/cookie.ts deleted file mode 100644 index 16f0546d..00000000 --- a/src/utils/cookie.ts +++ /dev/null @@ -1,51 +0,0 @@ -interface ICookie { - Key: string; - Value: string; - Expires: Date; - MaxAge: number; -} - -/** - * 把多个 cookie 字符串转换成 cookie 对象 - * 用于读取 cookie 的属性值 - * @param cookies cookie 数组 - * @returns - */ -function ejectCookies(cookies: string[]) { - const sevCookies: ICookie[] = []; - cookies.forEach((cookie) => { - const keyValves = cookie.split(";"); - const ckie: ICookie = { Key: "", Value: "", Expires: new Date(), MaxAge: 0 }; - if (keyValves.length > 0) { - keyValves.forEach((item) => { - const [key, value] = item.split("="); - if (key === "Expires") { - ckie.Expires = new Date(value); - } else if (key === "Max-Age") { - ckie.MaxAge = parseInt(value); - } else if (ckie.Key === "") { - ckie.Key = key; - ckie.Value = value; - } - }); - sevCookies.push(ckie); - } - }); - return sevCookies; -} - -/** - * 把对象数组转化成字符串 - * 在发送请求的时候 - * @param cookies cookie 对象数组 - * @returns - */ -function cookiesToString(cookies: ICookie[]) { - let cookieString = ""; - cookies.forEach((cokie) => { - cookieString += `${cokie.Key}=${cokie.Value};`; - }); - return cookieString; -} - -export { ICookie, ejectCookies, cookiesToString }; diff --git a/src/utils/debounce.ts b/src/utils/debounce.ts deleted file mode 100644 index c3632b2a..00000000 --- a/src/utils/debounce.ts +++ /dev/null @@ -1,12 +0,0 @@ -export function debounce any>(func: T, delay = 1000) { - let timer: number | null = null; - - return function(...args: Parameters) { - if (timer) clearTimeout(timer); - - timer = setTimeout(() => { - timer = null; - func.apply(this, args); - }, delay); - }; -} diff --git a/src/utils/fetch.ts b/src/utils/fetch.ts deleted file mode 100644 index ea0b708c..00000000 --- a/src/utils/fetch.ts +++ /dev/null @@ -1,77 +0,0 @@ -import Taro from "@tarojs/taro"; -import { cookiesToString } from "./cookie"; -import type { ICookie } from "./cookie"; - -interface FetchResult extends Taro.request.SuccessCallbackResult { - cookies?: string[]; -} - -/** - * @deprecated - */ -function get(url: string, cookies?: ICookie[]): Promise { - const header = cookies - ? { - "Content-type": "application/json", - Cookie: cookiesToString(cookies) - } - : { - "Content-type": "application/json" - }; - return new Promise((resolve, reject) => { - Taro.request({ - url: import.meta.env.VITE_HOST + url, - header: header, - mode: "cors", - success: (res) => { - resolve(res); - }, - fail: (e) => { - console.error(e); - reject(); - } - }); - }); -} - -/** - * @deprecated - */ -function postJson( - url: string, - data: any, - cookies?: ICookie[] -): Promise { - return new Promise((resolve, reject) => { - const header = cookies - ? { - "Content-type": "application/json", - Cookie: cookiesToString(cookies) - } - : { - "Content-type": "application/json" - }; - - Taro.request({ - url: import.meta.env.VITE_HOST + url, - data: data ? data : undefined, - header: header, - method: "POST", - mode: "cors", - success: (res) => { - resolve(res); - }, - fail: (e) => { - console.error(e); - reject(); - } - }); - }); -} - -const fetch = { - get: get, - post: postJson -}; - -export { fetch, FetchResult }; diff --git a/src/utils/index.ts b/src/utils/index.ts index c90b639c..849ef707 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,24 +1,13 @@ -import { cookiesToString, ejectCookies } from "./cookie"; import { getCopyRight } from "./effects"; -import { fetch } from "./fetch"; import timeUtils from "./time"; -import type { ICookie } from "./cookie"; -import type { FetchResult } from "./fetch"; -import { debounce } from "./debounce"; import request from "./request/requestImpl"; import RequestError, { ServiceErrorCode, MPErrorCode } from "./request/requestError"; import CookieUtils from "./request/cookie"; import { persistedStorage } from "./storage"; export { - ICookie, - FetchResult, - ejectCookies, - cookiesToString, getCopyRight, - fetch, timeUtils, - debounce, request, ServiceErrorCode, MPErrorCode, diff --git a/tsconfig.json b/tsconfig.json index 158c13f9..92c54443 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,6 +17,7 @@ "rootDir": ".", "resolveJsonModule": true, "jsx": "preserve", + "skipLibCheck": true, "typeRoots": [ "node_modules/@types", ],