Revert "Merge branch 'openapi'"

This reverts commit 9a6f0acdf0, reversing
changes made to 08a81e433b.
This commit is contained in:
feige996
2025-09-23 18:01:20 +08:00
parent 459c665ecb
commit 3b14ab942f
15 changed files with 784 additions and 149 deletions

View File

@@ -3,7 +3,6 @@ import { isApp, isAppAndroid, isAppHarmony, isAppIOS, isAppPlus, isH5, isMpWeixi
import { LOGIN_PAGE } from '@/router/config'
import { useTokenStore } from '@/store'
import { tabbarStore } from '@/tabbar/store'
import RequestCompOpenApi from './components/request-openapi.vue'
import RequestComp from './components/request.vue'
import VBindCss from './components/VBindCss.vue'
@@ -114,7 +113,6 @@ onShow(() => {
</button>
<RequestComp />
<VBindCss />
<RequestCompOpenApi />
<view class="mb-6 h-1px bg-#eee" />
<view class="text-center">
<button type="primary" size="mini" class="w-160px" @click="gotoAlova">

View File

@@ -1,67 +0,0 @@
<script lang="ts" setup>
import type { UserItem } from '@/service'
import { ref } from 'vue'
import useRequest from '@/hooks/useRequest'
import { infoUsingGet } from '@/service/info'
const loading = ref(false)
const error = ref<Error | null>(null)
const data = ref<UserItem>()
async function getUserInfo() {
try {
loading.value = true
// 直接使用openapi生成的请求需要解构获取promise
const { promise } = await infoUsingGet({})
const res = await promise
console.log(res)
data.value = res
error.value = null
}
catch (err) {
error.value = err as Error
data.value = null
}
finally {
loading.value = false
}
}
// 使用openapi + useRequest生成的请求
const { data: data2, loading: loading2, run } = useRequest<UserItem>(() => infoUsingGet({}), {
immediate: false,
})
</script>
<template>
<view class="p-6 text-center">
<view class="my-4 text-center">
1)直接使用 openapi 生成的请求
</view>
<view class="my-4 text-center">
<button type="primary" size="mini" class="w-160px" @click="getUserInfo">
发送请求
</button>
<view class="text-xl">
请求数据如下
</view>
<view class="text-green leading-8">
{{ JSON.stringify(data) }}
</view>
</view>
<view class="my-4 text-center">
2)直接使用 openapi + useRequest 生成的请求
</view>
<view class="my-4 text-center">
<button type="primary" size="mini" class="w-160px" @click="run">
发送请求
</button>
<view class="text-xl">
请求数据如下
</view>
<view class="text-green leading-8">
{{ JSON.stringify(data2) }}
</view>
</view>
</view>
</template>