mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-03-24 23:06:51 +00:00
feat: 支持忽略更新
This commit is contained in:
13
src/App.tsx
13
src/App.tsx
@@ -203,6 +203,18 @@ function App() {
|
||||
}
|
||||
}
|
||||
|
||||
const handleIgnoreUpdate = async () => {
|
||||
if (!updateInfo || !updateInfo.version) return
|
||||
|
||||
try {
|
||||
await window.electronAPI.app.ignoreUpdate(updateInfo.version)
|
||||
setShowUpdateDialog(false)
|
||||
setUpdateInfo(null)
|
||||
} catch (e: any) {
|
||||
console.error('忽略更新失败:', e)
|
||||
}
|
||||
}
|
||||
|
||||
const dismissUpdate = () => {
|
||||
setUpdateInfo(null)
|
||||
}
|
||||
@@ -383,6 +395,7 @@ function App() {
|
||||
updateInfo={updateInfo}
|
||||
onClose={() => setShowUpdateDialog(false)}
|
||||
onUpdate={handleUpdateNow}
|
||||
onIgnore={handleIgnoreUpdate}
|
||||
isDownloading={isDownloading}
|
||||
progress={downloadProgress}
|
||||
/>
|
||||
|
||||
@@ -171,6 +171,29 @@
|
||||
.actions {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
|
||||
.btn-ignore {
|
||||
background: transparent;
|
||||
color: #666666;
|
||||
border: 1px solid #d0d0d0;
|
||||
padding: 16px 32px;
|
||||
border-radius: 20px;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
|
||||
&:hover {
|
||||
background: #f5f5f5;
|
||||
border-color: #999999;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
&:active {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
}
|
||||
|
||||
.btn-update {
|
||||
background: #000000;
|
||||
|
||||
@@ -12,6 +12,7 @@ interface UpdateDialogProps {
|
||||
updateInfo: UpdateInfo | null
|
||||
onClose: () => void
|
||||
onUpdate: () => void
|
||||
onIgnore?: () => void
|
||||
isDownloading: boolean
|
||||
progress: number | {
|
||||
percent: number
|
||||
@@ -27,6 +28,7 @@ const UpdateDialog: React.FC<UpdateDialogProps> = ({
|
||||
updateInfo,
|
||||
onClose,
|
||||
onUpdate,
|
||||
onIgnore,
|
||||
isDownloading,
|
||||
progress
|
||||
}) => {
|
||||
@@ -118,6 +120,11 @@ const UpdateDialog: React.FC<UpdateDialogProps> = ({
|
||||
</div>
|
||||
) : (
|
||||
<div className="actions">
|
||||
{onIgnore && (
|
||||
<button className="btn-ignore" onClick={onIgnore}>
|
||||
忽略本次更新
|
||||
</button>
|
||||
)}
|
||||
<button className="btn-update" onClick={onUpdate}>
|
||||
开启新旅程
|
||||
</button>
|
||||
|
||||
@@ -316,6 +316,19 @@ function SettingsPage() {
|
||||
}
|
||||
}
|
||||
|
||||
const handleIgnoreUpdate = async () => {
|
||||
if (!updateInfo || !updateInfo.version) return
|
||||
|
||||
try {
|
||||
await window.electronAPI.app.ignoreUpdate(updateInfo.version)
|
||||
setShowUpdateDialog(false)
|
||||
setUpdateInfo(null)
|
||||
showMessage(`已忽略版本 ${updateInfo.version}`, true)
|
||||
} catch (e: any) {
|
||||
showMessage(`操作失败: ${e}`, false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
const showMessage = (text: string, success: boolean) => {
|
||||
|
||||
@@ -35,7 +35,10 @@ export const CONFIG_KEYS = {
|
||||
// 安全
|
||||
AUTH_ENABLED: 'authEnabled',
|
||||
AUTH_PASSWORD: 'authPassword',
|
||||
AUTH_USE_HELLO: 'authUseHello'
|
||||
AUTH_USE_HELLO: 'authUseHello',
|
||||
|
||||
// 更新
|
||||
IGNORED_UPDATE_VERSION: 'ignoredUpdateVersion'
|
||||
} as const
|
||||
|
||||
export interface WxidConfig {
|
||||
@@ -399,3 +402,17 @@ export async function getAuthUseHello(): Promise<boolean> {
|
||||
export async function setAuthUseHello(useHello: boolean): Promise<void> {
|
||||
await config.set(CONFIG_KEYS.AUTH_USE_HELLO, useHello)
|
||||
}
|
||||
|
||||
// === 更新相关 ===
|
||||
|
||||
// 获取被忽略的更新版本
|
||||
export async function getIgnoredUpdateVersion(): Promise<string | null> {
|
||||
const value = await config.get(CONFIG_KEYS.IGNORED_UPDATE_VERSION)
|
||||
return (value as string) || null
|
||||
}
|
||||
|
||||
// 设置被忽略的更新版本
|
||||
export async function setIgnoredUpdateVersion(version: string): Promise<void> {
|
||||
await config.set(CONFIG_KEYS.IGNORED_UPDATE_VERSION, version)
|
||||
}
|
||||
|
||||
|
||||
1
src/types/electron.d.ts
vendored
1
src/types/electron.d.ts
vendored
@@ -32,6 +32,7 @@ export interface ElectronAPI {
|
||||
getVersion: () => Promise<string>
|
||||
checkForUpdates: () => Promise<{ hasUpdate: boolean; version?: string; releaseNotes?: string }>
|
||||
downloadAndInstall: () => Promise<void>
|
||||
ignoreUpdate: (version: string) => Promise<{ success: boolean }>
|
||||
onDownloadProgress: (callback: (progress: number) => void) => () => void
|
||||
onUpdateAvailable: (callback: (info: { version: string; releaseNotes: string }) => void) => () => void
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user