Jelajahi Sumber

Auto merge base into main

GitHub Actions 1 tahun lalu
induk
melakukan
f15cf96adc

+ 3 - 1
openapi-ts-request.config.ts

@@ -4,8 +4,10 @@ export default [
   {
     schemaPath: 'http://petstore.swagger.io/v2/swagger.json',
     serversPath: './src/service/app',
-    requestLibPath: `import { request } from '@/utils/http';\n import { CustomRequestOptions } from '@/interceptors/request';`,
+    requestLibPath: `import request from '@/utils/request';\n import { CustomRequestOptions } from '@/interceptors/request';`,
     requestOptionsType: 'CustomRequestOptions',
+    isGenReactQuery: true,
+    reactQueryMode: 'vue',
     isGenJavaScript: false,
   },
 ] as GenerateServiceProps[]

+ 1 - 1
package.json

@@ -153,7 +153,7 @@
     "eslint-plugin-vue": "^9.32.0",
     "husky": "^8.0.3",
     "lint-staged": "^15.2.10",
-    "openapi-ts-request": "^1.0.1",
+    "openapi-ts-request": "^1.1.2",
     "postcss": "^8.4.49",
     "postcss-html": "^1.7.0",
     "postcss-scss": "^4.0.9",

+ 38 - 105
pnpm-lock.yaml

@@ -193,8 +193,8 @@ importers:
         specifier: ^15.2.10
         version: 15.2.10
       openapi-ts-request:
-        specifier: ^1.0.1
-        version: 1.0.1(@types/node@20.17.9)(@vue/compiler-sfc@3.5.13)(chokidar@3.6.0)(typescript@5.7.2)
+        specifier: ^1.1.2
+        version: 1.1.2(@types/node@20.17.9)(@vue/compiler-sfc@3.5.13)(chokidar@3.6.0)(typescript@5.7.2)
       postcss:
         specifier: ^8.4.49
         version: 8.4.49
@@ -358,10 +358,6 @@ packages:
     resolution: {integrity: sha512-i1SLeK+DzNnQ3LL/CswPCa/E5u4lh1k6IAEphON8F+cXt0t9euTshDru0q7/IqMa1PMPz5RnHuHscF8/ZJsStg==}
     engines: {node: '>=6.9.0'}
 
-  '@babel/generator@7.17.7':
-    resolution: {integrity: sha512-oLcVCTeIFadUoArDTwpluncplrYBmTCCZZgXCbgNGvOBBiSDDK3eWO4b/+eOTli5tKv1lg+a5/NAXg+nTcei1w==}
-    engines: {node: '>=6.9.0'}
-
   '@babel/generator@7.26.2':
     resolution: {integrity: sha512-zevQbhbau95nkoxSq3f/DC/SC+EEOUZd3DYqfSkMhY2/wfSeaHV1Ew4vk8e+x8lja31IbyuUa2uQ3JONqKbysw==}
     engines: {node: '>=6.9.0'}
@@ -395,18 +391,6 @@ packages:
     peerDependencies:
       '@babel/core': ^7.4.0 || ^8.0.0-0 <8.0.0
 
-  '@babel/helper-environment-visitor@7.24.7':
-    resolution: {integrity: sha512-DoiN84+4Gnd0ncbBOM9AZENV4a5ZiL39HYMyZJGZ/AZEykHYdJw0wW3kdcsh9/Kn+BRXHLkkklZ51ecPKmI1CQ==}
-    engines: {node: '>=6.9.0'}
-
-  '@babel/helper-function-name@7.24.7':
-    resolution: {integrity: sha512-FyoJTsj/PEUWu1/TYRiXTIHc8lbw+TDYkZuoE43opPS5TrI7MyONBE1oNvfguEXAD9yhQRrVBnXdXzSLQl9XnA==}
-    engines: {node: '>=6.9.0'}
-
-  '@babel/helper-hoist-variables@7.24.7':
-    resolution: {integrity: sha512-MJJwhkoGy5c4ehfoRyrJ/owKeMl19U54h27YYftT0o2teQ3FJ3nQUf/I3LlJsX4l3qlw7WRXUmiyajvHXoTubQ==}
-    engines: {node: '>=6.9.0'}
-
   '@babel/helper-member-expression-to-functions@7.25.9':
     resolution: {integrity: sha512-wbfdZ9w5vk0C0oyHqAJbc62+vet5prjj01jjJ8sKn3j9h3MQQlflEdXYvuqRWjHnM12coDEqiC1IRCi0U/EKwQ==}
     engines: {node: '>=6.9.0'}
@@ -449,10 +433,6 @@ packages:
     resolution: {integrity: sha512-K4Du3BFa3gvyhzgPcntrkDgZzQaq6uozzcpGbOO1OEJaI+EJdqWIMTLgFgQf6lrfiDFo5FU+BxKepI9RmZqahA==}
     engines: {node: '>=6.9.0'}
 
-  '@babel/helper-split-export-declaration@7.24.7':
-    resolution: {integrity: sha512-oy5V7pD+UvfkEATUKvIjvIAH/xCzfsFVw7ygW2SI6NClZzquT+mwdTfgfdbUiceh6iQO0CHtCPsyze/MZ2YbAA==}
-    engines: {node: '>=6.9.0'}
-
   '@babel/helper-string-parser@7.25.9':
     resolution: {integrity: sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==}
     engines: {node: '>=6.9.0'}
@@ -948,18 +928,10 @@ packages:
     resolution: {integrity: sha512-9DGttpmPvIxBb/2uwpVo3dqJ+O6RooAFOS+lB+xDqoE2PVCE8nfoHMdZLpfCQRLwvohzXISPZcgxt80xLfsuwg==}
     engines: {node: '>=6.9.0'}
 
-  '@babel/traverse@7.23.2':
-    resolution: {integrity: sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==}
-    engines: {node: '>=6.9.0'}
-
   '@babel/traverse@7.25.9':
     resolution: {integrity: sha512-ZCuvfwOwlz/bawvAuvcj8rrithP2/N55Tzz342AkTvq4qaWbGfmCk/tKhNaV2cthijKrPAA8SRJV5WWe7IBMJw==}
     engines: {node: '>=6.9.0'}
 
-  '@babel/types@7.17.0':
-    resolution: {integrity: sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==}
-    engines: {node: '>=6.9.0'}
-
   '@babel/types@7.26.0':
     resolution: {integrity: sha512-Z/yiTPj+lDVnF7lWeKCIJzaIkI0vYO87dMpZ4bg4TDrFe4XXLFWL1TbXU27gBP3QccxV9mZICCrnjnYlJjXHOA==}
     engines: {node: '>=6.9.0'}
