feat: 收口小程序构建上传阶段
This commit is contained in:
1 parent
6420b85019
commit
ec16fff70e
23 files changed
+1185
-104
No files matched your search
@@ -7,7 +7,7 @@ import type { StatusTone } from "../../components/StatusTag.js";
|
||||
|
||||
type ReleaseStatus = MiniAppReleaseTask["status"];
|
||||
|
||||
const STALE_BUILDING_MS = 15 * 60 * 1000;
|
||||
const STALE_BUILDING_MS = 30 * 60 * 1000;
|
||||
|
||||
function isStaleBuilding(task: MiniAppReleaseTask): boolean {
|
||||
if (task.buildStatus !== "building") return false;
|
||||
@@ -29,6 +29,27 @@ const statusView: Record<ReleaseStatus, { label: string; tone: StatusTone; hint:
|
||||
failed: { label: "失败", tone: "error", hint: "上次构建或上传失败,可直接重试。" },
|
||||
};
|
||||
|
||||
const uploadStatusView: Record<
|
||||
NonNullable<MiniAppReleaseTask["uploadStatus"]>,
|
||||
{ label: string; tone: StatusTone }
|
||||
> = {
|
||||
idle: { label: "未上传", tone: "neutral" },
|
||||
uploading: { label: "上传中", tone: "warning" },
|
||||
uploaded: { label: "上传完成", tone: "success" },
|
||||
failed: { label: "上传失败", tone: "error" },
|
||||
timed_out: { label: "上传超时", tone: "error" },
|
||||
};
|
||||
|
||||
const reviewStatusView: Record<
|
||||
NonNullable<MiniAppReleaseTask["reviewStatus"]>,
|
||||
{ label: string; tone: StatusTone }
|
||||
> = {
|
||||
not_submitted: { label: "未提交审核", tone: "neutral" },
|
||||
under_review: { label: "审核中", tone: "warning" },
|
||||
approved: { label: "审核通过", tone: "success" },
|
||||
rejected: { label: "审核驳回", tone: "error" },
|
||||
};
|
||||
|
||||
function formatTime(value: string): string {
|
||||
const date = new Date(value);
|
||||
if (Number.isNaN(date.getTime())) return value;
|
||||
@@ -55,6 +76,8 @@ export function MiniAppReleaseCard({
|
||||
const logRef = useRef<HTMLPreElement>(null);
|
||||
const logs = task.buildLogs ?? [];
|
||||
const status = statusView[task.status];
|
||||
const uploadStatus = task.uploadStatus ? uploadStatusView[task.uploadStatus] : null;
|
||||
const reviewStatus = task.reviewStatus ? reviewStatusView[task.reviewStatus] : null;
|
||||
const building = task.buildStatus === "building";
|
||||
const staleBuilding = isStaleBuilding(task);
|
||||
|
||||
@@ -109,12 +132,19 @@ export function MiniAppReleaseCard({
|
||||
{building && (
|
||||
<StatusTag tone="warning" label={staleBuilding ? "构建已中断" : "构建中"} />
|
||||
)}
|
||||
{!building && task.buildStatus === "success" && (
|
||||
<StatusTag tone="success" label="构建完成" />
|
||||
)}
|
||||
{uploadStatus && <StatusTag tone={uploadStatus.tone} label={uploadStatus.label} />}
|
||||
{reviewStatus && reviewStatusView[task.reviewStatus ?? "not_submitted"] && (
|
||||
<StatusTag tone={reviewStatus.tone} label={reviewStatus.label} />
|
||||
)}
|
||||
{task.weappUploadId && (
|
||||
<Typography.Text type="secondary">微信版本 {task.weappUploadId}</Typography.Text>
|
||||
)}
|
||||
</Space>
|
||||
<span className="admin-text-xs">
|
||||
{staleBuilding ? "超过 15 分钟没有新的构建输出,可能已中断;可直接重试。" : status.hint}
|
||||
{staleBuilding ? "超过 30 分钟没有新的构建输出,可能已中断;可直接重试。" : status.hint}
|
||||
</span>
|
||||
<Tooltip title={`创建于 ${formatTime(task.createdAt)}`}>
|
||||
<span className="admin-text-xs-quiet">更新于 {formatTime(task.updatedAt)}</span>
|
||||
|
||||
@@ -71,7 +71,7 @@ export function usePublicationQueries(
|
||||
const building = miniAppReleases.data?.find(
|
||||
(task) =>
|
||||
task.buildStatus === "building" &&
|
||||
Date.now() - new Date(task.updatedAt).getTime() < 15 * 60 * 1000,
|
||||
Date.now() - new Date(task.updatedAt).getTime() < 30 * 60 * 1000,
|
||||
);
|
||||
if (!building) return;
|
||||
const timer = setInterval(() => void miniAppReleases.refetch(), 1500);
|
||||
|
||||
@@ -21,6 +21,7 @@ const adminDevelopmentCsp = adminCsp.replace(
|
||||
);
|
||||
|
||||
export default defineConfig({
|
||||
base: process.env.VITE_APP_BASE_PATH ?? "/",
|
||||
plugins: [
|
||||
react(),
|
||||
{
|
||||
@@ -59,7 +60,6 @@ export default defineConfig({
|
||||
"Referrer-Policy": "no-referrer",
|
||||
"X-Content-Type-Options": "nosniff",
|
||||
},
|
||||
base: process.env.VITE_APP_BASE_PATH ?? "/",
|
||||
proxy: {
|
||||
"/api": {
|
||||
target: process.env.VITE_DEV_API_TARGET ?? "http://localhost:3001",
|
||||
@@ -87,7 +87,6 @@ export default defineConfig({
|
||||
"Referrer-Policy": "no-referrer",
|
||||
"X-Content-Type-Options": "nosniff",
|
||||
},
|
||||
base: process.env.VITE_APP_BASE_PATH ?? "/",
|
||||
},
|
||||
build: {
|
||||
outDir: "dist",
|
||||
|
||||
Reference in new issue
Block a user