fix: 增强错误处理与组件逻辑优化

- 在 App.vue 中添加 JSON 解析错误处理,确保站点信息获取的稳定性。
- 更新多个 API 请求,添加 loading 状态管理,提升用户体验。
- 在 Search.vue 中优化热词列表的解析逻辑,增强容错性。
- 改进购物车、地址管理等 API 请求参数,确保一致性与可用性。
- 新增用户中心布局组件,提升用户界面的一致性与可读性。
This commit is contained in:
田香琪
2026-07-03 18:29:41 +08:00
parent 99de0d4722
commit bd9a5f75b0
79 changed files with 2382 additions and 1207 deletions

View File

@@ -1,7 +1,8 @@
import { ElLoading, ElMessage, ElMessageBox } from "element-plus";
let loadingInstance = null;
const MESSAGE_OFFSET = 36;
let loadingInstance = null;
export const Spin = {
show(options = {}) {
Spin.hide();
@@ -28,19 +29,18 @@ export const Spin = {
export const Message = {
success(content) {
return ElMessage.success(normalize(content));
return showMessage("success", content);
},
error(content) {
return ElMessage.error(normalize(content));
return showMessage("error", content);
},
warning(content) {
return ElMessage.warning(normalize(content));
return showMessage("warning", content);
},
info(content) {
return ElMessage.info(normalize(content));
return showMessage("info", content);
},
};
export const Notice = {
open(options = {}) {
const fn = Message[options.type] || Message.info;
@@ -95,8 +95,14 @@ export const Modal = {
},
};
function normalize(content) {
if (typeof content === "string") return content;
function showMessage(type, content) {
return ElMessage[type]({
message: normalize(content),
offset: MESSAGE_OFFSET,
});
}
function normalize(content) { if (typeof content === "string") return content;
if (content && content.content) return content.content;
return String(content ?? "");
}