@@ -2015,14 +1987,21 @@ packages:
     resolution: {integrity: sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==}
     engines: {node: '>= 6'}
 
-  '@trivago/prettier-plugin-sort-imports@4.3.0':
-    resolution: {integrity: sha512-r3n0onD3BTOVUNPhR4lhVK4/pABGpbA7bW3eumZnYdKaHkf1qEC+Mag6DPbGNuuh0eG8AaYj+YqmVHSiGslaTQ==}
+  '@trivago/prettier-plugin-sort-imports@5.2.1':
+    resolution: {integrity: sha512-NDZndt0fmVThIx/8cExuJHLZagUVzfGCoVrwH9x6aZvwfBdkrDFTYujecek6X2WpG4uUFsVaPg5+aNQPSyjcmw==}
+    engines: {node: '>18.12'}
     peerDependencies:
       '@vue/compiler-sfc': 3.x
       prettier: 2.x - 3.x
+      prettier-plugin-svelte: 3.x
+      svelte: 4.x || 5.x
     peerDependenciesMeta:
       '@vue/compiler-sfc':
         optional: true
+      prettier-plugin-svelte:
+        optional: true
+      svelte:
+        optional: true
 
   '@types/babel__core@7.20.5':
     resolution: {integrity: sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==}
@@ -3161,6 +3140,14 @@ packages:
       cosmiconfig: '>=8.2'
       typescript: '>=4'
 
+  cosmiconfig-typescript-loader@6.1.0:
+    resolution: {integrity: sha512-tJ1w35ZRUiM5FeTzT7DtYWAFFv37ZLqSRkGi2oeCK1gPhvaWjkAtfXvLmvE1pRfxxp9aQo6ba/Pvg1dKj05D4g==}
+    engines: {node: '>=v18'}
+    peerDependencies:
+      '@types/node': '*'
+      cosmiconfig: '>=9'
+      typescript: '>=5'
+
   cosmiconfig@8.3.6:
     resolution: {integrity: sha512-kcZ6+W5QzcJ3P1Mt+83OUv/oHFqZHIx8DuxG6eZ5RGMERoLqp4BuGjhHLYGK+Kf5XVkQvqBSmAy/nGWN3qDgEA==}
     engines: {node: '>=14'}
@@ -4603,6 +4590,10 @@ packages:
     resolution: {integrity: sha512-2yTgeWTWzMWkHu6Jp9NKgePDaYHbntiwvYuuJLbbN9vl7DC9DvXKOB2BC3ZZ92D3cvV/aflH0osDfwpHepQ53w==}
     hasBin: true
 
+  jiti@2.4.2:
+    resolution: {integrity: sha512-rg9zJN+G4n2nfJl5MW3BMygZX56zKPNVEYYqq7adpmMh4Jn2QNEwhvQlFy6jPVdcod7txZtKHWnyZiA3a0zP7A==}
+    hasBin: true
+
   jpeg-js@0.3.7:
     resolution: {integrity: sha512-9IXdWudL61npZjvLuVe/ktHiA41iE8qFyLB+4VDTblEsWBzeg8WQTlktdUK4CdncUqtUgUg0bbOmTE2bKBKaBQ==}
 
@@ -4629,11 +4620,6 @@ packages:
       canvas:
         optional: true
 
-  jsesc@2.5.2:
-    resolution: {integrity: sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==}
-    engines: {node: '>=4'}
-    hasBin: true
-
   jsesc@3.0.2:
     resolution: {integrity: sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g==}
     engines: {node: '>=6'}
@@ -5230,8 +5216,8 @@ packages:
     resolution: {integrity: sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==}
     engines: {node: '>=12'}
 
-  openapi-ts-request@1.0.1:
-    resolution: {integrity: sha512-FcFJssF/820EPkA3g3AklKoT59h1If9CfnzkgV4ct4SJzn7up9V1fGaMoA9im/BTaH6wC8UpMXzE+pwsjaXYfQ==}
+  openapi-ts-request@1.1.2:
+    resolution: {integrity: sha512-Hzqm3JzxgzyGGrTv1THo21HqDea215IQq4I3Ic/WMh/Y+SbmeLb7VQmdeIORPP3Wx836qlTm3X0H10ignkPqfQ==}
     engines: {node: '>=18.0.0', pnpm: '>=9'}
     hasBin: true
 
@@ -5960,10 +5946,6 @@ packages:
   source-map-support@0.5.21:
     resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==}
 
-  source-map@0.5.7:
-    resolution: {integrity: sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==}
-    engines: {node: '>=0.10.0'}
-
   source-map@0.6.1:
     resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==}
     engines: {node: '>=0.10.0'}
@@ -6282,10 +6264,6 @@ packages:
   tmpl@1.0.5:
     resolution: {integrity: sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==}
 
-  to-fast-properties@2.0.0:
-    resolution: {integrity: sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==}
-    engines: {node: '>=4'}
-
   to-regex-range@5.0.1:
     resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}
     engines: {node: '>=8.0'}
@@ -7022,12 +7000,6 @@ snapshots:
     transitivePeerDependencies:
       - supports-color
 
-  '@babel/generator@7.17.7':
-    dependencies:
-      '@babel/types': 7.26.0
-      jsesc: 2.5.2
-      source-map: 0.5.7
-
   '@babel/generator@7.26.2':
     dependencies:
       '@babel/parser': 7.26.2
@@ -7086,19 +7058,6 @@ snapshots:
     transitivePeerDependencies:
       - supports-color
 
-  '@babel/helper-environment-visitor@7.24.7':
-    dependencies:
-      '@babel/types': 7.26.0
-
-  '@babel/helper-function-name@7.24.7':
-    dependencies:
-      '@babel/template': 7.25.9
-      '@babel/types': 7.26.0
-
-  '@babel/helper-hoist-variables@7.24.7':
-    dependencies:
-      '@babel/types': 7.26.0
-
   '@babel/helper-member-expression-to-functions@7.25.9':
     dependencies:
       '@babel/traverse': 7.25.9
@@ -7160,10 +7119,6 @@ snapshots:
     transitivePeerDependencies:
       - supports-color
 
-  '@babel/helper-split-export-declaration@7.24.7':
-    dependencies:
-      '@babel/types': 7.26.0
-
   '@babel/helper-string-parser@7.25.9': {}
 
   '@babel/helper-validator-identifier@7.25.9': {}
@@ -7759,21 +7714,6 @@ snapshots:
       '@babel/parser': 7.26.2
       '@babel/types': 7.26.0
 
