Skip to content

Commit ee131fa

Browse files
committed
refactor(modules): improve update logic
1 parent 9494d22 commit ee131fa

2 files changed

Lines changed: 20 additions & 13 deletions

File tree

src/app/(setting)/checkUpdate.tsx

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,23 @@ function CheckUpdate(): React.ReactNode {
7979
style={[styles.updateButton, currentStyle?.button_style]}
8080
onPress={() => {
8181
setLoading(true);
82-
Updates.checkForUpdateAsync()
83-
.then(res => {
84-
if (!res.isAvailable) {
85-
Toast.show({ text: '已是最新版', icon: 'success' });
86-
}
87-
})
88-
.catch(err => {
89-
Toast.show({ text: err.toString() });
90-
})
91-
.finally(() => {
92-
setLoading(false);
93-
});
82+
if (__DEV__) {
83+
Toast.show({ text: '已是最新版', icon: 'success' });
84+
setLoading(false);
85+
} else {
86+
Updates.checkForUpdateAsync()
87+
.then(res => {
88+
if (!res.isAvailable) {
89+
Toast.show({ text: '已是最新版', icon: 'success' });
90+
}
91+
})
92+
.catch(err => {
93+
Toast.show({ text: err.toString() });
94+
})
95+
.finally(() => {
96+
setLoading(false);
97+
});
98+
}
9499
}}
95100
isLoading={loading}
96101
>

src/app/_layout.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ export default function RootLayout() {
5050
// 配置Toast
5151
Toast.config({ mask: false, stackable: true });
5252
// 获取更新
53-
fetchUpdate();
53+
if (!__DEV__) {
54+
fetchUpdate();
55+
}
5456
// 在 store 中设置爬虫 ref
5557
setRef(scraperRef as React.RefObject<WebView>);
5658
// 在 store 中配置 portal ref

0 commit comments

Comments
 (0)