|
@@ -4,11 +4,14 @@ import { Router } from '@angular/router';
|
|
|
import { PlanCode } from '../../../core/api/models';
|
|
import { PlanCode } from '../../../core/api/models';
|
|
|
import { PlanService } from '../../../core/plan.service';
|
|
import { PlanService } from '../../../core/plan.service';
|
|
|
import { ProvisionService } from '../../../core/provision.service';
|
|
import { ProvisionService } from '../../../core/provision.service';
|
|
|
|
|
+import { LiveService } from '../../../core/live.service';
|
|
|
import { LoadingOverlayComponent } from '../../../components/domain/loading-overlay/loading-overlay';
|
|
import { LoadingOverlayComponent } from '../../../components/domain/loading-overlay/loading-overlay';
|
|
|
import { ProvisionInstructionComponent } from '../../../components/domain/provision-instruction/provision-instruction';
|
|
import { ProvisionInstructionComponent } from '../../../components/domain/provision-instruction/provision-instruction';
|
|
|
import { MAppBarComponent } from '../../components/m-app-bar/m-app-bar';
|
|
import { MAppBarComponent } from '../../components/m-app-bar/m-app-bar';
|
|
|
import { MDrawerComponent } from '../../components/m-drawer/m-drawer';
|
|
import { MDrawerComponent } from '../../components/m-drawer/m-drawer';
|
|
|
import { RenewalGuideComponent } from '../../../components/domain/renewal-guide/renewal-guide';
|
|
import { RenewalGuideComponent } from '../../../components/domain/renewal-guide/renewal-guide';
|
|
|
|
|
+import { ProvisionConfirmComponent } from '../../../components/domain/provision-confirm/provision-confirm';
|
|
|
|
|
+import { suggestContainerName } from '../../../components/domain/provision-confirm/container-name';
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 移动端套餐与开通(2026-11-25)
|
|
* 移动端套餐与开通(2026-11-25)
|
|
@@ -31,10 +34,18 @@ import { RenewalGuideComponent } from '../../../components/domain/renewal-guide/
|
|
|
@Component({
|
|
@Component({
|
|
|
selector: 'app-mb-plans-page',
|
|
selector: 'app-mb-plans-page',
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
|
- imports: [UserNoticePipe, MAppBarComponent, MDrawerComponent, ProvisionInstructionComponent, LoadingOverlayComponent, RenewalGuideComponent],
|
|
|
|
|
|
|
+ imports: [UserNoticePipe, MAppBarComponent, MDrawerComponent, ProvisionInstructionComponent, LoadingOverlayComponent, RenewalGuideComponent, ProvisionConfirmComponent],
|
|
|
template: `
|
|
template: `
|
|
|
<div class="m-page--scroll">
|
|
<div class="m-page--scroll">
|
|
|
<app-m-app-bar title="套餐与开通" [menu]="true" (menuTap)="drawerOpen.set(true)" />
|
|
<app-m-app-bar title="套餐与开通" [menu]="true" (menuTap)="drawerOpen.set(true)" />
|
|
|
|
|
+ <!-- 名额已满提示(2026-12-03):页面顶部,用户点了开通马上能看到 -->
|
|
|
|
|
+ @if (quotaFull(); as qf) {
|
|
|
|
|
+ <div class="quota-full" role="alert">
|
|
|
|
|
+ <p>「{{ qf.plan }}」的名额已满({{ existingNames().length }}/{{ qf.quota }})。</p>
|
|
|
|
|
+ <p>可以删除不用的容器,或升级到名额更多的套餐。</p>
|
|
|
|
|
+ <button type="button" (click)="quotaFull.set(null)">知道了</button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
<div class="m-body">
|
|
<div class="m-body">
|
|
|
<!--
|
|
<!--
|
|
@@ -175,13 +186,62 @@ import { RenewalGuideComponent } from '../../../components/domain/renewal-guide/
|
|
|
|
|
|
|
|
<app-m-drawer [open]="drawerOpen()" (close)="drawerOpen.set(false)" />
|
|
<app-m-drawer [open]="drawerOpen()" (close)="drawerOpen.set(false)" />
|
|
|
|
|
|
|
|
|
|
+ <!--
|
|
|
|
|
+ 开通命名确认弹窗(2026-12-03)。
|
|
|
|
|
+ 🔴 不能复用 app-prompt-modal:/plans 是顶层路由、不在 shell 内,
|
|
|
|
|
+ 全局弹窗在套餐页渲染不出来。本组件自带遮罩与对话框。
|
|
|
|
|
+ -->
|
|
|
|
|
+ @if (confirmOpen()) {
|
|
|
|
|
+ <app-provision-confirm
|
|
|
|
|
+ [planName]="pendingPlanName()"
|
|
|
|
|
+ [isOnboarding]="pendingIsOnboarding()"
|
|
|
|
|
+ [quota]="pendingQuota()"
|
|
|
|
|
+ [quotaUsed]="existingNames().length"
|
|
|
|
|
+ [existingNames]="existingNames()"
|
|
|
|
|
+ [busy]="submitting()"
|
|
|
|
|
+ (confirm)="onNameConfirmed($event)"
|
|
|
|
|
+ (cancel)="cancelConfirm()"
|
|
|
|
|
+ />
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
<!-- 全屏加载遮罩:明确告知正在进行 + 阻断误点(2026-11-27) -->
|
|
<!-- 全屏加载遮罩:明确告知正在进行 + 阻断误点(2026-11-27) -->
|
|
|
@if (loadingHint(); as hint) {
|
|
@if (loadingHint(); as hint) {
|
|
|
<app-loading-overlay [message]="hint.message" [hint]="hint.detail" />
|
|
<app-loading-overlay [message]="hint.message" [hint]="hint.detail" />
|
|
|
}
|
|
}
|
|
|
`,
|
|
`,
|
|
|
- styles: [
|
|
|
|
|
- `
|
|
|
|
|
|
|
+ styles: [`
|
|
|
|
|
+
|
|
|
|
|
+ /* 名额已满提示(2026-12-03):内联在页面顶部,不遮挡操作 */
|
|
|
|
|
+ .quota-full {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ flex-direction: column;
|
|
|
|
|
+ gap: var(--sp-1);
|
|
|
|
|
+ margin: 0 0 var(--sp-4);
|
|
|
|
|
+ padding: var(--sp-4);
|
|
|
|
|
+ border: 1px solid var(--warning);
|
|
|
|
|
+ border-radius: var(--r-md, 10px);
|
|
|
|
|
+ background: var(--surface-2);
|
|
|
|
|
+ color: var(--ink-2);
|
|
|
|
|
+ font-size: var(--fs-13);
|
|
|
|
|
+ }
|
|
|
|
|
+ .quota-full p {
|
|
|
|
|
+ margin: 0;
|
|
|
|
|
+ line-height: 1.55;
|
|
|
|
|
+ }
|
|
|
|
|
+ .quota-full button {
|
|
|
|
|
+ align-self: flex-start;
|
|
|
|
|
+ min-height: 36px;
|
|
|
|
|
+ margin-top: var(--sp-2);
|
|
|
|
|
+ padding: 0 var(--sp-4);
|
|
|
|
|
+ border: 1px solid var(--edge);
|
|
|
|
|
+ border-radius: var(--r-sm, 6px);
|
|
|
|
|
+ background: var(--surface);
|
|
|
|
|
+ color: var(--ink);
|
|
|
|
|
+ font: inherit;
|
|
|
|
|
+ font-size: var(--fs-13);
|
|
|
|
|
+ cursor: pointer;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
:host {
|
|
:host {
|
|
|
display: block;
|
|
display: block;
|
|
|
height: 100%;
|
|
height: 100%;
|
|
@@ -617,8 +677,16 @@ import { RenewalGuideComponent } from '../../../components/domain/renewal-guide/
|
|
|
export class MbPlansPage implements OnInit {
|
|
export class MbPlansPage implements OnInit {
|
|
|
protected readonly plan = inject(PlanService);
|
|
protected readonly plan = inject(PlanService);
|
|
|
protected readonly provision = inject(ProvisionService);
|
|
protected readonly provision = inject(ProvisionService);
|
|
|
|
|
+ protected readonly live = inject(LiveService);
|
|
|
private readonly router = inject(Router);
|
|
private readonly router = inject(Router);
|
|
|
|
|
|
|
|
|
|
+ /* 命名确认弹窗状态(2026-12-03) */
|
|
|
|
|
+ protected readonly confirmOpen = signal(false);
|
|
|
|
|
+ protected readonly pendingCode = signal<PlanCode | null>(null);
|
|
|
|
|
+ protected readonly submitting = signal(false);
|
|
|
|
|
+ /** 名额已满提示(2026-12-03)。null = 不显示 */
|
|
|
|
|
+ protected readonly quotaFull = signal<{ plan: string; quota: number } | null>(null);
|
|
|
|
|
+
|
|
|
ngOnInit(): void {
|
|
ngOnInit(): void {
|
|
|
void this.provision.restorePending();
|
|
void this.provision.restorePending();
|
|
|
}
|
|
}
|
|
@@ -680,20 +748,79 @@ export class MbPlansPage implements OnInit {
|
|
|
* 跳转前必须 `await` 到 `jobId` 存在 —— 带着 undefined 跳过去,
|
|
* 跳转前必须 `await` 到 `jobId` 存在 —— 带着 undefined 跳过去,
|
|
|
* 等待页会拉不到任务,用户看到的是空转。
|
|
* 等待页会拉不到任务,用户看到的是空转。
|
|
|
*/
|
|
*/
|
|
|
- protected async apply(code: PlanCode): Promise<void> {
|
|
|
|
|
|
|
+ protected apply(code: PlanCode): void {
|
|
|
if (this.provision.isRunning()) return;
|
|
if (this.provision.isRunning()) return;
|
|
|
|
|
+ /*
|
|
|
|
|
+ * 名额已满就别让用户填名字了(2026-12-03)。
|
|
|
|
|
+ * 在弹窗之前拦,而不是等提交后云函数返回 409 ——
|
|
|
|
|
+ * 「认真填完名字才被告知名额已满」是很差的体验。
|
|
|
|
|
+ */
|
|
|
|
|
+ const quota = code === 'trial' ? 1 : (this.plan.planOf(code as never)?.quota ?? 0);
|
|
|
|
|
+ if (quota > 0 && this.existingNames().length >= quota) {
|
|
|
|
|
+ this.quotaFull.set({ plan: this.plan.planOf(code as never)?.name || '该套餐', quota });
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ /* 先弹命名确认(用户裁决 2026-12-03),不再直接提交 */
|
|
|
|
|
+ this.pendingCode.set(code);
|
|
|
|
|
+ this.confirmOpen.set(true);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- const name = code === 'trial' ? '我的试用容器' : `我的${this.plan.planOf(code)?.name ?? '容器'}`;
|
|
|
|
|
- const result = await this.provision.start(code, name);
|
|
|
|
|
-
|
|
|
|
|
- if (result?.mode === 'provision' && result.jobId) {
|
|
|
|
|
- await this.router.navigateByUrl(`/provision?jobId=${encodeURIComponent(result.jobId)}`, {
|
|
|
|
|
- replaceUrl: true,
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 命名确认后真正提交(2026-12-03)。
|
|
|
|
|
+ *
|
|
|
|
|
+ * `name` 来自弹窗,已经过 `validateContainerName` 校验与 NFKC 归一化。
|
|
|
|
|
+ */
|
|
|
|
|
+ protected async onNameConfirmed(name: string): Promise<void> {
|
|
|
|
|
+ const code = this.pendingCode();
|
|
|
|
|
+ if (!code) return;
|
|
|
|
|
+ this.submitting.set(true);
|
|
|
|
|
+ try {
|
|
|
|
|
+ const result = await this.provision.start(code, name);
|
|
|
|
|
+ this.confirmOpen.set(false);
|
|
|
|
|
+ this.pendingCode.set(null);
|
|
|
|
|
+
|
|
|
|
|
+ if (result?.mode === 'provision' && result.jobId) {
|
|
|
|
|
+ await this.router.navigateByUrl(`/provision?jobId=${encodeURIComponent(result.jobId)}`, {
|
|
|
|
|
+ replaceUrl: true,
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ // onboarding 模式(试用/入门):留在本页,由模板渲染提示词
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ this.submitting.set(false);
|
|
|
}
|
|
}
|
|
|
- // onboarding 模式(试用/入门):留在本页,由模板渲染提示词
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ protected cancelConfirm(): void {
|
|
|
|
|
+ this.confirmOpen.set(false);
|
|
|
|
|
+ this.pendingCode.set(null);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /** 弹窗用:当前pending套餐的信息 */
|
|
|
|
|
+ protected readonly pendingPlanName = computed(() => {
|
|
|
|
|
+ const c = this.pendingCode();
|
|
|
|
|
+ if (!c) return '';
|
|
|
|
|
+ if (c === 'trial') return '试用';
|
|
|
|
|
+ return this.plan.planOf(c)?.name ?? '套餐';
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ protected readonly pendingIsOnboarding = computed(() => {
|
|
|
|
|
+ const c = this.pendingCode();
|
|
|
|
|
+ return c === 'trial' || c === 'starter';
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ protected readonly pendingQuota = computed(() => {
|
|
|
|
|
+ const c = this.pendingCode();
|
|
|
|
|
+ if (!c || c === 'trial') return 1;
|
|
|
|
|
+ return this.plan.planOf(c)?.quota ?? 0;
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ /** 已有容器名(重名校验 + 默认名生成) */
|
|
|
|
|
+ protected readonly existingNames = computed(() =>
|
|
|
|
|
+ this.live.agents().map((a) => a.name).filter((n): n is string => !!n),
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ protected readonly suggestedName = computed(() => suggestContainerName(this.existingNames()));
|
|
|
|
|
+
|
|
|
/** 导航;`jobId` 存在时拼进查询参数(如打开等待页) */
|
|
/** 导航;`jobId` 存在时拼进查询参数(如打开等待页) */
|
|
|
protected go(path: string, jobId?: string): void {
|
|
protected go(path: string, jobId?: string): void {
|
|
|
const url = jobId ? `${path}?jobId=${encodeURIComponent(jobId)}` : path;
|
|
const url = jobId ? `${path}?jobId=${encodeURIComponent(jobId)}` : path;
|