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

refactor(store): 使用pinia重构仓库 #134

Conversation

xixiIBN5100
Copy link
Collaborator

@xixiIBN5100 xixiIBN5100 linked an issue Oct 18, 2024 that may be closed by this pull request
Copy link
Collaborator

@j10ccc j10ccc left a comment

Choose a reason for hiding this comment

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

这么写是吧?我以为你会给每个业务模块拆出来作为一个 store,你现在还是分的 service 和 system。先这样吧

@xixiIBN5100
Copy link
Collaborator Author

这么写是吧?我以为你会给每个业务模块拆出来作为一个 store,你现在还是分的 service 和 system。先这样吧

其实两种都可以,我觉得全拆开会好一点,那就拆开写吧,套一层有种脱裤子放屁的感觉

Comment on lines 15 to 16
useSystemStore,
useServiceStore
Copy link
Collaborator

Choose a reason for hiding this comment

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

这两个函数在这了,为什么还要给他套一个 useMainStore?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

主要是想把所有仓库整合到一起,之前是这么开发的,有点繁琐了,我之后把这一层去掉

@j10ccc
Copy link
Collaborator

j10ccc commented Oct 18, 2024

这么写是吧?我以为你会给每个业务模块拆出来作为一个 store,你现在还是分的 service 和 system。先这样吧

其实两种都可以,我觉得全拆开会好一点,那就拆开写吧,套一层有种脱裤子放屁的感觉

先按你这样写吧,这样改动成本小,风险小。后面碰到具体业务的时候,再把这个业务对应的模块拆出来。

如果一次性拆完的话,所有用户在整个 app 范围内都要丢一次缓存。后面慢慢拆的话,业务模块更新了,一个模块丢缓存用户反馈应该不会太强。

你这次这样拆成两块也会丢缓存,但是粒度比较粗,方便给原来的缓存迁移过来。从 vuex 这个 key 下面拿到缓存,然后把 service 和 system 两个大对象拿出来,写到新的缓存项,然后给 vuex 这条缓存记录删掉。这部分逻辑在 app.use() 之前执行。你看这个缓存移植方案行不?

@xixiIBN5100
Copy link
Collaborator Author

这么写是吧?我以为你会给每个业务模块拆出来作为一个 store,你现在还是分的 service 和 system。先这样吧

其实两种都可以,我觉得全拆开会好一点,那就拆开写吧,套一层有种脱裤子放屁的感觉

先按你这样写吧,这样改动成本小,风险小。后面碰到具体业务的时候,再把这个业务对应的模块拆出来。

如果一次性拆完的话,所有用户在整个 app 范围内都要丢一次缓存。后面慢慢拆的话,业务模块更新了,一个模块丢缓存用户反馈应该不会太强。

你这次这样拆成两块也会丢缓存,但是粒度比较粗,方便给原来的缓存迁移过来。从 vuex 这个 key 下面拿到缓存,然后把 service 和 system 两个大对象拿出来,写到新的缓存项,然后给 vuex 这条缓存记录删掉。这部分逻辑在 app.use() 之前执行。你看这个缓存移植方案行不?

我觉得没问题

package.json Outdated
"babel-preset-taro": "3.6.8",
"css-loader": "3.4.2",
"dotenv": "^16.0.3",
"eslint": "^9.12.0",
"eslint-import-resolver-typescript": "^3.6.3",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-vue": "^9.28.0",
"eslint-plugin-vue": "^9.29.0",
Copy link
Collaborator

Choose a reason for hiding this comment

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

给这个更新了干啥?

@j10ccc
Copy link
Collaborator

j10ccc commented Oct 20, 2024

你快点合进来吧,小步快走,别问题都累计在一个 pr 上

@xixiIBN5100 xixiIBN5100 marked this pull request as ready for review October 20, 2024 09:45
@xixiIBN5100 xixiIBN5100 force-pushed the refactor/state-manage-hookify branch from 0800799 to d97375c Compare October 20, 2024 12:11
@xixiIBN5100
Copy link
Collaborator Author

CI报错是lint问题,用store.commit的地方太多了,要不先把这个pr合掉

@j10ccc
Copy link
Collaborator

j10ccc commented Oct 20, 2024

CI报错是lint问题,用store.commit的地方太多了,要不先把这个pr合掉

这不是 lint 问题啊,你把 store 都删了哪里还是 lint 问题,那几个模块逻辑都不正常了。

早知道你这问题了,直接合吧,后面解决

@j10ccc j10ccc closed this Oct 20, 2024
@j10ccc j10ccc force-pushed the refactor/state-manage-hookify branch from b11574b to 1487388 Compare October 20, 2024 14:54
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.

【方案设计】状态管理从 vuex 迁移至 pinia
2 participants