-
Notifications
You must be signed in to change notification settings - Fork 0
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: add width caculate #120
Changes from 3 commits
b3a4be5
0b26728
4a895ee
38e5517
0a0685f
5a54f23
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,8 @@ export interface GlobalStoreProps { | |
userInfo: UserInfo | null; | ||
goPage(page: PageType): void; | ||
logout(): void; | ||
drawerWidth: number; | ||
backWidth: number; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. emmm,看起来宽度没必要 lift 到全局把 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 主要是想把定时任务的代码都收拢到/content/index.ts中去方便管理。然后宽度这个东西勉强算个全局变量吧,描述的是整体的宽度 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 你放到 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 好的 放到drawer/index.tsx |
||
userVote: Record<string, boolean> | null; | ||
} | ||
|
||
|
@@ -48,6 +50,8 @@ const useGlobalStore = create<GlobalStoreProps>()( | |
page: PageType.Login, | ||
}); | ||
}, | ||
drawerWidth: 0, | ||
backWidth: 0, | ||
userVote: null, | ||
}), | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为啥要定时去算宽度来着
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
之前的计算频率是在onload onresize两个事件触发的时候进行计算。但是onresize不会经常被触发,除非用户手动调整窗口。onload要基于twitter全部加载完成,有时候时间很长,要30秒。其次是还有很多时候用户切换到其他页面等等因素,这两个时机是不够的,因此加入到全局的计算中去。定时计算宽度,如果宽度不变,我认为性能损耗是不高的。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我测试了下,宽度不变定时去 set 也会导致 rerender。而且因为是根节点和到处都用的全局 store,导致整个插件定时的 rerender。感觉 onLoad 够用了,长点的话插件有最小宽度保底问题不大