-  '@babel/traverse@7.23.2':
-    dependencies:
-      '@babel/code-frame': 7.26.2
-      '@babel/generator': 7.26.2
-      '@babel/helper-environment-visitor': 7.24.7
-      '@babel/helper-function-name': 7.24.7
-      '@babel/helper-hoist-variables': 7.24.7
-      '@babel/helper-split-export-declaration': 7.24.7
-      '@babel/parser': 7.26.2
-      '@babel/types': 7.26.0
-      debug: 4.3.7
-      globals: 11.12.0
-    transitivePeerDependencies:
-      - supports-color
-
   '@babel/traverse@7.25.9':
     dependencies:
       '@babel/code-frame': 7.26.2
@@ -7786,11 +7726,6 @@ snapshots:
     transitivePeerDependencies:
       - supports-color
 
-  '@babel/types@7.17.0':
-    dependencies:
-      '@babel/helper-validator-identifier': 7.25.9
-      to-fast-properties: 2.0.0
-
   '@babel/types@7.26.0':
     dependencies:
       '@babel/helper-string-parser': 7.25.9
@@ -9436,12 +9371,12 @@ snapshots:
 
   '@tootallnate/once@1.1.2': {}
 
-  '@trivago/prettier-plugin-sort-imports@4.3.0(@vue/compiler-sfc@3.5.13)(prettier@3.3.2)':
+  '@trivago/prettier-plugin-sort-imports@5.2.1(@vue/compiler-sfc@3.5.13)(prettier@3.3.2)':
     dependencies:
-      '@babel/generator': 7.17.7
+      '@babel/generator': 7.26.2
       '@babel/parser': 7.26.2
-      '@babel/traverse': 7.23.2
-      '@babel/types': 7.17.0
+      '@babel/traverse': 7.25.9
+      '@babel/types': 7.26.0
       javascript-natural-sort: 0.7.1
       lodash: 4.17.21
       prettier: 3.3.2
@@ -10914,11 +10849,11 @@ snapshots:
       jiti: 1.21.6
       typescript: 5.7.2
 
-  cosmiconfig-typescript-loader@5.1.0(@types/node@20.17.9)(cosmiconfig@9.0.0(typescript@5.7.2))(typescript@5.7.2):
+  cosmiconfig-typescript-loader@6.1.0(@types/node@20.17.9)(cosmiconfig@9.0.0(typescript@5.7.2))(typescript@5.7.2):
     dependencies:
       '@types/node': 20.17.9
       cosmiconfig: 9.0.0(typescript@5.7.2)
-      jiti: 1.21.6
+      jiti: 2.4.2
       typescript: 5.7.2
 
   cosmiconfig@8.3.6(typescript@5.7.2):
@@ -12724,6 +12659,8 @@ snapshots:
 
   jiti@1.21.6: {}
 
+  jiti@2.4.2: {}
+
   jpeg-js@0.3.7: {}
 
   js-tokens@4.0.0: {}
@@ -12773,8 +12710,6 @@ snapshots:
       - supports-color
       - utf-8-validate
 
-  jsesc@2.5.2: {}
-
   jsesc@3.0.2: {}
 
   json-buffer@3.0.1: {}
@@ -13352,16 +13287,16 @@ snapshots:
       is-docker: 2.2.1
       is-wsl: 2.2.0
 
-  openapi-ts-request@1.0.1(@types/node@20.17.9)(@vue/compiler-sfc@3.5.13)(chokidar@3.6.0)(typescript@5.7.2):
+  openapi-ts-request@1.1.2(@types/node@20.17.9)(@vue/compiler-sfc@3.5.13)(chokidar@3.6.0)(typescript@5.7.2):
     dependencies:
       '@prettier/sync': 0.5.2(prettier@3.3.2)
-      '@trivago/prettier-plugin-sort-imports': 4.3.0(@vue/compiler-sfc@3.5.13)(prettier@3.3.2)
+      '@trivago/prettier-plugin-sort-imports': 5.2.1(@vue/compiler-sfc@3.5.13)(prettier@3.3.2)
       axios: 1.7.9
       bing-translate-api: 4.0.2
       chalk: 4.1.2
       commander: 12.1.0
       cosmiconfig: 9.0.0(typescript@5.7.2)
-      cosmiconfig-typescript-loader: 5.1.0(@types/node@20.17.9)(cosmiconfig@9.0.0(typescript@5.7.2))(typescript@5.7.2)
+      cosmiconfig-typescript-loader: 6.1.0(@types/node@20.17.9)(cosmiconfig@9.0.0(typescript@5.7.2))(typescript@5.7.2)
       glob: 11.0.0
       js-yaml: 4.1.0
       lodash: 4.17.21
@@ -13381,7 +13316,9 @@ snapshots:
       - chokidar
       - debug
       - encoding
+      - prettier-plugin-svelte
       - supports-color
+      - svelte
       - typescript
 
   optionator@0.9.4:
@@ -14129,8 +14066,6 @@ snapshots:
       buffer-from: 1.1.2
       source-map: 0.6.1
 
-  source-map@0.5.7: {}
-
   source-map@0.6.1: {}
 
   source-map@0.7.4: {}
@@ -14511,8 +14446,6 @@ snapshots:
 
   tmpl@1.0.5: {}
 
-  to-fast-properties@2.0.0: {}
-
   to-regex-range@5.0.1:
     dependencies:
       is-number: 7.0.0

+ 3 - 8
src/pages/about/components/request.vue

@@ -24,7 +24,7 @@
 
     <!-- http://localhost:9000/#/pages/index/request -->
     <wd-button @click="run" class="my-6">发送请求</wd-button>
-    <view class="h-12">
+    <view class="h-16">
       <view v-if="loading">loading...</view>
       <block v-else>
         <view class="text-xl">请求数据如下</view>
@@ -37,7 +37,7 @@
 
 <script lang="ts" setup>
 import { getFooAPI, postFooAPI, IFooItem } from '@/service/index/foo'
-import { findPetsByStatus } from '@/service/app'
+import { findPetsByStatusQueryOptions } from '@/service/app'
 import { useQuery } from '@tanstack/vue-query'
 
 const recommendUrl = ref('http://laf.run/signup?code=ohaOgIX')
