From 09d53987b492914b0f163d87ee4ec4f8eef8e4ba Mon Sep 17 00:00:00 2001 From: yj <1336058017@qq.com> Date: Mon, 25 Nov 2024 14:13:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=9C=B0=E5=9D=80=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/xy.json | 2 +- main.js | 3 ++- src/components/UpdateModal/index.tsx | 3 ++- src/utils/package/public.ts | 9 +++++++++ src/utils/package/update.js | 10 ++++++++++ 5 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 src/utils/package/update.js diff --git a/config/xy.json b/config/xy.json index 068d254..adb8888 100644 --- a/config/xy.json +++ b/config/xy.json @@ -10,7 +10,7 @@ "publish": [ { "provider": "generic", - "url": "https://meeting-api.23544.com/meeting/update" + "url": "https://meeting-api.23544.com/meeting/update/syzh" } ], "files": [ diff --git a/main.js b/main.js index 24024bf..d80b57d 100644 --- a/main.js +++ b/main.js @@ -11,6 +11,7 @@ const { desktopCapturer, } = require('electron'); const path = require('node:path') +const updateJs = require('./src/utils/package/update') const fs = require('fs'); const Registry = require('winreg'); const { autoUpdater, CancellationToken } = require('electron-updater'); @@ -626,7 +627,7 @@ function updateHandle() { updateAva: '检测到新版本,正在下载……', updateNotAva: '已经是最新版本,不用更新' } - autoUpdater.setFeedURL('https://meeting-api.23544.com/meeting/update') + autoUpdater.setFeedURL(updateJs.getUpdateUrl(env)) autoUpdater.autoDownload = false // 不自动下载安装包 autoUpdater.autoInstallOnAppQuit = false // 不自动安装 autoUpdater.on('error', function (error) { diff --git a/src/components/UpdateModal/index.tsx b/src/components/UpdateModal/index.tsx index e97819b..261327d 100644 --- a/src/components/UpdateModal/index.tsx +++ b/src/components/UpdateModal/index.tsx @@ -1,5 +1,6 @@ import styles from '@/components/UpdateModal/index.module.scss' import ImageUrl from '@/utils/package/imageUrl'; +import { getUpdateUrl } from '@/utils/package/public'; import { Button, Flex, Modal, Progress } from 'antd'; import { forwardRef, useImperativeHandle, useState } from "react"; @@ -22,7 +23,7 @@ const UpdateModal = forwardRef((props: any, ref: any) => { const [updateContent, setUpdateContent] = useState('') // 版本更新内容 function getContent() { - fetch(`https://meeting-api.23544.com/meeting/update/update.txt?t=${+new Date()}`) // 配置服务器地址 + fetch(`${getUpdateUrl(import.meta.env.VITE_ENV)}/update.txt?t=${+new Date()}`) // 配置服务器地址 .then(async response => { if (response.status === 200) { return setUpdateContent(await response.text()) diff --git a/src/utils/package/public.ts b/src/utils/package/public.ts index 82f5aba..0dba0e1 100644 --- a/src/utils/package/public.ts +++ b/src/utils/package/public.ts @@ -53,4 +53,13 @@ export const storageSeeting: any = { color: '0xFFFFFF', // 纯色 sourceIndex: '', // 背景图下标 }, +} + +export const getUpdateUrl = (env: string) => { + switch (env) { + case 'xy': + return 'https://meeting-api.23544.com/meeting/update/syzh' + default: + return 'https://meeting-api.23544.com/meeting/update' + } } \ No newline at end of file diff --git a/src/utils/package/update.js b/src/utils/package/update.js new file mode 100644 index 0000000..bc6fa47 --- /dev/null +++ b/src/utils/package/update.js @@ -0,0 +1,10 @@ +module.exports = { + getUpdateUrl(env) { + switch (env) { + case 'xy': + return 'https://meeting-api.23544.com/meeting/update/syzh' + default: + return 'https://meeting-api.23544.com/meeting/update' + } + } +} \ No newline at end of file