fix(mobile-h5): polish dibang H5 adaptation after typecheck

Simplify App bootstrap, cast HTTP helpers for vue-tsc, and align leftover string ids.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
zlwuandCursor committed 2026-08-03 22:46:54 +08:00
1 parent 5f2a6f2338
commit 012a2ad68e
6 files changed
+22 -48

No files matched your search

+11 -38
View File
@@ -3,36 +3,10 @@
</template>
<script setup lang="ts">
import { onMounted } from 'vue'
import { useUserStore } from '@/store/modules/user'
import { UserService } from '@/api/usersApi'
import { ApiStatus } from '@/utils/http/status'
const userStore = useUserStore()
onMounted(() => {
// 初始化用户状态
if (userStore.isLogin && userStore.accessToken) {
getUserInfo()
}
})
// 获取用户信息
const getUserInfo = async () => {
try {
const userRes = await UserService.getUserInfo()
if (userRes.code === ApiStatus.success) {
userStore.setUserInfo(userRes.data)
} else if (userRes.code === 401) {
userStore.logOut()
}
} catch (error) {
// 静默处理错误
if (userStore.isLogin) {
userStore.logOut()
}
}
}
/**
* 用户信息在登录时写入 Pinia;H5 不额外拉取门户 current-user。
* 401 由 HTTP 拦截器统一处理登出。
*/
</script>
<style lang="scss">
@@ -42,15 +16,14 @@ const getUserInfo = async () => {
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
html,
body,
#app {
width: 100%;
height: 100%;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
background-color: #f5f7fa;
}
#app {
min-height: 100vh;
}
</style>
+2 -2
View File
@@ -72,8 +72,8 @@ dbAxios.interceptors.response.use(
}
)
function request<T = unknown>(config: AxiosRequestConfig) {
return dbAxios.request<any, T>(config)
function request<T = unknown>(config: AxiosRequestConfig): Promise<T> {
return dbAxios.request<any, T>(config) as Promise<T>
}
const db = {
+5 -5
View File
@@ -115,19 +115,19 @@ axiosInstance.interceptors.response.use(
const api = {
get<T = any>(config: AxiosRequestConfig): Promise<T> {
return axiosInstance.request({ ...config, method: 'GET' })
return axiosInstance.request({ ...config, method: 'GET' }) as Promise<T>
},
post<T = any>(config: AxiosRequestConfig): Promise<T> {
return axiosInstance.request({ ...config, method: 'POST' })
return axiosInstance.request({ ...config, method: 'POST' }) as Promise<T>
},
put<T = any>(config: AxiosRequestConfig): Promise<T> {
return axiosInstance.request({ ...config, method: 'PUT' })
return axiosInstance.request({ ...config, method: 'PUT' }) as Promise<T>
},
patch<T = any>(config: AxiosRequestConfig): Promise<T> {
return axiosInstance.request({ ...config, method: 'PATCH' })
return axiosInstance.request({ ...config, method: 'PATCH' }) as Promise<T>
},
del<T = any>(config: AxiosRequestConfig): Promise<T> {
return axiosInstance.request({ ...config, method: 'DELETE' })
return axiosInstance.request({ ...config, method: 'DELETE' }) as Promise<T>
}
}
+2 -1
View File
@@ -376,11 +376,12 @@ const handleCreateSubmit = async () => {
creating.value = true
try {
const p = pageData.value.plan
const productId = p.productId as string
await inventoryApi.create({
date: todayStr,
partnerCompany: p.customerName || '待填写',
businessType: p.businessType,
productId: p.productId,
productId,
quantity: Number(qty),
planNo: p.planNo,
vehicleNo: vehicle,
+1 -1
View File
@@ -104,7 +104,7 @@ const formData = reactive<UserCreate>({
const loadData = async () => {
if (isEdit.value && route.params.id) {
try {
const user = await userApi.get(Number(route.params.id))
const user = await userApi.get(String(route.params.id))
editingUser.value = user
Object.assign(formData, {
username: user.username,
+1 -1
View File
@@ -125,7 +125,7 @@ const handleEdit = (item: User) => {
router.push(`/user/detail/${item.id}?mode=edit`)
}
const handleDelete = (id: number, username: string) => {
const handleDelete = (id: string, username: string) => {
if (username === 'admin') {
showToast({ type: 'fail', message: '不能删除管理员账号' })
return