maa-copilot-frontend icon indicating copy to clipboard operation
maa-copilot-frontend copied to clipboard

feat: add rating in card

Open xxfttkx opened this issue 10 months ago • 11 comments

#328 相关

改动后ui表现如下: image

image

如果有代码问题请告诉我,我对react并不熟悉

xxfttkx avatar Feb 03 '25 17:02 xxfttkx

Also, another problem is that the state of the button requires refreshes, which requires the whole page of opeartions from the server side if my manual tests are undergoing correctly.

martinwang2002 avatar Feb 04 '25 14:02 martinwang2002

Also, another problem is that the state of the button requires refreshes, which requires the whole page of opeartions from the server side if my manual tests are undergoing correctly.

是说点赞的操作会导致别的operation也会从服务器重新获取吗,我在useOperation中打了断点,点赞时发现只有对应id的operation会进入,你测试的步骤是什么。

xxfttkx avatar Feb 04 '25 16:02 xxfttkx

Also, another problem is that the state of the button requires refreshes, which requires the whole page of opeartions from the server side if my manual tests are undergoing correctly.

This is not caused by the update in rating, sorry for my misinterpretation.

这不是由于评分api产生的,不好意思x

martinwang2002 avatar Feb 04 '25 16:02 martinwang2002

useOperation() 放在 OperationCard 里的做法会导致大量的额外请求

mutate() 的使用方式有误,可以参考上面的解释

另外,代码看起来没有经过格式化,建议运行 yarn lint:check:eslint 或者在 IDE 里装个 eslint 插件来检查一下

感谢反馈!我来研究一下该怎么修改

xxfttkx avatar Feb 06 '25 07:02 xxfttkx

@guansss 改了mutate使用key,目前这样行吗?

之前useOperation() 放在 OperationCard 里导致大量的额外请求是mutate造成的,它本身还会有问题吗?

xxfttkx avatar Feb 06 '25 08:02 xxfttkx

现在 mutate 的用法就没问题了

大量请求不仅仅是 mutate 造成的,列表里每个 useOperation() 都会发送一次请求,比如一页有 10 个作业,本来只需要发 1 个请求,现在要发 11 个 (之前的 mutate 导致每次点赞还会额外发 20 多个)

guansss avatar Feb 06 '25 18:02 guansss

现在 mutate 的用法就没问题了

大量请求不仅仅是 mutate 造成的,列表里每个 useOperation() 都会发送一次请求,比如一页有 10 个作业,本来只需要发 1 个请求,现在要发 11 个 (之前的 mutate 导致每次点赞还会额外发 20 多个)

啊,了解了,我再改改

xxfttkx avatar Feb 07 '25 01:02 xxfttkx

@guansss

将更新operation的逻辑移到了OperationList中,现在是纯前端表现了,没有同步后端的ratingType,这种表现能接受吗。

另外,useOperations中获得的operations的ratingType都是0,尝试使用getOperation获得到的operation能带有正确的ratingType,这是后端的问题吗,我对排查这个问题没有头绪

xxfttkx avatar Feb 07 '25 13:02 xxfttkx

@guansss

将更新operation的逻辑移到了OperationList中,现在是纯前端表现了,没有同步后端的ratingType,这种表现能接受吗。

另外,useOperations中获得的operations的ratingType都是0,尝试使用getOperation获得到的operation能带有正确的ratingType,这是后端的问题吗,我对排查这个问题没有头绪

带authorization: Bearer TOKEN 请求的会返回ratingType。

详见: https://github.com/MaaAssistantArknights/MaaBackendCenter/issues/179

https://github.com/MaaAssistantArknights/maa-copilot-frontend/blob/3a48c6104b71935f2eabb9a8ae57ee500ba8ca22/src/apis/operation.ts#L98-L102 以上请求未携带Bearer token

https://github.com/MaaAssistantArknights/maa-copilot-frontend/blob/3a48c6104b71935f2eabb9a8ae57ee500ba8ca22/src/apis/operation.ts#L169-L172 以上请求携带Bearer token,目的是为了获取用户是否获得点赞了该作业

可能需要后端确认一下query api是否支持带token访问,(毕竟有一些有cache)

martinwang2002 avatar Feb 07 '25 15:02 martinwang2002

@martinwang2002 感谢解答!看来我需要多了解token、cache相关的知识

xxfttkx avatar Feb 07 '25 16:02 xxfttkx

后端目前未处理列表页的点赞信息,ref: 列表查询逻辑

要支持该功能,后端需要在查询到数据后(不管是否为缓存中数据)都执行一次点赞信息查询。可以考虑先做上去观察一下会不会出现性能问题。

dragove avatar Feb 09 '25 14:02 dragove