@@ -59,12 +59,7 @@ const {
   error: error2,
   isLoading: isLoading2,
   refetch,
-} = useQuery({
-  queryKey: ['findPetsByStatus'],
-  queryFn: () => {
-    return findPetsByStatus({ params: { status: ['available'] } })
-  },
-})
+} = useQuery(findPetsByStatusQueryOptions({ params: { status: ['available'] } }))
 
 const reset = () => {
   data.value = initialData

+ 5 - 3
src/service/app/displayEnumLabel.ts

@@ -1,11 +1,13 @@
 /* eslint-disable */
 // @ts-ignore
-import * as API from './types'
+import * as API from './types';
 
 export function displayStatusEnum(field: API.IStatusEnum) {
-  return { available: 'available', pending: 'pending', sold: 'sold' }[field]
+  return { available: 'available', pending: 'pending', sold: 'sold' }[field];
 }
 
 export function displayStatusEnum2(field: API.IStatusEnum2) {
-  return { placed: 'placed', approved: 'approved', delivered: 'delivered' }[field]
+  return { placed: 'placed', approved: 'approved', delivered: 'delivered' }[
+    field
+  ];
 }

+ 8 - 5
src/service/app/index.ts

@@ -1,8 +1,11 @@
 /* eslint-disable */
 // @ts-ignore
-export * from './types'
-export * from './displayEnumLabel'
+export * from './types';
+export * from './displayEnumLabel';
 
-export * from './pet'
-export * from './store'
-export * from './user'
+export * from './pet';
+export * from './pet.vuequery';
+export * from './store';
+export * from './store.vuequery';
+export * from './user';
+export * from './user.vuequery';

+ 49 - 43
src/service/app/pet.ts

@@ -1,17 +1,17 @@
 /* eslint-disable */
 // @ts-ignore
-import { request } from '@/utils/http'
-import { CustomRequestOptions } from '@/interceptors/request'
+import request from '@/utils/request';
+import { CustomRequestOptions } from '@/interceptors/request';
 
-import * as API from './types'
+import * as API from './types';
 
 /** Update an existing pet PUT /pet */
 export async function updatePet({
   body,
   options,
 }: {
-  body: API.Pet
-  options?: CustomRequestOptions
+  body: API.Pet;
+  options?: CustomRequestOptions;
 }) {
   return request<unknown>('/pet', {
     method: 'PUT',
@@ -20,11 +20,17 @@ export async function updatePet({
     },
     data: body,
     ...(options || {}),
-  })
+  });
 }
 
 /** Add a new pet to the store POST /pet */
-export async function addPet({ body, options }: { body: API.Pet; options?: CustomRequestOptions }) {
+export async function addPet({
+  body,
+  options,
+}: {
+  body: API.Pet;
+  options?: CustomRequestOptions;
+}) {
   return request<unknown>('/pet', {
     method: 'POST',
     headers: {
@@ -32,7 +38,7 @@ export async function addPet({ body, options }: { body: API.Pet; options?: Custo
     },
     data: body,
     ...(options || {}),
-  })
+  });
 }
 
 /** Find pet by ID Returns a single pet GET /pet/${param0} */
@@ -41,16 +47,16 @@ export async function getPetById({
   options,
 }: {
   // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
-  params: API.getPetByIdParams
-  options?: CustomRequestOptions
+  params: API.getPetByIdParams;
+  options?: CustomRequestOptions;
 }) {
-  const { petId: param0, ...queryParams } = params
+  const { petId: param0, ...queryParams } = params;
 
   return request<API.Pet>(`/pet/${param0}`, {
     method: 'GET',
     params: { ...queryParams },
     ...(options || {}),
-  })
+  });
 }
 
 /** Updates a pet in the store with form data POST /pet/${param0} */
@@ -60,16 +66,16 @@ export async function updatePetWithForm({
   options,
 }: {
   // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
-  params: API.updatePetWithFormParams
+  params: API.updatePetWithFormParams;
   body: {
     /** Updated name of the pet */
-    name?: string
+    name?: string;
     /** Updated status of the pet */
-    status?: string
-  }
-  options?: CustomRequestOptions
+    status?: string;
+  };
+  options?: CustomRequestOptions;
 }) {
-  const { petId: param0, ...queryParams } = params
+  const { petId: param0, ...queryParams } = params;
 
   return request<unknown>(`/pet/${param0}`, {
     method: 'POST',
@@ -79,7 +85,7 @@ export async function updatePetWithForm({
     params: { ...queryParams },
     data: body,
     ...(options || {}),
-  })
+  });
 }
 
 /** Deletes a pet DELETE /pet/${param0} */
@@ -88,16 +94,16 @@ export async function deletePet({
   options,
 }: {
   // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
-  params: API.deletePetParams
-  options?: CustomRequestOptions
+  params: API.deletePetParams;
+  options?: CustomRequestOptions;
 }) {
-  const { petId: param0, ...queryParams } = params
+  const { petId: param0, ...queryParams } = params;
 
   return request<unknown>(`/pet/${param0}`, {
     method: 'DELETE',
     params: { ...queryParams },
     ...(options || {}),
-  })
+  });
 }
 
 /** uploads an image POST /pet/${param0}/uploadImage */
@@ -108,36 +114,36 @@ export async function uploadFile({
   options,
 }: {
   // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
-  params: API.uploadFileParams
+  params: API.uploadFileParams;
   body: {
     /** Additional data to pass to server */
-    additionalMetadata?: string
-  }
-  file?: File
-  options?: CustomRequestOptions
+    additionalMetadata?: string;
+  };
+  file?: File;
+  options?: CustomRequestOptions;
 }) {
-  const { petId: param0, ...queryParams } = params
-  const formData = new FormData()
+  const { petId: param0, ...queryParams } = params;
+  const formData = new FormData();
 
   if (file) {
-    formData.append('file', file)
+    formData.append('file', file);
   }
 
   Object.keys(body).forEach((ele) => {
-    const item = (body as { [key: string]: any })[ele]
+    const item = (body as { [key: string]: any })[ele];
 
     if (item !== undefined && item !== null) {
       if (typeof item === 'object' && !(item instanceof File)) {
         if (item instanceof Array) {
-          item.forEach((f) => formData.append(ele, f || ''))
+          item.forEach((f) => formData.append(ele, f || ''));
         } else {
-          formData.append(ele, JSON.stringify(item))
+          formData.append(ele, JSON.stringify(item));
         }
       } else {
-        formData.append(ele, item)
+        formData.append(ele, item);
       }
     }
-  })
+  });
 
   return request<API.ApiResponse>(`/pet/${param0}/uploadImage`, {
     method: 'POST',
@@ -147,7 +153,7 @@ export async function uploadFile({
     params: { ...queryParams },
     data: formData,
     ...(options || {}),
-  })
+  });
 }
 
 /** Finds Pets by status Multiple status values can be provided with comma separated strings GET /pet/findByStatus */
