新增实验功能:强度衰减

* 可设置输出指定次数波形后强度衰减指定值
This commit is contained in:
Fang_Zhijian 2024-05-29 01:37:58 +08:00
parent 9100d2d431
commit a109a58c87
4 changed files with 85 additions and 38 deletions

View File

@ -685,8 +685,6 @@ select {
color: #000; color: #000;
} }
.settings-window { .settings-window {
position: fixed; position: fixed;
top: 10%; top: 10%;
@ -700,6 +698,25 @@ select {
z-index: 100; z-index: 100;
padding: 20px; padding: 20px;
} }
.settings-window-body {
overflow-y: auto;
height: 500px;
}
.settings-window-body::-webkit-scrollbar {
width: 10px; /* 宽度 */
}
.settings-window-body::-webkit-scrollbar-track {
background: transparent; /* 轨道颜色 */
}
.settings-window-body::-webkit-scrollbar-thumb {
background: #ffe99d; /* 滚动条颜色 */
}
.settings-window-body::-webkit-scrollbar-thumb:hover {
background: #ffe99d; /* 滚动条鼠标悬停颜色 */
}
.tag { .tag {
background: #fce9a7; background: #fce9a7;

View File

@ -31,6 +31,7 @@ const api = axios.create({
// //
let settings = ref() let settings = ref()
let test_settings = ref()
const settings_text = localStorage.getItem('settings') || '' const settings_text = localStorage.getItem('settings') || ''
const settings_version = 1 const settings_version = 1
let showUpgrade = ref(false) let showUpgrade = ref(false)
@ -49,8 +50,17 @@ if (window.localStorage.getItem("settings")) {
strengthData: strengthData, strengthData: strengthData,
guardLevel: 0, guardLevel: 0,
fansMedal: false fansMedal: false
}; }
window.localStorage.setItem('settings', JSON.stringify(settings.value)); window.localStorage.setItem('settings', JSON.stringify(settings.value))
}
if (window.localStorage.getItem("test")) {
test_settings.value = JSON.parse(window.localStorage.getItem("test") || '{}')
} else {
test_settings.value = {
falloff: [0, 0]
}
window.localStorage.setItem('test', JSON.stringify(test_settings.value))
} }
let showSafetyNotice = ref(localStorage.getItem('showSafetyNotice') !== 'false') let showSafetyNotice = ref(localStorage.getItem('showSafetyNotice') !== 'false')
@ -156,8 +166,14 @@ const fansMedal = computed({
const getAuth = () => { const getAuth = () => {
api.post("/getAuth", {}) api.post("/getAuth", {})
.then(({ data }) => { .then(({ data }) => {
console.log("-----鉴权成功-----") if (typeof data.code !== "number") {
notyf.success({ message: "鉴权成功" }) console.log("-----鉴权失败-----")
notyf.error({ message: "服务端异常" })
return
} else {
console.log("-----鉴权成功-----")
notyf.success({ message: "鉴权成功" })
}
}) })
.catch((err) => { .catch((err) => {
console.log("-----鉴权失败-----") console.log("-----鉴权失败-----")
@ -308,6 +324,10 @@ const saveSettings = () => {
window.localStorage.setItem('settings', JSON.stringify(settings.value)); window.localStorage.setItem('settings', JSON.stringify(settings.value));
console.log(settings.value); console.log(settings.value);
} }
const saveTestSettings = () => {
window.localStorage.setItem('test', JSON.stringify(test_settings.value));
console.log(test_settings.value);
}
/** /**
* 添加并保存 waveData * 添加并保存 waveData
@ -429,9 +449,11 @@ const guardLevelText = computed(() => {
</div> </div>
<div class="settings-window" v-show="showSettings"> <div class="settings-window" v-show="showSettings">
<button @click="showSettings = false" style="float: right"></button> <div class="settings-window-btn">
<button @click="saveSettings" style="float: right"></button> <button @click="showSettings = false" style="float: right"></button>
<div> <button @click="saveSettings" style="float: right"></button>
</div>
<div class="settings-window-body">
<h2>大航海</h2> <h2>大航海</h2>
<p> <p>
身份至低为 身份至低为
@ -504,7 +526,18 @@ const guardLevelText = computed(() => {
</div> </div>
<button @click="addRelationAndSave">新建或保存</button> <button @click="addRelationAndSave">新建或保存</button>
</div> </div>
<h2>实验功能</h2>
<div>
<p><b> 请勿依赖实验功能实验功能可能在后续版本删除</b></p>
<p>
每输出<input size="1" v-model="test_settings.falloff[0]" />次波形强度衰减<input size="1" v-model="test_settings.falloff[1]" />
<span title="为了避免主包被电似,希望主包喜欢">?</span>
</p>
<button @click="saveTestSettings">保存实验功能数据</button>
</div>
</div> </div>
</div> </div>
<div class="game-tips"> <div class="game-tips">
@ -514,7 +547,7 @@ const guardLevelText = computed(() => {
<div class="game-info"> <div class="game-info">
<h2>主机状态</h2> <h2>主机状态</h2>
<div style="display: flex"> <div class="dashboard" style="display: flex">
<div class="channel-circle"> <div class="channel-circle">
<div class="channel-tag">A</div> <div class="channel-tag">A</div>
<div class="channel-strength">{{ channelAStrength }}</div> <div class="channel-strength">{{ channelAStrength }}</div>

File diff suppressed because one or more lines are too long

View File

@ -14,6 +14,9 @@ interface SettingsType {
guardLevel: number; guardLevel: number;
fansMedal: boolean; fansMedal: boolean;
} }
interface TestSettingsType {
falloff: number[];
}
let settings: Ref<SettingsType> = ref({ let settings: Ref<SettingsType> = ref({
version: 1, version: 1,
@ -21,21 +24,22 @@ let settings: Ref<SettingsType> = ref({
strengthData: strengthData, strengthData: strengthData,
guardLevel: 0, guardLevel: 0,
fansMedal: false fansMedal: false
}); })
let testSettings: Ref<TestSettingsType> = ref({
falloff: [0, 0],
})
if (window.localStorage.getItem("settings")) { if (window.localStorage.getItem("settings")) {
settings.value = JSON.parse(window.localStorage.getItem("settings") || '{}'); settings.value = JSON.parse(window.localStorage.getItem("settings") || '{}');
console.log(settings.value) console.log(settings.value)
} else {
// 如果没有,使用默认值
settings.value = {
version: 1,
waveData: waveData,
strengthData: strengthData,
guardLevel: 0,
fansMedal: false
};
} }
if (window.localStorage.getItem("test")) {
testSettings.value = JSON.parse(window.localStorage.getItem("test") || '{}');
console.log(testSettings.value)
}
let waveCounter = testSettings.value.falloff[0]
/** /**
* *
@ -66,20 +70,7 @@ function createSocket(authBody: string, wssLinks: string[]) {
...getWebSocketConfig(authBody, wssLinks), ...getWebSocketConfig(authBody, wssLinks),
// 收到消息, // 收到消息,
onReceivedMessage: (res) => { onReceivedMessage: (res) => {
console.log("收到"+ res.cmd +"消息:") // 从本地存储中获取设置
//console.log(res.data.uname + "(大航海" +res.data.guard_level + "级):" + res.data.msg)
// if (res.data.msg == "#UPA1") {
// try {
// addOrIncrease(2, 1, 1)
// notyf.success("A通道强度增加成功")
// }
// catch (e) {
// console.log(e)
// notyf.error("A通道强度增加失败")
// }
// }
settings = window.localStorage.getItem("settings") ? ref(JSON.parse(window.localStorage.getItem("settings") || '{}')) : null settings = window.localStorage.getItem("settings") ? ref(JSON.parse(window.localStorage.getItem("settings") || '{}')) : null
// 粉丝勋章 // 粉丝勋章
@ -88,10 +79,9 @@ function createSocket(authBody: string, wssLinks: string[]) {
// 大航海 // 大航海
let execute_2 = transformGuardLevel(res.data.guard_level) >= settings.value.guardLevel let execute_2 = transformGuardLevel(res.data.guard_level) >= settings.value.guardLevel
if (res.cmd == "LIVE_OPEN_PLATFORM_SEND_GIFT" && execute_1 && execute_2) { if (res.cmd == "LIVE_OPEN_PLATFORM_SEND_GIFT" && execute_1 && execute_2) {
if (settings && res.data.gift_id.toString() === settings.value.strengthData[0]) { if (settings && res.data.gift_id.toString() === settings.value.strengthData[0]) {
// 加强度1 // 加强度
try { try {
addOrIncrease(2, 1, res.data.gift_num) addOrIncrease(2, 1, res.data.gift_num)
addOrIncrease(2, 2, res.data.gift_num) addOrIncrease(2, 2, res.data.gift_num)
@ -102,7 +92,7 @@ function createSocket(authBody: string, wssLinks: string[]) {
notyf.error("强度操作失败!") notyf.error("强度操作失败!")
} }
} else if (settings && res.data.gift_id.toString() === settings.value.strengthData[1]) { } else if (settings && res.data.gift_id.toString() === settings.value.strengthData[1]) {
// 减强度1 // 减强度
try { try {
addOrIncrease(1, 1, res.data.gift_num) addOrIncrease(1, 1, res.data.gift_num)
addOrIncrease(1, 2, res.data.gift_num) addOrIncrease(1, 2, res.data.gift_num)
@ -117,6 +107,14 @@ function createSocket(authBody: string, wssLinks: string[]) {
try { try {
sendWaveData(5 * res.data.gift_num, 5 * res.data.gift_num, settings.value.waveData[res.data.gift_id], settings.value.waveData[res.data.gift_id]) sendWaveData(5 * res.data.gift_num, 5 * res.data.gift_num, settings.value.waveData[res.data.gift_id], settings.value.waveData[res.data.gift_id])
notyf.success("收到礼物" + res.data.gift_name + "*"+res.data.gift_num) notyf.success("收到礼物" + res.data.gift_name + "*"+res.data.gift_num)
waveCounter--
console.log(waveCounter)
if (waveCounter == 0 && testSettings.value.falloff[0] > 0) {
notyf.success("触发强度衰减")
waveCounter = testSettings.value.falloff[0]
addOrIncrease(1, 1, testSettings.value.falloff[1])
addOrIncrease(1, 2, testSettings.value.falloff[1])
}
} }
catch (e) { catch (e) {
console.log(e) console.log(e)