-
Notifications
You must be signed in to change notification settings - Fork 5
feat(quick-start): 角色确认后给出建 3D 资产的进阶入口 #773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| /** @vitest-environment jsdom */ | ||
| import { cleanup, fireEvent, render, screen } from '@testing-library/react' | ||
| import { afterEach, describe, expect, it, vi } from 'vitest' | ||
|
|
||
| vi.mock('@/entities', async () => { | ||
| const actual = await vi.importActual<Record<string, unknown>>('@/entities') | ||
| return { | ||
| ...actual, | ||
| render3DApis: { | ||
| precheckMaster: async () => ({}), | ||
| getOutfitAsset: async () => ({ | ||
| state: 'absent', | ||
| model3dUrl: null, | ||
| reviewModelUrl: null, | ||
| error: null, | ||
| cost: { | ||
| model3dCredits: 20, | ||
| autorigCredits: 10, | ||
| totalCredits: 30, | ||
| billing: 'postpaid', | ||
| scope: 'per_outfit_once', | ||
| }, | ||
| }), | ||
| buildOutfitAsset: async () => ({}), | ||
| approveOutfitAsset: async () => ({}), | ||
| discardOutfitAsset: async () => ({}), | ||
| getBakeJob: async () => null, | ||
| putBakeFrame: async () => 1, | ||
| completeBake: async () => undefined, | ||
| failBake: async () => undefined, | ||
| }, | ||
| } | ||
| }) | ||
|
|
||
| const { Render3DOption } = await import('./render3d-option') | ||
|
|
||
| afterEach(cleanup) | ||
|
|
||
| describe('Quick Start 的 3D 进阶入口', () => { | ||
| it('默认折叠 —— 主线是「一句话跑完」,按次计费的重动作不该摊在主线上', () => { | ||
| render( | ||
| <Render3DOption | ||
| session={{ getCharacterInfo: () => ({ characterId: '7', outfitId: 'outfit-default' }) }} | ||
| />, | ||
| ) | ||
| expect(screen.getByRole('button', { name: /建 3D 资产/ })).toBeTruthy() | ||
| expect(screen.queryByRole('group', { name: '3D 资产' })).toBeNull() | ||
| }) | ||
|
|
||
| it('展开后才出现资产面板', async () => { | ||
| render( | ||
| <Render3DOption | ||
| session={{ getCharacterInfo: () => ({ characterId: '7', outfitId: 'outfit-default' }) }} | ||
| />, | ||
| ) | ||
| fireEvent.click(screen.getByRole('button', { name: /建 3D 资产/ })) | ||
| expect(await screen.findByRole('group', { name: '3D 资产' })).toBeTruthy() | ||
| expect(screen.getByText(/只支持双足人形/)).toBeTruthy() | ||
| }) | ||
|
|
||
| it('还没有角色时不渲染 —— 没有 outfit 就没有可建的对象', () => { | ||
| const { container } = render(<Render3DOption session={{ getCharacterInfo: () => null }} />) | ||
| expect(container.textContent).toBe('') | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /** | ||
| * 角色确认之后的可选进阶路线:给这个造型建 3D 资产(Refs #518)。 | ||
| * | ||
| * 默认折叠。Quick Start 的主线是「一句话跑完」,而建 3D 是按次计费、带人工确认闸、 | ||
| * 每账号还有名额上限的重动作 —— 摊开在主线上会把它读成必经的一步。 | ||
| */ | ||
| import { useState } from 'react' | ||
|
|
||
| import { render3DApis } from '@/entities' | ||
| import { Render3DAssetPanel } from '@/pages/workflow-editor/render3d-panel' | ||
|
|
||
| /** 只取建资产要的那两个 id;不依赖整个会话,测试也就不必造一份完整会话。 */ | ||
| export interface Render3DOptionSession { | ||
| getCharacterInfo(): { characterId: string; outfitId: string } | null | ||
| } | ||
|
|
||
| export function Render3DOption({ session }: { session: Render3DOptionSession | null }) { | ||
| const [open, setOpen] = useState(false) | ||
| const info = session?.getCharacterInfo() ?? null | ||
| if (!info) return null | ||
|
|
||
| return ( | ||
| <div className="w-full max-w-2xl"> | ||
| {open ? ( | ||
| <div className="grid gap-2 rounded-2xl border border-app-line bg-app-surface-muted p-3"> | ||
| <div className="flex items-center justify-between gap-2"> | ||
| <p className="m-0 text-xs font-semibold text-app-ink">3D 资产 · 三渲二</p> | ||
| <button | ||
| type="button" | ||
| className="text-[11px] text-app-muted transition hover:text-app-ink" | ||
| onClick={() => setOpen(false)} | ||
| > | ||
| 收起 | ||
| </button> | ||
| </div> | ||
| <p className="m-0 text-[11px] leading-[1.6] text-app-muted"> | ||
| 建好后这个角色的每个动作都能改用三渲二出帧:多朝向零额外费用、各朝向天生一致。 | ||
| 目前只支持双足人形。 | ||
| </p> | ||
| <Render3DAssetPanel | ||
| render3d={render3DApis} | ||
| characterId={info.characterId} | ||
| outfitId={info.outfitId} | ||
| precheck={null} | ||
| disabled={false} | ||
| /> | ||
| </div> | ||
| ) : ( | ||
| <button | ||
| type="button" | ||
| className="rounded-xl border border-app-line bg-app-surface-muted px-3 py-2 text-xs font-semibold text-app-muted transition hover:border-app-accent hover:text-app-ink" | ||
| onClick={() => setOpen(true)} | ||
| > | ||
| 进阶 · 给这个角色建 3D 资产 | ||
| </button> | ||
| )} | ||
| </div> | ||
| ) | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] Preserve the master precheck before enabling 3D builds
Render3DAssetPaneltreatsprecheck={null}as no gate, so this Quick Start path never callsprecheckMasterfor the confirmed template and enables the paid build flow immediately. The backend still rejects an unacceptable master, but only after the user opens the confirmation flow and submits the paid action, which removes the existing #518 precheck/readout behavior and gives a worse, late error instead of explaining the unusable master before submission. Pass the selected template URL through a precheck hook/report (or otherwise preserve the panel's precheck contract) before allowingbuildOutfitAsset.