@@ -156,8 +162,8 @@ export async function findPetsByStatus({
   options,
 }: {
   // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
-  params: API.findPetsByStatusParams
-  options?: CustomRequestOptions
+  params: API.findPetsByStatusParams;
+  options?: CustomRequestOptions;
 }) {
   return request<API.Pet[]>('/pet/findByStatus', {
     method: 'GET',
@@ -165,7 +171,7 @@ export async function findPetsByStatus({
       ...params,
     },
     ...(options || {}),
-  })
+  });
 }
 
 /** Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. GET /pet/findByTags */
@@ -174,8 +180,8 @@ export async function findPetsByTags({
   options,
 }: {
   // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
-  params: API.findPetsByTagsParams
-  options?: CustomRequestOptions
+  params: API.findPetsByTagsParams;
+  options?: CustomRequestOptions;
 }) {
   return request<API.Pet[]>('/pet/findByTags', {
     method: 'GET',
@@ -183,5 +189,5 @@ export async function findPetsByTags({
       ...params,
     },
     ...(options || {}),
-  })
+  });
 }

+ 151 - 0
src/service/app/pet.vuequery.ts

@@ -0,0 +1,151 @@
+/* eslint-disable */
+// @ts-ignore
+import { queryOptions, useMutation } from '@tanstack/vue-query';
+import type { DefaultError } from '@tanstack/vue-query';
+import request from '@/utils/request';
+import { CustomRequestOptions } from '@/interceptors/request';
+
+import * as apis from './pet';
+import * as API from './types';
+
+/** Update an existing pet PUT /pet */
+export function useUpdatePetMutation(options?: {
+  onSuccess?: (value?: unknown) => void;
+  onError?: (error?: DefaultError) => void;
+}) {
+  const { onSuccess, onError } = options || {};
+
+  const response = useMutation({
+    mutationFn: apis.updatePet,
+    onSuccess(data: unknown) {
+      onSuccess?.(data);
+    },
+    onError(error) {
+      onError?.(error);
+    },
+  });
+
+  return response;
+}
+
+/** Add a new pet to the store POST /pet */
+export function useAddPetMutation(options?: {
+  onSuccess?: (value?: unknown) => void;
+  onError?: (error?: DefaultError) => void;
+}) {
+  const { onSuccess, onError } = options || {};
+
+  const response = useMutation({
+    mutationFn: apis.addPet,
+    onSuccess(data: unknown) {
+      onSuccess?.(data);
+    },
+    onError(error) {
+      onError?.(error);
+    },
+  });
+
+  return response;
+}
+
+/** Find pet by ID Returns a single pet GET /pet/${param0} */
+export function getPetByIdQueryOptions(options: {
+  // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
+  params: API.getPetByIdParams;
+  options?: CustomRequestOptions;
+}) {
+  return queryOptions({
+    queryFn: async ({ queryKey }) => {
+      return apis.getPetById(queryKey[1] as typeof options);
+    },
+    queryKey: ['getPetById', options],
+  });
+}
+
+/** Updates a pet in the store with form data POST /pet/${param0} */
+export function useUpdatePetWithFormMutation(options?: {
+  onSuccess?: (value?: unknown) => void;
+  onError?: (error?: DefaultError) => void;
+}) {
+  const { onSuccess, onError } = options || {};
+
+  const response = useMutation({
+    mutationFn: apis.updatePetWithForm,
+    onSuccess(data: unknown) {
+      onSuccess?.(data);
+    },
+    onError(error) {
+      onError?.(error);
+    },
+  });
+
+  return response;
+}
+
+/** Deletes a pet DELETE /pet/${param0} */
+export function useDeletePetMutation(options?: {
+  onSuccess?: (value?: unknown) => void;
+  onError?: (error?: DefaultError) => void;
+}) {
+  const { onSuccess, onError } = options || {};
+
+  const response = useMutation({
+    mutationFn: apis.deletePet,
+    onSuccess(data: unknown) {
+      onSuccess?.(data);
+    },
+    onError(error) {
+      onError?.(error);
+    },
+  });
+
+  return response;
+}
+
+/** uploads an image POST /pet/${param0}/uploadImage */
+export function useUploadFileMutation(options?: {
+  onSuccess?: (value?: API.ApiResponse) => void;
+  onError?: (error?: DefaultError) => void;
+}) {
+  const { onSuccess, onError } = options || {};
+
+  const response = useMutation({
+    mutationFn: apis.uploadFile,
+    onSuccess(data: API.ApiResponse) {
+      onSuccess?.(data);
+    },
+    onError(error) {
+      onError?.(error);
+    },
+  });
+
+  return response;
+}
+
+/** Finds Pets by status Multiple status values can be provided with comma separated strings GET /pet/findByStatus */
+export function findPetsByStatusQueryOptions(options: {
+  // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
+  params: API.findPetsByStatusParams;
+  options?: CustomRequestOptions;
+}) {
+  return queryOptions({
+    queryFn: async ({ queryKey }) => {
+      return apis.findPetsByStatus(queryKey[1] as typeof options);
+    },
+    queryKey: ['findPetsByStatus', options],
+  });
+}
+
+/** Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. GET /pet/findByTags */
+export function findPetsByTagsQueryOptions(options: {
+  // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
+  params: API.findPetsByTagsParams;
+  options?: CustomRequestOptions;
+}) {
+  return queryOptions({
+    queryFn: async ({ queryKey }) => {
+      return apis.findPetsByTags(queryKey[1] as typeof options);
+    },
+    queryKey: ['findPetsByTags', options],
+  });
+}

+ 20 - 16
src/service/app/store.ts

@@ -1,16 +1,20 @@
 /* eslint-disable */
 // @ts-ignore
-import { request } from '@/utils/http'
-import { CustomRequestOptions } from '@/interceptors/request'
+import request from '@/utils/request';
+import { CustomRequestOptions } from '@/interceptors/request';
 
-import * as API from './types'
+import * as API from './types';
 
 /** Returns pet inventories by status Returns a map of status codes to quantities GET /store/inventory */
-export async function getInventory({ options }: { options?: CustomRequestOptions }) {
+export async function getInventory({
+  options,
+}: {
+  options?: CustomRequestOptions;
+}) {
   return request<Record<string, unknown>>('/store/inventory', {
     method: 'GET',
     ...(options || {}),
-  })
+  });
 }
 
 /** Place an order for a pet POST /store/order */
@@ -18,8 +22,8 @@ export async function placeOrder({
   body,
   options,
 }: {
-  body: API.Order
-  options?: CustomRequestOptions
+  body: API.Order;
+  options?: CustomRequestOptions;
 }) {
   return request<API.Order>('/store/order', {
     method: 'POST',
@@ -28,7 +32,7 @@ export async function placeOrder({
     },
     data: body,
     ...(options || {}),
-  })
+  });
 }
 
 /** Find purchase order by ID For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions GET /store/order/${param0} */
