时间
This commit is contained in:
@@ -16,11 +16,21 @@ import {
|
|||||||
import { fetchStats, incrementGenerationCount, type StatsResponse } from "@/lib/stats";
|
import { fetchStats, incrementGenerationCount, type StatsResponse } from "@/lib/stats";
|
||||||
import { TemplateScaleFrame } from "@/templates/template-primitives";
|
import { TemplateScaleFrame } from "@/templates/template-primitives";
|
||||||
|
|
||||||
|
function getTodayDateValue() {
|
||||||
|
const now = new Date();
|
||||||
|
const year = now.getFullYear();
|
||||||
|
const month = `${now.getMonth() + 1}`.padStart(2, "0");
|
||||||
|
const day = `${now.getDate()}`.padStart(2, "0");
|
||||||
|
|
||||||
|
return `${year}-${month}-${day}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const defaultFormData: CertificateFormData = {
|
const defaultFormData: CertificateFormData = {
|
||||||
childName: "",
|
childName: "",
|
||||||
familyAddress: "腾讯云LightHouse",
|
familyAddress: "腾讯云LightHouse",
|
||||||
parentName: "",
|
parentName: "",
|
||||||
birthDate: "",
|
birthDate: getTodayDateValue(),
|
||||||
birthAddress: "腾讯云x星洋智慧",
|
birthAddress: "腾讯云x星洋智慧",
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -33,9 +43,9 @@ const emptyStats: StatsResponse = {
|
|||||||
const desktopPreviewWidth = 760;
|
const desktopPreviewWidth = 760;
|
||||||
const mobileBreakpoint = 768;
|
const mobileBreakpoint = 768;
|
||||||
const statsUnavailableMessage =
|
const statsUnavailableMessage =
|
||||||
"统计服务未连接,当前数量不会持久化。请同时运行 npm run dev 和 npm run dev:server,或直接运行 npm run dev:all。";
|
"统计服务未连接。";
|
||||||
const statsIncrementFailedMessage =
|
const statsIncrementFailedMessage =
|
||||||
"图片已下载,但统计服务没有记录这次生成。请同时运行 npm run dev 和 npm run dev:server,或直接运行 npm run dev:all。";
|
"图片已下载。";
|
||||||
|
|
||||||
function TemplateThumbnail({
|
function TemplateThumbnail({
|
||||||
template,
|
template,
|
||||||
@@ -137,9 +147,10 @@ function CertificateFormFields({
|
|||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<input
|
<input
|
||||||
|
type={key === "birthDate" ? "date" : "text"}
|
||||||
value={formData[key]}
|
value={formData[key]}
|
||||||
onChange={onChange(key)}
|
onChange={onChange(key)}
|
||||||
placeholder={`请输入${certificateFieldLabels[key]}`}
|
placeholder={key === "birthDate" ? undefined : `请输入${certificateFieldLabels[key]}`}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</label>
|
</label>
|
||||||
@@ -198,7 +209,7 @@ export function CertificateGenerator() {
|
|||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
if (!active) return;
|
if (!active) return;
|
||||||
setStatsMessage(statsUnavailableMessage);
|
// setStatsMessage(statsUnavailableMessage);
|
||||||
});
|
});
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
@@ -266,7 +277,7 @@ export function CertificateGenerator() {
|
|||||||
setStats(nextStats);
|
setStats(nextStats);
|
||||||
setStatsMessage("");
|
setStatsMessage("");
|
||||||
} catch {
|
} catch {
|
||||||
setStatsMessage(statsIncrementFailedMessage);
|
// setStatsMessage(statsIncrementFailedMessage);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setErrorMessage(error instanceof Error ? error.message : "导出失败,请稍后重试。");
|
setErrorMessage(error instanceof Error ? error.message : "导出失败,请稍后重试。");
|
||||||
@@ -352,8 +363,8 @@ export function CertificateGenerator() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{errorMessage ? <div className="error-box">{errorMessage}</div> : null}
|
{/* {errorMessage ? <div className="error-box">{errorMessage}</div> : null}
|
||||||
{statsMessage ? <div className="error-box">{statsMessage}</div> : null}
|
{statsMessage ? <div className="error-box">{statsMessage}</div> : null} */}
|
||||||
|
|
||||||
<div ref={previewMeasureRef} className="preview-frame preview-frame--studio">
|
<div ref={previewMeasureRef} className="preview-frame preview-frame--studio">
|
||||||
<TemplateScaleFrame
|
<TemplateScaleFrame
|
||||||
|
|||||||
Reference in New Issue
Block a user