修改前端
This commit is contained in:
@@ -4,13 +4,13 @@ import axios from 'axios';
|
|||||||
import * as echarts from 'echarts';
|
import * as echarts from 'echarts';
|
||||||
|
|
||||||
// 输入框数据
|
// 输入框数据
|
||||||
const input1 = ref('');
|
const betAmount = ref('');
|
||||||
const input2 = ref('');
|
|
||||||
|
|
||||||
// 登录模态框数据
|
// 登录模态框数据
|
||||||
const loginDialogVisible = ref(false);
|
const loginDialogVisible = ref(false);
|
||||||
const isLoggedIn = ref(false);
|
const isLoggedIn = ref(false);
|
||||||
const username = ref('未记录');
|
const username = ref('未记录');
|
||||||
|
const balance = ref('0'); // 余额
|
||||||
const loginForm = ref({
|
const loginForm = ref({
|
||||||
username: '',
|
username: '',
|
||||||
password: '',
|
password: '',
|
||||||
@@ -237,20 +237,20 @@ async function fetchUserSettings() {
|
|||||||
username.value = response.data.username;
|
username.value = response.data.username;
|
||||||
isLoggedIn.value = true;
|
isLoggedIn.value = true;
|
||||||
}
|
}
|
||||||
// 更新止盈点
|
// 更新投注金额
|
||||||
if (response.data.winNum) {
|
if (response.data.betAmount) {
|
||||||
input1.value = response.data.winNum;
|
betAmount.value = response.data.betAmount;
|
||||||
}
|
}
|
||||||
// 更新止亏点
|
// 更新余额
|
||||||
if (response.data.loseNum) {
|
if (response.data.balance) {
|
||||||
input2.value = response.data.loseNum;
|
balance.value = response.data.balance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('用户设置数据获取完成');
|
console.log('用户设置数据获取完成');
|
||||||
console.log('username.value:', username.value);
|
console.log('username.value:', username.value);
|
||||||
console.log('input1.value:', input1.value);
|
console.log('betAmount.value:', betAmount.value);
|
||||||
console.log('input2.value:', input2.value);
|
console.log('balance.value:', balance.value);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('获取用户设置数据失败:', err);
|
console.error('获取用户设置数据失败:', err);
|
||||||
// 失败时不显示错误,使用默认值
|
// 失败时不显示错误,使用默认值
|
||||||
@@ -343,19 +343,18 @@ function handleLogout() {
|
|||||||
|
|
||||||
// 处理确认按钮点击
|
// 处理确认按钮点击
|
||||||
async function handleConfirm() {
|
async function handleConfirm() {
|
||||||
console.log('确认按钮点击,止盈点:', input1.value, '止亏点:', input2.value);
|
console.log('确认按钮点击,投注金额:', betAmount.value);
|
||||||
|
|
||||||
// 验证输入
|
// 验证输入
|
||||||
if (!input1.value || !input2.value) {
|
if (!betAmount.value) {
|
||||||
alert('请填写完整的止盈止亏点');
|
alert('请填写投注金额');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 构建提交数据
|
// 构建提交数据
|
||||||
const submitData = {
|
const submitData = {
|
||||||
winNum: input1.value,
|
betAmount: betAmount.value
|
||||||
loseNum: input2.value
|
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log('提交数据:', submitData);
|
console.log('提交数据:', submitData);
|
||||||
@@ -446,6 +445,7 @@ onUnmounted(() => {
|
|||||||
<div class="account-avatar">👤</div>
|
<div class="account-avatar">👤</div>
|
||||||
<div class="account-details">
|
<div class="account-details">
|
||||||
<div class="account-name">{{ username }}</div>
|
<div class="account-name">{{ username }}</div>
|
||||||
|
<div class="account-balance">余额: {{ balance }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="account-actions">
|
<div class="account-actions">
|
||||||
<button type="button" class="login-button" @click="loginDialogVisible = true">账号信息</button>
|
<button type="button" class="login-button" @click="loginDialogVisible = true">账号信息</button>
|
||||||
@@ -493,15 +493,9 @@ onUnmounted(() => {
|
|||||||
<!-- 顶部输入框区域 -->
|
<!-- 顶部输入框区域 -->
|
||||||
<div class="top-inputs">
|
<div class="top-inputs">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<label for="input1">止盈点:</label>
|
<label for="betAmount">投注金额:</label>
|
||||||
<div class="input-with-button">
|
<div class="input-with-button">
|
||||||
<input type="text" id="input1" v-model="input1" placeholder="请输入止盈点">
|
<input type="text" id="betAmount" v-model="betAmount" 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="请输入止亏点">
|
|
||||||
<div class="button-group">
|
<div class="button-group">
|
||||||
<button type="button" class="confirm-button" @click="handleConfirm">确认</button>
|
<button type="button" class="confirm-button" @click="handleConfirm">确认</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -612,6 +606,11 @@ onUnmounted(() => {
|
|||||||
margin-bottom: 4px;
|
margin-bottom: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.account-balance {
|
||||||
|
font-size: 0.85rem;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
.account-role {
|
.account-role {
|
||||||
font-size: 0.85rem;
|
font-size: 0.85rem;
|
||||||
color: #666;
|
color: #666;
|
||||||
@@ -683,14 +682,15 @@ onUnmounted(() => {
|
|||||||
.input-group {
|
.input-group {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.input-with-button {
|
.input-with-button {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
align-items: flex-start;
|
align-items: center;
|
||||||
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.input-with-button input {
|
.input-with-button input {
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ public class LoginInfoResult {
|
|||||||
@Column(name = "balance")
|
@Column(name = "balance")
|
||||||
private String balance;
|
private String balance;
|
||||||
|
|
||||||
|
private Integer betAmount;
|
||||||
|
|
||||||
@Column(name = "create_time", nullable = false, updatable = false)
|
@Column(name = "create_time", nullable = false, updatable = false)
|
||||||
@CreationTimestamp
|
@CreationTimestamp
|
||||||
@Convert(converter = SQLiteDateConverter.class)
|
@Convert(converter = SQLiteDateConverter.class)
|
||||||
|
|||||||
@@ -188,6 +188,10 @@ public class LoginServiceImpl implements LoginService {
|
|||||||
if (loginInfoResult.getAmount() != null) {
|
if (loginInfoResult.getAmount() != null) {
|
||||||
dbUser.setAmount(loginInfoResult.getAmount());
|
dbUser.setAmount(loginInfoResult.getAmount());
|
||||||
}
|
}
|
||||||
|
// 如果传入了 betAmount,写入到配置文件
|
||||||
|
if (loginInfoResult.getBetAmount() != null) {
|
||||||
|
writeBaseBetUnitToConfig(loginInfoResult.getBetAmount());
|
||||||
|
}
|
||||||
if (loginInfoResult.getOnOff() != null) {
|
if (loginInfoResult.getOnOff() != null) {
|
||||||
dbUser.setOnOff(loginInfoResult.getOnOff());
|
dbUser.setOnOff(loginInfoResult.getOnOff());
|
||||||
if (loginInfoResult.getOnOff().equals(1)) {
|
if (loginInfoResult.getOnOff().equals(1)) {
|
||||||
@@ -258,16 +262,115 @@ public class LoginServiceImpl implements LoginService {
|
|||||||
return SQLiteUtil.addOrUpdateLoginInfo(loginInfo);
|
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
|
@Override
|
||||||
public LoginInfoResult getUserSettings() {
|
public LoginInfoResult getUserSettings() {
|
||||||
try {
|
try {
|
||||||
// 获取最新的用户设置信息
|
// 获取最新的用户设置信息
|
||||||
Optional<LoginInfoResult> existingUser = loginInfoRepository.findFirstByOrderByCreateTimeDesc();
|
Optional<LoginInfoResult> existingUser = loginInfoRepository.findFirstByOrderByCreateTimeDesc();
|
||||||
|
LoginInfoResult loginInfoResult;
|
||||||
if (existingUser.isPresent()) {
|
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) {
|
} catch (Exception e) {
|
||||||
System.err.println("获取用户设置信息失败: " + e.getMessage());
|
System.err.println("获取用户设置信息失败: " + e.getMessage());
|
||||||
return new LoginInfoResult();
|
return new LoginInfoResult();
|
||||||
|
|||||||
Reference in New Issue
Block a user