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

使用Vuex替代globalData #31

Closed
wants to merge 3 commits into from
Closed

Conversation

mayeths
Copy link
Collaborator

@mayeths mayeths commented Nov 13, 2019

前端开发公共事项 #14 中,第三个 Comment 提到了globalData。在 Issue #30 中,阐述了 globalData 的弊端。为此,本 PR 新建了 src/store/文件夹,计划使用 Vuex 替代 globalData。

此外,在 src/commons 文件夹下添加了 api.ts,借鉴了 Promisify.ts。为了搭配使用 Vuex,请将 Promisify 更换为使用 api.ts 里的 ApiService。

mayeths added 2 commits November 8, 2019 16:02
- 在store文件夹下添加了基本Vuex,已经可以正常使用了
- 在commons文件夹下添加了api.ts,借鉴了apps/Promisify.ts。为了使用Vuex,应该尽快
  更换为使用api.ts里的ApiService。
@mayeths mayeths requested a review from Starrah November 13, 2019 14:40
}

async request(method: "GET" | "POST" | "PUT" | "DELETE", resource: string, param: object = {}) {
let res = await new Promise((resolve, reject) => {
Copy link
Owner

Choose a reason for hiding this comment

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

建议增加自动附加session的方法

});
let code = res["statusCode"];
if (code >= 400) throw Error(code);
return res["data"];
Copy link
Owner

Choose a reason for hiding this comment

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

可以考虑把原来promisify里的在errid5xx时showToast加进来?
之后就不用那个promisify了。

@mayeths mayeths closed this Nov 17, 2019
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.

2 participants