收敛客户端静态发布链路
This commit is contained in:
@@ -5,7 +5,7 @@ import { hasRendererCapability } from '../renderer-capability';
|
||||
import { WORKS_SQUARE_CONFIG } from '../works-config';
|
||||
import { getValidWorksSquareAccessToken } from '../../services/works-square-session';
|
||||
import { proxyAwareFetch } from '../../utils/proxy-fetch';
|
||||
import type { WorksCloudDeploymentRecord } from '../../../shared/works-cloud-deployment';
|
||||
import type { WorksSubmissionBindingRecord } from '../../../shared/works-submission-binding';
|
||||
import type { DevicePreviewSnapshot } from '../../../shared/device-preview';
|
||||
|
||||
type RemoteProjectSnapshot = {
|
||||
@@ -66,7 +66,7 @@ function projectFromPayload(payload: unknown): RemoteProjectSnapshot | null {
|
||||
return {
|
||||
appId: readString(project.app_id),
|
||||
playable: typeof project.playable === 'boolean' ? project.playable : null,
|
||||
runtimeUrl: readString(project.runtime_url) ?? readString(project.play_url),
|
||||
runtimeUrl: readString(project.play_url) ?? readString(project.runtime_url),
|
||||
runtimeVersionName: readString(project.version_name),
|
||||
latestVersionId: readString(latestVersion?.id) ?? readString(latestVersion?.version_id),
|
||||
latestVersionName: readString(latestVersion?.version_name),
|
||||
@@ -214,7 +214,7 @@ async function createOwnedReleasePreview(
|
||||
|
||||
function localSnapshot(
|
||||
projectId: string,
|
||||
deployment: WorksCloudDeploymentRecord | null,
|
||||
deployment: WorksSubmissionBindingRecord | null,
|
||||
): Omit<DevicePreviewSnapshot, 'state' | 'message'> {
|
||||
return {
|
||||
projectId,
|
||||
@@ -226,19 +226,13 @@ function localSnapshot(
|
||||
};
|
||||
}
|
||||
|
||||
function buildingMessage(status: WorksCloudDeploymentRecord['status']): string {
|
||||
if (status === 'waiting_for_login') return '正在等待登录状态恢复,恢复后会继续提交预览版本。';
|
||||
if (status === 'uploading') return '预览包正在上传到服务端。';
|
||||
return '正在等待新的预览包与安全检查完成。';
|
||||
}
|
||||
|
||||
function normalizedReviewStatus(value: string | null): string | null {
|
||||
return value?.trim().toLowerCase() || null;
|
||||
}
|
||||
|
||||
async function resolveDevicePreview(
|
||||
projectId: string,
|
||||
deployment: WorksCloudDeploymentRecord | null,
|
||||
deployment: WorksSubmissionBindingRecord | null,
|
||||
): Promise<DevicePreviewSnapshot> {
|
||||
if (!deployment) {
|
||||
return {
|
||||
@@ -258,19 +252,11 @@ async function resolveDevicePreview(
|
||||
|
||||
const base = localSnapshot(projectId, deployment);
|
||||
|
||||
if (deployment.status === 'failed') {
|
||||
if (deployment.status === 'legacy_retired') {
|
||||
return {
|
||||
...base,
|
||||
state: 'unavailable',
|
||||
message: deployment.error || '预览版本生成失败,请重新生成。',
|
||||
};
|
||||
}
|
||||
|
||||
if (deployment.status !== 'submitted') {
|
||||
return {
|
||||
...base,
|
||||
state: 'building',
|
||||
message: buildingMessage(deployment.status),
|
||||
message: deployment.message || '旧版自动部署任务已停用,请重新提交审核。',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -438,8 +424,8 @@ export async function handleDevicePreviewRoutes(
|
||||
return true;
|
||||
}
|
||||
|
||||
const deployment = ctx.worksCloudDeployment
|
||||
? await ctx.worksCloudDeployment.get(projectId)
|
||||
const deployment = ctx.worksSubmissionBinding
|
||||
? await ctx.worksSubmissionBinding.get(projectId)
|
||||
: null;
|
||||
const preview = await resolveDevicePreview(projectId, deployment);
|
||||
sendJson(res, 200, { success: true, preview });
|
||||
|
||||
Reference in New Issue
Block a user