优化更新

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

View File

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

View File

@ -16,6 +16,8 @@ import { GetSubDpList } from '@/api/Home/User';
import FeedBackModel from '@/components/FeedBackModel'; import FeedBackModel from '@/components/FeedBackModel';
import { PostHomeVerLog } from '@/api/Meeting'; import { PostHomeVerLog } from '@/api/Meeting';
import Code from '@/components/Code'; import Code from '@/components/Code';
import { isVersion } from "@/utils/package/public";
const { setInterval, clearInterval } = require('timers'); const { setInterval, clearInterval } = require('timers');
const fs = require('fs').promises; const fs = require('fs').promises;
const { exec } = require('child_process'); const { exec } = require('child_process');
@ -308,35 +310,43 @@ const Index: React.FC = () => {
<Button type="primary" <Button type="primary"
iconPosition={'end'} iconPosition={'end'}
onClick={async () => { onClick={async () => {
if (role.ID.includes(userInfo.roleId)) { storage.setItem('loading', true)
joinSettingRef.current.changeModal(item.roomNum) isVersion((bool: boolean) => {
} else { storage.setItem('loading', false)
storage.setItem('loading', true) if (bool) {
postRefresh(() => { window.electron.onDownload('3')
getRoomRtcToken(item.roomNum, async (options: any) => { } else {
if (options) { if (role.ID.includes(userInfo.roleId)) {
await window.electron.getVersion().then(async req => { joinSettingRef.current.changeModal(item.roomNum)
await PostHomeVerLog({ } else {
version: req, storage.setItem('loading', true)
platformType: 1, postRefresh(() => {
roomNum: item.roomNum, getRoomRtcToken(item.roomNum, async (options: any) => {
}) if (options) {
}) await window.electron.getVersion().then(async req => {
navigate(`/meeting`, { await PostHomeVerLog({
state: { version: req,
channelId: item.roomNum, platformType: 1,
token: options.token, roomNum: item.roomNum,
tokenA: options.tokenA, })
roomId: item.id, })
roomName: item.roomName, navigate(`/meeting`, {
enableMicr: false, state: {
enableCamera: false, channelId: item.roomNum,
token: options.token,
tokenA: options.tokenA,
roomId: item.id,
roomName: item.roomName,
enableMicr: false,
enableCamera: false,
}
})
} }
}) })
} })
}) }
}) }
} })
}} }}
icon={<img src={ImageUrl.icon9} alt="" />} icon={<img src={ImageUrl.icon9} alt="" />}
className='m-ant-btn'> className='m-ant-btn'>

View File

@ -10,6 +10,7 @@ import ImageUrl from '@/utils/package/imageUrl'
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import { GetCheckoutRoomNum, GetRoomInfo, GetRoomRtcToken } from '@/api/Home/Index'; import { GetCheckoutRoomNum, GetRoomInfo, GetRoomRtcToken } from '@/api/Home/Index';
import { ExclamationCircleFilled } from '@ant-design/icons'; import { ExclamationCircleFilled } from '@ant-design/icons';
import { isVersion } from '@/utils/package/public';
const { confirm } = Modal; const { confirm } = Modal;
const Login: React.FC = () => { const Login: React.FC = () => {
const navigate = useNavigate(); const navigate = useNavigate();
@ -346,46 +347,54 @@ const Login: React.FC = () => {
return message.error('参会昵称最多10个字') return message.error('参会昵称最多10个字')
} }
storage.setItem('loading', true) storage.setItem('loading', true)
PostAnonLogin(anonInfo).then(async (res) => { isVersion((bool: boolean) => {
if (res.code == 200) { storage.setItem('loading', false)
storage.setItem('user', JSON.stringify(res.data)) if (bool) {
storage.setItem('userLogin', true) window.electron.onDownload('3')
await window.electron.startSignalr(res.data) } else {
getRoomRtcToken(anonInfo.roomNum, (options: any) => { storage.setItem('loading', true)
if (options) { PostAnonLogin(anonInfo).then(async (res) => {
GetRoomInfo(anonInfo.roomNum).then(async (res) => { if (res.code == 200) {
if (res.code === 200) { storage.setItem('user', JSON.stringify(res.data))
setTimeout(() => { storage.setItem('userLogin', true)
await window.electron.startSignalr(res.data)
getRoomRtcToken(anonInfo.roomNum, (options: any) => {
if (options) {
GetRoomInfo(anonInfo.roomNum).then(async (res) => {
if (res.code === 200) {
setTimeout(() => {
storage.setItem('loading', false)
window.electron.getWindowSize().then((res: any) => {
window.electron.setMainWindowSize({
width: Math.ceil(res.width / 1.5),
height: Math.ceil(res.height / 1.3),
})
})
navigate(`/meeting`, {
state: {
channelId: anonInfo.roomNum,
token: options.token,
tokenA: options.tokenA,
roomId: res.data.id,
roomName: res.data.roomName,
enableMicr: false,
enableCamera: false,
}
})
}, 2000)
} else {
storage.setItem('loading', false)
}
}).catch(() => {
storage.setItem('loading', false) storage.setItem('loading', false)
window.electron.getWindowSize().then((res: any) => { })
window.electron.setMainWindowSize({
width: Math.ceil(res.width / 1.5),
height: Math.ceil(res.height / 1.3),
})
})
navigate(`/meeting`, {
state: {
channelId: anonInfo.roomNum,
token: options.token,
tokenA: options.tokenA,
roomId: res.data.id,
roomName: res.data.roomName,
enableMicr: false,
enableCamera: false,
}
})
}, 2000)
} else {
storage.setItem('loading', false)
} }
}).catch(() => {
storage.setItem('loading', false)
}) })
} }
}).catch(() => {
storage.setItem('loading', false)
}) })
} }
}).catch(() => {
storage.setItem('loading', false)
}) })
}}></Button> }}></Button>
</div> </div>

View File

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

View File

@ -1,5 +1,7 @@
import path from "path"; import path from "path";
import storage from "./storage"; import storage from "./storage";
import axios from "axios";
import yaml from 'js-yaml'
export const setKeyOpenChildWindow = async (key: string, bool: boolean) => { export const setKeyOpenChildWindow = async (key: string, bool: boolean) => {
const openChildWindow = await JSON.parse(storage.getItem('openChildWindow') as string) const openChildWindow = await JSON.parse(storage.getItem('openChildWindow') as string)
openChildWindow[key] = bool; openChildWindow[key] = bool;
@ -71,4 +73,36 @@ export const getTitle = (env: string) => {
default: default:
return '智汇享' 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)
})
} }