@@ -37,16 +41,16 @@ export async function getOrderById({
   options,
 }: {
   // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
-  params: API.getOrderByIdParams
-  options?: CustomRequestOptions
+  params: API.getOrderByIdParams;
+  options?: CustomRequestOptions;
 }) {
-  const { orderId: param0, ...queryParams } = params
+  const { orderId: param0, ...queryParams } = params;
 
   return request<API.Order>(`/store/order/${param0}`, {
     method: 'GET',
     params: { ...queryParams },
     ...(options || {}),
-  })
+  });
 }
 
 /** Delete purchase order by ID For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors DELETE /store/order/${param0} */
@@ -55,14 +59,14 @@ export async function deleteOrder({
   options,
 }: {
   // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
-  params: API.deleteOrderParams
-  options?: CustomRequestOptions
+  params: API.deleteOrderParams;
+  options?: CustomRequestOptions;
 }) {
-  const { orderId: param0, ...queryParams } = params
+  const { orderId: param0, ...queryParams } = params;
 
   return request<unknown>(`/store/order/${param0}`, {
     method: 'DELETE',
     params: { ...queryParams },
     ...(options || {}),
-  })
+  });
 }

+ 75 - 0
src/service/app/store.vuequery.ts

@@ -0,0 +1,75 @@
+/* eslint-disable */
+// @ts-ignore
+import { queryOptions, useMutation } from '@tanstack/vue-query';
+import type { DefaultError } from '@tanstack/vue-query';
+import request from '@/utils/request';
+import { CustomRequestOptions } from '@/interceptors/request';
+
+import * as apis from './store';
+import * as API from './types';
+
+/** Returns pet inventories by status Returns a map of status codes to quantities GET /store/inventory */
+export function getInventoryQueryOptions(options: {
+  options?: CustomRequestOptions;
+}) {
+  return queryOptions({
+    queryFn: async ({ queryKey }) => {
+      return apis.getInventory(queryKey[1] as typeof options);
+    },
+    queryKey: ['getInventory', options],
+  });
+}
+
+/** Place an order for a pet POST /store/order */
+export function usePlaceOrderMutation(options?: {
+  onSuccess?: (value?: API.Order) => void;
+  onError?: (error?: DefaultError) => void;
+}) {
+  const { onSuccess, onError } = options || {};
+
+  const response = useMutation({
+    mutationFn: apis.placeOrder,
+    onSuccess(data: API.Order) {
+      onSuccess?.(data);
+    },
+    onError(error) {
+      onError?.(error);
+    },
+  });
+
+  return response;
+}
+
+/** Find purchase order by ID For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions GET /store/order/${param0} */
+export function getOrderByIdQueryOptions(options: {
+  // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
+  params: API.getOrderByIdParams;
+  options?: CustomRequestOptions;
+}) {
+  return queryOptions({
+    queryFn: async ({ queryKey }) => {
+      return apis.getOrderById(queryKey[1] as typeof options);
+    },
+    queryKey: ['getOrderById', options],
+  });
+}
+
+/** Delete purchase order by ID For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors DELETE /store/order/${param0} */
+export function useDeleteOrderMutation(options?: {
+  onSuccess?: (value?: unknown) => void;
+  onError?: (error?: DefaultError) => void;
+}) {
+  const { onSuccess, onError } = options || {};
+
+  const response = useMutation({
+    mutationFn: apis.deleteOrder,
+    onSuccess(data: unknown) {
+      onSuccess?.(data);
+    },
+    onError(error) {
+      onError?.(error);
+    },
+  });
+
+  return response;
+}

+ 60 - 60
src/service/app/types.ts

@@ -2,82 +2,82 @@
 // @ts-ignore
 
 export type ApiResponse = {
-  code?: number
-  type?: string
-  message?: string
-}
+  code?: number;
+  type?: string;
+  message?: string;
+};
 
 export type Category = {
-  id?: number
-  name?: string
-}
+  id?: number;
+  name?: string;
+};
 
 export type deleteOrderParams = {
   /** ID of the order that needs to be deleted */
-  orderId: number
-}
+  orderId: number;
+};
 
 export type deletePetParams = {
   /** Pet id to delete */
-  petId: number
-}
+  petId: number;
+};
 
 export type deleteUserParams = {
   /** The name that needs to be deleted */
-  username: string
-}
+  username: string;
+};
 
 export type findPetsByStatusParams = {
   /** Status values that need to be considered for filter */
-  status: ('available' | 'pending' | 'sold')[]
-}
+  status: ('available' | 'pending' | 'sold')[];
+};
 
 export type findPetsByTagsParams = {
   /** Tags to filter by */
-  tags: string[]
-}
+  tags: string[];
+};
 
 export type getOrderByIdParams = {
   /** ID of pet that needs to be fetched */
-  orderId: number
-}
+  orderId: number;
+};
 
 export type getPetByIdParams = {
   /** ID of pet to return */
-  petId: number
-}
+  petId: number;
+};
 
 export type getUserByNameParams = {
   /** The name that needs to be fetched. Use user1 for testing.  */
-  username: string
-}
+  username: string;
+};
 
 export type loginUserParams = {
   /** The user name for login */
-  username: string
+  username: string;
   /** The password for login in clear text */
-  password: string
-}
+  password: string;
+};
 
 export type Order = {
-  id?: number
-  petId?: number
-  quantity?: number
-  shipDate?: string
+  id?: number;
+  petId?: number;
+  quantity?: number;
+  shipDate?: string;
   /** Order Status */
-  status?: 'placed' | 'approved' | 'delivered'
-  complete?: boolean
-}
+  status?: 'placed' | 'approved' | 'delivered';
+  complete?: boolean;
+};
 
 export type Pet = {
-  id?: number
-  category?: Category
-  name: string
-  photoUrls: string[]
-  tags?: Tag[]
+  id?: number;
+  category?: Category;
+  name: string;
+  photoUrls: string[];
+  tags?: Tag[];
   /** pet status in the store */
-  status?: 'available' | 'pending' | 'sold'
-}
+  status?: 'available' | 'pending' | 'sold';
+};
 
 export enum StatusEnum {
   available = 'available',
@@ -85,7 +85,7 @@ export enum StatusEnum {
   sold = 'sold',
 }
 
-export type IStatusEnum = keyof typeof StatusEnum
+export type IStatusEnum = keyof typeof StatusEnum;
 
 export enum StatusEnum2 {
   placed = 'placed',
@@ -93,36 +93,36 @@ export enum StatusEnum2 {
   delivered = 'delivered',
 }
 
-export type IStatusEnum2 = keyof typeof StatusEnum2
+export type IStatusEnum2 = keyof typeof StatusEnum2;
 
 export type Tag = {
-  id?: number
-  name?: string
-}
+  id?: number;
+  name?: string;
+};
 
 export type updatePetWithFormParams = {
   /** ID of pet that needs to be updated */
-  petId: number
-}
+  petId: number;
+};
 
 export type updateUserParams = {
   /** name that need to be updated */
-  username: string
-}
+  username: string;
+};
 
 export type uploadFileParams = {
   /** ID of pet to update */
-  petId: number
-}
+  petId: number;
+};
 
 export type User = {
-  id?: number
-  username?: string
-  firstName?: string
-  lastName?: string
-  email?: string
-  password?: string
-  phone?: string
+  id?: number;
+  username?: string;
+  firstName?: string;
+  lastName?: string;
+  email?: string;
+  password?: string;
+  phone?: string;
   /** User Status */
-  userStatus?: number
-}
+  userStatus?: number;
+};

