fix: 修复预览成功页与记录页运行时报错

This commit is contained in:
que01 committed 2026-10-09 15:24:15 +08:00
1 parent fd2e970d8b
commit 541304a763
4 files changed
+31 -8

No files matched your search

+10 -3
View File
@@ -25,13 +25,20 @@ const labels: Record<string, string> = {
converted: "已转化",
closed: "已关闭",
};
export function Records({ workspace }: { workspace: RuntimeWorkspace }) {
export function Records({
workspace,
preview = false,
}: {
workspace: RuntimeWorkspace;
preview?: boolean;
}) {
const [records, setRecords] = useState<RecordItem[]>([]);
const [error, setError] = useState("");
const [loading, setLoading] = useState(false);
const [authenticated, setAuthenticated] = useState(hasSession());
const [authenticated, setAuthenticated] = useState(preview ? false : hasSession());
const p = presentation(workspace, "records");
const load = useCallback(() => {
if (preview) return;
if (!hasSession()) {
setAuthenticated(false);
setRecords([]);
@@ -46,7 +53,7 @@ export function Records({ workspace }: { workspace: RuntimeWorkspace }) {
setAuthenticated(hasSession());
})
.finally(() => setLoading(false));
}, []);
}, [preview]);
useDidShow(load);
return (
<View className="records-page">
+11 -3
View File
@@ -4,10 +4,18 @@ import type { RuntimeWorkspace } from "@personal-brand/types";
import { presentation, object, text } from "../runtime/content";
import { brandSlug } from "../runtime/api";
import { navigate } from "../runtime/navigation";
export function Success({ workspace }: { workspace: RuntimeWorkspace }) {
export function Success({
workspace,
preview = false,
}: {
workspace: RuntimeWorkspace;
preview?: boolean;
}) {
const p = presentation(workspace, "success");
const result = object(Taro.getStorageSync<unknown>(`latestInquiry:${brandSlug()}`));
if (!text(result.id))
const submitted =
preview ||
Boolean(text(object(Taro.getStorageSync<unknown>(`latestInquiry:${brandSlug()}`)).id));
if (!submitted)
return (
<View className="runtime-state">
尚未提交咨询<Button onClick={() => navigate("inquiry")}>填写需求</Button>