This commit is contained in:
lyswhut
2023-02-01 12:50:52 +08:00
parent ba3b2f613a
commit 6075f413dc
50 changed files with 74 additions and 70 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
// import { throttle } from '@common/utils/common'
import { Server } from 'socket.io'
import { type Server } from 'socket.io'
// import { sendSyncActionList } from '@main/modules/winMain'
import { encryptMsg, decryptMsg } from '../server/utils'
+1 -1
View File
@@ -1,4 +1,4 @@
import http from 'http'
import type http from 'http'
import { SYNC_CODE } from './config'
import {
aesEncrypt,
+2 -2
View File
@@ -1,6 +1,6 @@
import http from 'http'
import { Server, Socket } from 'socket.io'
import { createHttpTerminator, HttpTerminator } from 'http-terminator'
import { Server, type Socket } from 'socket.io'
import { createHttpTerminator, type HttpTerminator } from 'http-terminator'
import * as modules from '../modules'
import { authCode, authConnect } from './auth'
import { getAddress, getServerId, generateCode as handleGenerateCode, getClientKeyInfo, setClientKeyInfo } from './utils'
+10 -10
View File
@@ -1,7 +1,7 @@
import { promises as fsPromises } from 'fs'
import { encryptMsg, decryptMsg, getSnapshotFilePath } from './utils'
import { throttle } from '@common/utils'
import { Server } from 'socket.io'
import { type Server } from 'socket.io'
import { sendCloseSelectMode, sendSelectMode } from '@main/modules/winMain'
import { LIST_IDS } from '@common/constants'
@@ -98,7 +98,7 @@ const setRemotelList = async(socket: LX.Sync.Socket, listData: LX.Sync.ListData)
}
}
const writeFilePromises: Map<string, Promise<void>> = new Map()
const writeFilePromises = new Map<string, Promise<void>>()
const updateSnapshot = async(path: string, data: string) => {
console.log('updateSnapshot', path)
let writeFilePromise = writeFilePromises.get(path) ?? Promise.resolve()
@@ -136,7 +136,7 @@ const handleMergeList = (
newList = [...sourceList, ...targetList]
break
}
const map: Map<string | number, LX.Music.MusicInfo> = new Map()
const map = new Map<string | number, LX.Music.MusicInfo>()
const ids: Array<string | number> = []
switch (addMusicLocationType) {
case 'top':
@@ -313,9 +313,9 @@ const mergeListDataFromSnapshot = (
snapshotList: LX.Music.MusicInfo[],
addMusicLocationType: LX.AddMusicLocationType,
): LX.Music.MusicInfo[] => {
const removedListIds: Set<string | number> = new Set()
const sourceListItemIds: Set<string | number> = new Set()
const targetListItemIds: Set<string | number> = new Set()
const removedListIds = new Set<string | number>()
const sourceListItemIds = new Set<string | number>()
const targetListItemIds = new Set<string | number>()
for (const m of sourceList) sourceListItemIds.add(m.id)
for (const m of targetList) targetListItemIds.add(m.id)
if (snapshotList) {
@@ -325,7 +325,7 @@ const mergeListDataFromSnapshot = (
}
let newList
const map: Map<string | number, LX.Music.MusicInfo> = new Map()
const map = new Map<string | number, LX.Music.MusicInfo>()
const ids = []
switch (addMusicLocationType) {
case 'top':
@@ -362,9 +362,9 @@ const handleMergeListDataFromSnapshot = async(socket: LX.Sync.Socket, snapshot:
const localUserListData = createUserListDataObj(localListData)
const remoteUserListData = createUserListDataObj(remoteListData)
const snapshotUserListData = createUserListDataObj(snapshot)
const removedListIds: Set<string | number> = new Set()
const localUserListIds: Set<string | number> = new Set()
const remoteUserListIds: Set<string | number> = new Set()
const removedListIds = new Set<string | number>()
const localUserListIds = new Set<string | number>()
const remoteUserListIds = new Set<string | number>()
for (const l of localListData.userList) localUserListIds.add(l.id)
for (const l of remoteListData.userList) remoteUserListIds.add(l.id)