+ 34 - 30
src/service/app/user.ts

@@ -1,17 +1,17 @@
 /* eslint-disable */
 // @ts-ignore
-import { request } from '@/utils/http'
-import { CustomRequestOptions } from '@/interceptors/request'
+import request from '@/utils/request';
+import { CustomRequestOptions } from '@/interceptors/request';
 
-import * as API from './types'
+import * as API from './types';
 
 /** Create user This can only be done by the logged in user. 返回值: successful operation POST /user */
 export async function createUser({
   body,
   options,
 }: {
-  body: API.User
-  options?: CustomRequestOptions
+  body: API.User;
+  options?: CustomRequestOptions;
 }) {
   return request<unknown>('/user', {
     method: 'POST',
@@ -20,7 +20,7 @@ export async function createUser({
     },
     data: body,
     ...(options || {}),
-  })
+  });
 }
 
 /** Get user by user name GET /user/${param0} */
@@ -29,16 +29,16 @@ export async function getUserByName({
   options,
 }: {
   // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
-  params: API.getUserByNameParams
-  options?: CustomRequestOptions
+  params: API.getUserByNameParams;
+  options?: CustomRequestOptions;
 }) {
-  const { username: param0, ...queryParams } = params
+  const { username: param0, ...queryParams } = params;
 
   return request<API.User>(`/user/${param0}`, {
     method: 'GET',
     params: { ...queryParams },
     ...(options || {}),
-  })
+  });
 }
 
 /** Updated user This can only be done by the logged in user. PUT /user/${param0} */
@@ -48,11 +48,11 @@ export async function updateUser({
   options,
 }: {
   // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
-  params: API.updateUserParams
-  body: API.User
-  options?: CustomRequestOptions
+  params: API.updateUserParams;
+  body: API.User;
+  options?: CustomRequestOptions;
 }) {
-  const { username: param0, ...queryParams } = params
+  const { username: param0, ...queryParams } = params;
 
   return request<unknown>(`/user/${param0}`, {
     method: 'PUT',
@@ -62,7 +62,7 @@ export async function updateUser({
     params: { ...queryParams },
     data: body,
     ...(options || {}),
-  })
+  });
 }
 
 /** Delete user This can only be done by the logged in user. DELETE /user/${param0} */
@@ -71,16 +71,16 @@ export async function deleteUser({
   options,
 }: {
   // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
-  params: API.deleteUserParams
-  options?: CustomRequestOptions
+  params: API.deleteUserParams;
+  options?: CustomRequestOptions;
 }) {
-  const { username: param0, ...queryParams } = params
+  const { username: param0, ...queryParams } = params;
 
   return request<unknown>(`/user/${param0}`, {
     method: 'DELETE',
     params: { ...queryParams },
     ...(options || {}),
-  })
+  });
 }
 
 /** Creates list of users with given input array 返回值: successful operation POST /user/createWithArray */
@@ -88,8 +88,8 @@ export async function createUsersWithArrayInput({
   body,
   options,
 }: {
-  body: API.User[]
-  options?: CustomRequestOptions
+  body: API.User[];
+  options?: CustomRequestOptions;
 }) {
   return request<unknown>('/user/createWithArray', {
     method: 'POST',
@@ -98,7 +98,7 @@ export async function createUsersWithArrayInput({
     },
     data: body,
     ...(options || {}),
-  })
+  });
 }
 
 /** Creates list of users with given input array 返回值: successful operation POST /user/createWithList */
@@ -106,8 +106,8 @@ export async function createUsersWithListInput({
   body,
   options,
 }: {
-  body: API.User[]
-  options?: CustomRequestOptions
+  body: API.User[];
+  options?: CustomRequestOptions;
 }) {
   return request<unknown>('/user/createWithList', {
     method: 'POST',
@@ -116,7 +116,7 @@ export async function createUsersWithListInput({
     },
     data: body,
     ...(options || {}),
-  })
+  });
 }
 
 /** Logs user into the system GET /user/login */
@@ -125,8 +125,8 @@ export async function loginUser({
   options,
 }: {
   // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
-  params: API.loginUserParams
-  options?: CustomRequestOptions
+  params: API.loginUserParams;
+  options?: CustomRequestOptions;
 }) {
   return request<string>('/user/login', {
     method: 'GET',
@@ -134,13 +134,17 @@ export async function loginUser({
       ...params,
     },
     ...(options || {}),
-  })
+  });
 }
 
 /** Logs out current logged in user session 返回值: successful operation GET /user/logout */
-export async function logoutUser({ options }: { options?: CustomRequestOptions }) {
+export async function logoutUser({
+  options,
+}: {
+  options?: CustomRequestOptions;
+}) {
   return request<unknown>('/user/logout', {
     method: 'GET',
     ...(options || {}),
-  })
+  });
 }

+ 149 - 0
src/service/app/user.vuequery.ts

