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

fix: san-store中使用了动态返回的keyMap后报错 #45 #46

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
ChangeLog
========
3.1.8
-------
- [Bugfix]
- Fix bug introduced by san-store 2.2.0
3.1.7
-------
- [Add]
Expand Down
14 changes: 8 additions & 6 deletions packages/backend/src/agents/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ export class StoreAgent extends Agent {
* 页面 import san-store: 创建默认的 store,new Store({name: '__default__'})
*/
case 'store-default-inited': {
let {store} = data;
storeDecorator.handler(store);
if (store.name !== '__default__') {
console.warn('[SAN_DEVTOOLS]: there is must be something bad has happened in san-store');
return;
let store = data.store || data.defaultStore;
if (store) {
storeDecorator.handler(store);
if (store.name !== '__default__') {
console.warn('[SAN_DEVTOOLS]: there is must be something bad has happened in san-store');
return;
}
this.setStore(store);
}
this.setStore(store);
break;
}
/**
Expand Down
6 changes: 5 additions & 1 deletion packages/backend/src/agents/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,14 @@ export class StoreService implements IStoreService {
key = cur.join('.');
value = cur;
}
else {
else if (typeof cur === 'string') {
value = parseName(cur);
key = value.join('.');
}
else if (typeof cur === 'function') {
// TODO:处理 mapState 的 value 为函数
return prev;
}
prev[key] = value;
return prev;
}, this.paths);
Expand Down