refactor(config): 将环境配置文件从 TypeScript 转换为 JavaScript

- 移除 config/env.ts 文件并将环境配置转换为 config/env.js
- 更新 config/index.ts 中的导入路径以匹配新的 JavaScript 文件扩展名
- 修改 src/utils/server.ts 中的开发服务器 URL 配置
- 更新 tsconfig.json 的 include 配置移除 config 目录
- 调整环境配置中的 API 地址设置统一使用生产环境地址
- 更新 .workbuddy/expert-history.json 中的时间戳记录
This commit is contained in:
2026-04-10 01:48:22 +08:00
parent 12917a4766
commit e3181c8ade
16 changed files with 1314 additions and 88 deletions

View File

@@ -1,6 +1,6 @@
import React from 'react'
import React, { useEffect } from 'react'
import {View, Text} from '@tarojs/components'
import {ConfigProvider, Button, Grid, Avatar} from '@nutui/nutui-react-taro'
import {ConfigProvider, Button, Grid, Avatar, Badge} from '@nutui/nutui-react-taro'
import {
User,
Shopping,
@@ -8,11 +8,13 @@ import {
ArrowRight,
Purse,
People,
Scan
Scan,
Setting
} from '@nutui/icons-react-taro'
import {useDealerUser} from '@/hooks/useDealerUser'
import {useUser} from '@/hooks/useUser'
import { useThemeStyles } from '@/hooks/useTheme'
import { useRiderNotification } from '@/hooks/useRiderNotification'
import {businessGradients, cardGradients, gradientUtils} from '@/styles/gradients'
import {updateShopDealerUser} from '@/api/shop/shopDealerUser'
import Taro from '@tarojs/taro'
@@ -27,6 +29,15 @@ const DealerIndex: React.FC = () => {
// 获取用户角色信息
const { hasRole } = useUser()
// 配送员通知功能
const { pendingCount, startPolling, stopPolling, soundEnabled, toggleSound } = useRiderNotification()
// 页面生命周期管理
useEffect(() => {
startPolling()
return () => stopPolling()
}, [startPolling, stopPolling])
// 使用主题样式
const themeStyles = useThemeStyles()
@@ -64,6 +75,55 @@ const DealerIndex: React.FC = () => {
// 判断是否是配送员
const isRider = hasRole('rider')
// 请求订阅消息授权
const handleRequestSubscribeMessage = () => {
// 微信订阅消息模板ID需在微信公众平台配置后替换
const templateIds = [
'YOUR_TEMPLATE_ID', // TODO: 替换为实际的订阅消息模板ID
]
// 过滤出有效的模板ID
const validTemplateIds = templateIds.filter(id => id && !id.includes('YOUR_'))
if (validTemplateIds.length === 0) {
Taro.showModal({
title: '提示',
content: '订阅消息功能尚未配置,请联系管理员',
showCancel: false
})
return
}
// 请求订阅
Taro.requestSubscribeMessage({
tmplIds: validTemplateIds,
success: (res) => {
console.log('订阅消息授权结果:', res)
const accepted = Object.values(res).some(v => v === 'accept')
if (accepted) {
Taro.showToast({
title: '订阅成功',
icon: 'success'
})
// 保存授权状态到本地
Taro.setStorageSync('rider_subscribed', '1')
} else {
Taro.showToast({
title: '您已拒绝订阅',
icon: 'none'
})
}
},
fail: (err) => {
console.error('订阅消息授权失败:', err)
Taro.showToast({
title: '授权失败',
icon: 'none'
})
}
})
}
// 点击待使用金额 - 配送员专用:将冻结金额转入可提现
const handleFreezeMoneyClick = async () => {
// 检查是否是配送员
@@ -284,8 +344,15 @@ const DealerIndex: React.FC = () => {
>
<Grid.Item text="配送订单" onClick={() => navigateToPage('/rider/orders/index')}>
<View className="text-center">
<View className="w-12 h-12 bg-blue-50 rounded-xl flex items-center justify-center mx-auto mb-2">
<View className="w-12 h-12 bg-blue-50 rounded-xl flex items-center justify-center mx-auto mb-2 relative">
<Shopping color="#3b82f6" size="20"/>
{pendingCount > 0 && (
<Badge
value={pendingCount > 99 ? '99+' : pendingCount}
max={99}
style={{ position: 'absolute', top: '-4px', right: '-4px' }}
/>
)}
</View>
</View>
</Grid.Item>
@@ -323,46 +390,96 @@ const DealerIndex: React.FC = () => {
</Grid.Item>
</Grid>
{/* 第二行功能 */}
{/*<Grid*/}
{/* columns={4}*/}
{/* className="no-border-grid mt-4"*/}
{/* style={{*/}
{/* '--nutui-grid-border-color': 'transparent',*/}
{/* '--nutui-grid-item-border-width': '0px',*/}
{/* border: 'none'*/}
{/* } as React.CSSProperties}*/}
{/*>*/}
{/* <Grid.Item text={'邀请统计'} onClick={() => navigateToPage('/dealer/invite-stats/index')}>*/}
{/* <View className="text-center">*/}
{/* <View className="w-12 h-12 bg-indigo-50 rounded-xl flex items-center justify-center mx-auto mb-2">*/}
{/* <Presentation color="#6366f1" size="20"/>*/}
{/* </View>*/}
{/* </View>*/}
{/* </Grid.Item>*/}
{/* 第二行功能 - 通知设置 */}
<Grid
columns={4}
className="no-border-grid mt-4"
style={{
'--nutui-grid-border-color': 'transparent',
'--nutui-grid-item-border-width': '0px',
border: 'none'
} as React.CSSProperties}
>
<Grid.Item text={'通知设置'} onClick={() => {
const isSubscribed = Taro.getStorageSync('rider_subscribed') === '1'
Taro.showModal({
title: '通知设置',
content: `声音提醒:${soundEnabled ? '已开启' : '已关闭'}\n订阅消息${isSubscribed ? '已订阅' : '未订阅'}`,
confirmText: '更多设置',
cancelText: '关闭',
success: (res) => {
if (res.confirm) {
// 显示更多设置选项
Taro.showActionSheet({
itemList: [
soundEnabled ? '关闭声音提醒' : '开启声音提醒',
isSubscribed ? '订阅状态正常' : '订阅消息通知',
'检查更新'
],
success: (sheetRes) => {
if (sheetRes.tapIndex === 0) {
// 切换声音
toggleSound()
Taro.showToast({
title: soundEnabled ? '已关闭声音' : '已开启声音',
icon: 'none'
})
} else if (sheetRes.tapIndex === 1) {
// 订阅消息
if (!isSubscribed) {
handleRequestSubscribeMessage()
} else {
Taro.showToast({
title: '已订阅消息通知',
icon: 'success'
})
}
} else if (sheetRes.tapIndex === 2) {
Taro.showToast({
title: '已是最新版本',
icon: 'success'
})
}
}
})
}
}
})
}}>
<View className="text-center">
<View className="w-12 h-12 bg-indigo-50 rounded-xl flex items-center justify-center mx-auto mb-2 relative">
<Setting color={soundEnabled ? '#6366f1' : '#9ca3af'} size="20"/>
{soundEnabled ? (
<View className="absolute -bottom-1 -right-1 w-3 h-3 bg-green-500 rounded-full border-2 border-white"></View>
) : (
<View className="absolute -bottom-1 -right-1 w-3 h-3 bg-gray-400 rounded-full border-2 border-white"></View>
)}
</View>
</View>
</Grid.Item>
{/* /!* 预留其他功能位置 *!/*/}
{/* <Grid.Item text={''}>*/}
{/* <View className="text-center">*/}
{/* <View className="w-12 h-12 bg-gray-50 rounded-xl flex items-center justify-center mx-auto mb-2">*/}
{/* </View>*/}
{/* </View>*/}
{/* </Grid.Item>*/}
{/* 预留功能位置 */}
<Grid.Item text={''}>
<View className="text-center">
<View className="w-12 h-12 bg-gray-50 rounded-xl flex items-center justify-center mx-auto mb-2">
</View>
</View>
</Grid.Item>
{/* <Grid.Item text={''}>*/}
{/* <View className="text-center">*/}
{/* <View className="w-12 h-12 bg-gray-50 rounded-xl flex items-center justify-center mx-auto mb-2">*/}
{/* </View>*/}
{/* </View>*/}
{/* </Grid.Item>*/}
<Grid.Item text={''}>
<View className="text-center">
<View className="w-12 h-12 bg-gray-50 rounded-xl flex items-center justify-center mx-auto mb-2">
</View>
</View>
</Grid.Item>
{/* <Grid.Item text={''}>*/}
{/* <View className="text-center">*/}
{/* <View className="w-12 h-12 bg-gray-50 rounded-xl flex items-center justify-center mx-auto mb-2">*/}
{/* </View>*/}
{/* </View>*/}
{/* </Grid.Item>*/}
{/*</Grid>*/}
<Grid.Item text={''}>
<View className="text-center">
<View className="w-12 h-12 bg-gray-50 rounded-xl flex items-center justify-center mx-auto mb-2">
</View>
</View>
</Grid.Item>
</Grid>
</ConfigProvider>
</View>
</View>