feat(update): add toast notifications for update failures

- Add toast error messages when version check fails
- Show user-friendly error notifications for download failures
- Display specific installation error messages with troubleshooting hints
- Improve logging from console.error to console.info for better categorization
This commit is contained in:
zimplexing
2025-08-13 18:58:32 +08:00
parent df8fae96ac
commit fc81de1728
4 changed files with 21 additions and 12 deletions

View File

@@ -124,7 +124,7 @@ const usePlayerStore = create<PlayerState>((set, get) => ({
try {
await videoRef?.current?.replayAsync();
} catch (error) {
console.error("Failed to replay video:", error);
console.info("Failed to replay video:", error);
Toast.show({ type: "error", text1: "播放失败" });
}
}
@@ -140,7 +140,7 @@ const usePlayerStore = create<PlayerState>((set, get) => ({
await videoRef?.current?.playAsync();
}
} catch (error) {
console.error("Failed to toggle play/pause:", error);
console.info("Failed to toggle play/pause:", error);
Toast.show({ type: "error", text1: "操作失败" });
}
}
@@ -154,7 +154,7 @@ const usePlayerStore = create<PlayerState>((set, get) => ({
try {
await videoRef?.current?.setPositionAsync(newPosition);
} catch (error) {
console.error("Failed to seek video:", error);
console.info("Failed to seek video:", error);
Toast.show({ type: "error", text1: "快进/快退失败" });
}

View File

@@ -73,7 +73,7 @@ export const useUpdateStore = create<UpdateState>((set, get) => ({
Date.now().toString()
);
} catch (error) {
console.error('检查更新失败:', error);
// console.info('检查更新失败:', error);
set({
error: error instanceof Error ? error.message : '检查更新失败',
updateAvailable: false
@@ -110,7 +110,7 @@ export const useUpdateStore = create<UpdateState>((set, get) => ({
downloadProgress: 100,
});
} catch (error) {
console.error('下载失败:', error);
// console.info('下载失败:', error);
set({
downloading: false,
downloadProgress: 0,
@@ -133,7 +133,7 @@ export const useUpdateStore = create<UpdateState>((set, get) => ({
// 安装开始后,关闭弹窗
set({ showUpdateModal: false });
} catch (error) {
console.error('安装失败:', error);
console.info('安装失败:', error);
set({
error: error instanceof Error ? error.message : '安装失败',
});
@@ -181,6 +181,6 @@ export const initUpdateStore = async () => {
skipVersion: skipVersion || null,
});
} catch (error) {
console.error('初始化更新存储失败:', error);
console.info('初始化更新存储失败:', error);
}
};