@@ -0,0 +1,149 @@
+/* eslint-disable */
+// @ts-ignore
+import { queryOptions, useMutation } from '@tanstack/vue-query';
+import type { DefaultError } from '@tanstack/vue-query';
+import request from '@/utils/request';
+import { CustomRequestOptions } from '@/interceptors/request';
+
+import * as apis from './user';
+import * as API from './types';
+
+/** Create user This can only be done by the logged in user. 返回值: successful operation POST /user */
+export function useCreateUserMutation(options?: {
+  onSuccess?: (value?: unknown) => void;
+  onError?: (error?: DefaultError) => void;
+}) {
+  const { onSuccess, onError } = options || {};
+
+  const response = useMutation({
+    mutationFn: apis.createUser,
+    onSuccess(data: unknown) {
+      onSuccess?.(data);
+    },
+    onError(error) {
+      onError?.(error);
+    },
+  });
+
+  return response;
+}
+
+/** Get user by user name GET /user/${param0} */
+export function getUserByNameQueryOptions(options: {
+  // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
+  params: API.getUserByNameParams;
+  options?: CustomRequestOptions;
+}) {
+  return queryOptions({
+    queryFn: async ({ queryKey }) => {
+      return apis.getUserByName(queryKey[1] as typeof options);
+    },
+    queryKey: ['getUserByName', options],
+  });
+}
+
+/** Updated user This can only be done by the logged in user. PUT /user/${param0} */
+export function useUpdateUserMutation(options?: {
+  onSuccess?: (value?: unknown) => void;
+  onError?: (error?: DefaultError) => void;
+}) {
+  const { onSuccess, onError } = options || {};
+
+  const response = useMutation({
+    mutationFn: apis.updateUser,
+    onSuccess(data: unknown) {
+      onSuccess?.(data);
+    },
+    onError(error) {
+      onError?.(error);
+    },
+  });
+
+  return response;
+}
+
+/** Delete user This can only be done by the logged in user. DELETE /user/${param0} */
+export function useDeleteUserMutation(options?: {
+  onSuccess?: (value?: unknown) => void;
+  onError?: (error?: DefaultError) => void;
+}) {
+  const { onSuccess, onError } = options || {};
+
+  const response = useMutation({
+    mutationFn: apis.deleteUser,
+    onSuccess(data: unknown) {
+      onSuccess?.(data);
+    },
+    onError(error) {
+      onError?.(error);
+    },
+  });
+
+  return response;
+}
+
+/** Creates list of users with given input array 返回值: successful operation POST /user/createWithArray */
+export function useCreateUsersWithArrayInputMutation(options?: {
+  onSuccess?: (value?: unknown) => void;
+  onError?: (error?: DefaultError) => void;
+}) {
+  const { onSuccess, onError } = options || {};
+
+  const response = useMutation({
+    mutationFn: apis.createUsersWithArrayInput,
+    onSuccess(data: unknown) {
+      onSuccess?.(data);
+    },
+    onError(error) {
+      onError?.(error);
+    },
+  });
+
+  return response;
+}
+
+/** Creates list of users with given input array 返回值: successful operation POST /user/createWithList */
+export function useCreateUsersWithListInputMutation(options?: {
+  onSuccess?: (value?: unknown) => void;
+  onError?: (error?: DefaultError) => void;
+}) {
+  const { onSuccess, onError } = options || {};
+
+  const response = useMutation({
+    mutationFn: apis.createUsersWithListInput,
+    onSuccess(data: unknown) {
+      onSuccess?.(data);
+    },
+    onError(error) {
+      onError?.(error);
+    },
+  });
+
+  return response;
+}
+
+/** Logs user into the system GET /user/login */
+export function loginUserQueryOptions(options: {
+  // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
+  params: API.loginUserParams;
+  options?: CustomRequestOptions;
+}) {
+  return queryOptions({
+    queryFn: async ({ queryKey }) => {
+      return apis.loginUser(queryKey[1] as typeof options);
+    },
+    queryKey: ['loginUser', options],
+  });
+}
+
+/** Logs out current logged in user session 返回值: successful operation GET /user/logout */
+export function logoutUserQueryOptions(options: {
+  options?: CustomRequestOptions;
+}) {
+  return queryOptions({
+    queryFn: async ({ queryKey }) => {
+      return apis.logoutUser(queryKey[1] as typeof options);
+    },
+    queryKey: ['logoutUser', options],
+  });
+}

+ 0 - 28
src/utils/http.ts

@@ -78,31 +78,3 @@ export const httpPost = <T>(
 
 http.get = httpGet
 http.post = httpPost
-
-/*
- * openapi-ts-request 工具的 request 跨客户端适配方法
- */
-export const request = <T = unknown>(
-  url: string,
-  options: Omit<CustomRequestOptions, 'url'> & {
-    params?: Record<string, unknown>
-    headers?: Record<string, unknown>
-  },
-) => {
-  const requestOptions = {
-    url,
-    ...options,
-  }
-
-  if (options.params) {
-    requestOptions.query = requestOptions.params
-    delete requestOptions.params
-  }
-
-  if (options.headers) {
-    requestOptions.header = options.headers
-    delete requestOptions.headers
-  }
-
-  return http<T>(requestOptions)
-}

+ 76 - 0
src/utils/request.ts

@@ -0,0 +1,76 @@
+import { CustomRequestOptions } from '@/interceptors/request'
+
+/**
+ * 请求方法: 主要是对 uni.request 的封装,去适配 openapi-ts-request 的 request 方法
+ * @param options 请求参数
+ * @returns 返回 Promise 对象
+ */
+const http = <T>(options: CustomRequestOptions) => {
+  // 1. 返回 Promise 对象
+  return new Promise<T>((resolve, reject) => {
+    uni.request({
+      ...options,
+      dataType: 'json',
+      // #ifndef MP-WEIXIN
+      responseType: 'json',
+      // #endif
+      // 响应成功
+      success(res) {
+        // 状态码 2xx,参考 axios 的设计
+        if (res.statusCode >= 200 && res.statusCode < 300) {
+          // 2.1 提取核心数据 res.data
+          resolve(res.data as T)
+        } else if (res.statusCode === 401) {
+          // 401错误  -> 清理用户信息,跳转到登录页
+          // userStore.clearUserInfo()
+          // uni.navigateTo({ url: '/pages/login/login' })
+          reject(res)
+        } else {
+          // 其他错误 -> 根据后端错误信息轻提示
+          !options.hideErrorToast &&
+            uni.showToast({
+              icon: 'none',
+              title: (res.data as T & { msg?: string })?.msg || '请求错误',
+            })
+          reject(res)
+        }
+      },
+      // 响应失败
+      fail(err) {
+        uni.showToast({
+          icon: 'none',
+          title: '网络错误,换个网络试试',
+        })
+        reject(err)
+      },
+    })
+  })
+}
+
+/*
+ * openapi-ts-request 工具的 request 跨客户端适配方法
+ */
+export default function request<T = unknown>(
+  url: string,
+  options: Omit<CustomRequestOptions, 'url'> & {
+    params?: Record<string, unknown>
+    headers?: Record<string, unknown>
+  },
+) {
+  const requestOptions = {
+    url,
+    ...options,
+  }
+
+  if (options.params) {
+    requestOptions.query = requestOptions.params
+    delete requestOptions.params
+  }
+
+  if (options.headers) {
+    requestOptions.header = options.headers
+    delete requestOptions.headers
+  }
+
+  return http<T>(requestOptions)
+}