diff --git a/package.json b/package.json index 912c6b3..44f05de 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,9 @@ "dev": "concurrently \"electron .\" \"cross-env BROWSER=none vite\"", "build": "vite build", "preview": "vite preview", - "build:electron": "vite build & electron-builder -w --config=./config/development.json" + "build:dev": "vite build & electron-builder -w --config=./config/development.json", + "build:prod": "vite build & electron-builder -w --config=./config/production.json", + "build:xy": "vite build & electron-builder -w --config=./config/xy.json" }, "agora_electron": { "platform": "win32", diff --git a/src/components/Code/index.tsx b/src/components/Code/index.tsx index b593e31..4e25825 100644 --- a/src/components/Code/index.tsx +++ b/src/components/Code/index.tsx @@ -1,7 +1,7 @@ import ImageUrl from '@/utils/package/imageUrl'; import { Empty, Popover } from 'antd'; import { GetQrcode } from '@/api/Home/Index'; -import { memo, useImperativeHandle, forwardRef, useState } from "react"; +import { memo, useImperativeHandle, forwardRef, useState, useEffect } from "react"; import { storage } from '@/utils'; const Code = forwardRef((props: any, ref: any) => { useImperativeHandle(ref, () => ({ @@ -10,15 +10,19 @@ const Code = forwardRef((props: any, ref: any) => { } })) const [baseImage, setBaseImage] = useState(''); + const [env, setEnv] = useState('') const [roomNum, setRoomNum] = useState(props.roomNum); + useEffect(() => { + setEnv(storage.getItem('env') as string) + }, []) return ( <> { setBaseImage('') - if (e) { - GetQrcode(roomNum, storage.getItem('env') === 'development' ? 'trial' : 'release').then(res => { + if (e && env) { + GetQrcode(roomNum, env === 'development' ? 'trial' : 'release').then(res => { if (res.code === 200) { setBaseImage(res.data) } diff --git a/src/components/UpdateModal/index.tsx b/src/components/UpdateModal/index.tsx index 7f8ce77..0f63b62 100644 --- a/src/components/UpdateModal/index.tsx +++ b/src/components/UpdateModal/index.tsx @@ -3,7 +3,7 @@ import { storage } from '@/utils'; import ImageUrl from '@/utils/package/imageUrl'; import { getUpdateUrl } from '@/utils/package/public'; import { Button, Flex, Modal, Progress } from 'antd'; -import { forwardRef, useImperativeHandle, useState, memo } from "react"; +import { forwardRef, useImperativeHandle, useState, memo, useEffect } from "react"; const UpdateModal = forwardRef((props: any, ref: any) => { useImperativeHandle(ref, () => ({ @@ -42,10 +42,14 @@ const UpdateModal = forwardRef((props: any, ref: any) => { } } })) + const [env, setEnv] = useState('') const [isUpdateModal, setIsUpdateModal] = useState(false); const [progress, setProgress] = useState(0); // 下载进度值 const [updateContent, setUpdateContent] = useState('') // 版本更新内容 + useEffect(() => { + setEnv(storage.getItem('env') as string) + }, []) function getContent() { fetch(`${getUpdateUrl()}/update.txt?t=${+new Date()}`) // 配置服务器地址 .then(async response => { @@ -91,7 +95,7 @@ const UpdateModal = forwardRef((props: any, ref: any) => { style={{ width: '100%', height: '40px', marginBottom: '10px' }} className={`m-ant-btn`} >立即更新 - {storage.getItem('env') === "development" ?
setIsUpdateModal(false)}>暂不更新
: null} + {env === "development" ?
setIsUpdateModal(false)}>暂不更新
: null} : progress < 100 ?
下载进度:{progress}% diff --git a/src/page/Login/index.tsx b/src/page/Login/index.tsx index 64354b2..9de96a3 100644 --- a/src/page/Login/index.tsx +++ b/src/page/Login/index.tsx @@ -203,7 +203,7 @@ const Login: React.FC = () => { <>
- + {env ? : null}
diff --git a/src/utils/package/public.ts b/src/utils/package/public.ts index b2a605a..d7108da 100644 --- a/src/utils/package/public.ts +++ b/src/utils/package/public.ts @@ -59,7 +59,8 @@ export const storageSeeting: any = { } export const getUpdateUrl = () => { - switch (storage.getItem('env')) { + let env = storage.getItem('env'); + switch (env) { case 'xy': return 'https://meeting-api.23544.com/meeting/xysz' case 'development': @@ -69,7 +70,8 @@ export const getUpdateUrl = () => { } } export const getTitle = () => { - switch (storage.getItem('env')) { + let env = storage.getItem('env'); + switch (env) { case 'xy': return '湖北襄阳四中教研平台' case 'development':