diff --git a/apps/admin/src/components/ImageUrlField.tsx b/apps/admin/src/components/ImageUrlField.tsx
index 9f9ec00..1728afd 100644
--- a/apps/admin/src/components/ImageUrlField.tsx
+++ b/apps/admin/src/components/ImageUrlField.tsx
@@ -66,9 +66,8 @@ export function ImageUrlField({ id, value, onChange, placeholder, scope }: Image
});
if (!response.ok) throw new Error(`upload failed: ${response.status}`);
onChange?.(presign.publicUrl);
- } catch {
- setStorageStatus("unavailable");
- message.error("图片上传失败,请检查对象存储后重试");
+ } catch (error) {
+ message.error(error instanceof Error ? error.message : "图片上传失败,请重试");
} finally {
setUploading(false);
}
diff --git a/apps/admin/src/features/publication/PublicationPage.tsx b/apps/admin/src/features/publication/PublicationPage.tsx
index fec3a20..afd04d9 100644
--- a/apps/admin/src/features/publication/PublicationPage.tsx
+++ b/apps/admin/src/features/publication/PublicationPage.tsx
@@ -196,7 +196,7 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
},
onSuccess: () => {
message.success("小程序代码已上传");
- void miniAppReleases.refetch();
+ void queryClient.invalidateQueries({ queryKey: ["publication-miniapp-releases"] });
},
});
const saveMiniAppSettings = useMutation({
@@ -208,14 +208,14 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
}),
onSuccess: () => {
message.success("小程序上传配置已保存");
- void miniAppSettings.refetch();
+ void queryClient.invalidateQueries({ queryKey: ["publication-miniapp-settings"] });
},
});
const uploadMiniAppRelease = useMutation({
mutationFn: (id: string) => client.uploadAdminMiniAppRelease(id),
onSuccess: () => {
message.success("小程序代码已上传");
- void miniAppReleases.refetch();
+ void queryClient.invalidateQueries({ queryKey: ["publication-miniapp-releases"] });
},
});
const updateMiniAppStatus = useMutation({
@@ -228,7 +228,7 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
}) => client.updateAdminMiniAppReleaseStatus(id, { status }),
onSuccess: () => {
message.success("小程序发布状态已更新");
- void miniAppReleases.refetch();
+ void queryClient.invalidateQueries({ queryKey: ["publication-miniapp-releases"] });
},
});
const loading = [
diff --git a/apps/admin/src/main.tsx b/apps/admin/src/main.tsx
index 0b556b2..7c746e7 100644
--- a/apps/admin/src/main.tsx
+++ b/apps/admin/src/main.tsx
@@ -78,7 +78,18 @@ const FeaturePublicationPage = React.lazy(() =>
import { BrowserRouter, Navigate, Route, Routes, useLocation, useNavigate } from "react-router-dom";
import "antd/dist/reset.css";
-const queryClient = new QueryClient();
+const queryClient = new QueryClient({
+ defaultOptions: {
+ queries: {
+ staleTime: 30_000,
+ retry: 2,
+ refetchOnWindowFocus: false,
+ },
+ mutations: {
+ retry: 0,
+ },
+ },
+});
const api = createApiClient;
function Login({
diff --git a/apps/miniapp/components/modules/records/records.js b/apps/miniapp/components/modules/records/records.js
index c39f4ab..8bf8cbc 100644
--- a/apps/miniapp/components/modules/records/records.js
+++ b/apps/miniapp/components/modules/records/records.js
@@ -1,6 +1,7 @@
Component({
properties: {
records: { type: Array, value: [] },
+ loadError: { type: String, value: "" },
presentation: { type: Object, value: {} },
},
methods: {
diff --git a/apps/miniapp/components/modules/records/records.wxml b/apps/miniapp/components/modules/records/records.wxml
index a3465a9..1da74a1 100644
--- a/apps/miniapp/components/modules/records/records.wxml
+++ b/apps/miniapp/components/modules/records/records.wxml
@@ -1 +1 @@
-{{presentation.emptyTitle}}{{presentation.emptyDescription}}{{item.type}}{{item.status}}{{item.project}} · {{item.offeringName}}档案编号 {{item.id}} {{item.createdAt}}●{{item.status}} · {{item.createdAt}}
+记录加载失败{{loadError}}{{presentation.emptyTitle}}{{presentation.emptyDescription}}{{item.type}}{{item.status}}{{item.project}} · {{item.offeringName}}档案编号 {{item.id}} {{item.createdAt}}●{{item.status}} · {{item.createdAt}}
diff --git a/apps/miniapp/pages/records/index.js b/apps/miniapp/pages/records/index.js
index 6b3f978..f5bf687 100644
--- a/apps/miniapp/pages/records/index.js
+++ b/apps/miniapp/pages/records/index.js
@@ -12,7 +12,7 @@ const statusLabels = {
};
Page({
- data: { records: [], loading: false, presentation: {} },
+ data: { records: [], loading: false, loadError: "", presentation: {} },
onLoad() {
loadWorkspaceWithFallback()
.then((workspace) =>
@@ -21,12 +21,13 @@ Page({
.catch(() => {});
},
onShow() {
- if (!wx.getStorageSync(customerTokenKey())) return this.setData({ records: [] });
- this.setData({ loading: true });
+ if (!wx.getStorageSync(customerTokenKey())) return this.setData({ records: [], loadError: "" });
+ this.setData({ loading: true, loadError: "" });
customerRequest("/customer/inquiry-submissions")
.then((items) =>
this.setData({
loading: false,
+ loadError: "",
records: items.map((item) => ({
...item,
type: item.inquiryForm?.name || "品牌咨询",
@@ -42,8 +43,7 @@ Page({
}),
)
.catch((error) => {
- this.setData({ loading: false });
- wx.showToast({ title: error.message || "记录加载失败", icon: "none" });
+ this.setData({ loading: false, loadError: error.message || "记录加载失败" });
});
},
inquire() {
diff --git a/apps/miniapp/pages/records/index.wxml b/apps/miniapp/pages/records/index.wxml
index 866fc1c..3ac812c 100644
--- a/apps/miniapp/pages/records/index.wxml
+++ b/apps/miniapp/pages/records/index.wxml
@@ -1 +1 @@
-{{presentation.title}}
+{{presentation.title}}
diff --git a/packages/template-acheng-campus-food/miniapp/pages/inquiry/index.js b/packages/template-acheng-campus-food/miniapp/pages/inquiry/index.js
index 3cc6d96..99fd79e 100644
--- a/packages/template-acheng-campus-food/miniapp/pages/inquiry/index.js
+++ b/packages/template-acheng-campus-food/miniapp/pages/inquiry/index.js
@@ -28,6 +28,7 @@ Page({
data: {
subView: "form",
records: [],
+ recordsError: "",
// 字段全部来自后台已发布的咨询表单,模板只负责呈现。
fields: [],
values: {},
@@ -76,10 +77,13 @@ Page({
this.loadRecords();
},
loadRecords() {
- if (!wx.getStorageSync(customerTokenKey())) return;
+ if (!wx.getStorageSync(customerTokenKey()))
+ return this.setData({ records: [], recordsError: "" });
+ this.setData({ recordsError: "" });
customerRequest("/customer/inquiry-submissions")
.then((items) =>
this.setData({
+ recordsError: "",
records: (items || []).map((item) => ({
...item,
title: item.inquiryForm?.name || "品牌咨询",
@@ -90,7 +94,9 @@ Page({
})),
}),
)
- .catch(() => {});
+ .catch((error) =>
+ this.setData({ recordsError: error.message || "记录加载失败,请下拉或稍后重试" }),
+ );
},
switchView(e) {
this.setData({ subView: e.currentTarget.dataset.view });
diff --git a/packages/template-acheng-campus-food/miniapp/pages/inquiry/index.wxml b/packages/template-acheng-campus-food/miniapp/pages/inquiry/index.wxml
index 4da88a5..46df609 100644
--- a/packages/template-acheng-campus-food/miniapp/pages/inquiry/index.wxml
+++ b/packages/template-acheng-campus-food/miniapp/pages/inquiry/index.wxml
@@ -21,7 +21,8 @@
- ▣暂无咨询记录提交需求后,可以在这里查看处理进度。
+ !记录加载失败{{recordsError}}
+ ▣暂无咨询记录提交需求后,可以在这里查看处理进度。
单号 #{{item.id}}{{item.status}}
diff --git a/packages/template-acheng-campus-food/miniapp/pages/records/index.js b/packages/template-acheng-campus-food/miniapp/pages/records/index.js
index 6b3f978..f5bf687 100644
--- a/packages/template-acheng-campus-food/miniapp/pages/records/index.js
+++ b/packages/template-acheng-campus-food/miniapp/pages/records/index.js
@@ -12,7 +12,7 @@ const statusLabels = {
};
Page({
- data: { records: [], loading: false, presentation: {} },
+ data: { records: [], loading: false, loadError: "", presentation: {} },
onLoad() {
loadWorkspaceWithFallback()
.then((workspace) =>
@@ -21,12 +21,13 @@ Page({
.catch(() => {});
},
onShow() {
- if (!wx.getStorageSync(customerTokenKey())) return this.setData({ records: [] });
- this.setData({ loading: true });
+ if (!wx.getStorageSync(customerTokenKey())) return this.setData({ records: [], loadError: "" });
+ this.setData({ loading: true, loadError: "" });
customerRequest("/customer/inquiry-submissions")
.then((items) =>
this.setData({
loading: false,
+ loadError: "",
records: items.map((item) => ({
...item,
type: item.inquiryForm?.name || "品牌咨询",
@@ -42,8 +43,7 @@ Page({
}),
)
.catch((error) => {
- this.setData({ loading: false });
- wx.showToast({ title: error.message || "记录加载失败", icon: "none" });
+ this.setData({ loading: false, loadError: error.message || "记录加载失败" });
});
},
inquire() {
diff --git a/packages/template-acheng-campus-food/miniapp/pages/records/index.wxml b/packages/template-acheng-campus-food/miniapp/pages/records/index.wxml
index ce2475e..7e305b8 100644
--- a/packages/template-acheng-campus-food/miniapp/pages/records/index.wxml
+++ b/packages/template-acheng-campus-food/miniapp/pages/records/index.wxml
@@ -1 +1 @@
-我的预订{{presentation.title || '我的预订记录'}}
+我的预订{{presentation.title || '我的预订记录'}}
diff --git a/packages/template-linjing-editorial/miniapp/pages/bookings/index.js b/packages/template-linjing-editorial/miniapp/pages/bookings/index.js
index ba93bd9..05929b0 100644
--- a/packages/template-linjing-editorial/miniapp/pages/bookings/index.js
+++ b/packages/template-linjing-editorial/miniapp/pages/bookings/index.js
@@ -2,7 +2,7 @@ const { loadWorkspaceWithFallback } = require("../../utils/runtime-workspace");
const { customerRequest, customerTokenKey } = require("../../utils/request");
Page({
- data: { brand: {}, records: [], error: "" },
+ data: { brand: {}, records: [], error: "", recordsError: "" },
onLoad() {
loadWorkspaceWithFallback()
.then((workspace) =>
@@ -17,10 +17,15 @@ Page({
this.loadRecords();
},
loadRecords() {
- if (!wx.getStorageSync(customerTokenKey())) return this.setData({ records: [] });
+ if (!wx.getStorageSync(customerTokenKey()))
+ return this.setData({ records: [], recordsError: "" });
customerRequest("/customer/inquiry-submissions")
- .then((records) => this.setData({ records: Array.isArray(records) ? records : [] }))
- .catch(() => this.setData({ records: [] }));
+ .then((records) =>
+ this.setData({ records: Array.isArray(records) ? records : [], recordsError: "" }),
+ )
+ .catch((error) =>
+ this.setData({ recordsError: error.message || "记录加载失败,请稍后重试" }),
+ );
},
call() {
wx.makePhoneCall({
diff --git a/packages/template-linjing-editorial/miniapp/pages/bookings/index.wxml b/packages/template-linjing-editorial/miniapp/pages/bookings/index.wxml
index 104beaa..3c51333 100644
--- a/packages/template-linjing-editorial/miniapp/pages/bookings/index.wxml
+++ b/packages/template-linjing-editorial/miniapp/pages/bookings/index.wxml
@@ -1,4 +1,5 @@
- {{error}}
+ {{recordsError}}
+ {{error}}