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

组件重构、解耦与部分bug修复 #45

Merged
merged 20 commits into from
Mar 3, 2025
Merged

Conversation

Autumnal-Joy
Copy link
Collaborator

refactor:

  1. 新增一个useStorage的hook,const [data, setData] = useStorage<DataType>("key", { defaultValue: defaultValue })。调用setData自动更新data并同步到localStorage。支持多个标签页同步更新data。
const useStorage: <T = undefined>(
  key: string,
  options?: {
    type?: "local" | "session";
    defaultValue?: T;
    encryption?: {
      encrypt: (data: string) => string;
      decrypt: (data: string) => string;
    };
  }
) => [T, Dispatch<SetStateAction<T>>];
  1. 用useStorage重构各模块、组件访问localStorage的操作。对于扁平化保存的题目进度数据,即键为`lc-rating-zen-progress-${questionID}`的部分,暂时没有做改动。
  2. 重构useContests的返回值,用对象来代替字段和类型不明确的数组。
  3. 重构useSolutions的返回值,用对象来代替字段和类型不明确的数组。
  4. 重构ListContest组件,提取子组件,props解耦。
  5. 在typescript严格模式下,给大部分any类型更新为更准确的类型,并修复所有的类型错误。

fix:

  1. 修复ProblemCategory类型定义错误。
  2. 修复竞赛列表第一列的checkbox的id相同的错误。
  3. 修复难度练习页面设置弹窗,在取消勾选tag并应用之后,筛选结果出现的错误。
  4. 修复难度练习页面设置弹窗,调用react hook没有放在最顶层的未定义行为错误。
  5. 修复难度练习页面设置弹窗,各个选项的保存行为不一致的问题。

feature:

  1. 题单页面右上角的switcher设置保存到localStorage,占用键名"lc-rating-list-settings"。
  2. 修复难度练习页面设置弹窗,按照进度筛选新增"TODO"的选项。

image

@huxulm huxulm merged commit eaedc8f into huxulm:main Mar 3, 2025
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