每周更新

This commit is contained in:
2026-01-16 15:03:50 +08:00
parent cb0a715f4a
commit da223f8935
28 changed files with 738 additions and 888 deletions

View File

@@ -223,7 +223,7 @@
>
<el-input
v-model="form.sellCount"
placeholder="0 - 9999"
placeholder="1 - 9999"
inputmode="numeric"
style="width: 50%"
@input="handleSellCountInput"
@@ -625,9 +625,43 @@ export default {
this.getPayTypes();
this.loadSupportCoins();
this.userEmail = JSON.parse(localStorage.getItem("leasEmail")) || "";
this.userEmail = this.getLeasEmailFromStorage();
},
methods: {
/**
* 安全获取本地缓存的邮箱(兼容:纯字符串 / JSON 字符串)
*
* 背景:项目里 `leasEmail` 存储方式不一致,有的地方直接 `setItem('leasEmail', email)` 存纯字符串,
* 如果这里强行 JSON.parse 会导致 created hook 直接报错并中断页面逻辑。
*
* @returns {string} 邮箱;获取失败返回空字符串
*/
getLeasEmailFromStorage() {
const raw = localStorage.getItem("leasEmail");
if (!raw) return "";
const trimmed = String(raw).trim();
if (!trimmed) return "";
// 常见情况:直接存的纯字符串邮箱
if (!trimmed.startsWith("{") && !trimmed.startsWith("[") && !trimmed.startsWith('"')) {
return trimmed;
}
// 兼容情况:存了 JSON例如 '"a@b.com"' 或 { email: '...' }
try {
const parsed = JSON.parse(trimmed);
if (typeof parsed === "string") return parsed.trim();
if (parsed && typeof parsed === "object") {
const v = parsed.email || parsed.leasEmail || parsed.userEmail;
return v ? String(v).trim() : "";
}
return "";
} catch (e) {
// JSON 解析失败兜底:按纯字符串处理,避免抛错
return trimmed;
}
},
/** ASIC 行校验:币种/算法/理论算力/单位 */
validateCoinAlgoRows(rule, value, callback) {
try {
@@ -954,6 +988,12 @@ export default {
if (n > 9999) v = "9999";
}
this.form.sellCount = v;
// 当输入框为空时,清除验证错误
if (!v || v === "") {
this.$nextTick(() => {
this.$refs.machineForm && this.$refs.machineForm.clearValidate('sellCount');
});
}
},
handleSellCountBlur() {
const raw = String(this.form.sellCount ?? "");
@@ -976,17 +1016,17 @@ export default {
*/
handleDownloadClient(types) {
// 走后端接口下载客户端程序
let userEmail = "";
try {
const email = localStorage.getItem("leasEmail");
if (email) {
userEmail = JSON.parse(email);
}
} catch (e) {
// 忽略解析错误userEmail 保持为空字符串
const userEmail = this.getLeasEmailFromStorage();
console.log(userEmail, "userEmail");
if (!userEmail) {
this.$message.warning("未获取到登录邮箱,无法下载客户端,请重新登录后再试");
return;
}
this.downloadUrl = `${request.defaults.baseURL}/lease/user/downloadClient?userEmail=${userEmail || ""}&type=${types}`;
this.downloadUrl = `${request.defaults.baseURL}/lease/user/downloadClient?userEmail=${encodeURIComponent(
userEmail
)}&type=${encodeURIComponent(types || "")}`;
let a = document.createElement(`a`);
a.href = this.downloadUrl;
a.click();
@@ -1179,6 +1219,12 @@ export default {
if (typeof this.form.type === "string" && this.form.type.length > 20) {
this.form.type = this.form.type.slice(0, 20);
}
// 当输入框为空时,清除验证错误
if (!this.form.type || this.form.type.trim() === "") {
this.$nextTick(() => {
this.$refs.machineForm && this.$refs.machineForm.clearValidate('type');
});
}
},
syncCostToRows() {
const newCost = Number(this.form.cost);