feat: 交互优化与代码质量改进

- SvgIcon 改为 PNG 图标方案,组件重命名为 Icon
- 修复 TransactionItem tap 事件名冲突,改为 item-tap
- 修复 Stats 页面切换 tab 时 overview 不更新
- 修复 CategoryIcon bgColor 必填问题
- 修复 ChartWrapper import 顺序
- 修复 budget onDelete 空字符串问题
- 清理 profile 页面未使用 CSS
- 统一所有页面 header 为 sticky 定位
- 修复导航栏返回按钮不统一
- 添加导出功能 loading 状态
- 优化 scroll-into-view 延迟
This commit is contained in:
2026-06-02 16:04:17 +08:00
parent 36baa9a2b5
commit d5e5655b88
34 changed files with 318 additions and 451 deletions

View File

@@ -1,9 +1,5 @@
// API 基础地址 - 上线后改成真实域名
let BASE_URL = 'http://106.14.208.43:3000/api'
if (typeof wx !== 'undefined' && wx.getSystemInfoSync) {
// 微信小程序环境使用 HTTPS 域名(上线后配置)
// BASE_URL = 'https://your-domain.com/api'
}
// API 基础地址
const BASE_URL = 'https://xiaocai.j35.site/api'
interface RequestOptions {
url: string
@@ -48,10 +44,12 @@ export function request<T = any>(options: RequestOptions): Promise<T> {
reject({ code: 40100, message: '未登录' })
}).finally(() => { isRedirectingToLogin = false })
} else {
// 小程序环境重新触发 wx.login
uni.showToast({ title: '请重新登录', icon: 'none' })
setTimeout(() => { reLogin(); isRedirectingToLogin = false }, 1500)
reject({ code: 40100, message: '未登录' })
// 小程序环境自动重新登录
reLogin().then(() => {
request(options).then(resolve).catch(reject)
}).catch(() => {
reject({ code: 40100, message: '未登录' })
}).finally(() => { isRedirectingToLogin = false })
}
} else {
reject({ code: 40100, message: '未登录' })
@@ -76,25 +74,38 @@ export function request<T = any>(options: RequestOptions): Promise<T> {
}
// 微信小程序自动重新登录
function reLogin() {
// #ifdef MP-WEIXIN
uni.login({
provider: 'weixin',
success: async (loginRes) => {
if (loginRes.code) {
try {
const data = await request<{ token: string; userId: number }>({
url: '/auth/login',
method: 'POST',
data: { code: loginRes.code }
})
uni.setStorageSync('xc:token', data.token)
uni.setStorageSync('xc:userId', data.userId)
} catch (e) {
console.error('[Auth] Re-login failed:', e)
function reLogin(): Promise<void> {
return new Promise((resolve, reject) => {
// #ifdef MP-WEIXIN
uni.login({
provider: 'weixin',
success: async (loginRes) => {
if (loginRes.code) {
try {
const data = await request<{ token: string; userId: number }>({
url: '/auth/login',
method: 'POST',
data: { code: loginRes.code }
})
uni.setStorageSync('xc:token', data.token)
uni.setStorageSync('xc:userId', data.userId)
resolve()
} catch (e) {
console.error('[Auth] Re-login failed:', e)
reject(e)
}
} else {
reject(new Error('wx.login failed'))
}
},
fail: (err) => {
console.error('[Auth] wx.login failed:', err)
reject(err)
}
}
})
// #endif
// #ifndef MP-WEIXIN
resolve()
// #endif
})
// #endif
}