fix(web): code review round 1 -- auth pages design fidelity + missing screens

- CRITICAL correctness bug: resetTinode() was defined but never called
  anywhere. Switching tenants (TenantEntryPage) only updated the session
  store; the Tinode singleton it drives is created once and permanently
  cached (getTinode() lazily creates it, reusing it forever afterward), so
  every subsequent login kept talking to the FIRST tenant's host regardless
  of which tenant was actually selected -- multi-tenant switching was
  silently broken. Also moved LoginPage's getTinode() call to after its
  "no tenant yet" redirect guard, so it can't get created against a
  not-yet-resolved tenant in the first place.
- Error strips across all four auth pages were missing the
  error_outline icon README §10.1 specifies.
- Fixed a token mix-up affecting every error-state input border across
  Register/PasswordInput: README's exact spec is border #d94b4b (this app's
  --color-danger-text) with #cf3f3f text below (--color-danger-border) --
  the code had them backwards, borders were using danger-border.
- TenantEntryPage: added the missing 企业注册/遇到问题 links (now real,
  working pages -- see below), fixed the business icon's color token
  (was accent #1677ff, spec calls for focus-border #4091ff).
- LoginPage/ResetPasswordPage: the "切换企业"/"返回登录" back link was nested
  inside the vertically-centered form container, so it got pulled to the
  page's middle instead of staying pinned to the top like every reference
  screenshot shows it. Also gave LoginPage's brand panel the spec's 56/44
  split (was an even 50/50), 40px headline (was Tailwind's 36px text-4xl),
  and the missing footer links row; added a mobile-only large-logo facade
  (matches 1e-mobile-login.png) since the desktop split-panel brand block
  is hidden below 900px and mobile had no tenant-identifying visual at all.
- RegisterPage: removed an extra 56px-logo+tenant-name block that appears
  in neither the desktop nor mobile reference screenshots; added the
  mobile-only 48px back-chevron+title header bar the design calls for
  (RegisterPage previously had zero back-navigation on any breakpoint).
- ResetPasswordPage: the password error text said "需要包含字母和数字" while
  the actual check only enforces a minimum length (>=8, no character-class
  requirement, matching Register's own rule) -- the message was promising
  a validation this page doesn't perform.
- VerificationCodeButton: the resend countdown's setInterval was never
  cleared on unmount -- a real leak if the user navigates away mid-countdown.
- New: EnterpriseRegisterPage (企业注册, README §10.5) and
  TenantFeedbackPage (问题反馈, README §10.6 / `01/1j`), both previously
  linked-to-but-nonexistent. lib/api/tenant.ts gained the REST calls they
  need (submitTenantApplication, submitTenantEntryFeedback,
  uploadPublicFile against the pre-login /v1/im/public/uploads surface,
  distinct from the chat-file upload endpoint).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Your Name
2026-09-08 03:23:30 +08:00
co-authored by Claude Sonnet 5
parent 986432addd
commit 569f266390
10 changed files with 580 additions and 190 deletions
+66 -1
View File
@@ -1,4 +1,6 @@
import { imRequest } from './client';
import { API_KEY } from '@/lib/config';
import { apiBase, currentTenantCode, imPost, imRequest, ImApiError, requestId } from './client';
/**
* Shape verified against a real `POST /v1/im/tenants/resolve` response (not assumed from memory/
@@ -37,3 +39,66 @@ export async function resolveTenant(tenantCode: string): Promise<ResolveTenantRe
}
return res;
}
function clientContext() {
return {
user_agent: typeof navigator !== 'undefined' ? navigator.userAgent : '',
language: typeof navigator !== 'undefined' ? navigator.language : '',
};
}
export interface PublicUploadResult {
file_id: string;
purpose: string;
mime_type: string;
size: number;
expires_at: string;
}
/**
* POST /v1/im/public/uploads -- a pre-login upload surface distinct from the chat file endpoint
* (lib/api/upload.ts's uploadFile, which lives at the separate file-serving origin). This one goes
* through the regular /v1/im REST API, so it needs imRequest's usual headers -- but as a multipart
* body, not the JSON imRequest always sends, so it can't reuse imRequest itself (that function
* hardcodes `Content-Type: application/json` and JSON.stringifies its body, which would corrupt a
* FormData payload and fight the browser's own multipart boundary header).
*/
export async function uploadPublicFile(file: File, purpose: 'enterprise_license' | 'tenant_entry_feedback'): Promise<PublicUploadResult> {
const form = new FormData();
form.append('purpose', purpose);
form.append('file', file);
const res = await fetch(`${apiBase()}/public/uploads`, {
method: 'POST',
headers: {
'X-MeetingIM-APIKey': API_KEY,
'X-IM-Schema': '1',
'X-Tenant-Code': currentTenantCode(),
'X-Request-ID': requestId(),
},
body: form,
});
const text = await res.text();
let payload: { code?: number; data?: PublicUploadResult; message?: string; reason?: string } = {};
try {
payload = JSON.parse(text);
} catch {
throw new ImApiError('文件上传失败:服务器返回异常', undefined, res.status);
}
if (!res.ok || (payload.code && payload.code !== 0) || !payload.data) {
throw new ImApiError(payload.message || payload.reason || '文件上传失败', payload.reason, res.status);
}
return payload.data;
}
export interface TenantApplicationResult {
application_id?: string;
estimated_review_hours?: number;
}
export function submitTenantApplication(body: { credit_code: string; enterprise_email?: string; license_file_id?: string; tenant_code_hint?: string }) {
return imPost<TenantApplicationResult>('/tenant-applications', { client_context: clientContext(), ...body }, { auth: false });
}
export function submitTenantEntryFeedback(body: { description: string; tenant_code_hint?: string; screenshot_file_ids?: string[]; contact?: string }) {
return imPost<{ received: boolean }>('/tenant-entry-feedback', { client_context: clientContext(), ...body }, { auth: false });
}