feat(release): bump version to 0.1.2

## 详细信息
- 升级项目版本号到 0.1.2
- 增强刷课稳定性(失败重试、心跳检测、状态自动纠正)
- 优化账号页与工作台紧凑布局,增加已学/未学区分与记录筛选
- 新增首次进入更新检查、更新日志弹窗与在线下载/回退 Release 跳转
This commit is contained in:
2026-04-02 22:33:04 +08:00
parent a061123e36
commit 58555c5043
12 changed files with 1569 additions and 413 deletions

View File

@@ -35,6 +35,38 @@ type SettingsState = {
};
const accountStorageKey = "account-storage";
type PersistedStorage = {
state?: Record<string, unknown>;
version?: number;
};
const patchAccountStorage = (
patcher: (state: Record<string, unknown>) => Record<string, unknown>,
) => {
const rawValue = localStorage.getItem(accountStorageKey);
if (!rawValue) {
return;
}
try {
const parsedValue = JSON.parse(rawValue) as PersistedStorage;
const currentState =
parsedValue.state && typeof parsedValue.state === "object"
? parsedValue.state
: {};
const nextState = patcher(currentState);
localStorage.setItem(
accountStorageKey,
JSON.stringify({
...parsedValue,
state: nextState,
}),
);
} catch {
localStorage.removeItem(accountStorageKey);
}
};
const uniqueHosts = (hosts: HostOption[]) => {
const map = new Map<string, HostOption>();
@@ -74,26 +106,59 @@ export const settingsStore = createStore<SettingsState>()(
if (section === "accounts") set({ persistAccounts: value });
if (section === "records") set({ persistRecords: value });
if (section === "logs") set({ persistLogs: value });
if (!value) {
queueMicrotask(() => get().clearPersistedSection(section));
}
},
clearPersistedSection: (section) => {
if (section === "accounts") {
localStorage.removeItem(accountStorageKey);
patchAccountStorage((state) => {
const {
accounts,
selectedAccountId,
expandedAccountId,
selectedCourseId,
records,
recordCacheMap,
studyLogsMap,
runningStudyMap,
...rest
} = state;
void accounts;
void selectedAccountId;
void expandedAccountId;
void selectedCourseId;
void records;
void recordCacheMap;
void studyLogsMap;
void runningStudyMap;
return rest;
});
}
if (section === "records") {
set({ persistRecords: false });
queueMicrotask(() => set({ persistRecords: true }));
patchAccountStorage((state) => {
const { records, recordCacheMap, selectedCourseId, ...rest } =
state;
void records;
void recordCacheMap;
void selectedCourseId;
return rest;
});
}
if (section === "logs") {
set({ persistLogs: false });
queueMicrotask(() => set({ persistLogs: true }));
patchAccountStorage((state) => {
const { studyLogsMap, runningStudyMap, ...rest } = state;
void studyLogsMap;
void runningStudyMap;
return rest;
});
}
},
clearAllPersistedData: () => {
localStorage.removeItem(accountStorageKey);
get().clearPersistedSection("records");
get().clearPersistedSection("logs");
},
setAutoScrollLogs: (value) => set({ autoScrollLogs: value }),
setShowLogTimestamps: (value) => set({ showLogTimestamps: value }),