Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
lls_program
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2025-09-06 21:05:37 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d4f0ccfcc354623abf9fbd6089540e905b5dc740
d4f0ccfc
1 parent
7af3e9c2
fix: 修复可选链操作符和移除未使用的数据参数
修复多处可选链操作符(?.)的使用问题,并移除微信步数同步中未使用的data参数
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
14 deletions
src/components/PointsCollector.vue
src/components/WeRunAuth.vue
src/pages/Dashboard/index.vue
src/components/PointsCollector.vue
View file @
d4f0ccf
...
...
@@ -79,7 +79,7 @@ const isCollecting = ref(false) // 是否正在收集,防止重复触发
*/
const dynamicFontSize = computed(() => {
const pointsStr = animatedTotalPoints.value + '分'
const length = pointsStr.length
const length = pointsStr
?
.length
// 基础字体大小36rpx,超过6位数开始缩小
if (length <= 6) {
...
...
@@ -107,7 +107,7 @@ const sourceTypeMap = {
* 根据pending_points数据生成漂浮积分项并分配随机位置
*/
const generatePointsData = () => {
if (!props.pendingPoints || props.pendingPoints.length === 0) {
if (!props.pendingPoints || props.pendingPoints
?
.length === 0) {
return [];
}
...
...
@@ -211,7 +211,7 @@ const generatePointsData = () => {
*/
const getItemStyle = (item) => {
const baseSize = 90; // 增大基础尺寸从80到90
const maxValue = Math.max(...(floatingItems.value.map(i => i.points).length > 0 ? floatingItems.value.map(i => i.points) : [1]));
const maxValue = Math.max(...(floatingItems.value.map(i => i.points)
?
.length > 0 ? floatingItems.value.map(i => i.points) : [1]));
const sizeRatio = item.points / maxValue;
const size = baseSize + (sizeRatio * 50); // 增大最大额外尺寸从40到50
...
...
@@ -222,7 +222,7 @@ const getItemStyle = (item) => {
// 根据圆圈大小和文字长度计算合适的字体大小
const labelLength = item.sourceLabel?.length || 0;
const pointsLength = (item.points + '分').length;
const pointsLength = (item.points + '分')
?
.length;
// 优化字体计算:根据圆圈大小和文字长度动态调整
let dynamicFontSize = Math.max(
...
...
@@ -286,7 +286,7 @@ const collectItem = async (item) => {
animateNumber(animatedTotalPoints.value, newTotal);
floatingItems.value = floatingItems.value.filter(i => i.id !== item.id);
if (floatingItems.value.length === 0) {
if (floatingItems.value
?
.length === 0) {
emit('collection-complete', newTotal);
}
}, 800); // 动画时长
...
...
@@ -332,7 +332,7 @@ const collectAll = async () => {
}, index * 80); // 依次触发动画
});
const totalAnimationTime = itemsToCollect.length * 80 + 800;
const totalAnimationTime = itemsToCollect
?
.length * 80 + 800;
setTimeout(() => {
// 使用接口返回的最新积分总数
const newTotal = data.new_total_points;
...
...
src/components/WeRunAuth.vue
View file @
d4f0ccf
...
...
@@ -174,17 +174,17 @@ const getWeRunData = async () => {
// 同步微信步数 - 直接调用原始API以获取完整响应
try {
const response = await fetch.post('/srv/?a=point&t=sync_wx_step', { encryptedData: weRunRes.encryptedData, iv: weRunRes.iv });
const { code,
data,
msg } = response.data;
const { code, msg } = response.data;
if (code == 1) {
// 提示获取步数成功
console.warn('同步微信步数成功'
, data
);
console.warn('同步微信步数成功');
// 同步成功,隐藏手动更新按钮
showManualUpdate.value = false;
// 触发步数同步完成事件,通知父组件
emit('steps-synced'
, data
);
emit('steps-synced');
isLoading.value = false
} else {
...
...
src/pages/Dashboard/index.vue
View file @
d4f0ccf
...
...
@@ -280,10 +280,9 @@ const handleAuthChange = (authorized) => {
/**
* 处理微信步数同步完成事件
* @param {Object} data - 同步返回的数据
*/
const handleStepsSynced = async (
data
) => {
console.log('微信步数同步完成
:', data
)
const handleStepsSynced = async () => {
console.log('微信步数同步完成
'
)
// 步数同步完成后,重新获取家庭数据
await initPageData()
}
...
...
@@ -342,7 +341,7 @@ const initPageData = async () => {
// 获取今日家庭总步数
familyMembers.value = data.step_ranking || [];
// 根据是否有待收集积分决定显示模式
showTotalPointsOnly.value = !data.pending_points.length;
showTotalPointsOnly.value = !data.pending_points
?
.length;
// 总积分数量从接口获取
finalTotalPoints.value = data.family.total_points || 0;
// 获取用户信息
...
...
@@ -362,7 +361,7 @@ useDidShow(async () => {
const { code, data } = await getMyFamiliesAPI()
if (code) {
// 如果没有加入家庭
if (!data.length) {
if (!data
?
.length) {
Taro.redirectTo({ url: '/pages/Welcome/index' });
return; // 直接返回,不执行后续逻辑
} else {
...
...
Please
register
or
login
to post a comment