Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add mobx-strapi #209

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

feat: add mobx-strapi #209

wants to merge 8 commits into from

Conversation

luojiyin1987
Copy link
Contributor

@luojiyin1987 luojiyin1987 commented Feb 22, 2024

Checklist(清单):

  • Labels
  • Assignees
  • Reviewers

Closes #204

@luojiyin1987 luojiyin1987 self-assigned this Feb 22, 2024
package.json Outdated Show resolved Hide resolved
Copy link
Member

@TechQuery TechQuery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请把整个项目运行起来,看看控制台有没有任何网络接口报错、在后台添加的数据前台能不能显示出来。

models/Activity/Award.ts Show resolved Hide resolved
@@ -22,8 +23,8 @@ export interface AwardAssignment
award: Award;
}

export class AwardModel extends Stream<Award>(ListModel) {
client = sessionStore.client;
export class AwardModel extends Stream<Award>(StrapiListModel) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export class AwardModel extends Stream<Award>(StrapiListModel) {
export class AwardModel extends StrapiListModel<Award> {

Strapi 有能定位到具体页数的分页参数,不需要 Stream 流式加载。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看不懂上面的两次修改

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看不懂上面的两次修改

以前是附加流式加载特性,需要用 mixin(混入)的写法,也就是单继承语言实现多继承。

但 Strapi 不需要流式加载,就直接继承基类即可。

@@ -22,8 +23,8 @@ export interface AwardAssignment
award: Award;
}

export class AwardModel extends Stream<Award>(ListModel) {
client = sessionStore.client;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

此处不要改动,已经配置好登录验证机制的 API 客户端就是放在这个 store 上的。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这我也看不懂了

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这我也看不懂了

先说说你个人的理解。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

原来25 26 行代码是否要改动? 我已经迷糊了。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

原来25 26 行代码是否要改动? 我已经迷糊了。

Screenshot_2024-05-22-21-41-41-623_com.github.android-edit.jpg

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

现在遇到 类型“AwardModel”上不存在属性“baseURI 的报错

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

此处不要改动,已经配置好登录验证机制的 API 客户端就是放在这个 store 上的。

关于 client 的问题是我昏头了,你改为 strapiClient 是对的,是我在迁移阶段还没把 client 移到 sessionStore 上。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

现在遇到 类型“AwardModel”上不存在属性“baseURI 的报错

非流式加载的列表必须声明对应数据结构 API 根路径:
image

参考:https://github.com/idea2app/MobX-RESTful/tree/main/wrapper/Strapi#modelarticlets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

对接后端 v5 API
2 participants