maa-copilot-frontend
maa-copilot-frontend copied to clipboard
feat: add rating in card
#328 相关
改动后ui表现如下:
如果有代码问题请告诉我,我对react并不熟悉
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.
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会进入,你测试的步骤是什么。
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
把
useOperation()放在OperationCard里的做法会导致大量的额外请求
mutate()的使用方式有误,可以参考上面的解释另外,代码看起来没有经过格式化,建议运行
yarn lint:check:eslint或者在 IDE 里装个 eslint 插件来检查一下
感谢反馈!我来研究一下该怎么修改
@guansss
改了mutate使用key,目前这样行吗?
之前useOperation() 放在 OperationCard 里导致大量的额外请求是mutate造成的,它本身还会有问题吗?
现在 mutate 的用法就没问题了
大量请求不仅仅是 mutate 造成的,列表里每个 useOperation() 都会发送一次请求,比如一页有 10 个作业,本来只需要发 1 个请求,现在要发 11 个 (之前的 mutate 导致每次点赞还会额外发 20 多个)
现在
mutate的用法就没问题了大量请求不仅仅是
mutate造成的,列表里每个useOperation()都会发送一次请求,比如一页有 10 个作业,本来只需要发 1 个请求,现在要发 11 个 (之前的mutate导致每次点赞还会额外发 20 多个)
啊,了解了,我再改改
@guansss
将更新operation的逻辑移到了OperationList中,现在是纯前端表现了,没有同步后端的ratingType,这种表现能接受吗。
另外,useOperations中获得的operations的ratingType都是0,尝试使用getOperation获得到的operation能带有正确的ratingType,这是后端的问题吗,我对排查这个问题没有头绪
@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 感谢解答!看来我需要多了解token、cache相关的知识