优化更新

This commit is contained in:
yj 2025-02-27 09:47:17 +08:00
parent 1e3107d0e2
commit ed2c39e7fc
6 changed files with 122 additions and 66 deletions

7
package-lock.json generated
View File

@ -1,17 +1,17 @@
{
"name": "WGShare.Metting",
"version": "0.4.8",
"version": "0.7.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "WGShare.Metting",
"version": "0.4.8",
"version": "0.7.1",
"dependencies": {
"@ant-design/icons": "^5.3.7",
"@microsoft/signalr": "^8.0.0",
"@types/node": "^20.14.9",
"agora-electron-sdk": "^4.4.0",
"agora-electron-sdk": "4.4.0",
"animate.css": "^4.1.1",
"antd": "^5.18.2",
"axios": "^1.7.2",
@ -19,6 +19,7 @@
"dayjs": "^1.11.11",
"electron-squirrel-startup": "^1.0.1",
"electron-updater": "^6.2.1",
"js-yaml": "^4.1.0",
"os": "^0.1.2",
"path": "^0.12.7",
"postcss-px-to-viewport-8-plugin": "^1.2.5",

View File

@ -1,7 +1,7 @@
{
"name": "WGShare.Metting",
"private": true,
"version": "0.7.1",
"version": "0.7.0",
"main": "main.js",
"authors": "yj",
"description": "智汇享",
@ -34,6 +34,7 @@
"dayjs": "^1.11.11",
"electron-squirrel-startup": "^1.0.1",
"electron-updater": "^6.2.1",
"js-yaml": "^4.1.0",
"os": "^0.1.2",
"path": "^0.12.7",
"postcss-px-to-viewport-8-plugin": "^1.2.5",

View File

@ -16,6 +16,8 @@ import { GetSubDpList } from '@/api/Home/User';
import FeedBackModel from '@/components/FeedBackModel';
import { PostHomeVerLog } from '@/api/Meeting';
import Code from '@/components/Code';
import { isVersion } from "@/utils/package/public";
const { setInterval, clearInterval } = require('timers');
const fs = require('fs').promises;
const { exec } = require('child_process');
@ -308,6 +310,12 @@ const Index: React.FC = () => {
<Button type="primary"
iconPosition={'end'}
onClick={async () => {
storage.setItem('loading', true)
isVersion((bool: boolean) => {
storage.setItem('loading', false)
if (bool) {
window.electron.onDownload('3')
} else {
if (role.ID.includes(userInfo.roleId)) {
joinSettingRef.current.changeModal(item.roomNum)
} else {
@ -337,6 +345,8 @@ const Index: React.FC = () => {
})
})
}
}
})
}}
icon={<img src={ImageUrl.icon9} alt="" />}
className='m-ant-btn'>

View File

@ -10,6 +10,7 @@ import ImageUrl from '@/utils/package/imageUrl'
import { v4 as uuidv4 } from 'uuid';
import { GetCheckoutRoomNum, GetRoomInfo, GetRoomRtcToken } from '@/api/Home/Index';
import { ExclamationCircleFilled } from '@ant-design/icons';
import { isVersion } from '@/utils/package/public';
const { confirm } = Modal;
const Login: React.FC = () => {
const navigate = useNavigate();
@ -345,6 +346,12 @@ const Login: React.FC = () => {
if (anonInfo.nickName.length > 10) {
return message.error('参会昵称最多10个字')
}
storage.setItem('loading', true)
isVersion((bool: boolean) => {
storage.setItem('loading', false)
if (bool) {
window.electron.onDownload('3')
} else {
storage.setItem('loading', true)
PostAnonLogin(anonInfo).then(async (res) => {
if (res.code == 200) {
@ -387,6 +394,8 @@ const Login: React.FC = () => {
}).catch(() => {
storage.setItem('loading', false)
})
}
})
}}></Button>
</div>
</div>

View File

@ -1,3 +1,4 @@
declare module 'react-dom/client';
declare module 'crypto-js';
declare module 'js-yaml';
declare module 'uuid';

View File

@ -1,5 +1,7 @@
import path from "path";
import storage from "./storage";
import axios from "axios";
import yaml from 'js-yaml'
export const setKeyOpenChildWindow = async (key: string, bool: boolean) => {
const openChildWindow = await JSON.parse(storage.getItem('openChildWindow') as string)
openChildWindow[key] = bool;
@ -72,3 +74,35 @@ export const getTitle = (env: string) => {
return '智汇享'
}
}
export const compareVersions = (version1: string, version2: string): number => {
const v1Parts = version1.split('.').map(Number);
const v2Parts = version2.split('.').map(Number);
const maxLength = Math.max(v1Parts.length, v2Parts.length);
for (let i = 0; i < maxLength; i++) {
const v1 = v1Parts[i] || 0;
const v2 = v2Parts[i] || 0;
if (v1 > v2) {
return 1;
} else if (v1 < v2) {
return -1;
}
}
return 0;
}
export const isVersion = (callBack: Function) => {
axios.get(import.meta.env.VITE_ENV !== 'development' ? 'https://meeting-api.23544.com/meeting/update' : 'http://192.168.2.9:8827/latest.yml').then(res => {
if (res.status === 200 && res.data) {
const data = yaml.load(res.data); // 解析 YAML 内容
window.electron.getVersion().then(req => {
if (compareVersions(data.version, req) === -1) {
callBack(false)
} else {
callBack(true)
}
})
}
}).catch(() => {
callBack(true)
})
}