From 9f4e4790f5cc4d2cf30bdf6ac5adc6e103a6fd2a Mon Sep 17 00:00:00 2001 From: JiQingzhe2004 Date: Fri, 27 Mar 2026 14:43:08 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E5=BC=BA=E5=88=B6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=94=AF=E6=8C=81=20minimumVersion=EF=BC=8C=E9=98=BB?= =?UTF-8?q?=E6=AD=A2=E4=BD=8E=E7=89=88=E6=9C=AC=E7=94=A8=E6=88=B7=E7=BB=A7?= =?UTF-8?q?=E7=BB=AD=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 58 ++++++++++++++++++++++++++++++++ electron/main.ts | 6 ++-- src/App.tsx | 15 ++++++--- src/components/UpdateDialog.scss | 11 +++++- src/components/UpdateDialog.tsx | 9 +++-- 5 files changed, 89 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7ee3510..ca03b1e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -49,6 +49,22 @@ jobs: run: | npx electron-builder --mac dmg --arm64 --publish always + - name: Inject minimumVersion into latest yml + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + shell: bash + run: | + TAG=${GITHUB_REF_NAME} + REPO=${{ github.repository }} + MINIMUM_VERSION="4.1.7" + for YML_FILE in latest-mac.yml latest-arm64-mac.yml; do + gh release download "$TAG" --repo "$REPO" --pattern "$YML_FILE" --output "/tmp/$YML_FILE" 2>/dev/null || continue + if ! grep -q 'minimumVersion' "/tmp/$YML_FILE"; then + echo "minimumVersion: $MINIMUM_VERSION" >> "/tmp/$YML_FILE" + fi + gh release upload "$TAG" --repo "$REPO" "/tmp/$YML_FILE" --clobber + done + release-linux: runs-on: ubuntu-latest @@ -85,6 +101,20 @@ jobs: run: | npx electron-builder --linux --publish always + - name: Inject minimumVersion into latest yml + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + shell: bash + run: | + TAG=${GITHUB_REF_NAME} + REPO=${{ github.repository }} + MINIMUM_VERSION="4.1.7" + gh release download "$TAG" --repo "$REPO" --pattern "latest-linux.yml" --output "/tmp/latest-linux.yml" 2>/dev/null + if [ -f /tmp/latest-linux.yml ] && ! grep -q 'minimumVersion' /tmp/latest-linux.yml; then + echo "minimumVersion: $MINIMUM_VERSION" >> /tmp/latest-linux.yml + gh release upload "$TAG" --repo "$REPO" /tmp/latest-linux.yml --clobber + fi + release: runs-on: windows-latest @@ -121,6 +151,20 @@ jobs: run: | npx electron-builder --win nsis --x64 --publish always '--config.artifactName=${productName}-${version}-x64-Setup.${ext}' + - name: Inject minimumVersion into latest yml + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + shell: bash + run: | + TAG=${GITHUB_REF_NAME} + REPO=${{ github.repository }} + MINIMUM_VERSION="4.1.7" + gh release download "$TAG" --repo "$REPO" --pattern "latest.yml" --output "/tmp/latest.yml" 2>/dev/null + if [ -f /tmp/latest.yml ] && ! grep -q 'minimumVersion' /tmp/latest.yml; then + echo "minimumVersion: $MINIMUM_VERSION" >> /tmp/latest.yml + gh release upload "$TAG" --repo "$REPO" /tmp/latest.yml --clobber + fi + release-windows-arm64: runs-on: windows-latest @@ -157,6 +201,20 @@ jobs: run: | npx electron-builder --win nsis --arm64 --publish always '--config.publish.channel=latest-arm64' '--config.artifactName=${productName}-${version}-arm64-Setup.${ext}' + - name: Inject minimumVersion into latest yml + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + shell: bash + run: | + TAG=${GITHUB_REF_NAME} + REPO=${{ github.repository }} + MINIMUM_VERSION="4.1.7" + gh release download "$TAG" --repo "$REPO" --pattern "latest-arm64.yml" --output "/tmp/latest-arm64.yml" 2>/dev/null + if [ -f /tmp/latest-arm64.yml ] && ! grep -q 'minimumVersion' /tmp/latest-arm64.yml; then + echo "minimumVersion: $MINIMUM_VERSION" >> /tmp/latest-arm64.yml + gh release upload "$TAG" --repo "$REPO" /tmp/latest-arm64.yml --clobber + fi + update-release-notes: runs-on: ubuntu-latest needs: diff --git a/electron/main.ts b/electron/main.ts index 813c397..2e46d48 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -1200,7 +1200,8 @@ function registerIpcHandlers() { return { hasUpdate: true, version: latestVersion, - releaseNotes: normalizeReleaseNotes(result.updateInfo.releaseNotes) + releaseNotes: normalizeReleaseNotes(result.updateInfo.releaseNotes), + minimumVersion: (result.updateInfo as any).minimumVersion } } } @@ -2661,7 +2662,8 @@ function checkForUpdatesOnStartup() { // 通知渲染进程有新版本 mainWindow.webContents.send('app:updateAvailable', { version: latestVersion, - releaseNotes: normalizeReleaseNotes(result.updateInfo.releaseNotes) + releaseNotes: normalizeReleaseNotes(result.updateInfo.releaseNotes), + minimumVersion: (result.updateInfo as any).minimumVersion }) } } diff --git a/src/App.tsx b/src/App.tsx index e09f7ef..83af689 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -312,10 +312,14 @@ function App() { const removeUpdateListener = window.electronAPI?.app?.onUpdateAvailable?.((info: any) => { // 发现新版本时保存更新信息,锁定状态下不弹窗,解锁后再显示 if (info) { - setUpdateInfo({ ...info, hasUpdate: true }) - if (!useAppStore.getState().isLocked) { - setShowUpdateDialog(true) - } + window.electronAPI.app.getVersion().then((currentVersion: string) => { + const isMandatory = !!(info.minimumVersion && currentVersion && + currentVersion.localeCompare(info.minimumVersion, undefined, { numeric: true, sensitivity: 'base' }) <= 0) + setUpdateInfo({ ...info, hasUpdate: true, isMandatory }) + if (!useAppStore.getState().isLocked) { + setShowUpdateDialog(true) + } + }) } }) const removeProgressListener = window.electronAPI?.app?.onDownloadProgress?.((progress: any) => { @@ -685,10 +689,11 @@ function App() { setShowUpdateDialog(false)} + onClose={() => { if (!(updateInfo as any)?.isMandatory) setShowUpdateDialog(false) }} onUpdate={handleUpdateNow} onIgnore={handleIgnoreUpdate} isDownloading={isDownloading} + isMandatory={!!(updateInfo as any)?.isMandatory} progress={downloadProgress} /> diff --git a/src/components/UpdateDialog.scss b/src/components/UpdateDialog.scss index a1a4e39..9b007ef 100644 --- a/src/components/UpdateDialog.scss +++ b/src/components/UpdateDialog.scss @@ -282,4 +282,13 @@ transform: translateY(0); opacity: 1; } -} \ No newline at end of file +} +.mandatory-tip { + color: #e53e3e; + font-size: 13px; + text-align: center; + margin: 0 0 8px; + padding: 6px 12px; + background: rgba(229, 62, 62, 0.08); + border-radius: 6px; +} diff --git a/src/components/UpdateDialog.tsx b/src/components/UpdateDialog.tsx index 0dce27d..98be24e 100644 --- a/src/components/UpdateDialog.tsx +++ b/src/components/UpdateDialog.tsx @@ -14,6 +14,7 @@ interface UpdateDialogProps { onUpdate: () => void onIgnore?: () => void isDownloading: boolean + isMandatory?: boolean progress: number | { percent: number bytesPerSecond?: number @@ -30,6 +31,7 @@ const UpdateDialog: React.FC = ({ onUpdate, onIgnore, isDownloading, + isMandatory, progress }) => { if (!open || !updateInfo) return null @@ -69,7 +71,7 @@ const UpdateDialog: React.FC = ({ return (
- {!isDownloading && ( + {!isDownloading && !isMandatory && ( @@ -119,11 +121,14 @@ const UpdateDialog: React.FC = ({
) : (
- {onIgnore && ( + {onIgnore && !isMandatory && ( )} + {isMandatory && ( +

此版本存在安全风险,必须更新后才能继续使用

+ )} From 2201d369fa2cbdb4a51303eabbe368433ce407d7 Mon Sep 17 00:00:00 2001 From: JiQingzhe2004 Date: Fri, 27 Mar 2026 14:43:33 +0800 Subject: [PATCH 2/2] chore: bump version to 4.3.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6b32450..23f453f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "weflow", - "version": "2.1.0", + "version": "4.3.0", "description": "WeFlow", "main": "dist-electron/main.js", "author": {