Commit f016ce50 by 胡悦

fix(agent-admin): 修复H5官网二维码弹窗、岗位选择及方法论配置页面问题

- 修复二维码弹窗状态泄漏:切换岗位或二维码信息变更时重置图片加载失败状态,避免旧状态污染当前展示,新增对应回归测试
- 修复岗位展示新建页岗位选择回显:修正下拉框字段映射逻辑,选中后回显岗位名称而非渠道编码,确保保存参数正确
- 优化方法论配置页面:统一表单提示样式,普通辅助提示使用弱提示风格、校验错误使用红色文字;输入阶段截断超长步骤名称;调整页面为固定header+独立滚动内容区,补充相关测试
- 归档本次变更的OpenSpec规范文档,优化独立页面布局组件支持传递额外HTML属性
1 parent 7097be05
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
- 已通过 `openspec status --change "official-site-agent-display-config" --json` 确认 proposal、design、specs、tasks 均完成,并通过 `openspec validate "official-site-agent-display-config" --strict`。 - 已通过 `openspec status --change "official-site-agent-display-config" --json` 确认 proposal、design、specs、tasks 均完成,并通过 `openspec validate "official-site-agent-display-config" --strict`。
- 已完成 `official-site-agent-display-config-sort-status` 的 OpenSpec 锁定与实现,官网 Agent 展示配置编辑弹窗已将 `disable` 文案改为 `不展示`,并补齐排序下限与回归测试;已通过 `npm test -- src/routes/official-site-agent-display-config/AgentDisplayConfigEditModal.test.tsx src/routes/official-site-agent-display-config/OfficialSiteAgentDisplayConfigEdit.test.tsx`、`npm run typecheck`、`npm run build` 和 `openspec validate "official-site-agent-display-config-sort-status" --strict`。 - 已完成 `official-site-agent-display-config-sort-status` 的 OpenSpec 锁定与实现,官网 Agent 展示配置编辑弹窗已将 `disable` 文案改为 `不展示`,并补齐排序下限与回归测试;已通过 `npm test -- src/routes/official-site-agent-display-config/AgentDisplayConfigEditModal.test.tsx src/routes/official-site-agent-display-config/OfficialSiteAgentDisplayConfigEdit.test.tsx`、`npm run typecheck`、`npm run build` 和 `openspec validate "official-site-agent-display-config-sort-status" --strict`。
- 2026-05-30:已执行 `standardize-admin-shell-layout` 并补充全框架前端规则:独立新增/编辑页页头左侧保留 `返回`、右侧仅保留 `保存`、不展示右侧 `取消`,页面滚动时返回/保存操作区保持可见。该规则已写入全局 `web-desktop-ui-standard`、`component-guidelines.md` 和 `frontend-conventions.md`;`agent-admin` 的 Agent、岗位标签、渠道活码、官网岗位展示新增/编辑页已按规则调整。 - 2026-05-30:已执行 `standardize-admin-shell-layout` 并补充全框架前端规则:独立新增/编辑页页头左侧保留 `返回`、右侧仅保留 `保存`、不展示右侧 `取消`,页面滚动时返回/保存操作区保持可见。该规则已写入全局 `web-desktop-ui-standard`、`component-guidelines.md` 和 `frontend-conventions.md`;`agent-admin` 的 Agent、岗位标签、渠道活码、官网岗位展示新增/编辑页已按规则调整。
- 2026-06-11:已完成并归档 `fix-official-site-job-tab-position-select-label` 与 `highlight-methodology-upload-prompts`。官网岗位展示新建页 `/official-site/job-tabs/new` 的“对应岗位”选择后回显岗位名称,渠道编码仅在只读项展示;官网方法论配置页 `/official-site/methodology` 的普通上传 tips 保持弱提示,必填/格式/大小/上传失败校验使用红色错误文字,步骤名称输入阶段截断到 20 字,页面 header 固定且下方内容区独立滚动。已通过相关页面测试、`npm run typecheck`、`npm run build`、两个 change 的 `openspec validate --strict`,并由用户完成浏览器验证。归档生成 `2026-06-11-fix-official-site-job-tab-position-select-label` 与 `2026-06-11-highlight-methodology-upload-prompts`,归档后 `official-site-job-tab-ai-intro` 和 `official-site-methodology-config` 稳定规范均校验通过;全量 `openspec validate --all --strict` 仍受既有 `agent-tags-management` 失败影响。
## 当前重点 ## 当前重点
......
...@@ -91,6 +91,20 @@ ...@@ -91,6 +91,20 @@
- **THEN** 系统 SHALL 将其作为该步骤的展示图标资源保存到配置数据 - **THEN** 系统 SHALL 将其作为该步骤的展示图标资源保存到配置数据
- **AND** 系统 SHALL NOT 将上传进度、上传中、重试等临时状态保存为步骤图标数据 - **AND** 系统 SHALL NOT 将上传进度、上传中、重试等临时状态保存为步骤图标数据
#### Scenario: 步骤图标上传辅助提示
- **WHEN** 用户查看方法论步骤的步骤图标上传区域
- **THEN** 系统 SHALL 展示步骤图标格式与大小限制提示
- **AND** 系统 SHALL 使用与 `BusinessForm` 帮助文案一致的普通 tips 样式展示该提示
- **AND** 即使步骤配置区使用页面自定义布局,系统 SHALL 按表单字段提示规范在步骤图标字段附近展示该提示
- **AND** 当步骤图标出现必填、格式、大小或上传错误时,系统 SHALL 在字段附近使用与 `BusinessForm` 错误文案一致的红色错误文字展示错误提示
#### Scenario: 步骤名称长度限制
- **WHEN** 用户在步骤名称输入框输入或粘贴超过 20 字内容
- **THEN** 系统 SHALL 将步骤名称字段值立即限制在 20 字以内
- **AND** 系统 SHALL NOT 在字段值超过 20 字后等待提交时才展示超长错误
- **AND** 系统 SHALL 继续展示步骤名称字数计数
- **AND** 系统 SHALL 保持步骤名称必填保存校验不变
### Requirement: 内容图上传校验 ### Requirement: 内容图上传校验
系统 SHALL 对每个步骤的内容图执行前端 mock 上传和校验。 系统 SHALL 对每个步骤的内容图执行前端 mock 上传和校验。
...@@ -114,6 +128,13 @@ ...@@ -114,6 +128,13 @@
- **THEN** 系统 SHALL 展示图片上传失败状态 - **THEN** 系统 SHALL 展示图片上传失败状态
- **AND** 系统 SHALL 允许用户重新选择或重试 - **AND** 系统 SHALL 允许用户重新选择或重试
#### Scenario: 内容图上传辅助提示
- **WHEN** 用户查看方法论步骤的内容图上传区域
- **THEN** 系统 SHALL 展示内容图格式与大小限制提示
- **AND** 系统 SHALL 使用与 `BusinessForm` 帮助文案一致的普通 tips 样式展示该提示
- **AND** 即使步骤配置区使用页面自定义布局,系统 SHALL 按表单字段提示规范在内容图字段附近展示该提示
- **AND** 当内容图出现必填、格式、大小或上传错误时,系统 SHALL 在字段附近使用与 `BusinessForm` 错误文案一致的红色错误文字展示错误提示
### Requirement: 页面状态与保存行为 ### Requirement: 页面状态与保存行为
系统 SHALL 覆盖方法论展示配置页的加载、保存和错误状态。 系统 SHALL 覆盖方法论展示配置页的加载、保存和错误状态。
...@@ -163,3 +184,14 @@ ...@@ -163,3 +184,14 @@
- **WHEN** 测试读取方法论配置 mock fixture - **WHEN** 测试读取方法论配置 mock fixture
- **THEN** fixture SHALL 覆盖正常配置、关闭展示、步骤为空、图片上传失败、图片格式错误、图片过大、保存失败和加载失败 - **THEN** fixture SHALL 覆盖正常配置、关闭展示、步骤为空、图片上传失败、图片格式错误、图片过大、保存失败和加载失败
### Requirement: 页面滚动布局
系统 SHALL 在方法论展示配置页内保持 header 区域固定,并允许下方配置区域独立滚动。
#### Scenario: Header 固定且内容区滚动
- **WHEN** 用户打开 `/official-site/methodology` 方法论展示配置页
- **THEN** 系统 SHALL 将页面标题、说明和保存操作放置在固定 header 区域
- **AND** 系统 SHALL 将加载态、错误态、空态和步骤配置内容放置在 header 下方的独立滚动区域
- **AND** 当配置内容超过可视区域高度时,系统 SHALL 仅滚动 header 下方内容区域
- **AND** 系统 SHALL 保持保存操作在内容滚动过程中可见并可点击
- **AND** 系统 SHALL NOT 改变后台全局导航、侧边栏或其他页面的滚动布局
import type { ReactNode } from 'react'; import type { HTMLAttributes, ReactNode } from 'react';
const rootClassName = 'flex h-full min-h-0 flex-col gap-6 overflow-hidden'; const rootClassName = 'flex h-full min-h-0 flex-col gap-6 overflow-hidden';
const headerClassName = const headerClassName =
...@@ -13,6 +13,10 @@ export function IndependentPageHeader({ children }: { children: ReactNode }) { ...@@ -13,6 +13,10 @@ export function IndependentPageHeader({ children }: { children: ReactNode }) {
return <header className={headerClassName}>{children}</header>; return <header className={headerClassName}>{children}</header>;
} }
export function IndependentPageBody({ children, className = '' }: { children: ReactNode; className?: string }) { export function IndependentPageBody({
return <div className={`${bodyClassName} ${className}`.trim()}>{children}</div>; children,
className = '',
...restProps
}: { children: ReactNode; className?: string } & HTMLAttributes<HTMLDivElement>) {
return <div className={`${bodyClassName} ${className}`.trim()} {...restProps}>{children}</div>;
} }
...@@ -168,6 +168,18 @@ describe('OfficialSiteJobTabEditorPage', () => { ...@@ -168,6 +168,18 @@ describe('OfficialSiteJobTabEditorPage', () => {
}); });
}); });
it('shows selected position name instead of channel code after selecting position', async () => {
renderApp('/official-site/job-tabs/new');
await selectLiveOpsPosition();
const positionSelect = screen.getByRole('combobox', { name: '对应岗位' });
const positionInput = positionSelect.querySelector('input') as HTMLInputElement | null;
expect(positionInput).not.toBeNull();
await waitFor(() => {
expect(positionInput).toHaveValue('直播运营');
});
expect(positionInput).not.toHaveValue('live_ops');
});
it('shows derived info after selecting position with channel code', async () => { it('shows derived info after selecting position with channel code', async () => {
renderApp('/official-site/job-tabs/new'); renderApp('/official-site/job-tabs/new');
await selectLiveOpsPosition(); await selectLiveOpsPosition();
...@@ -208,6 +220,15 @@ describe('OfficialSiteJobTabEditorPage', () => { ...@@ -208,6 +220,15 @@ describe('OfficialSiteJobTabEditorPage', () => {
fireEvent.click(screen.getByRole('button', { name: '保存' })); fireEvent.click(screen.getByRole('button', { name: '保存' }));
}); });
await waitFor(() => { await waitFor(() => {
expect(createOfficialSiteTab).toHaveBeenCalledWith({
position_code: 'live_ops',
position_name: '直播运营',
qrcode_id: '3',
main_title: 'AI 标题',
sub_title: 'AI 说明',
display_status: 'enable',
sort_order: 10,
});
expect(screen.getByRole('heading', { name: '岗位展示配置' })).toBeInTheDocument(); expect(screen.getByRole('heading', { name: '岗位展示配置' })).toBeInTheDocument();
}); });
}); });
......
...@@ -123,7 +123,7 @@ export function OfficialSiteJobTabEditorPage({ mode }: { mode: 'create' | 'edit' ...@@ -123,7 +123,7 @@ export function OfficialSiteJobTabEditorPage({ mode }: { mode: 'create' | 'edit'
const currentTabDetail = currentTab as OfficialSiteTabDetail | undefined; const currentTabDetail = currentTab as OfficialSiteTabDetail | undefined;
const availableQRCodeOptions = availableQRCodes.filter((qr) => { const availableQRCodeOptions = availableQRCodes.filter((qr) => {
if (mode === 'edit') return true; if (mode === 'edit') return true;
return !existingPositions.includes(qr.position_name); return !existingPositions.includes(qr.channel_code);
}); });
const createFields: BusinessFormField[] = [ const createFields: BusinessFormField[] = [
...@@ -133,21 +133,22 @@ export function OfficialSiteJobTabEditorPage({ mode }: { mode: 'create' | 'edit' ...@@ -133,21 +133,22 @@ export function OfficialSiteJobTabEditorPage({ mode }: { mode: 'create' | 'edit'
type: 'select', type: 'select',
required: true, required: true,
options: availableQRCodeOptions.map((qr) => ({ options: availableQRCodeOptions.map((qr) => ({
value: String(qr.qrcode_id), value: qr.channel_code,
label: qr.position_name, label: qr.position_name,
disabled: existingPositions.includes(qr.position_name) || qr.status === 'disable', disabled: existingPositions.includes(qr.channel_code) || qr.status === 'disable',
})), })),
placeholder: '请选择对应岗位', placeholder: '请选择对应岗位',
validator: (value) => (value ? undefined : '请选择对应岗位'), validator: (value) => (value ? undefined : '请选择对应岗位'),
onChange: (value, context) => { onChange: (value, context) => {
const qr = availableQRCodes.find((item) => item.qrcode_id === Number(value)); const positionCode = String(value ?? '');
const qr = availableQRCodes.find((item) => item.channel_code === positionCode);
return { return {
...context.values, ...context.values,
position_code: qr?.channel_code ?? '', position_code: positionCode,
position_name: qr?.position_name ?? '', position_name: qr?.position_name ?? '',
qrcode_id: qr?.qrcode_id ?? 0, qrcode_id: qr?.qrcode_id ?? 0,
qrcode_name: qr?.qrcode_name ?? '', qrcode_name: qr?.qrcode_name ?? '',
channel_code: qr?.channel_code ?? '', channel_code: qr?.channel_code ?? positionCode,
employee_name: qr?.employee_name ?? '', employee_name: qr?.employee_name ?? '',
employee_role_text: '', employee_role_text: '',
}; };
......
...@@ -66,6 +66,24 @@ describe('OfficialSiteMethodologyPage form and steps', () => { ...@@ -66,6 +66,24 @@ describe('OfficialSiteMethodologyPage form and steps', () => {
expect(within(cards[2]).getByLabelText('步骤1名称')).toHaveValue('需求澄清'); expect(within(cards[2]).getByLabelText('步骤1名称')).toHaveValue('需求澄清');
}); });
it('keeps the page header fixed while the methodology content scrolls independently', async () => {
renderMethodology();
await waitFor(() => {
expect(screen.getByRole('heading', { name: '方法论展示配置' })).toBeInTheDocument();
});
const pageHeader = screen.getByRole('heading', { name: '方法论展示配置' }).closest('header') as HTMLElement;
const pageRoot = pageHeader.closest('section') as HTMLElement;
const scrollArea = pageRoot.querySelector('[data-testid="methodology-page-scroll-area"]') as HTMLElement;
expect(pageRoot).toHaveClass('h-full', 'min-h-0', 'overflow-hidden');
expect(pageHeader).toHaveClass('shrink-0', 'bg-[var(--gl-color-bg-container)]');
expect(scrollArea).toHaveClass('min-h-0', 'flex-1', 'overflow-y-auto');
expect(within(pageHeader).getByRole('button', { name: '保存配置' })).toBeInTheDocument();
expect(within(scrollArea).getByLabelText('主标题')).toHaveValue('四步打造可复用的岗位 Agent');
});
it('supports disabled display status and empty-step fixtures', async () => { it('supports disabled display status and empty-step fixtures', async () => {
vi.mocked(getMethodologyConfig).mockResolvedValueOnce({ vi.mocked(getMethodologyConfig).mockResolvedValueOnce({
...mockMethodologyConfig, ...mockMethodologyConfig,
......
...@@ -9,6 +9,7 @@ import { ...@@ -9,6 +9,7 @@ import {
} from '@gl/business-components'; } from '@gl/business-components';
import { Button } from 'tdesign-react'; import { Button } from 'tdesign-react';
import { FormItem, Input } from '../../components/TDesignAccessibleControls'; import { FormItem, Input } from '../../components/TDesignAccessibleControls';
import { IndependentPageBody, IndependentPageHeader, IndependentPageLayout } from '../components/IndependentPageLayout';
import { import {
getMethodologyConfig, getMethodologyConfig,
saveMethodologyConfig, saveMethodologyConfig,
...@@ -48,6 +49,16 @@ type MethodologyTopFormValues = Pick<MethodologyFormState, 'display_status' | 'm ...@@ -48,6 +49,16 @@ type MethodologyTopFormValues = Pick<MethodologyFormState, 'display_status' | 'm
const contentImageHelperText = '支持 PNG/JPG/JPEG,最大 10MB'; const contentImageHelperText = '支持 PNG/JPG/JPEG,最大 10MB';
const stepIconHelperText = '支持 PNG/JPG/JPEG,最大 2MB'; const stepIconHelperText = '支持 PNG/JPG/JPEG,最大 2MB';
const formErrorTextColor = '#d94841';
function renderFormErrorTip(error: string | undefined, testId: string) {
if (!error) return undefined;
return (
<span data-testid={testId} style={{ color: formErrorTextColor }}>
{error}
</span>
);
}
function normalizeSteps(steps: MethodologyStepFormState[]) { function normalizeSteps(steps: MethodologyStepFormState[]) {
return steps.map((step, index) => ({ return steps.map((step, index) => ({
...@@ -434,7 +445,13 @@ export function OfficialSiteMethodologyPage() { ...@@ -434,7 +445,13 @@ export function OfficialSiteMethodologyPage() {
</div> </div>
</div> </div>
<FormItem label="步骤图标" requiredMark status={step.iconError ? 'error' : undefined} tips={step.iconError} help={stepIconHelperText}> <FormItem
label="步骤图标"
requiredMark
status={step.iconError ? 'error' : undefined}
tips={renderFormErrorTip(step.iconError, `methodology-step-icon-error-${step.step_order}`)}
help={stepIconHelperText}
>
<div className="grid gap-3"> <div className="grid gap-3">
<MediaWall <MediaWall
accept="image/png,image/jpg,image/jpeg" accept="image/png,image/jpg,image/jpeg"
...@@ -569,25 +586,36 @@ export function OfficialSiteMethodologyPage() { ...@@ -569,25 +586,36 @@ export function OfficialSiteMethodologyPage() {
</div> </div>
</FormItem> </FormItem>
<FormItem label="步骤名称" requiredMark status={step.nameError ? 'error' : undefined} tips={step.nameError}> <FormItem
label="步骤名称"
requiredMark
status={step.nameError ? 'error' : undefined}
tips={renderFormErrorTip(step.nameError, `methodology-step-name-error-${step.step_order}`)}
>
<Input <Input
aria-label={`步骤${step.step_order}名称`} aria-label={`步骤${step.step_order}名称`}
className="w-full max-w-[360px]" className="w-full max-w-[360px]"
maxlength={20} maxlength={20}
allowInputOverMax
showLimitNumber showLimitNumber
value={step.step_name} value={step.step_name}
onChange={(value) => { onChange={(value) => {
const nextValue = String(value ?? '').slice(0, 20);
updateStep(index, (currentStep) => ({ updateStep(index, (currentStep) => ({
...currentStep, ...currentStep,
step_name: value, step_name: nextValue,
nameError: undefined, nameError: undefined,
})); }));
}} }}
/> />
</FormItem> </FormItem>
<FormItem label="内容图" requiredMark status={step.imageError ? 'error' : undefined} tips={step.imageError} help={contentImageHelperText}> <FormItem
label="内容图"
requiredMark
status={step.imageError ? 'error' : undefined}
tips={renderFormErrorTip(step.imageError, `methodology-content-image-error-${step.step_order}`)}
help={contentImageHelperText}
>
<MediaWall <MediaWall
accept="image/png,image/jpg,image/jpeg" accept="image/png,image/jpg,image/jpeg"
items={step.step_image ? [{ items={step.step_image ? [{
...@@ -661,8 +689,8 @@ export function OfficialSiteMethodologyPage() { ...@@ -661,8 +689,8 @@ export function OfficialSiteMethodologyPage() {
}; };
return ( return (
<section className="grid gap-6"> <IndependentPageLayout>
<header className="flex items-center justify-between gap-6 rounded-[var(--gl-radius-md)] border border-[var(--gl-color-border-secondary)] bg-[var(--gl-color-bg-container)] px-8 py-6"> <IndependentPageHeader>
<div> <div>
<h2 className="m-0 text-2xl leading-[var(--gl-line-height-xl)]">方法论展示配置</h2> <h2 className="m-0 text-2xl leading-[var(--gl-line-height-xl)]">方法论展示配置</h2>
<p className="m-0 mt-1 text-sm text-[var(--gl-color-text-secondary)]">维护官网方法论模块的展示状态、标题和步骤内容。</p> <p className="m-0 mt-1 text-sm text-[var(--gl-color-text-secondary)]">维护官网方法论模块的展示状态、标题和步骤内容。</p>
...@@ -670,8 +698,10 @@ export function OfficialSiteMethodologyPage() { ...@@ -670,8 +698,10 @@ export function OfficialSiteMethodologyPage() {
<Button theme="primary" loading={saving} aria-label="保存配置" onClick={handleSave}> <Button theme="primary" loading={saving} aria-label="保存配置" onClick={handleSave}>
保存配置 保存配置
</Button> </Button>
</header> </IndependentPageHeader>
<IndependentPageBody data-testid="methodology-page-scroll-area">
{renderContent()} {renderContent()}
</section> </IndependentPageBody>
</IndependentPageLayout>
); );
} }
...@@ -125,9 +125,56 @@ describe('OfficialSiteMethodologyPage upload, save, and state handling', () => { ...@@ -125,9 +125,56 @@ describe('OfficialSiteMethodologyPage upload, save, and state handling', () => {
fireEvent.click(screen.getByRole('button', { name: '保存配置' })); fireEvent.click(screen.getByRole('button', { name: '保存配置' }));
await waitFor(() => {
expect(screen.getByText('请配置步骤图标')).toBeInTheDocument(); expect(screen.getByText('请配置步骤图标')).toBeInTheDocument();
expect(screen.getByText('请上传内容图')).toBeInTheDocument(); expect(screen.getByText('请上传内容图')).toBeInTheDocument();
}); });
expect(screen.getByTestId('methodology-step-icon-error-2')).toHaveStyle({ color: '#d94841' });
expect(screen.getByTestId('methodology-content-image-error-2')).toHaveStyle({ color: '#d94841' });
});
it('keeps upload helper prompts as ordinary help text', async () => {
renderMethodology();
await waitFor(() => {
expect(screen.getAllByTestId('methodology-step-card')).toHaveLength(2);
});
const stepIconHelpers = screen.getAllByText('支持 PNG/JPG/JPEG,最大 2MB');
const contentImageHelpers = screen.getAllByText('支持 PNG/JPG/JPEG,最大 10MB');
expect(stepIconHelpers).toHaveLength(2);
expect(contentImageHelpers).toHaveLength(2);
expect(screen.queryByTestId('methodology-step-icon-help-1')).not.toBeInTheDocument();
expect(screen.queryByTestId('methodology-step-icon-help-2')).not.toBeInTheDocument();
expect(screen.queryByTestId('methodology-content-image-help-1')).not.toBeInTheDocument();
expect(screen.queryByTestId('methodology-content-image-help-2')).not.toBeInTheDocument();
[...stepIconHelpers, ...contentImageHelpers].forEach((helper) => {
expect(helper).not.toHaveClass('text-[var(--gl-color-warning-text)]');
expect(helper).not.toHaveClass('bg-[var(--gl-color-warning-bg)]');
});
});
it('caps step name input at 20 characters before save validation', async () => {
renderMethodology();
await waitFor(() => {
expect(screen.getAllByTestId('methodology-step-card')).toHaveLength(2);
});
const firstCard = screen.getAllByTestId('methodology-step-card')[0];
const stepNameInput = within(firstCard).getByLabelText('步骤2名称');
fireEvent.change(stepNameInput, { target: { value: '1234567890123456789012345' } });
expect(stepNameInput).toHaveValue('12345678901234567890');
fireEvent.click(screen.getByRole('button', { name: '保存配置' }));
await waitFor(() => {
expect(saveMethodologyConfig).toHaveBeenCalled();
});
expect(screen.queryByText('步骤名称不能超过 20 字')).not.toBeInTheDocument();
});
it('validates content image type and size before mock upload', async () => { it('validates content image type and size before mock upload', async () => {
renderMethodology(); renderMethodology();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!