修改前端
This commit is contained in:
@@ -4,13 +4,13 @@ import axios from 'axios';
|
||||
import * as echarts from 'echarts';
|
||||
|
||||
// 输入框数据
|
||||
const input1 = ref('');
|
||||
const input2 = ref('');
|
||||
const betAmount = ref('');
|
||||
|
||||
// 登录模态框数据
|
||||
const loginDialogVisible = ref(false);
|
||||
const isLoggedIn = ref(false);
|
||||
const username = ref('未记录');
|
||||
const balance = ref('0'); // 余额
|
||||
const loginForm = ref({
|
||||
username: '',
|
||||
password: '',
|
||||
@@ -237,20 +237,20 @@ async function fetchUserSettings() {
|
||||
username.value = response.data.username;
|
||||
isLoggedIn.value = true;
|
||||
}
|
||||
// 更新止盈点
|
||||
if (response.data.winNum) {
|
||||
input1.value = response.data.winNum;
|
||||
// 更新投注金额
|
||||
if (response.data.betAmount) {
|
||||
betAmount.value = response.data.betAmount;
|
||||
}
|
||||
// 更新止亏点
|
||||
if (response.data.loseNum) {
|
||||
input2.value = response.data.loseNum;
|
||||
// 更新余额
|
||||
if (response.data.balance) {
|
||||
balance.value = response.data.balance;
|
||||
}
|
||||
}
|
||||
|
||||
console.log('用户设置数据获取完成');
|
||||
console.log('username.value:', username.value);
|
||||
console.log('input1.value:', input1.value);
|
||||
console.log('input2.value:', input2.value);
|
||||
console.log('betAmount.value:', betAmount.value);
|
||||
console.log('balance.value:', balance.value);
|
||||
} catch (err) {
|
||||
console.error('获取用户设置数据失败:', err);
|
||||
// 失败时不显示错误,使用默认值
|
||||
@@ -343,19 +343,18 @@ function handleLogout() {
|
||||
|
||||
// 处理确认按钮点击
|
||||
async function handleConfirm() {
|
||||
console.log('确认按钮点击,止盈点:', input1.value, '止亏点:', input2.value);
|
||||
console.log('确认按钮点击,投注金额:', betAmount.value);
|
||||
|
||||
// 验证输入
|
||||
if (!input1.value || !input2.value) {
|
||||
alert('请填写完整的止盈止亏点');
|
||||
if (!betAmount.value) {
|
||||
alert('请填写投注金额');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// 构建提交数据
|
||||
const submitData = {
|
||||
winNum: input1.value,
|
||||
loseNum: input2.value
|
||||
betAmount: betAmount.value
|
||||
};
|
||||
|
||||
console.log('提交数据:', submitData);
|
||||
@@ -446,6 +445,7 @@ onUnmounted(() => {
|
||||
<div class="account-avatar">👤</div>
|
||||
<div class="account-details">
|
||||
<div class="account-name">{{ username }}</div>
|
||||
<div class="account-balance">余额: {{ balance }}</div>
|
||||
</div>
|
||||
<div class="account-actions">
|
||||
<button type="button" class="login-button" @click="loginDialogVisible = true">账号信息</button>
|
||||
@@ -493,15 +493,9 @@ onUnmounted(() => {
|
||||
<!-- 顶部输入框区域 -->
|
||||
<div class="top-inputs">
|
||||
<div class="input-group">
|
||||
<label for="input1">止盈点:</label>
|
||||
<label for="betAmount">投注金额:</label>
|
||||
<div class="input-with-button">
|
||||
<input type="text" id="input1" v-model="input1" placeholder="请输入止盈点">
|
||||
</div>
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<label for="input2">止亏点:</label>
|
||||
<div class="input-with-button">
|
||||
<input type="text" id="input2" v-model="input2" placeholder="请输入止亏点">
|
||||
<input type="text" id="betAmount" v-model="betAmount" placeholder="请输入投注金额">
|
||||
<div class="button-group">
|
||||
<button type="button" class="confirm-button" @click="handleConfirm">确认</button>
|
||||
</div>
|
||||
@@ -612,6 +606,11 @@ onUnmounted(() => {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.account-balance {
|
||||
font-size: 0.85rem;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.account-role {
|
||||
font-size: 0.85rem;
|
||||
color: #666;
|
||||
@@ -683,14 +682,15 @@ onUnmounted(() => {
|
||||
.input-group {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.input-with-button {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: flex-start;
|
||||
align-items: center;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.input-with-button input {
|
||||
|
||||
@@ -56,6 +56,8 @@ public class LoginInfoResult {
|
||||
@Column(name = "balance")
|
||||
private String balance;
|
||||
|
||||
private Integer betAmount;
|
||||
|
||||
@Column(name = "create_time", nullable = false, updatable = false)
|
||||
@CreationTimestamp
|
||||
@Convert(converter = SQLiteDateConverter.class)
|
||||
|
||||
@@ -188,6 +188,10 @@ public class LoginServiceImpl implements LoginService {
|
||||
if (loginInfoResult.getAmount() != null) {
|
||||
dbUser.setAmount(loginInfoResult.getAmount());
|
||||
}
|
||||
// 如果传入了 betAmount,写入到配置文件
|
||||
if (loginInfoResult.getBetAmount() != null) {
|
||||
writeBaseBetUnitToConfig(loginInfoResult.getBetAmount());
|
||||
}
|
||||
if (loginInfoResult.getOnOff() != null) {
|
||||
dbUser.setOnOff(loginInfoResult.getOnOff());
|
||||
if (loginInfoResult.getOnOff().equals(1)) {
|
||||
@@ -258,16 +262,115 @@ public class LoginServiceImpl implements LoginService {
|
||||
return SQLiteUtil.addOrUpdateLoginInfo(loginInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 BASE_BET_UNIT 值写入到配置文件,保留原有结构
|
||||
*/
|
||||
private void writeBaseBetUnitToConfig(Integer betAmount) {
|
||||
String configPath = pypath+"/conf.ini";
|
||||
java.io.File configFile = new java.io.File(configPath);
|
||||
if (configFile.exists()) {
|
||||
try {
|
||||
// 读取所有行
|
||||
java.util.List<String> lines = new java.util.ArrayList<>();
|
||||
try (java.io.BufferedReader br = new java.io.BufferedReader(new java.io.FileReader(configFile))) {
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
lines.add(line);
|
||||
}
|
||||
}
|
||||
|
||||
// 查找并更新 BASE_BET_UNIT 行
|
||||
boolean updated = false;
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
String line = lines.get(i);
|
||||
if (line.startsWith("BASE_BET_UNIT =")) {
|
||||
lines.set(i, "BASE_BET_UNIT = " + betAmount);
|
||||
updated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果没有找到,在 [init] 节末尾添加
|
||||
if (!updated) {
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
String line = lines.get(i);
|
||||
if (line.startsWith("[init]")) {
|
||||
// 找到 [init] 节,在其后添加
|
||||
for (int j = i + 1; j < lines.size(); j++) {
|
||||
String nextLine = lines.get(j);
|
||||
if (nextLine.startsWith("[")) {
|
||||
// 遇到下一个节,在此之前添加
|
||||
lines.add(j, "BASE_BET_UNIT = " + betAmount);
|
||||
updated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!updated) {
|
||||
// 如果是最后一个节,在文件末尾添加
|
||||
lines.add("BASE_BET_UNIT = " + betAmount);
|
||||
updated = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 写回文件
|
||||
if (updated) {
|
||||
try (java.io.BufferedWriter bw = new java.io.BufferedWriter(new java.io.FileWriter(configFile))) {
|
||||
for (String line : lines) {
|
||||
bw.write(line);
|
||||
bw.newLine();
|
||||
}
|
||||
}
|
||||
System.out.println("BASE_BET_UNIT 已更新为: " + betAmount);
|
||||
} else {
|
||||
System.err.println("未找到 [init] 节,无法更新 BASE_BET_UNIT");
|
||||
}
|
||||
} catch (java.io.IOException e) {
|
||||
System.err.println("读写配置文件失败: " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
System.err.println("配置文件不存在: " + configPath);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoginInfoResult getUserSettings() {
|
||||
try {
|
||||
// 获取最新的用户设置信息
|
||||
Optional<LoginInfoResult> existingUser = loginInfoRepository.findFirstByOrderByCreateTimeDesc();
|
||||
LoginInfoResult loginInfoResult;
|
||||
if (existingUser.isPresent()) {
|
||||
return existingUser.get();
|
||||
loginInfoResult = existingUser.get();
|
||||
} else {
|
||||
// 如果没有找到,返回一个空的对象
|
||||
loginInfoResult = new LoginInfoResult();
|
||||
}
|
||||
// 如果没有找到,返回一个空的对象
|
||||
return new LoginInfoResult();
|
||||
|
||||
// 读取 PyModel/conf.ini 文件中的 BASE_BET_UNIT 值
|
||||
String configPath = pypath+"/conf.ini";
|
||||
java.io.File configFile = new java.io.File(configPath);
|
||||
if (configFile.exists()) {
|
||||
java.util.Properties properties = new java.util.Properties();
|
||||
try (java.io.FileInputStream fis = new java.io.FileInputStream(configFile)) {
|
||||
properties.load(fis);
|
||||
String baseBetUnit = properties.getProperty("BASE_BET_UNIT");
|
||||
if (baseBetUnit != null) {
|
||||
try {
|
||||
loginInfoResult.setBetAmount(Integer.parseInt(baseBetUnit));
|
||||
} catch (NumberFormatException e) {
|
||||
System.err.println("BASE_BET_UNIT 格式错误: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
} catch (java.io.IOException e) {
|
||||
System.err.println("读取配置文件失败: " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
System.err.println("配置文件不存在: " + configPath);
|
||||
}
|
||||
|
||||
return loginInfoResult;
|
||||
} catch (Exception e) {
|
||||
System.err.println("获取用户设置信息失败: " + e.getMessage());
|
||||
return new LoginInfoResult();
|
||||
|
||||
Reference in New Issue
Block a user