diff --git a/package.json b/package.json index f990eb1..d4ee066 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,6 @@ "vue-tsc": "0.29.8", "ws": "8.17.0", "qrcode": "1.5.3", - "notyf": "3.0.0", - "node-localstorage": "3.0.5" + "notyf": "3.0.0" } } diff --git a/src/App.vue b/src/App.vue index 34298cb..4a59546 100644 --- a/src/App.vue +++ b/src/App.vue @@ -34,11 +34,12 @@ if (window.localStorage.getItem("settings")) { settings.value = JSON.parse(window.localStorage.getItem("settings") || '{}'); // console.log(settings.value) } else { - // 如果没有,使用默认值 + // 如果没有,使用默认值并且保存 settings.value = { waveData: waveData, strengthData: strengthData }; + window.localStorage.setItem('settings', JSON.stringify(settings.value)); } diff --git a/src/socket/index.ts b/src/socket/index.ts index 0dfaa68..1d27bcc 100644 --- a/src/socket/index.ts +++ b/src/socket/index.ts @@ -54,10 +54,8 @@ function createSocket(authBody: string, wssLinks: string[]) { settings = window.localStorage.getItem("settings") ? ref(JSON.parse(window.localStorage.getItem("settings") || '{}')) : null - console.log(settings.value) - if (res.cmd == "LIVE_OPEN_PLATFORM_SEND_GIFT") { - if (res.data.gift_id.toString() === settings.value.strengthData[0]) { + if (settings && res.data.gift_id.toString() === settings.value.strengthData[0]) { // 牛哇牛哇:加强度1 try { console.log("开始操作") @@ -70,7 +68,7 @@ function createSocket(authBody: string, wssLinks: string[]) { console.log(e) notyf.error("强度操作失败!") } - } else if (res.data.gift_id.toString() === settings.value.strengthData[1]) { + } else if (settings && res.data.gift_id.toString() === settings.value.strengthData[1]) { // 小花花:减强度1 try { addOrIncrease(1, 1, 1) @@ -81,7 +79,7 @@ function createSocket(authBody: string, wssLinks: string[]) { console.log(e) notyf.error("强度操作失败!") } - } else if(settings.value.waveData[res.data.gift_id]) { + } else if(settings && settings.value.waveData[res.data.gift_id]) { // 其他礼物,发送波形数据 try { sendWaveData(5, 5, settings.value.waveData[res.data.gift_id], settings.value.waveData[res.data.gift_id])