Commit 93727beb by venus

feat(kernel): UI 组件统一改用 V* 前缀 - UButton/UAlert/useUMessage 等全量改名,内核 v2.0.0

1 parent 54f49730
Pipeline #524 for 93727beb failed in 0 seconds
Showing 61 changed files with 346 additions and 335 deletions
...@@ -21,7 +21,7 @@ import { ...@@ -21,7 +21,7 @@ import {
KeyOutlined, KeyOutlined,
UserOutlined, UserOutlined,
} from '@ant-design/icons'; } from '@ant-design/icons';
import { UButton } from '@venus/ui'; import { VButton } from '@venus/ui';
import { useAppStore } from '@/store/useAppStore'; import { useAppStore } from '@/store/useAppStore';
import { roleLabels, useAccess, type RoleKey } from '@/access'; import { roleLabels, useAccess, type RoleKey } from '@/access';
import { WorkbenchBackdrop } from './WorkbenchBackdrop'; import { WorkbenchBackdrop } from './WorkbenchBackdrop';
...@@ -95,10 +95,10 @@ function ActionCard({ ...@@ -95,10 +95,10 @@ function ActionCard({
<p className="venus-wb-action__desc">{desc}</p> <p className="venus-wb-action__desc">{desc}</p>
{action && onClick ? ( {action && onClick ? (
<div className="venus-wb-action__foot"> <div className="venus-wb-action__foot">
<UButton type="link" onClick={onClick}> <VButton type="link" onClick={onClick}>
{action} {action}
<ArrowRightOutlined /> <ArrowRightOutlined />
</UButton> </VButton>
</div> </div>
) : null} ) : null}
</section> </section>
......
...@@ -17,13 +17,13 @@ import { protocols as bizProtocols } from '@/protocols'; ...@@ -17,13 +17,13 @@ import { protocols as bizProtocols } from '@/protocols';
import { createLoginDeps, toMessageSink } from '../../../auth-deps'; import { createLoginDeps, toMessageSink } from '../../../auth-deps';
import { executeLoginFlow, resolveLoginProtocols } from '@venus/platform-core'; import { executeLoginFlow, resolveLoginProtocols } from '@venus/platform-core';
import type { VenusSession } from '@venus/contracts'; import type { VenusSession } from '@venus/contracts';
import { UButton, UForm, UFormItem, UInput, UTitle, UText } from '@venus/ui'; import { VButton, VForm, VFormItem, VInput, VTitle, VText } from '@venus/ui';
export function LoginForm() { export function LoginForm() {
const navigate = useNavigate(); const navigate = useNavigate();
const { message } = App.useApp(); const { message } = App.useApp();
const { applyLogin } = useAccess(); const { applyLogin } = useAccess();
const [form] = UForm.useForm(); const [form] = VForm.useForm();
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
// host 能力装配固定引用:协议实现常把它存进闭包,每次渲染换新对象会破坏缓存语义。 // host 能力装配固定引用:协议实现常把它存进闭包,每次渲染换新对象会破坏缓存语义。
...@@ -61,27 +61,27 @@ export function LoginForm() { ...@@ -61,27 +61,27 @@ export function LoginForm() {
return ( return (
<> <>
<UTitle level={3} style={{ marginBottom: 4 }}> <VTitle level={3} style={{ marginBottom: 4 }}>
{brand.welcomeTitle} {brand.welcomeTitle}
</UTitle> </VTitle>
<UText type="secondary">{brand.welcomeDesc}</UText> <VText type="secondary">{brand.welcomeDesc}</VText>
<UForm <VForm
form={form} form={form}
layout="vertical" layout="vertical"
onFinish={onFinish} onFinish={onFinish}
style={{ marginTop: 24 }} style={{ marginTop: 24 }}
requiredMark={false} requiredMark={false}
> >
<UFormItem name="account" label="账号" rules={[{ required: true, message: '请输入账号' }]}> <VFormItem name="account" label="账号" rules={[{ required: true, message: '请输入账号' }]}>
<UInput prefix={<UserOutlined />} placeholder="请输入账号" size="large" /> <VInput prefix={<UserOutlined />} placeholder="请输入账号" size="large" />
</UFormItem> </VFormItem>
<UFormItem name="password" label="密码" rules={[{ required: true, message: '请输入密码' }]}> <VFormItem name="password" label="密码" rules={[{ required: true, message: '请输入密码' }]}>
<UInput.Password prefix={<LockOutlined />} placeholder="请输入密码" size="large" /> <VInput.Password prefix={<LockOutlined />} placeholder="请输入密码" size="large" />
</UFormItem> </VFormItem>
<UButton htmlType="submit" size="large" block loading={loading}> <VButton htmlType="submit" size="large" block loading={loading}>
登 录 登 录
</UButton> </VButton>
</UForm> </VForm>
{FormExtra ? <FormExtra /> : null} {FormExtra ? <FormExtra /> : null}
</> </>
); );
......
import { LoginAside as DefaultLoginAside } from './components/LoginAside'; import { LoginAside as DefaultLoginAside } from './components/LoginAside';
import { LoginForm } from './components/LoginForm'; import { LoginForm } from './components/LoginForm';
import { UText } from '@venus/ui'; import { VText } from '@venus/ui';
import { brand } from '@/brand'; import { brand } from '@/brand';
import { slots } from '@/slots'; import { slots } from '@/slots';
/** 默认版权区;业务可用 slots.LoginFooter 整体替换。 */ /** 默认版权区;业务可用 slots.LoginFooter 整体替换。 */
function DefaultLoginFooter() { function DefaultLoginFooter() {
return ( return (
<UText type="secondary" style={{ marginTop: 24, fontSize: 12 }}> <VText type="secondary" style={{ marginTop: 24, fontSize: 12 }}>
© {new Date().getFullYear()} {brand.copyrightName} · {brand.copyrightSuffix} © {new Date().getFullYear()} {brand.copyrightName} · {brand.copyrightSuffix}
</UText> </VText>
); );
} }
......
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import { UButton, UResult } from '@venus/ui'; import { VButton, VResult } from '@venus/ui';
export default function NotFound() { export default function NotFound() {
const nav = useNavigate(); const nav = useNavigate();
return ( return (
<UResult <VResult
status="404" status="404"
title="404" title="404"
subTitle="页面不存在" subTitle="页面不存在"
extra={<UButton onClick={() => nav('/dashboard')}>返回工作台</UButton>} extra={<VButton onClick={() => nav('/dashboard')}>返回工作台</VButton>}
/> />
); );
} }
...@@ -5,7 +5,7 @@ import { useEffect, useState, type ReactNode } from 'react'; ...@@ -5,7 +5,7 @@ import { useEffect, useState, type ReactNode } from 'react';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import { App, Avatar, Tag } from 'antd'; import { App, Avatar, Tag } from 'antd';
import { UserOutlined } from '@ant-design/icons'; import { UserOutlined } from '@ant-design/icons';
import { UCard, UForm, UInput, UButton, UAlert, UText, Skeleton } from '@venus/ui'; import { VCard, VForm, VInput, VButton, VAlert, VText, Skeleton } from '@venus/ui';
import { auth, type UserInfo } from '@/api'; import { auth, type UserInfo } from '@/api';
import { useAppStore } from '@/store/useAppStore'; import { useAppStore } from '@/store/useAppStore';
import { useAccess } from '@/access'; import { useAccess } from '@/access';
...@@ -26,7 +26,7 @@ export default function Profile() { ...@@ -26,7 +26,7 @@ export default function Profile() {
const [info, setInfo] = useState<UserInfo | null>(null); const [info, setInfo] = useState<UserInfo | null>(null);
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
const [submitting, setSubmitting] = useState(false); const [submitting, setSubmitting] = useState(false);
const [form] = UForm.useForm<PasswordForm>(); const [form] = VForm.useForm<PasswordForm>();
useEffect(() => { useEffect(() => {
let alive = true; let alive = true;
...@@ -67,7 +67,7 @@ export default function Profile() { ...@@ -67,7 +67,7 @@ export default function Profile() {
}; };
if (loading) return <Skeleton variant="detail" />; if (loading) return <Skeleton variant="detail" />;
if (!info) return <UCard>{<UText type="secondary">暂无账号信息</UText>}</UCard>; if (!info) return <VCard>{<VText type="secondary">暂无账号信息</VText>}</VCard>;
const codes = info.roleCodes?.length ? info.roleCodes : roleCodes; const codes = info.roleCodes?.length ? info.roleCodes : roleCodes;
const detailRows: { label: string; value: ReactNode }[] = [ const detailRows: { label: string; value: ReactNode }[] = [
...@@ -98,7 +98,7 @@ export default function Profile() { ...@@ -98,7 +98,7 @@ export default function Profile() {
return ( return (
<div className="venus-profile"> <div className="venus-profile">
{/* 顶部身份横幅(整宽) */} {/* 顶部身份横幅(整宽) */}
<UCard <VCard
className="venus-profile-hero" className="venus-profile-hero"
styles={{ styles={{
body: { padding: 0, background: 'linear-gradient(135deg,#f3f7ff 0%,#eaf0ff 100%)' }, body: { padding: 0, background: 'linear-gradient(135deg,#f3f7ff 0%,#eaf0ff 100%)' },
...@@ -109,9 +109,9 @@ export default function Profile() { ...@@ -109,9 +109,9 @@ export default function Profile() {
<Avatar size={64} className="venus-profile-avatar" icon={<UserOutlined />} /> <Avatar size={64} className="venus-profile-avatar" icon={<UserOutlined />} />
<div> <div>
<div className="venus-profile-name">{info.name}</div> <div className="venus-profile-name">{info.name}</div>
<UText type="secondary" className="venus-profile-account"> <VText type="secondary" className="venus-profile-account">
{info.account} {info.account}
</UText> </VText>
</div> </div>
</div> </div>
<div className="venus-profile-hero-meta"> <div className="venus-profile-hero-meta">
...@@ -123,12 +123,12 @@ export default function Profile() { ...@@ -123,12 +123,12 @@ export default function Profile() {
))} ))}
</div> </div>
</div> </div>
</UCard> </VCard>
{/* 下方双栏(等高) */} {/* 下方双栏(等高) */}
<div className="venus-profile-grid"> <div className="venus-profile-grid">
{/* 左:账户详情 */} {/* 左:账户详情 */}
<UCard <VCard
className="venus-profile-info" className="venus-profile-info"
title={<span className="venus-profile-card-title">账户详情</span>} title={<span className="venus-profile-card-title">账户详情</span>}
styles={{ body: { padding: 20 } }} styles={{ body: { padding: 20 } }}
...@@ -144,29 +144,29 @@ export default function Profile() { ...@@ -144,29 +144,29 @@ export default function Profile() {
<div className="venus-profile-note"> <div className="venus-profile-note">
账号信息由系统管理员维护,如需变更请联系管理员处理。 账号信息由系统管理员维护,如需变更请联系管理员处理。
</div> </div>
</UCard> </VCard>
{/* 右:修改密码 */} {/* 右:修改密码 */}
<UCard <VCard
className="venus-profile-security" className="venus-profile-security"
title={<span className="venus-profile-card-title">修改密码</span>} title={<span className="venus-profile-card-title">修改密码</span>}
styles={{ body: { padding: 20 } }} styles={{ body: { padding: 20 } }}
> >
<UAlert <VAlert
type="info" type="info"
showIcon showIcon
message="修改成功后当前登录令牌失效,需使用新密码重新登录。" message="修改成功后当前登录令牌失效,需使用新密码重新登录。"
style={{ marginBottom: 18 }} style={{ marginBottom: 18 }}
/> />
<UForm form={form} layout="vertical" onFinish={onSubmit} style={{ maxWidth: 380 }}> <VForm form={form} layout="vertical" onFinish={onSubmit} style={{ maxWidth: 380 }}>
<UForm.Item <VForm.Item
name="oldPassword" name="oldPassword"
label="当前密码" label="当前密码"
rules={[{ required: true, message: '请输入当前密码' }]} rules={[{ required: true, message: '请输入当前密码' }]}
> >
<UInput.Password placeholder="请输入当前密码" autoComplete="current-password" /> <VInput.Password placeholder="请输入当前密码" autoComplete="current-password" />
</UForm.Item> </VForm.Item>
<UForm.Item <VForm.Item
name="newPassword" name="newPassword"
label="新密码" label="新密码"
rules={[ rules={[
...@@ -180,9 +180,9 @@ export default function Profile() { ...@@ -180,9 +180,9 @@ export default function Profile() {
}), }),
]} ]}
> >
<UInput.Password placeholder="至少 8 位" autoComplete="new-password" /> <VInput.Password placeholder="至少 8 位" autoComplete="new-password" />
</UForm.Item> </VForm.Item>
<UForm.Item <VForm.Item
name="confirmPassword" name="confirmPassword"
label="确认新密码" label="确认新密码"
dependencies={['newPassword']} dependencies={['newPassword']}
...@@ -196,13 +196,13 @@ export default function Profile() { ...@@ -196,13 +196,13 @@ export default function Profile() {
}), }),
]} ]}
> >
<UInput.Password placeholder="请再次输入新密码" autoComplete="new-password" /> <VInput.Password placeholder="请再次输入新密码" autoComplete="new-password" />
</UForm.Item> </VForm.Item>
<UButton htmlType="submit" loading={submitting}> <VButton htmlType="submit" loading={submitting}>
确认修改 确认修改
</UButton> </VButton>
</UForm> </VForm>
</UCard> </VCard>
</div> </div>
</div> </div>
); );
......
import { useEffect } from 'react'; import { useEffect } from 'react';
import { useRouteError } from 'react-router-dom'; import { useRouteError } from 'react-router-dom';
import { UButton, UResult } from '@venus/ui'; import { VButton, VResult } from '@venus/ui';
const RELOAD_KEY = 'venus:chunk-reload-attempted'; const RELOAD_KEY = 'venus:chunk-reload-attempted';
...@@ -33,7 +33,7 @@ export default function RouteErrorBoundary() { ...@@ -33,7 +33,7 @@ export default function RouteErrorBoundary() {
}, [resourceLoadFailed]); }, [resourceLoadFailed]);
return ( return (
<UResult <VResult
status="error" status="error"
title={resourceLoadFailed ? '页面资源加载失败' : '页面发生错误'} title={resourceLoadFailed ? '页面资源加载失败' : '页面发生错误'}
subTitle={ subTitle={
...@@ -41,7 +41,7 @@ export default function RouteErrorBoundary() { ...@@ -41,7 +41,7 @@ export default function RouteErrorBoundary() {
? '请检查网络后刷新页面。如果仍无法打开,请联系管理员。' ? '请检查网络后刷新页面。如果仍无法打开,请联系管理员。'
: '请刷新页面重试。如果问题持续出现,请联系管理员。' : '请刷新页面重试。如果问题持续出现,请联系管理员。'
} }
extra={<UButton onClick={() => window.location.reload()}>刷新页面</UButton>} extra={<VButton onClick={() => window.location.reload()}>刷新页面</VButton>}
/> />
); );
} }
{ {
"name": "venus-kernel", "name": "venus-kernel",
"version": "1.5.0", "version": "2.0.0",
"description": "VENUS 微前端基座内核。派生应用通过 venus kernel upgrade 升级,禁止直接修改 .kernel/ 下文件。", "description": "VENUS 微前端基座内核。派生应用通过 venus kernel upgrade 升级,禁止直接修改 .kernel/ 下文件。",
"minCliVersion": "1.0.0", "minCliVersion": "1.0.0",
"minKernelVersion": "1.0.0", "minKernelVersion": "1.0.0",
...@@ -53,6 +53,17 @@ ...@@ -53,6 +53,17 @@
"首次部署跑 pnpm release:all;日常增量跑 pnpm release:dev|test(按各 package.json.version 与线上清单比对);回滚加 --switch-only", "首次部署跑 pnpm release:all;日常增量跑 pnpm release:dev|test(按各 package.json.version 与线上清单比对);回滚加 --switch-only",
"deploy/ 属于业务区,内核升级不覆盖;发布前需在 nginx 给 /mfe/manifest.json 与 /index.html 配 Cache-Control: no-cache" "deploy/ 属于业务区,内核升级不覆盖;发布前需在 nginx 给 /mfe/manifest.json 与 /index.html 配 Cache-Control: no-cache"
] ]
},
{
"from": "1.5.0",
"to": "2.0.0",
"summary": "UI 组件统一改用 V* 前缀(venus 首字母):UButton→VButton、UTable→VTable、useUMessage→useVMessage 等;不再保留 U* 兼容别名",
"manual": [
"破坏性:@venus/ui 的所有 U* 组件/类型/hooks 已改名 V*,无兼容别名。升级后需把业务代码里的 import 与 JSX 标签统一替换(U→V,useUApp→useVApp、useUMessage→useVMessage)",
"机械替换即可:全词匹配 U<大写字母> 前缀改为 V<大写字母>;注意只改组件名,不要动 URL/UI/UUID 等普通单词",
"子应用仍需从 @venus/ui 消费组件,禁止直引 antd(eslint 门禁提示文案已同步为 V*)"
],
"breaking": true
} }
], ],
"protectedDir": ".kernel/", "protectedDir": ".kernel/",
......
import type { CSSProperties, ReactNode } from 'react'; import type { CSSProperties, ReactNode } from 'react';
import type { FormInstance, FormProps } from 'antd'; import type { FormInstance, FormProps } from 'antd';
import { UCascader, UDescriptions, UForm, UFormItem, UInput, USelect, USwitch } from '@venus/ui'; import { VCascader, VDescriptions, VForm, VFormItem, VInput, VSelect, VSwitch } from '@venus/ui';
import type { FieldSchema } from '../formSchema'; import type { FieldSchema } from '../formSchema';
export interface CombiFormProps<T extends Record<string, unknown>> { export interface CombiFormProps<T extends Record<string, unknown>> {
...@@ -40,9 +40,9 @@ export function CombiForm<T extends Record<string, unknown>>({ ...@@ -40,9 +40,9 @@ export function CombiForm<T extends Record<string, unknown>>({
labelWidth, labelWidth,
labelAlign = 'right', labelAlign = 'right',
}: CombiFormProps<T>) { }: CombiFormProps<T>) {
const [innerForm] = UForm.useForm<T>(); const [innerForm] = VForm.useForm<T>();
const form = externalForm ?? innerForm; const form = externalForm ?? innerForm;
const values = UForm.useWatch([], form) as T | undefined; const values = VForm.useWatch([], form) as T | undefined;
// 详情模式只展示调用方传入的数据;空的内部表单状态不能覆盖接口返回的详情值。 // 详情模式只展示调用方传入的数据;空的内部表单状态不能覆盖接口返回的详情值。
const data = (mode === 'detail' ? initialValues : (values ?? initialValues ?? {})) as T; const data = (mode === 'detail' ? initialValues : (values ?? initialValues ?? {})) as T;
const visible = fields.filter( const visible = fields.filter(
...@@ -50,7 +50,7 @@ export function CombiForm<T extends Record<string, unknown>>({ ...@@ -50,7 +50,7 @@ export function CombiForm<T extends Record<string, unknown>>({
); );
if (mode === 'detail') if (mode === 'detail')
return ( return (
<UDescriptions <VDescriptions
column={detailColumns} column={detailColumns}
styles={ styles={
labelWidth === undefined labelWidth === undefined
...@@ -79,7 +79,7 @@ export function CombiForm<T extends Record<string, unknown>>({ ...@@ -79,7 +79,7 @@ export function CombiForm<T extends Record<string, unknown>>({
const disabled = typeof field.disabled === 'function' ? field.disabled(data) : field.disabled; const disabled = typeof field.disabled === 'function' ? field.disabled(data) : field.disabled;
if (field.type === 'cascader') if (field.type === 'cascader')
return ( return (
<UCascader <VCascader
options={field.options} options={field.options}
disabled={disabled} disabled={disabled}
style={{ width: '100%' }} style={{ width: '100%' }}
...@@ -88,7 +88,7 @@ export function CombiForm<T extends Record<string, unknown>>({ ...@@ -88,7 +88,7 @@ export function CombiForm<T extends Record<string, unknown>>({
); );
if (field.type === 'select' || field.type === 'selectMultiple') if (field.type === 'select' || field.type === 'selectMultiple')
return ( return (
<USelect <VSelect
options={field.options} options={field.options}
mode={field.type === 'selectMultiple' ? 'multiple' : undefined} mode={field.type === 'selectMultiple' ? 'multiple' : undefined}
placeholder={ placeholder={
...@@ -100,21 +100,21 @@ export function CombiForm<T extends Record<string, unknown>>({ ...@@ -100,21 +100,21 @@ export function CombiForm<T extends Record<string, unknown>>({
{...field.selectProps} {...field.selectProps}
/> />
); );
if (field.type === 'switch') return <USwitch disabled={disabled} />; if (field.type === 'switch') return <VSwitch disabled={disabled} />;
if (field.type === 'textarea') if (field.type === 'textarea')
return ( return (
<UInput.TextArea <VInput.TextArea
disabled={disabled} disabled={disabled}
placeholder={inputPlaceholder(field)} placeholder={inputPlaceholder(field)}
{...field.textareaProps} {...field.textareaProps}
/> />
); );
return ( return (
<UInput disabled={disabled} placeholder={inputPlaceholder(field)} {...field.inputProps} /> <VInput disabled={disabled} placeholder={inputPlaceholder(field)} {...field.inputProps} />
); );
}; };
return ( return (
<UForm <VForm
form={form} form={form}
initialValues={initialValues} initialValues={initialValues}
layout={layout} layout={layout}
...@@ -129,7 +129,7 @@ export function CombiForm<T extends Record<string, unknown>>({ ...@@ -129,7 +129,7 @@ export function CombiForm<T extends Record<string, unknown>>({
{section.title ? renderSectionTitle?.(section.title) : null} {section.title ? renderSectionTitle?.(section.title) : null}
<div style={sectionContentStyle}> <div style={sectionContentStyle}>
{section.fields.map((field) => ( {section.fields.map((field) => (
<UFormItem <VFormItem
key={field.name} key={field.name}
name={field.name as string} name={field.name as string}
label={field.label} label={field.label}
...@@ -138,12 +138,12 @@ export function CombiForm<T extends Record<string, unknown>>({ ...@@ -138,12 +138,12 @@ export function CombiForm<T extends Record<string, unknown>>({
normalize={field.normalize} normalize={field.normalize}
> >
{renderControl?.(field, form, data) ?? defaultControl(field)} {renderControl?.(field, form, data) ?? defaultControl(field)}
</UFormItem> </VFormItem>
))} ))}
</div> </div>
</section> </section>
))} ))}
</UForm> </VForm>
); );
} }
......
import type { ReactNode } from 'react'; import type { ReactNode } from 'react';
import { UModal } from '@venus/ui'; import { VModal } from '@venus/ui';
export interface ConfirmModalProps { export interface ConfirmModalProps {
open: boolean; open: boolean;
...@@ -26,7 +26,7 @@ export function ConfirmModal({ ...@@ -26,7 +26,7 @@ export function ConfirmModal({
onConfirm, onConfirm,
}: ConfirmModalProps) { }: ConfirmModalProps) {
return ( return (
<UModal <VModal
open={open} open={open}
title={title} title={title}
width={width} width={width}
...@@ -37,6 +37,6 @@ export function ConfirmModal({ ...@@ -37,6 +37,6 @@ export function ConfirmModal({
onOk={onConfirm} onOk={onConfirm}
> >
<div style={{ padding: '8px 0 24px' }}>{content}</div> <div style={{ padding: '8px 0 24px' }}>{content}</div>
</UModal> </VModal>
); );
} }
import { useLayoutEffect, useRef, useState } from 'react'; import { useLayoutEffect, useRef, useState } from 'react';
import type { CSSProperties, ReactNode } from 'react'; import type { CSSProperties, ReactNode } from 'react';
import type { ColumnsType, TableProps } from 'antd/es/table'; import type { ColumnsType, TableProps } from 'antd/es/table';
import { UButton, UTable, UTooltip, UExportIcon, FillTable } from '@venus/ui'; import { VButton, VTable, VTooltip, VExportIcon, FillTable } from '@venus/ui';
import { PermButton } from '@/access'; import { PermButton } from '@/access';
import type { ActionSchema } from '../formSchema'; import type { ActionSchema } from '../formSchema';
...@@ -155,7 +155,7 @@ export function DataTable<T extends object>({ ...@@ -155,7 +155,7 @@ export function DataTable<T extends object>({
onClick, onClick,
type: isExport ? ('default' as const) : type, type: isExport ? ('default' as const) : type,
size: 'small' as const, size: 'small' as const,
icon: isExport ? <UExportIcon /> : undefined, icon: isExport ? <VExportIcon /> : undefined,
className: isRowAction className: isRowAction
? undefined ? undefined
: isExport : isExport
...@@ -173,9 +173,9 @@ export function DataTable<T extends object>({ ...@@ -173,9 +173,9 @@ export function DataTable<T extends object>({
{content} {content}
</PermButton> </PermButton>
) : ( ) : (
<UButton key={key} {...buttonProps}> <VButton key={key} {...buttonProps}>
{content} {content}
</UButton> </VButton>
); );
}; };
// 操作列宽由「内容」决定,页面传值降级为下限建议。 // 操作列宽由「内容」决定,页面传值降级为下限建议。
...@@ -239,7 +239,7 @@ export function DataTable<T extends object>({ ...@@ -239,7 +239,7 @@ export function DataTable<T extends object>({
// 统一注入默认列宽 + 默认省略能力后再算最小宽度,scroll.x 与列宽始终一致。 // 统一注入默认列宽 + 默认省略能力后再算最小宽度,scroll.x 与列宽始终一致。
const tableColumns = withLineLimit(sourceColumns, defaultColumnWidth); const tableColumns = withLineLimit(sourceColumns, defaultColumnWidth);
const minTableWidth = getMinimumTableWidth(tableColumns, defaultColumnWidth); const minTableWidth = getMinimumTableWidth(tableColumns, defaultColumnWidth);
const TableComponent = fillHeight ? FillTable<T> : UTable<T>; const TableComponent = fillHeight ? FillTable<T> : VTable<T>;
return ( return (
<> <>
{toolbarTitle || actions?.length || toolbarExtra ? ( {toolbarTitle || actions?.length || toolbarExtra ? (
...@@ -327,7 +327,7 @@ function estimateActionWidth<T extends object>(actions?: RowActionSchema<T>[]): ...@@ -327,7 +327,7 @@ function estimateActionWidth<T extends object>(actions?: RowActionSchema<T>[]):
* - line=0:显式禁用省略,内容原样。 * - line=0:显式禁用省略,内容原样。
* - line>0:按指定行数强制截断(兼容既有 line:1 / line:2 配置)。 * - line>0:按指定行数强制截断(兼容既有 line:1 / line:2 配置)。
* - 未配置:智能默认 —— 纯文本(string/number)单行省略; * - 未配置:智能默认 —— 纯文本(string/number)单行省略;
* JSX(UTag / 链接 / 按钮 / venus-code 等带样式节点)原样返回,避免 toCellContent 剥掉样式。 * JSX(VTag / 链接 / 按钮 / venus-code 等带样式节点)原样返回,避免 toCellContent 剥掉样式。
* 只有实际溢出被省略时才由 EllipsisText 挂完整 tip;没省略的列不挂。 * 只有实际溢出被省略时才由 EllipsisText 挂完整 tip;没省略的列不挂。
* 内部生成的序号列、操作列不参与省略包装。 * 内部生成的序号列、操作列不参与省略包装。
*/ */
...@@ -388,7 +388,7 @@ function withLineLimit<T extends object>( ...@@ -388,7 +388,7 @@ function withLineLimit<T extends object>(
* 省略列:只有内容确实被截断时才挂 tip。 * 省略列:只有内容确实被截断时才挂 tip。
* 单行比对 scrollWidth/clientWidth,多行比对 scrollHeight/clientHeight(+1 容忍亚像素取整); * 单行比对 scrollWidth/clientWidth,多行比对 scrollHeight/clientHeight(+1 容忍亚像素取整);
* ResizeObserver 监听列宽变化,避免固定布局下窗口缩放后提示状态失真。 * ResizeObserver 监听列宽变化,避免固定布局下窗口缩放后提示状态失真。
* 保持始终渲染 UTooltip(title=null 即无提示)以稳定 span 的 DOM 节点和 ref。 * 保持始终渲染 VTooltip(title=null 即无提示)以稳定 span 的 DOM 节点和 ref。
*/ */
function EllipsisText({ function EllipsisText({
line, line,
...@@ -419,11 +419,11 @@ function EllipsisText({ ...@@ -419,11 +419,11 @@ function EllipsisText({
}, [line, children]); }, [line, children]);
return ( return (
<UTooltip title={truncated ? title : null}> <VTooltip title={truncated ? title : null}>
<span ref={spanRef} style={lineStyle(line)}> <span ref={spanRef} style={lineStyle(line)}>
{children} {children}
</span> </span>
</UTooltip> </VTooltip>
); );
} }
......
import { useEffect, useRef, useState } from 'react'; import { useEffect, useRef, useState } from 'react';
import { import {
UCascader, VCascader,
UButton, VButton,
UDatePicker, VDatePicker,
UForm, VForm,
UFormItem, VFormItem,
UInput, VInput,
UPopover, VPopover,
URadio, VRadio,
USelect, VSelect,
} from '@venus/ui'; } from '@venus/ui';
import type { FieldOption, FieldSchema } from '../formSchema'; import type { FieldOption, FieldSchema } from '../formSchema';
import { DEFAULT_PAGE_SIZE } from '../DataTable'; import { DEFAULT_PAGE_SIZE } from '../DataTable';
...@@ -70,7 +70,7 @@ export function SearchForm<T extends Record<string, unknown>>({ ...@@ -70,7 +70,7 @@ export function SearchForm<T extends Record<string, unknown>>({
className, className,
defaultExpanded = false, defaultExpanded = false,
}: SearchFormProps<T>) { }: SearchFormProps<T>) {
const [form] = UForm.useForm(); const [form] = VForm.useForm();
// 普通单选下拉以空值代表「全部」。除了补选项外,也要把未指定的初始值设为空, // 普通单选下拉以空值代表「全部」。除了补选项外,也要把未指定的初始值设为空,
// 否则组件只会显示占位状态,看起来像没有选中「全部」。 // 否则组件只会显示占位状态,看起来像没有选中「全部」。
const formInitialValues = fields.reduce<Record<string, unknown>>( const formInitialValues = fields.reduce<Record<string, unknown>>(
...@@ -84,7 +84,7 @@ export function SearchForm<T extends Record<string, unknown>>({ ...@@ -84,7 +84,7 @@ export function SearchForm<T extends Record<string, unknown>>({
) as Partial<T>; ) as Partial<T>;
// 空数组 = 监听整张表单。用于「收起状态下已设条件」的角标计数与悬浮卡: // 空数组 = 监听整张表单。用于「收起状态下已设条件」的角标计数与悬浮卡:
// 收起了不等于没生效,用户必须看得见自己身上还挂着几个条件、分别是什么。 // 收起了不等于没生效,用户必须看得见自己身上还挂着几个条件、分别是什么。
const values = UForm.useWatch([], form) as Partial<T> | undefined; const values = VForm.useWatch([], form) as Partial<T> | undefined;
const [expanded, setExpanded] = useState(defaultExpanded); const [expanded, setExpanded] = useState(defaultExpanded);
const [activePopoverOpen, setActivePopoverOpen] = useState(false); const [activePopoverOpen, setActivePopoverOpen] = useState(false);
// 触发区只有主色实心的「已填数」角标。antd Popover 的 hover 触发器绑在 children 上时, // 触发区只有主色实心的「已填数」角标。antd Popover 的 hover 触发器绑在 children 上时,
...@@ -242,9 +242,9 @@ export function SearchForm<T extends Record<string, unknown>>({ ...@@ -242,9 +242,9 @@ export function SearchForm<T extends Record<string, unknown>>({
</div> </div>
<div className="venus-filter-active__foot"> <div className="venus-filter-active__foot">
<span className="venus-filter-active__hint">点 × 移除单项</span> <span className="venus-filter-active__hint">点 × 移除单项</span>
<UButton type="default" size="small" danger onClick={clearAllConditions}> <VButton type="default" size="small" danger onClick={clearAllConditions}>
全部清空 全部清空
</UButton> </VButton>
</div> </div>
</div> </div>
); );
...@@ -266,7 +266,7 @@ export function SearchForm<T extends Record<string, unknown>>({ ...@@ -266,7 +266,7 @@ export function SearchForm<T extends Record<string, unknown>>({
const options = field.options ?? []; const options = field.options ?? [];
const hasAllOption = options.some((option) => option.label === '全部' || option.value === ''); const hasAllOption = options.some((option) => option.label === '全部' || option.value === '');
return ( return (
<USelect <VSelect
{...common} {...common}
allowClear={false} allowClear={false}
style={{ width }} style={{ width }}
...@@ -281,41 +281,41 @@ export function SearchForm<T extends Record<string, unknown>>({ ...@@ -281,41 +281,41 @@ export function SearchForm<T extends Record<string, unknown>>({
); );
} }
if (field.type === 'cascader') if (field.type === 'cascader')
return <UCascader {...common} style={{ width }} options={field.options} allowClear={false} />; return <VCascader {...common} style={{ width }} options={field.options} allowClear={false} />;
if (field.type === 'date') return <UDatePicker {...common} style={{ width }} />; if (field.type === 'date') return <VDatePicker {...common} style={{ width }} />;
if (field.type === 'dateRange') { if (field.type === 'dateRange') {
const picker = <UDatePicker.RangePicker disabled={common.disabled} style={{ width }} />; const picker = <VDatePicker.RangePicker disabled={common.disabled} style={{ width }} />;
if (!field.selector) return picker; if (!field.selector) return picker;
return ( return (
<div style={{ display: 'flex', width, minWidth: 0 }}> <div style={{ display: 'flex', width, minWidth: 0 }}>
<UFormItem name={field.selector.name as string} noStyle> <VFormItem name={field.selector.name as string} noStyle>
<USelect <VSelect
allowClear={false} allowClear={false}
style={{ width: 165, flex: '0 0 165px' }} style={{ width: 165, flex: '0 0 165px' }}
options={field.selector.options} options={field.selector.options}
/> />
</UFormItem> </VFormItem>
<div style={{ minWidth: 0, flex: 1 }}>{picker}</div> <div style={{ minWidth: 0, flex: 1 }}>{picker}</div>
</div> </div>
); );
} }
if (field.type === 'radio') return <URadio.Group {...common} options={field.options} />; if (field.type === 'radio') return <VRadio.Group {...common} options={field.options} />;
const input = const input =
field.type === 'textarea' ? ( field.type === 'textarea' ? (
<UInput.TextArea {...common} style={{ width }} /> <VInput.TextArea {...common} style={{ width }} />
) : ( ) : (
<UInput {...common} style={{ width }} /> <VInput {...common} style={{ width }} />
); );
if (!field.selector) return input; if (!field.selector) return input;
return ( return (
<div style={{ display: 'flex', width, minWidth: 0 }}> <div style={{ display: 'flex', width, minWidth: 0 }}>
<UFormItem name={field.selector.name as string} noStyle> <VFormItem name={field.selector.name as string} noStyle>
<USelect <VSelect
allowClear={false} allowClear={false}
style={{ width: 140, flex: '0 0 140px' }} style={{ width: 140, flex: '0 0 140px' }}
options={field.selector.options} options={field.selector.options}
/> />
</UFormItem> </VFormItem>
<div style={{ minWidth: 0, flex: 1 }}>{input}</div> <div style={{ minWidth: 0, flex: 1 }}>{input}</div>
</div> </div>
); );
...@@ -331,14 +331,14 @@ export function SearchForm<T extends Record<string, unknown>>({ ...@@ -331,14 +331,14 @@ export function SearchForm<T extends Record<string, unknown>>({
const style: React.CSSProperties = { marginBottom: 0, minWidth: 0 }; const style: React.CSSProperties = { marginBottom: 0, minWidth: 0 };
if (span > 1) style.gridColumn = `span ${span}`; if (span > 1) style.gridColumn = `span ${span}`;
return ( return (
<UFormItem key={field.name} name={field.name as string} label={field.label} style={style}> <VFormItem key={field.name} name={field.name as string} label={field.label} style={style}>
{control(field)} {control(field)}
</UFormItem> </VFormItem>
); );
}; };
return ( return (
<UForm <VForm
form={form} form={form}
initialValues={formInitialValues} initialValues={formInitialValues}
// 标签在左、控件在右:标签列宽固定,四组控件的左缘落在同一条竖线上。 // 标签在左、控件在右:标签列宽固定,四组控件的左缘落在同一条竖线上。
...@@ -357,7 +357,7 @@ export function SearchForm<T extends Record<string, unknown>>({ ...@@ -357,7 +357,7 @@ export function SearchForm<T extends Record<string, unknown>>({
<div className="venus-filter-actions"> <div className="venus-filter-actions">
{hasExtra ? ( {hasExtra ? (
<UButton <VButton
type="text" type="text"
size="small" size="small"
className="venus-filter-more-btn" className="venus-filter-more-btn"
...@@ -381,7 +381,7 @@ export function SearchForm<T extends Record<string, unknown>>({ ...@@ -381,7 +381,7 @@ export function SearchForm<T extends Record<string, unknown>>({
) : null} ) : null}
</span> </span>
{activeFilterCount > 0 ? ( {activeFilterCount > 0 ? (
<UPopover <VPopover
// 触发区是主色实心的「已填数」角标:无背景的总数上标、按钮文案都不触发。 // 触发区是主色实心的「已填数」角标:无背景的总数上标、按钮文案都不触发。
// 开/关由角标自己的 mouse/focus 事件控制,不给 Popover 留触发方式, // 开/关由角标自己的 mouse/focus 事件控制,不给 Popover 留触发方式,
// 否则点击按钮也会经由 onOpenChange 把它打开。 // 否则点击按钮也会经由 onOpenChange 把它打开。
...@@ -405,19 +405,19 @@ export function SearchForm<T extends Record<string, unknown>>({ ...@@ -405,19 +405,19 @@ export function SearchForm<T extends Record<string, unknown>>({
> >
{activeFilterCount} {activeFilterCount}
</span> </span>
</UPopover> </VPopover>
) : null} ) : null}
<span className={`venus-filter-toggle-icon${expanded ? ' is-open' : ''}`} aria-hidden> <span className={`venus-filter-toggle-icon${expanded ? ' is-open' : ''}`} aria-hidden>
▾ ▾
</span> </span>
</UButton> </VButton>
) : null} ) : null}
<UButton type="default" size="small" onClick={clearAllConditions}> <VButton type="default" size="small" onClick={clearAllConditions}>
重置 重置
</UButton> </VButton>
<UButton size="small" htmlType="submit"> <VButton size="small" htmlType="submit">
查询 查询
</UButton> </VButton>
</div> </div>
</div> </div>
...@@ -428,7 +428,7 @@ export function SearchForm<T extends Record<string, unknown>>({ ...@@ -428,7 +428,7 @@ export function SearchForm<T extends Record<string, unknown>>({
{extraFields.map(renderField)} {extraFields.map(renderField)}
</div> </div>
) : null} ) : null}
</UForm> </VForm>
); );
} }
......
import { UTag } from '@venus/ui'; import { VTag } from '@venus/ui';
import { STORE_STATUS, type StoreStatus } from '@/config/storeStatus'; import { STORE_STATUS, type StoreStatus } from '@/config/storeStatus';
/** 门店状态徽标(对应 PRD §4.2 状态规范) */ /** 门店状态徽标(对应 PRD §4.2 状态规范) */
export function StatusTag({ status }: { status?: StoreStatus | string | null }) { export function StatusTag({ status }: { status?: StoreStatus | string | null }) {
const meta = STORE_STATUS[status as StoreStatus] ?? { label: status || '—', color: 'default' }; const meta = STORE_STATUS[status as StoreStatus] ?? { label: status || '—', color: 'default' };
return ( return (
<UTag color={meta.color} style={{ marginInlineEnd: 0, borderRadius: 6 }}> <VTag color={meta.color} style={{ marginInlineEnd: 0, borderRadius: 6 }}>
{meta.label} {meta.label}
</UTag> </VTag>
); );
} }
...@@ -59,7 +59,7 @@ export const app = (options = {}) => ...@@ -59,7 +59,7 @@ export const app = (options = {}) =>
group: ['antd', 'antd/*'], group: ['antd', 'antd/*'],
allowTypeImports: true, allowTypeImports: true,
message: message:
'子应用必须经 @venus/ui 消费组件(UAlert / UTable / useUMessage …)。缺组件就往 packages/ui 补一个 U** 再引用,不要绕过共享层直接用 antd。', '子应用必须经 @venus/ui 消费组件(VAlert / VTable / useVMessage …)。缺组件就往 packages/ui 补一个 V** 再引用,不要绕过共享层直接用 antd。',
}, },
], ],
}, },
......
import { forwardRef } from 'react'; import { forwardRef } from 'react';
import { UButton, UTooltip, type UButtonProps } from '@venus/ui'; import { VButton, VTooltip, type VButtonProps } from '@venus/ui';
import { useAccess } from '../runtime/AccessProvider'; import { useAccess } from '../runtime/AccessProvider';
interface PermButtonProps extends UButtonProps { interface PermButtonProps extends VButtonProps {
/** 所需权限点,如 'store:approve:pass';无该权限时按 fallback 处理 */ /** 所需权限点,如 'store:approve:pass';无该权限时按 fallback 处理 */
permission: string; permission: string;
/** 无权限时的表现:'hide' 不渲染(默认)| 'disabled' 渲染禁用态 */ /** 无权限时的表现:'hide' 不渲染(默认)| 'disabled' 渲染禁用态 */
...@@ -23,7 +23,7 @@ export const PermButton = forwardRef<HTMLButtonElement, PermButtonProps>( ...@@ -23,7 +23,7 @@ export const PermButton = forwardRef<HTMLButtonElement, PermButtonProps>(
if (!ok && fallback === 'hide') return null; if (!ok && fallback === 'hide') return null;
const btn = ( const btn = (
<UButton <VButton
ref={ref} ref={ref}
{...rest} {...rest}
disabled={!ok || rest.disabled} disabled={!ok || rest.disabled}
...@@ -32,7 +32,7 @@ export const PermButton = forwardRef<HTMLButtonElement, PermButtonProps>( ...@@ -32,7 +32,7 @@ export const PermButton = forwardRef<HTMLButtonElement, PermButtonProps>(
); );
if (!ok && fallback === 'disabled' && unauthorizedTip) { if (!ok && fallback === 'disabled' && unauthorizedTip) {
return <UTooltip title={unauthorizedTip}>{btn}</UTooltip>; return <VTooltip title={unauthorizedTip}>{btn}</VTooltip>;
} }
return btn; return btn;
}, },
......
import { forwardRef } from 'react'; import { forwardRef } from 'react';
import { UButton, UTooltip, type UButtonProps } from '@venus/ui'; import { VButton, VTooltip, type VButtonProps } from '@venus/ui';
import { useAccess } from '../runtime/AccessProvider'; import { useAccess } from '../runtime/AccessProvider';
interface PermButtonProps extends UButtonProps { interface PermButtonProps extends VButtonProps {
/** 所需权限点,如 'store:approve:pass';无该权限时按 fallback 处理 */ /** 所需权限点,如 'store:approve:pass';无该权限时按 fallback 处理 */
permission: string; permission: string;
/** 无权限时的表现:'hide' 不渲染(默认)| 'disabled' 渲染禁用态 */ /** 无权限时的表现:'hide' 不渲染(默认)| 'disabled' 渲染禁用态 */
...@@ -23,7 +23,7 @@ export const PermButton = forwardRef<HTMLButtonElement, PermButtonProps>( ...@@ -23,7 +23,7 @@ export const PermButton = forwardRef<HTMLButtonElement, PermButtonProps>(
if (!ok && fallback === 'hide') return null; if (!ok && fallback === 'hide') return null;
const btn = ( const btn = (
<UButton <VButton
ref={ref} ref={ref}
{...rest} {...rest}
disabled={!ok || rest.disabled} disabled={!ok || rest.disabled}
...@@ -32,7 +32,7 @@ export const PermButton = forwardRef<HTMLButtonElement, PermButtonProps>( ...@@ -32,7 +32,7 @@ export const PermButton = forwardRef<HTMLButtonElement, PermButtonProps>(
); );
if (!ok && fallback === 'disabled' && unauthorizedTip) { if (!ok && fallback === 'disabled' && unauthorizedTip) {
return <UTooltip title={unauthorizedTip}>{btn}</UTooltip>; return <VTooltip title={unauthorizedTip}>{btn}</VTooltip>;
} }
return btn; return btn;
}, },
......
import { Alert, type AlertProps } from 'antd'; import { Alert, type AlertProps } from 'antd';
export type UAlertProps = AlertProps; export type VAlertProps = AlertProps;
/** /**
* 项目提示条。 * 项目提示条。
* 淡底与淡描边由 themeConfig 的 color*Bg / color*Border 别名统一给出, * 淡底与淡描边由 themeConfig 的 color*Bg / color*Border 别名统一给出,
* 不在页面里为每种状态各写一套背景色。 * 不在页面里为每种状态各写一套背景色。
*/ */
export function UAlert({ className, ...rest }: UAlertProps) { export function VAlert({ className, ...rest }: VAlertProps) {
return <Alert className={['uj-alert', className].filter(Boolean).join(' ')} {...rest} />; return <Alert className={['uj-alert', className].filter(Boolean).join(' ')} {...rest} />;
} }
import { Alert, type AlertProps } from 'antd'; import { Alert, type AlertProps } from 'antd';
export type UAlertProps = AlertProps; export type VAlertProps = AlertProps;
/** /**
* 项目提示条。 * 项目提示条。
* 淡底与淡描边由 themeConfig 的 color*Bg / color*Border 别名统一给出, * 淡底与淡描边由 themeConfig 的 color*Bg / color*Border 别名统一给出,
* 不在页面里为每种状态各写一套背景色。 * 不在页面里为每种状态各写一套背景色。
*/ */
export function UAlert({ className, ...rest }: UAlertProps) { export function VAlert({ className, ...rest }: VAlertProps) {
return <Alert className={['venus-alert', className].filter(Boolean).join(' ')} {...rest} />; return <Alert className={['venus-alert', className].filter(Boolean).join(' ')} {...rest} />;
} }
...@@ -2,7 +2,7 @@ import { App as AntApp } from 'antd'; ...@@ -2,7 +2,7 @@ import { App as AntApp } from 'antd';
import { useMemo } from 'react'; import { useMemo } from 'react';
/** 取当前 App 边界上的 message / notification / modal 实例。 */ /** 取当前 App 边界上的 message / notification / modal 实例。 */
export function useUApp() { export function useVApp() {
return AntApp.useApp(); return AntApp.useApp();
} }
...@@ -11,7 +11,7 @@ export function useUApp() { ...@@ -11,7 +11,7 @@ export function useUApp() {
* 返回的实例走 ConfigProvider 的主题与 locale,静态 message.xxx 拿不到, * 返回的实例走 ConfigProvider 的主题与 locale,静态 message.xxx 拿不到,
* 在 wujie 的 shadowRoot 内还会挂到文档 body 上、脱离子应用样式作用域。 * 在 wujie 的 shadowRoot 内还会挂到文档 body 上、脱离子应用样式作用域。
*/ */
export function useUMessage() { export function useVMessage() {
const { message } = useUApp(); const { message } = useVApp();
return useMemo(() => message, [message]); return useMemo(() => message, [message]);
} }
import { App as AntApp, type AppProps } from 'antd'; import { App as AntApp, type AppProps } from 'antd';
export type UAppProps = AppProps; export type VAppProps = AppProps;
/** /**
* 项目统一的 antd App 边界。 * 项目统一的 antd App 边界。
* *
* 为什么要单独封一层:`import { App } from 'antd'` 在三个子应用里出现了 14 次, * 为什么要单独封一层:`import { App } from 'antd'` 在三个子应用里出现了 14 次,
* 目的全是拿 `App.useApp()` 的 message/notification —— 但那意味着每个页面都直接认识 antd。 * 目的全是拿 `App.useApp()` 的 message/notification —— 但那意味着每个页面都直接认识 antd。
* 子应用不许直引 antd(eslint 门禁),入口层由 @venus/ui 承担,页面只认 useUApp。 * 子应用不许直引 antd(eslint 门禁),入口层由 @venus/ui 承担,页面只认 useVApp。
* *
* 挂载点在 platform-sdk 的 SubAppProvider 里(那里是唯一的 ConfigProvider + App 边界), * 挂载点在 platform-sdk 的 SubAppProvider 里(那里是唯一的 ConfigProvider + App 边界),
* 本组件只给需要显式声明边界的场景用,行为与 antd App 一致。 * 本组件只给需要显式声明边界的场景用,行为与 antd App 一致。
*/ */
export function UApp(props: UAppProps) { export function VApp(props: VAppProps) {
return <AntApp {...props} />; return <AntApp {...props} />;
} }
import { Button, type ButtonProps } from 'antd'; import { Button, type ButtonProps } from 'antd';
import { forwardRef } from 'react'; import { forwardRef } from 'react';
export type UButtonProps = ButtonProps; export type VButtonProps = ButtonProps;
/** /**
* 项目统一按钮。约定主操作默认 primary、统一尺寸 middle, * 项目统一按钮。约定主操作默认 primary、统一尺寸 middle,
* 仍可通过 props 覆盖。后续可在此注入埋点/权限/loading 自动处理等横切逻辑。 * 仍可通过 props 覆盖。后续可在此注入埋点/权限/loading 自动处理等横切逻辑。
*/ */
export const UButton = forwardRef<HTMLButtonElement, UButtonProps>( export const VButton = forwardRef<HTMLButtonElement, VButtonProps>(
({ type = 'primary', size = 'middle', ...rest }, ref) => ( ({ type = 'primary', size = 'middle', ...rest }, ref) => (
<Button ref={ref} type={type} size={size} {...rest} /> <Button ref={ref} type={type} size={size} {...rest} />
), ),
); );
UButton.displayName = 'UButton'; VButton.displayName = 'VButton';
import { Card, type CardProps } from 'antd'; import { Card, type CardProps } from 'antd';
export type UCardProps = CardProps & { export type VCardProps = CardProps & {
/** /**
* 铺满父容器剩余高度,内部由表体自己滚动(列表页用)。 * 铺满父容器剩余高度,内部由表体自己滚动(列表页用)。
* 只是往根节点加一格布局类,不改 Card 的 DOM 结构,所以 antd 的尺寸计算不受影响。 * 只是往根节点加一格布局类,不改 Card 的 DOM 结构,所以 antd 的尺寸计算不受影响。
...@@ -12,13 +12,13 @@ export type UCardProps = CardProps & { ...@@ -12,13 +12,13 @@ export type UCardProps = CardProps & {
* 项目卡片容器。 * 项目卡片容器。
* *
* 与旧版的关键差异:默认 variant="borderless"。卡片靠「浅底 + 柔影」分层, * 与旧版的关键差异:默认 variant="borderless"。卡片靠「浅底 + 柔影」分层,
* 再叠一圈实描边会让每块内容都多一条硬线 —— 三个子应用原来既在 UCard 外 * 再叠一圈实描边会让每块内容都多一条硬线 —— 三个子应用原来既在 VCard 外
* 又各自写一遍 border + box-shadow(store-filter-card / venus-points-table-card), * 又各自写一遍 border + box-shadow(store-filter-card / venus-points-table-card),
* 阴影值还被旧令牌覆盖成单层弱影,所以子应用的卡片一直比主壳「平」。 * 阴影值还被旧令牌覆盖成单层弱影,所以子应用的卡片一直比主壳「平」。
* *
* 需要表达「可点击 / 选中」时才显式传 variant="outlined"。 * 需要表达「可点击 / 选中」时才显式传 variant="outlined"。
*/ */
export function UCard({ variant = 'borderless', fill, className, ...rest }: UCardProps) { export function VCard({ variant = 'borderless', fill, className, ...rest }: VCardProps) {
return ( return (
<Card <Card
variant={variant} variant={variant}
......
import { Cascader, type CascaderProps } from 'antd'; import { Cascader, type CascaderProps } from 'antd';
import type { DefaultOptionType } from 'antd/es/cascader'; import type { DefaultOptionType } from 'antd/es/cascader';
export type UCascaderProps = CascaderProps<DefaultOptionType, keyof DefaultOptionType, false>; export type VCascaderProps = CascaderProps<DefaultOptionType, keyof DefaultOptionType, false>;
/** 项目统一级联选择。 */ /** 项目统一级联选择。 */
export function UCascader(props: UCascaderProps) { export function VCascader(props: VCascaderProps) {
return <Cascader {...props} />; return <Cascader {...props} />;
} }
import { Checkbox } from 'antd'; import { Checkbox } from 'antd';
/** 项目统一多选框,透传 antd Checkbox。 */ /** 项目统一多选框,透传 antd Checkbox。 */
export const UCheckbox = Checkbox; export const VCheckbox = Checkbox;
export default UCheckbox; export default VCheckbox;
import { DatePicker, type DatePickerProps } from 'antd'; import { DatePicker, type DatePickerProps } from 'antd';
export type UDatePickerProps = DatePickerProps; export type VDatePickerProps = DatePickerProps;
export const UDatePicker = Object.assign((props: UDatePickerProps) => <DatePicker {...props} />, { export const VDatePicker = Object.assign((props: VDatePickerProps) => <DatePicker {...props} />, {
RangePicker: DatePicker.RangePicker, RangePicker: DatePicker.RangePicker,
}); });
import { Descriptions, type DescriptionsProps } from 'antd'; import { Descriptions, type DescriptionsProps } from 'antd';
export type UDescriptionsProps = DescriptionsProps; export type VDescriptionsProps = DescriptionsProps;
export const UDescriptions = Object.assign( export const VDescriptions = Object.assign(
(props: UDescriptionsProps) => <Descriptions {...props} />, (props: VDescriptionsProps) => <Descriptions {...props} />,
{ {
Item: Descriptions.Item, Item: Descriptions.Item,
}, },
......
import { Drawer, type DrawerProps } from 'antd'; import { Drawer, type DrawerProps } from 'antd';
export type UDrawerProps = DrawerProps; export type VDrawerProps = DrawerProps;
/** /**
* Unified detail drawer; responsive width and lifecycle defaults remain overridable. * Unified detail drawer; responsive width and lifecycle defaults remain overridable.
* 约定:footer 里的取消/关闭按钮一律 type="default"(UButton 默认 primary, * 约定:footer 里的取消/关闭按钮一律 type="default"(VButton 默认 primary,
* 不显式写就是主色)—— antd v6 的 Drawer 已无内置 footer 按钮,约定只能落在调用点。 * 不显式写就是主色)—— antd v6 的 Drawer 已无内置 footer 按钮,约定只能落在调用点。
*/ */
export function UDrawer({ size = 760, destroyOnHidden = true, styles, ...props }: UDrawerProps) { export function VDrawer({ size = 760, destroyOnHidden = true, styles, ...props }: VDrawerProps) {
return ( return (
<Drawer <Drawer
size={size} size={size}
......
import { Dropdown, type DropdownProps } from 'antd'; import { Dropdown, type DropdownProps } from 'antd';
export type UDropdownProps = DropdownProps; export type VDropdownProps = DropdownProps;
/** /**
* 项目统一下拉菜单。 * 项目统一下拉菜单。
* 触发方式、placement 一律沿用 antd 默认,不在这一层改行为 —— 封装只为收口引用入口, * 触发方式、placement 一律沿用 antd 默认,不在这一层改行为 —— 封装只为收口引用入口,
* 让「能不能从 antd 直引」这条门禁在子应用里可以强制生效。 * 让「能不能从 antd 直引」这条门禁在子应用里可以强制生效。
*/ */
export function UDropdown(props: UDropdownProps) { export function VDropdown(props: VDropdownProps) {
return <Dropdown {...props} />; return <Dropdown {...props} />;
} }
import { Empty, type EmptyProps } from 'antd'; import { Empty, type EmptyProps } from 'antd';
export type UEmptyProps = EmptyProps; export type VEmptyProps = EmptyProps;
/** /**
* 项目统一空态。 * 项目统一空态。
...@@ -12,6 +12,6 @@ export type UEmptyProps = EmptyProps; ...@@ -12,6 +12,6 @@ export type UEmptyProps = EmptyProps;
* 本组件是那份统一入口;空态撑满表体的行为在 Table 的 locale 里注入,见 ui.css 的 * 本组件是那份统一入口;空态撑满表体的行为在 Table 的 locale 里注入,见 ui.css 的
* .venus-table-fill 一节。 * .venus-table-fill 一节。
*/ */
export function UEmpty({ image = Empty.PRESENTED_IMAGE_SIMPLE, ...rest }: UEmptyProps) { export function VEmpty({ image = Empty.PRESENTED_IMAGE_SIMPLE, ...rest }: VEmptyProps) {
return <Empty image={image} {...rest} />; return <Empty image={image} {...rest} />;
} }
...@@ -34,7 +34,7 @@ export function FillTable<T extends object = Record<string, unknown>>(props: Tab ...@@ -34,7 +34,7 @@ export function FillTable<T extends object = Record<string, unknown>>(props: Tab
<Table <Table
key={`venus-fill-${remeasureEpoch}`} key={`venus-fill-${remeasureEpoch}`}
{...props} {...props}
// 与 UTable 共用同一个注入点,图片单元格能力在底层表格统一收口。 // 与 VTable 共用同一个注入点,图片单元格能力在底层表格统一收口。
columns={withImageCell(props.columns)} columns={withImageCell(props.columns)}
loading={resolveTableLoading(props.loading)} loading={resolveTableLoading(props.loading)}
rootClassName="venus-table" rootClassName="venus-table"
......
...@@ -6,7 +6,7 @@ import type { FC } from 'react'; ...@@ -6,7 +6,7 @@ import type { FC } from 'react';
* 注:antd 6 的 Form 为泛型组件,JSX 直接透传时类型较严格,此处将底层实现显式标注为 FC<FormProps>。 */ * 注:antd 6 的 Form 为泛型组件,JSX 直接透传时类型较严格,此处将底层实现显式标注为 FC<FormProps>。 */
const AntForm = Form as unknown as FC<FormProps>; const AntForm = Form as unknown as FC<FormProps>;
export const UForm = Object.assign( export const VForm = Object.assign(
(props: FormProps) => <AntForm {...props} layout={props.layout ?? 'vertical'} />, (props: FormProps) => <AntForm {...props} layout={props.layout ?? 'vertical'} />,
{ {
Item: Form.Item, Item: Form.Item,
...@@ -16,6 +16,6 @@ export const UForm = Object.assign( ...@@ -16,6 +16,6 @@ export const UForm = Object.assign(
}, },
); );
export const UFormItem = Form.Item; export const VFormItem = Form.Item;
export default UForm; export default VForm;
import { Image, type ImageProps } from 'antd'; import { Image, type ImageProps } from 'antd';
export type UImageProps = ImageProps; export type VImageProps = ImageProps;
/** /**
* 项目图片组件:antd Image 的 U* 出口。 * 项目图片组件:antd Image 的 V* 出口。
* *
* 默认开启点击预览大图(antd 原生 preview 带缩放/旋转/翻页), * 默认开启点击预览大图(antd 原生 preview 带缩放/旋转/翻页),
* 对齐源系统列表缩略图点击弹 image-viewer 的行为。 * 对齐源系统列表缩略图点击弹 image-viewer 的行为。
...@@ -13,6 +13,6 @@ export type UImageProps = ImageProps; ...@@ -13,6 +13,6 @@ export type UImageProps = ImageProps;
* antd 自带 `.ant-image-img { width:100%; height:auto }` 与业务 class 同特异性, * antd 自带 `.ant-image-img { width:100%; height:auto }` 与业务 class 同特异性,
* 故 object-fit 走 styles.image(inline)确保覆盖,不依赖 CSS 注入顺序。 * 故 object-fit 走 styles.image(inline)确保覆盖,不依赖 CSS 注入顺序。
*/ */
export function UImage({ preview = true, ...rest }: UImageProps) { export function VImage({ preview = true, ...rest }: VImageProps) {
return <Image preview={preview} {...rest} />; return <Image preview={preview} {...rest} />;
} }
import { Input, type InputProps, type InputRef } from 'antd'; import { Input, type InputProps, type InputRef } from 'antd';
import { forwardRef } from 'react'; import { forwardRef } from 'react';
export type UInputProps = InputProps; export type VInputProps = InputProps;
/** 项目统一输入框,默认开启 allowClear。 */ /** 项目统一输入框,默认开启 allowClear。 */
const UInputBase = forwardRef<InputRef, UInputProps>(({ allowClear = true, ...rest }, ref) => ( const VInputBase = forwardRef<InputRef, VInputProps>(({ allowClear = true, ...rest }, ref) => (
<Input ref={ref} allowClear={allowClear} {...rest} /> <Input ref={ref} allowClear={allowClear} {...rest} />
)); ));
UInputBase.displayName = 'UInput'; VInputBase.displayName = 'VInput';
/** 复合形态均沿用 antd 同名子组件;Password/TextArea/Search 默认不开 allowClear。 */ /** 复合形态均沿用 antd 同名子组件;Password/TextArea/Search 默认不开 allowClear。 */
export const UInput = Object.assign(UInputBase, { export const VInput = Object.assign(VInputBase, {
Password: Input.Password, Password: Input.Password,
TextArea: Input.TextArea, TextArea: Input.TextArea,
Search: Input.Search, Search: Input.Search,
}); });
export default UInput; export default VInput;
import { List } from 'antd'; import { List } from 'antd';
/** 项目统一列表,透传 antd List。 */ /** 项目统一列表,透传 antd List。 */
export const UList = List; export const VList = List;
export default UList; export default VList;
...@@ -3,9 +3,9 @@ import { Modal, type ModalProps } from 'antd'; ...@@ -3,9 +3,9 @@ import { Modal, type ModalProps } from 'antd';
/** /**
* 项目统一弹窗。约定默认居中、关闭时销毁内容、确认按钮为主色。 * 项目统一弹窗。约定默认居中、关闭时销毁内容、确认按钮为主色。
* 取消按钮一律普通按钮(default),不随调用方默认样式漂移; * 取消按钮一律普通按钮(default),不随调用方默认样式漂移;
* 若需 Modal.confirm 等静态方法,后续可在此封装 UModal.confirm 包装器。 * 若需 Modal.confirm 等静态方法,后续可在此封装 VModal.confirm 包装器。
*/ */
export function UModal(props: ModalProps) { export function VModal(props: ModalProps) {
const { const {
centered = true, centered = true,
destroyOnClose, destroyOnClose,
......
export type UPageTransitionDirection = 'forward' | 'back'; export type VPageTransitionDirection = 'forward' | 'back';
/** /**
* 按路由深浅判断方向:层级变深=进入详情,层级变浅=返回。 * 按路由深浅判断方向:层级变深=进入详情,层级变浅=返回。
* 同级切换(leads → assessment)按 forward 处理,保持一致的轻微右进。 * 同级切换(leads → assessment)按 forward 处理,保持一致的轻微右进。
*/ */
export function pageDirection(previous: string, next: string): UPageTransitionDirection { export function pageDirection(previous: string, next: string): VPageTransitionDirection {
const depth = (path: string) => path.split('/').filter(Boolean).length; const depth = (path: string) => path.split('/').filter(Boolean).length;
return depth(next) < depth(previous) ? 'back' : 'forward'; return depth(next) < depth(previous) ? 'back' : 'forward';
} }
import type { ReactNode } from 'react'; import type { ReactNode } from 'react';
import type { UPageTransitionDirection } from './direction'; import type { VPageTransitionDirection } from './direction';
export interface UPageTransitionProps { export interface VPageTransitionProps {
/** 页面标识:变化即换掉内容并重新进场(如 users → users/1)。 */ /** 页面标识:变化即换掉内容并重新进场(如 users → users/1)。 */
pageKey: string; pageKey: string;
/** 进场方向:由列表进入详情为 forward,从详情返回列表为 back。 */ /** 进场方向:由列表进入详情为 forward,从详情返回列表为 back。 */
direction?: UPageTransitionDirection; direction?: VPageTransitionDirection;
children: ReactNode; children: ReactNode;
} }
...@@ -18,11 +18,11 @@ export interface UPageTransitionProps { ...@@ -18,11 +18,11 @@ export interface UPageTransitionProps {
* 放在 @venus/ui 而不是主壳:子应用跑在 wujie 的 shadowRoot 内,主壳样式穿不进去; * 放在 @venus/ui 而不是主壳:子应用跑在 wujie 的 shadowRoot 内,主壳样式穿不进去;
* 而 subPath 变化时主壳的 <Outlet> 不重挂载,动效必须在子应用自己的 render 链上。 * 而 subPath 变化时主壳的 <Outlet> 不重挂载,动效必须在子应用自己的 render 链上。
*/ */
export function UPageTransition({ export function VPageTransition({
pageKey, pageKey,
direction = 'forward', direction = 'forward',
children, children,
}: UPageTransitionProps) { }: VPageTransitionProps) {
return ( return (
<div key={pageKey} className={`venus-page-transition venus-page-transition--${direction}`}> <div key={pageKey} className={`venus-page-transition venus-page-transition--${direction}`}>
{/* 位移放在内层:外层只裁横向,避免 6px 横移临时顶出父容器的横向滚动条。 */} {/* 位移放在内层:外层只裁横向,避免 6px 横移临时顶出父容器的横向滚动条。 */}
......
import { Popover } from 'antd'; import { Popover } from 'antd';
/** 项目统一悬浮卡,透传 antd Popover。可交互内容(按钮、输入)用它,不用 Tooltip。 */ /** 项目统一悬浮卡,透传 antd Popover。可交互内容(按钮、输入)用它,不用 Tooltip。 */
export const UPopover = Popover; export const VPopover = Popover;
export default UPopover; export default VPopover;
import { Radio, type RadioGroupProps, type RadioProps } from 'antd'; import { Radio, type RadioGroupProps, type RadioProps } from 'antd';
export type URadioProps = RadioProps; export type VRadioProps = RadioProps;
export type URadioGroupProps = RadioGroupProps; export type VRadioGroupProps = RadioGroupProps;
export const URadio = Object.assign((props: URadioProps) => <Radio {...props} />, { export const VRadio = Object.assign((props: VRadioProps) => <Radio {...props} />, {
Group: Radio.Group, Group: Radio.Group,
}); });
import { Result } from 'antd'; import { Result } from 'antd';
/** 项目统一结果页,透传 antd Result。 */ /** 项目统一结果页,透传 antd Result。 */
export const UResult = Result; export const VResult = Result;
export default UResult; export default VResult;
import { Select, type SelectProps } from 'antd'; import { Select, type SelectProps } from 'antd';
export type USelectProps = SelectProps; export type VSelectProps = SelectProps;
/** /**
* 项目统一下拉选择,默认开启 allowClear。 * 项目统一下拉选择,默认开启 allowClear。
* 当前不转发 ref 以规避各 antd 大版本 ref 类型差异;如需 ref 再按需补充。 * 当前不转发 ref 以规避各 antd 大版本 ref 类型差异;如需 ref 再按需补充。
*/ */
export function USelect(props: USelectProps) { export function VSelect(props: VSelectProps) {
const { allowClear = true, ...rest } = props; const { allowClear = true, ...rest } = props;
return <Select allowClear={allowClear} {...rest} />; return <Select allowClear={allowClear} {...rest} />;
} }
import { Steps, type StepsProps } from 'antd'; import { Steps, type StepsProps } from 'antd';
export type UStepsProps = StepsProps; export type VStepsProps = StepsProps;
/** /**
* 项目统一步骤条(模板导入的四步流程用)。 * 项目统一步骤条(模板导入的四步流程用)。
* 尺寸与字号由 themeConfig 的 Steps token 下发,这里只作统一命名入口。 * 尺寸与字号由 themeConfig 的 Steps token 下发,这里只作统一命名入口。
*/ */
export function USteps(props: UStepsProps) { export function VSteps(props: VStepsProps) {
return <Steps {...props} />; return <Steps {...props} />;
} }
import { Switch, type SwitchProps } from 'antd'; import { Switch, type SwitchProps } from 'antd';
export type USwitchProps = SwitchProps; export type VSwitchProps = SwitchProps;
export const USwitch = (props: USwitchProps) => <Switch {...props} />; export const VSwitch = (props: VSwitchProps) => <Switch {...props} />;
import type { ReactNode } from 'react'; import type { ReactNode } from 'react';
import type { ColumnsType } from 'antd/es/table'; import type { ColumnsType } from 'antd/es/table';
import { UImage } from '../Image'; import { VImage } from '../Image';
/** 常见图片扩展名:去 query/hash 后按路径结尾判断。 */ /** 常见图片扩展名:去 query/hash 后按路径结尾判断。 */
const IMAGE_EXT = /\.(jpe?g|png|gif|bmp|webp|svg|avif|ico|tiff?|heic|heif)$/i; const IMAGE_EXT = /\.(jpe?g|png|gif|bmp|webp|svg|avif|ico|tiff?|heic|heif)$/i;
...@@ -34,7 +34,7 @@ const THUMB_HEIGHT = 48; ...@@ -34,7 +34,7 @@ const THUMB_HEIGHT = 48;
* 统一渲染成可点击查看大图的 cover 缩略图,消费方无需各自实现。 * 统一渲染成可点击查看大图的 cover 缩略图,消费方无需各自实现。
* *
* 判断基于 render 的原始 value 参数,因此可安全叠加在 DataTable 的省略包装 * 判断基于 render 的原始 value 参数,因此可安全叠加在 DataTable 的省略包装
* (withLineLimit)之上:图片列在这里直接返回 UImage、不会走进 EllipsisText; * (withLineLimit)之上:图片列在这里直接返回 VImage、不会走进 EllipsisText;
* 非图片列调用原 render,行为与未包装完全一致。递归处理表头分组 children。 * 非图片列调用原 render,行为与未包装完全一致。递归处理表头分组 children。
*/ */
export function withImageCell<T>(columns: ColumnsType<T> | undefined): ColumnsType<T> | undefined { export function withImageCell<T>(columns: ColumnsType<T> | undefined): ColumnsType<T> | undefined {
...@@ -52,7 +52,7 @@ export function withImageCell<T>(columns: ColumnsType<T> | undefined): ColumnsTy ...@@ -52,7 +52,7 @@ export function withImageCell<T>(columns: ColumnsType<T> | undefined): ColumnsTy
render: (value: unknown, record: T, index: number) => { render: (value: unknown, record: T, index: number) => {
if (isImageUrl(value)) { if (isImageUrl(value)) {
return ( return (
<UImage <VImage
src={value} src={value}
width={THUMB_WIDTH} width={THUMB_WIDTH}
height={THUMB_HEIGHT} height={THUMB_HEIGHT}
......
...@@ -15,7 +15,7 @@ import { withImageCell } from './imageCell'; ...@@ -15,7 +15,7 @@ import { withImageCell } from './imageCell';
* *
* loading:统一交给 resolveTableLoading 注入品牌指示器,页面仍只传 boolean。 * loading:统一交给 resolveTableLoading 注入品牌指示器,页面仍只传 boolean。
*/ */
export function UTable<T>(props: TableProps<T>) { export function VTable<T>(props: TableProps<T>) {
const { size = 'middle', rootClassName, loading, ...rest } = props; const { size = 'middle', rootClassName, loading, ...rest } = props;
const remeasureEpoch = useScrollbarRemeasure(true); const remeasureEpoch = useScrollbarRemeasure(true);
return ( return (
...@@ -26,7 +26,7 @@ export function UTable<T>(props: TableProps<T>) { ...@@ -26,7 +26,7 @@ export function UTable<T>(props: TableProps<T>) {
loading={resolveTableLoading(loading)} loading={resolveTableLoading(loading)}
{...rest} {...rest}
// 图片单元格能力收口在表格底层:原始值是图片链接的列自动渲染成可点大图的 // 图片单元格能力收口在表格底层:原始值是图片链接的列自动渲染成可点大图的
// cover 缩略图,所有消费方(含裸用 UTable 的页面)无需各自实现。 // cover 缩略图,所有消费方(含裸用 VTable 的页面)无需各自实现。
columns={withImageCell(rest.columns)} columns={withImageCell(rest.columns)}
/> />
); );
......
...@@ -6,7 +6,7 @@ import { TableLoader } from '../TableLoader'; ...@@ -6,7 +6,7 @@ import { TableLoader } from '../TableLoader';
* *
* antd Table 的 loading 支持 boolean | SpinProps,页面一直只传 boolean(19 个列表页 * antd Table 的 loading 支持 boolean | SpinProps,页面一直只传 boolean(19 个列表页
* 全是 `loading={query.isPending || query.isFetching}`),于是转圈图标由 antd 默认下发。 * 全是 `loading={query.isPending || query.isFetching}`),于是转圈图标由 antd 默认下发。
* UTable / FillTable 在这里把 boolean 规范化成带品牌 indicator 的 SpinProps, * VTable / FillTable 在这里把 boolean 规范化成带品牌 indicator 的 SpinProps,
* 页面一行都不用改;已经传对象且自带 indicator / spinning 的调用方保持原样。 * 页面一行都不用改;已经传对象且自带 indicator / spinning 的调用方保持原样。
* *
* 只作用于表格:按钮 loading 走 antd Button 自己的图标,抽屉/卡片里的 Spin 不受影响。 * 只作用于表格:按钮 loading 走 antd Button 自己的图标,抽屉/卡片里的 Spin 不受影响。
......
...@@ -10,7 +10,7 @@ import type { CSSProperties } from 'react'; ...@@ -10,7 +10,7 @@ import type { CSSProperties } from 'react';
* - 3 行左侧的青绿节点沿用 venus-brand-node 的 1.8s 错峰呼吸(0 / 0.3 / 0.6s), * - 3 行左侧的青绿节点沿用 venus-brand-node 的 1.8s 错峰呼吸(0 / 0.3 / 0.6s),
* 行占位条另用 2.2s 提亮,两个周期互质,避免整枚图机械同步摆动。 * 行占位条另用 2.2s 提亮,两个周期互质,避免整枚图机械同步摆动。
* *
* 由 UTable / FillTable 的 resolveTableLoading 统一注入 antd Spin 的 indicator, * 由 VTable / FillTable 的 resolveTableLoading 统一注入 antd Spin 的 indicator,
* 页面只传 boolean,不需要知道这个组件存在。动效与色值全部由 ui.css 下发。 * 页面只传 boolean,不需要知道这个组件存在。动效与色值全部由 ui.css 下发。
* 组件无状态、无随机数、无定时器,纯 SVG + CSS,尊重 prefers-reduced-motion。 * 组件无状态、无随机数、无定时器,纯 SVG + CSS,尊重 prefers-reduced-motion。
*/ */
......
/* eslint-disable react-refresh/only-export-components -- tabLabel 是与 UTabs 配套的无状态渲染函数,拆出组件目录会破坏 U* 单一出口约定 */ /* eslint-disable react-refresh/only-export-components -- tabLabel 是与 VTabs 配套的无状态渲染函数,拆出组件目录会破坏 V* 单一出口约定 */
import type { ElementRef, ReactNode } from 'react'; import type { ElementRef, ReactNode } from 'react';
import { forwardRef } from 'react'; import { forwardRef } from 'react';
import { Tabs } from 'antd'; import { Tabs } from 'antd';
import type { TabsProps } from 'antd'; import type { TabsProps } from 'antd';
export type UTabsSize = 'md' | 'lg'; export type VTabsSize = 'md' | 'lg';
// antd Tabs 自带 size(SizeType),语义是控件尺寸,与我们「页面级 / 抽屉放大版」不同, // antd Tabs 自带 size(SizeType),语义是控件尺寸,与我们「页面级 / 抽屉放大版」不同,
// 这里剔除后自定义 size,避免两套 size 含义打架。 // 这里剔除后自定义 size,避免两套 size 含义打架。
export interface UTabsProps extends Omit<TabsProps, 'size'> { export interface VTabsProps extends Omit<TabsProps, 'size'> {
/** 尺寸:md 页面级(默认,14px);lg 抽屉/详情内的放大版(16px)。 */ /** 尺寸:md 页面级(默认,14px);lg 抽屉/详情内的放大版(16px)。 */
size?: UTabsSize; size?: VTabsSize;
} }
/** /**
...@@ -21,16 +21,16 @@ export interface UTabsProps extends Omit<TabsProps, 'size'> { ...@@ -21,16 +21,16 @@ export interface UTabsProps extends Omit<TabsProps, 'size'> {
* *
* 计角标请用配套 tabLabel(),替代各页面手搓的 venus-num / approval-detail-tab-count。 * 计角标请用配套 tabLabel(),替代各页面手搓的 venus-num / approval-detail-tab-count。
*/ */
export const UTabs = forwardRef<ElementRef<typeof Tabs>, UTabsProps>( export const VTabs = forwardRef<ElementRef<typeof Tabs>, VTabsProps>(
({ className, size = 'md', ...rest }, ref) => { ({ className, size = 'md', ...rest }, ref) => {
const base = size === 'lg' ? 'venus-page__tabs venus-page__tabs--lg' : 'venus-page__tabs'; const base = size === 'lg' ? 'venus-page__tabs venus-page__tabs--lg' : 'venus-page__tabs';
return <Tabs ref={ref} {...rest} className={className ? `${base} ${className}` : base} />; return <Tabs ref={ref} {...rest} className={className ? `${base} ${className}` : base} />;
}, },
); );
UTabs.displayName = 'UTabs'; VTabs.displayName = 'VTabs';
export default UTabs; export default VTabs;
export interface TabLabelOptions { export interface TabLabelOptions {
/** 角标数字/文案;传 null / undefined / '' 则不渲染角标。 */ /** 角标数字/文案;传 null / undefined / '' 则不渲染角标。 */
......
import { Tag, type TagProps } from 'antd'; import { Tag, type TagProps } from 'antd';
import type { ReactNode } from 'react'; import type { ReactNode } from 'react';
export type UTagProps = TagProps; export type VTagProps = TagProps;
/** /**
* 把状态标签里的文字圆点「● 启用」收成 CSS 圆点(见 ui.css 的 .venus-tag--dot)。 * 把状态标签里的文字圆点「● 启用」收成 CSS 圆点(见 ui.css 的 .venus-tag--dot)。
...@@ -25,7 +25,7 @@ function splitDot(children: ReactNode): ReactNode | null { ...@@ -25,7 +25,7 @@ function splitDot(children: ReactNode): ReactNode | null {
* 柔和填充 + 4px 圆角既分得清层级,又不抢正文。需要强分隔时显式传 bordered。 * 柔和填充 + 4px 圆角既分得清层级,又不抢正文。需要强分隔时显式传 bordered。
* 传「● 状态」时圆点自动改由 CSS 绘制,基线不随字体漂移。 * 传「● 状态」时圆点自动改由 CSS 绘制,基线不随字体漂移。
*/ */
export function UTag({ bordered = false, className, children, ...rest }: UTagProps) { export function VTag({ bordered = false, className, children, ...rest }: VTagProps) {
const dotless = splitDot(children); const dotless = splitDot(children);
const hasDot = dotless !== null; const hasDot = dotless !== null;
return ( return (
......
import { Timeline, type TimelineProps } from 'antd'; import { Timeline, type TimelineProps } from 'antd';
export type UTimelineProps = TimelineProps; export type VTimelineProps = TimelineProps;
/** /**
* 项目统一时间轴(提现审批流转用)。 * 项目统一时间轴(提现审批流转用)。
* 圆点配色取 themeConfig 的语义色,不在页面里为「已完成 / 当前」各写一个 hex。 * 圆点配色取 themeConfig 的语义色,不在页面里为「已完成 / 当前」各写一个 hex。
*/ */
export function UTimeline(props: UTimelineProps) { export function VTimeline(props: VTimelineProps) {
return <Timeline {...props} />; return <Timeline {...props} />;
} }
import { Tooltip } from 'antd'; import { Tooltip } from 'antd';
/** 项目统一文字提示,透传 antd Tooltip。 */ /** 项目统一文字提示,透传 antd Tooltip。 */
export const UTooltip = Tooltip; export const VTooltip = Tooltip;
export default UTooltip; export default VTooltip;
import { Typography } from 'antd'; import { Typography } from 'antd';
/** 项目统一排版组件,透传 antd Typography 全部能力与子组件。 */ /** 项目统一排版组件,透传 antd Typography 全部能力与子组件。 */
export const UTypography = Object.assign(Typography, { export const VTypography = Object.assign(Typography, {
Title: Typography.Title, Title: Typography.Title,
Text: Typography.Text, Text: Typography.Text,
Paragraph: Typography.Paragraph, Paragraph: Typography.Paragraph,
Link: Typography.Link, Link: Typography.Link,
}); });
export const UTitle = Typography.Title; export const VTitle = Typography.Title;
export const UText = Typography.Text; export const VText = Typography.Text;
export const UParagraph = Typography.Paragraph; export const VParagraph = Typography.Paragraph;
export default UTypography; export default VTypography;
import { Upload } from 'antd'; import { Upload } from 'antd';
/** 项目上传。统一命名入口,UUpload.Dragger 可直接使用。 */ /** 项目上传。统一命名入口,VUpload.Dragger 可直接使用。 */
export const UUpload = Upload; export const VUpload = Upload;
// @venus/ui —— VENUS 应用基座自定义组件库(基于 antd,前缀 U*) // @venus/ui —— VENUS 应用基座自定义组件库(基于 antd,前缀 V*)
// 模块化管理:每个组件一个文件夹,位于 ./components/<Name>/index.tsx, // 模块化管理:每个组件一个文件夹,位于 ./components/<Name>/index.tsx,
// 本文件为统一导出口,外部消费方式不变: // 本文件为统一导出口,外部消费方式不变:
// import { UButton, UTable } from '@venus/ui'; // import { VButton, VTable } from '@venus/ui';
// //
// 子应用禁止从 antd 直引组件(eslint no-restricted-imports 门禁)。 // 子应用禁止从 antd 直引组件(eslint no-restricted-imports 门禁)。
// 缺什么就在这里补一个 U*,再去页面里消费 —— 不要在页面里绕过去。 // 缺什么就在这里补一个 V*,再去页面里消费 —— 不要在页面里绕过去。
// 样式层:精致度与布局的公共规则。CSS 会随各应用打包进自己的 style-*.css, // 样式层:精致度与布局的公共规则。CSS 会随各应用打包进自己的 style-*.css,
// 在 wujie 的 shadowRoot 内生效;主壳文档样式表穿不进 shadow DOM,别把规则写回 shell。 // 在 wujie 的 shadowRoot 内生效;主壳文档样式表穿不进 shadow DOM,别把规则写回 shell。
...@@ -16,74 +16,74 @@ import './styles/injectThinScrollbar'; ...@@ -16,74 +16,74 @@ import './styles/injectThinScrollbar';
import './styles/ui.css'; import './styles/ui.css';
import './styles/feedback.css'; import './styles/feedback.css';
export { UApp } from './components/App'; export { VApp } from './components/App';
export type { UAppProps } from './components/App'; export type { VAppProps } from './components/App';
export { useUApp, useUMessage } from './components/App/hooks'; export { useVApp, useVMessage } from './components/App/hooks';
export { installGlobalUnhandledRejectionHandler } from './components/App/globalError'; export { installGlobalUnhandledRejectionHandler } from './components/App/globalError';
export { UButton } from './components/Button'; export { VButton } from './components/Button';
export type { UButtonProps } from './components/Button'; export type { VButtonProps } from './components/Button';
// 表格工具栏「导出」动作的统一图标。DataTable 检测 tone='export' 自动前置, // 表格工具栏「导出」动作的统一图标。DataTable 检测 tone='export' 自动前置,
// 各列表页不再各自 import 图标,保证全站导出按钮外观一致。 // 各列表页不再各自 import 图标,保证全站导出按钮外观一致。
export { DownloadOutlined as UExportIcon } from '@ant-design/icons'; export { DownloadOutlined as VExportIcon } from '@ant-design/icons';
export { UInput } from './components/Input'; export { VInput } from './components/Input';
export type { UInputProps } from './components/Input'; export type { VInputProps } from './components/Input';
export { USelect } from './components/Select'; export { VSelect } from './components/Select';
export type { USelectProps } from './components/Select'; export type { VSelectProps } from './components/Select';
export { UCascader } from './components/Cascader'; export { VCascader } from './components/Cascader';
export type { UCascaderProps } from './components/Cascader'; export type { VCascaderProps } from './components/Cascader';
export { UForm, UFormItem } from './components/Form'; export { VForm, VFormItem } from './components/Form';
export { UTypography, UTitle, UText, UParagraph } from './components/Typography'; export { VTypography, VTitle, VText, VParagraph } from './components/Typography';
export { UCard } from './components/Card'; export { VCard } from './components/Card';
export type { UCardProps } from './components/Card'; export type { VCardProps } from './components/Card';
export { UTag } from './components/Tag'; export { VTag } from './components/Tag';
export type { UTagProps } from './components/Tag'; export type { VTagProps } from './components/Tag';
export { UImage } from './components/Image'; export { VImage } from './components/Image';
export type { UImageProps } from './components/Image'; export type { VImageProps } from './components/Image';
export { UAlert } from './components/Alert'; export { VAlert } from './components/Alert';
export type { UAlertProps } from './components/Alert'; export type { VAlertProps } from './components/Alert';
export { UModal } from './components/Modal'; export { VModal } from './components/Modal';
export { UDrawer } from './components/Drawer'; export { VDrawer } from './components/Drawer';
export type { UDrawerProps } from './components/Drawer'; export type { VDrawerProps } from './components/Drawer';
export { UTable } from './components/Table'; export { VTable } from './components/Table';
export { FillTable } from './components/FillTable'; export { FillTable } from './components/FillTable';
export { TableLoader } from './components/TableLoader'; export { TableLoader } from './components/TableLoader';
export type { TableLoaderProps } from './components/TableLoader'; export type { TableLoaderProps } from './components/TableLoader';
export { UUpload } from './components/Upload'; export { VUpload } from './components/Upload';
export { Skeleton } from './components/Skeleton'; export { Skeleton } from './components/Skeleton';
export type { SkeletonVariant } from './components/Skeleton'; export type { SkeletonVariant } from './components/Skeleton';
export { UTabs, tabLabel } from './components/Tabs'; export { VTabs, tabLabel } from './components/Tabs';
export type { UTabsProps, UTabsSize, TabLabelOptions } from './components/Tabs'; export type { VTabsProps, VTabsSize, TabLabelOptions } from './components/Tabs';
export { UCheckbox } from './components/Checkbox'; export { VCheckbox } from './components/Checkbox';
export { UList } from './components/List'; export { VList } from './components/List';
export { UTooltip } from './components/Tooltip'; export { VTooltip } from './components/Tooltip';
export { UPopover } from './components/Popover'; export { VPopover } from './components/Popover';
export { UResult } from './components/Result'; export { VResult } from './components/Result';
export { UEmpty } from './components/Empty'; export { VEmpty } from './components/Empty';
export type { UEmptyProps } from './components/Empty'; export type { VEmptyProps } from './components/Empty';
export { UPageTransition } from './components/PageTransition'; export { VPageTransition } from './components/PageTransition';
export type { UPageTransitionProps } from './components/PageTransition'; export type { VPageTransitionProps } from './components/PageTransition';
export { pageDirection } from './components/PageTransition/direction'; export { pageDirection } from './components/PageTransition/direction';
export type { UPageTransitionDirection } from './components/PageTransition/direction'; export type { VPageTransitionDirection } from './components/PageTransition/direction';
export { USteps } from './components/Steps'; export { VSteps } from './components/Steps';
export type { UStepsProps } from './components/Steps'; export type { VStepsProps } from './components/Steps';
export { UTimeline } from './components/Timeline'; export { VTimeline } from './components/Timeline';
export type { UTimelineProps } from './components/Timeline'; export type { VTimelineProps } from './components/Timeline';
export { UDropdown } from './components/Dropdown'; export { VDropdown } from './components/Dropdown';
export type { UDropdownProps } from './components/Dropdown'; export type { VDropdownProps } from './components/Dropdown';
export { UDatePicker } from './components/DatePicker'; export { VDatePicker } from './components/DatePicker';
export type { UDatePickerProps } from './components/DatePicker'; export type { VDatePickerProps } from './components/DatePicker';
export { URadio } from './components/Radio'; export { VRadio } from './components/Radio';
export type { URadioProps, URadioGroupProps } from './components/Radio'; export type { VRadioProps, VRadioGroupProps } from './components/Radio';
export { USwitch } from './components/Switch'; export { VSwitch } from './components/Switch';
export type { USwitchProps } from './components/Switch'; export type { VSwitchProps } from './components/Switch';
export { UDescriptions } from './components/Descriptions'; export { VDescriptions } from './components/Descriptions';
export type { UDescriptionsProps } from './components/Descriptions'; export type { VDescriptionsProps } from './components/Descriptions';
...@@ -292,7 +292,7 @@ pnpm release:preview # 本地预览 dist/(行为对 ...@@ -292,7 +292,7 @@ pnpm release:preview # 本地预览 dist/(行为对
api-core/ 请求签名框架(web-host / ROP / GSC 策略) api-core/ 请求签名框架(web-host / ROP / GSC 策略)
download-center/ 系统级下载网关(引擎 / 状态机 / 落地) download-center/ 系统级下载网关(引擎 / 状态机 / 落地)
design-tokens/ 主题令牌(palette.ts + tokens.css 双真源) design-tokens/ 主题令牌(palette.ts + tokens.css 双真源)
ui/ biz/ U* 组件库 / 通用业务组件层 ui/ biz/ V* 组件库 / 通用业务组件层
vite-config/ alias 单一真源 + shell/子应用两套 Vite 工厂 vite-config/ alias 单一真源 + shell/子应用两套 Vite 工厂
typescript-config/ eslint-config/ typescript-config/ eslint-config/
scripts/ dev / 边界闸门 / 令牌对账 / 结构对账 / release/ 发布引擎(全量·增量·回滚·自检) scripts/ dev / 边界闸门 / 令牌对账 / 结构对账 / release/ 发布引擎(全量·增量·回滚·自检)
......
...@@ -4,7 +4,7 @@ import { SubAppProvider, readInitialPage, shortName, subappBus } from '@venus/pl ...@@ -4,7 +4,7 @@ import { SubAppProvider, readInitialPage, shortName, subappBus } from '@venus/pl
import RoleManage from './pages/RoleManage'; import RoleManage from './pages/RoleManage';
import AccountManage from './pages/AccountManage'; import AccountManage from './pages/AccountManage';
import { UEmpty, UPageTransition } from '@venus/ui'; import { VEmpty, VPageTransition } from '@venus/ui';
/** /**
* 页名 -> 页面组件。 * 页名 -> 页面组件。
* 页名来自后端菜单 route 的末段:/system/role -> role、/system/user -> user。 * 页名来自后端菜单 route 的末段:/system/role -> role、/system/user -> user。
...@@ -19,7 +19,7 @@ const PAGES = { ...@@ -19,7 +19,7 @@ const PAGES = {
function renderPage(page: string) { function renderPage(page: string) {
const Page = PAGES[page as keyof typeof PAGES]; const Page = PAGES[page as keyof typeof PAGES];
return Page ? <Page /> : <UEmpty description={`没有名为「${page}」的页面`} />; return Page ? <Page /> : <VEmpty description={`没有名为「${page}」的页面`} />;
} }
function SystemApp() { function SystemApp() {
...@@ -51,7 +51,7 @@ function SystemApp() { ...@@ -51,7 +51,7 @@ function SystemApp() {
}; };
}, []); }, []);
return <UPageTransition pageKey={page}>{renderPage(page)}</UPageTransition>; return <VPageTransition pageKey={page}>{renderPage(page)}</VPageTransition>;
} }
export function App() { export function App() {
......
import { useEffect } from 'react'; import { useEffect } from 'react';
import { useMutation } from '@tanstack/react-query'; import { useMutation } from '@tanstack/react-query';
import { UButton, UDrawer, UForm, useUMessage } from '@venus/ui'; import { VButton, VDrawer, VForm, useVMessage } from '@venus/ui';
import { user, type OrgNode, type RoleOption, type UserPageItem } from '@/api'; import { user, type OrgNode, type RoleOption, type UserPageItem } from '@/api';
import { CombiForm, type FieldSchema } from '@/components'; import { CombiForm, type FieldSchema } from '@/components';
import { dataScopeOptions } from '@/constants/dataScope'; import { dataScopeOptions } from '@/constants/dataScope';
...@@ -33,9 +33,9 @@ export function AccountFormDrawer({ ...@@ -33,9 +33,9 @@ export function AccountFormDrawer({
onClose, onClose,
onSuccess, onSuccess,
}: AccountFormDrawerProps) { }: AccountFormDrawerProps) {
const message = useUMessage(); const message = useVMessage();
const [form] = UForm.useForm<AccountFormValues>(); const [form] = VForm.useForm<AccountFormValues>();
const selectedRoleIds = UForm.useWatch('roleIds', form) ?? []; const selectedRoleIds = VForm.useWatch('roleIds', form) ?? [];
const isEdit = Boolean(account); const isEdit = Boolean(account);
const saveMutation = useMutation({ const saveMutation = useMutation({
mutationFn: (values: AccountFormValues) => { mutationFn: (values: AccountFormValues) => {
...@@ -150,17 +150,17 @@ export function AccountFormDrawer({ ...@@ -150,17 +150,17 @@ export function AccountFormDrawer({
]; ];
return ( return (
<UDrawer <VDrawer
open={open} open={open}
title={isEdit ? '编辑账号' : '新增账号'} title={isEdit ? '编辑账号' : '新增账号'}
size={560} size={560}
onClose={onClose} onClose={onClose}
footer={ footer={
<div style={footerStyle}> <div style={footerStyle}>
<UButton type="default" onClick={onClose}>取消</UButton> <VButton type="default" onClick={onClose}>取消</VButton>
<UButton type="primary" loading={saveMutation.isPending} onClick={() => form.submit()}> <VButton type="primary" loading={saveMutation.isPending} onClick={() => form.submit()}>
保存 保存
</UButton> </VButton>
</div> </div>
} }
> >
...@@ -178,7 +178,7 @@ export function AccountFormDrawer({ ...@@ -178,7 +178,7 @@ export function AccountFormDrawer({
return ( return (
<div style={roleListStyle}> <div style={roleListStyle}>
{roleOptions.map((item) => ( {roleOptions.map((item) => (
<UButton <VButton
key={item.roleId} key={item.roleId}
type={selectedRoleIds.includes(item.roleId) ? 'primary' : 'default'} type={selectedRoleIds.includes(item.roleId) ? 'primary' : 'default'}
style={roleOptionStyle} style={roleOptionStyle}
...@@ -190,14 +190,14 @@ export function AccountFormDrawer({ ...@@ -190,14 +190,14 @@ export function AccountFormDrawer({
}} }}
> >
{item.roleName} {item.roleName}
</UButton> </VButton>
))} ))}
</div> </div>
); );
return undefined; return undefined;
}} }}
/> />
</UDrawer> </VDrawer>
); );
} }
......
import { useMemo, useState } from 'react'; import { useMemo, useState } from 'react';
import { useMutation, useQuery } from '@tanstack/react-query'; import { useMutation, useQuery } from '@tanstack/react-query';
import { UCard, UTag, UText, useUMessage } from '@venus/ui'; import { VCard, VTag, VText, useVMessage } from '@venus/ui';
import { import {
DataTable, DataTable,
DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE,
...@@ -40,7 +40,7 @@ function toParams(values: Record<string, unknown>, pagination: SearchPagination) ...@@ -40,7 +40,7 @@ function toParams(values: Record<string, unknown>, pagination: SearchPagination)
} }
export default function AccountManage() { export default function AccountManage() {
const message = useUMessage(); const message = useVMessage();
const [params, setParams] = useState<UserPageParams>({ current: 1, size: DEFAULT_PAGE_SIZE }); const [params, setParams] = useState<UserPageParams>({ current: 1, size: DEFAULT_PAGE_SIZE });
const [queryVersion, setQueryVersion] = useState(0); const [queryVersion, setQueryVersion] = useState(0);
const [accountFormOpen, setAccountFormOpen] = useState(false); const [accountFormOpen, setAccountFormOpen] = useState(false);
...@@ -132,9 +132,9 @@ export default function AccountManage() { ...@@ -132,9 +132,9 @@ export default function AccountManage() {
width: 160, width: 160,
line: 1, line: 1,
render: (value) => ( render: (value) => (
<UText> <VText>
<code className="venus-code">{value}</code> <code className="venus-code">{value}</code>
</UText> </VText>
), ),
}, },
{ title: '姓名', dataIndex: 'name', width: 130, line: 1 }, { title: '姓名', dataIndex: 'name', width: 130, line: 1 },
...@@ -148,9 +148,9 @@ export default function AccountManage() { ...@@ -148,9 +148,9 @@ export default function AccountManage() {
names.length ? ( names.length ? (
<span className="venus-tag-list"> <span className="venus-tag-list">
{names.map((name) => ( {names.map((name) => (
<UTag key={name} color="blue"> <VTag key={name} color="blue">
{name} {name}
</UTag> </VTag>
))} ))}
</span> </span>
) : ( ) : (
...@@ -162,9 +162,9 @@ export default function AccountManage() { ...@@ -162,9 +162,9 @@ export default function AccountManage() {
title: '状态', title: '状态',
width: 90, width: 90,
render: (_, row) => ( render: (_, row) => (
<UTag color={row.status === 1 ? 'green' : 'default'}> <VTag color={row.status === 1 ? 'green' : 'default'}>
{row.status === 1 ? '启用' : '停用'} {row.status === 1 ? '启用' : '停用'}
</UTag> </VTag>
), ),
}, },
{ title: '最后登录', dataIndex: 'lastLoginAt', width: 170 }, { title: '最后登录', dataIndex: 'lastLoginAt', width: 170 },
...@@ -207,7 +207,7 @@ export default function AccountManage() { ...@@ -207,7 +207,7 @@ export default function AccountManage() {
</PermButton> </PermButton>
} }
> >
<UCard className="venus-filter-card" size="small"> <VCard className="venus-filter-card" size="small">
<SearchForm <SearchForm
fields={fields} fields={fields}
initialValues={{ orgId: [''], roleId: '', status: '' }} initialValues={{ orgId: [''], roleId: '', status: '' }}
...@@ -220,8 +220,8 @@ export default function AccountManage() { ...@@ -220,8 +220,8 @@ export default function AccountManage() {
setQueryVersion((version) => version + 1); setQueryVersion((version) => version + 1);
}} }}
/> />
</UCard> </VCard>
<UCard size="small" fill> <VCard size="small" fill>
<DataTable<AccountRow> <DataTable<AccountRow>
rowKey="id" rowKey="id"
fillHeight fillHeight
...@@ -240,7 +240,7 @@ export default function AccountManage() { ...@@ -240,7 +240,7 @@ export default function AccountManage() {
}, },
}} }}
/> />
</UCard> </VCard>
<AccountFormDrawer <AccountFormDrawer
open={accountFormOpen} open={accountFormOpen}
account={editingAccount} account={editingAccount}
......
import { useMemo, useState } from 'react'; import { useMemo, useState } from 'react';
import { CheckOutlined, DownOutlined, MinusOutlined, RightOutlined } from '@ant-design/icons'; import { CheckOutlined, DownOutlined, MinusOutlined, RightOutlined } from '@ant-design/icons';
import { useQuery } from '@tanstack/react-query'; import { useQuery } from '@tanstack/react-query';
import { UAlert, UButton, UDescriptions, UDrawer, UText } from '@venus/ui'; import { VAlert, VButton, VDescriptions, VDrawer, VText } from '@venus/ui';
import { menu, role, type MenuNode } from '@/api'; import { menu, role, type MenuNode } from '@/api';
import { getDataScopeLabel } from '@/constants/dataScope'; import { getDataScopeLabel } from '@/constants/dataScope';
...@@ -29,19 +29,19 @@ export function RoleDetailDrawer({ open, roleId, onClose }: RoleDetailDrawerProp ...@@ -29,19 +29,19 @@ export function RoleDetailDrawer({ open, roleId, onClose }: RoleDetailDrawerProp
const detail = detailQuery.data; const detail = detailQuery.data;
return ( return (
<UDrawer <VDrawer
open={open} open={open}
placement="right" placement="right"
size={760} size={760}
title={detail ? `角色详情 · ${detail.roleName}` : '角色详情'} title={detail ? `角色详情 · ${detail.roleName}` : '角色详情'}
onClose={onClose} onClose={onClose}
footer={ footer={
<UButton type="default" style={{ float: 'right' }} onClick={onClose}> <VButton type="default" style={{ float: 'right' }} onClick={onClose}>
关闭 关闭
</UButton> </VButton>
} }
> >
{error ? <UAlert type="error" showIcon message="角色详情加载失败,请关闭后重试" /> : null} {error ? <VAlert type="error" showIcon message="角色详情加载失败,请关闭后重试" /> : null}
{detail ? ( {detail ? (
<> <>
<div style={summaryStyle}> <div style={summaryStyle}>
...@@ -58,7 +58,7 @@ export function RoleDetailDrawer({ open, roleId, onClose }: RoleDetailDrawerProp ...@@ -58,7 +58,7 @@ export function RoleDetailDrawer({ open, roleId, onClose }: RoleDetailDrawerProp
<span>类型 {detail.isBuiltin === 1 ? '内置' : '自定义'}</span> <span>类型 {detail.isBuiltin === 1 ? '内置' : '自定义'}</span>
</div> </div>
<SectionTitle>角色基本信息</SectionTitle> <SectionTitle>角色基本信息</SectionTitle>
<UDescriptions <VDescriptions
size="small" size="small"
column={1} column={1}
items={[ items={[
...@@ -76,7 +76,7 @@ export function RoleDetailDrawer({ open, roleId, onClose }: RoleDetailDrawerProp ...@@ -76,7 +76,7 @@ export function RoleDetailDrawer({ open, roleId, onClose }: RoleDetailDrawerProp
/> />
<SectionTitle>菜单可见范围(权限矩阵)</SectionTitle> <SectionTitle>菜单可见范围(权限矩阵)</SectionTitle>
<div style={matrixStyle}> <div style={matrixStyle}>
{isLoading ? <UText type="secondary">权限加载中…</UText> : null} {isLoading ? <VText type="secondary">权限加载中…</VText> : null}
{!isLoading ? ( {!isLoading ? (
<PermissionTree <PermissionTree
nodes={menuQuery.data ?? []} nodes={menuQuery.data ?? []}
...@@ -100,7 +100,7 @@ export function RoleDetailDrawer({ open, roleId, onClose }: RoleDetailDrawerProp ...@@ -100,7 +100,7 @@ export function RoleDetailDrawer({ open, roleId, onClose }: RoleDetailDrawerProp
</div> </div>
</> </>
) : null} ) : null}
</UDrawer> </VDrawer>
); );
} }
...@@ -199,7 +199,7 @@ function PermissionTreeNode({ ...@@ -199,7 +199,7 @@ function PermissionTreeNode({
> >
<div style={{ ...treeLabelStyle, paddingLeft: depth * 22 }}> <div style={{ ...treeLabelStyle, paddingLeft: depth * 22 }}>
{hasChildren ? ( {hasChildren ? (
<UButton <VButton
type="text" type="text"
size="small" size="small"
aria-label={`${expanded ? '收起' : '展开'}${node.label}`} aria-label={`${expanded ? '收起' : '展开'}${node.label}`}
...@@ -211,7 +211,7 @@ function PermissionTreeNode({ ...@@ -211,7 +211,7 @@ function PermissionTreeNode({
<span style={treeBranchStyle}>•</span> <span style={treeBranchStyle}>•</span>
)} )}
<PermissionMark state={nodePermissionState(node, grantedIds)} /> <PermissionMark state={nodePermissionState(node, grantedIds)} />
<UText strong={node.nodeType === 1}>{node.label}</UText> <VText strong={node.nodeType === 1}>{node.label}</VText>
</div> </div>
{expanded && buttons.length ? ( {expanded && buttons.length ? (
<div style={{ ...buttonListStyle, marginLeft: (depth + 1) * 22 + 18 }} role="group"> <div style={{ ...buttonListStyle, marginLeft: (depth + 1) * 22 + 18 }} role="group">
......
import { useEffect } from 'react'; import { useEffect } from 'react';
import { useMutation } from '@tanstack/react-query'; import { useMutation } from '@tanstack/react-query';
import { UButton, UDrawer, UForm, useUMessage } from '@venus/ui'; import { VButton, VDrawer, VForm, useVMessage } from '@venus/ui';
import { role, type RolePageItem } from '@/api'; import { role, type RolePageItem } from '@/api';
import { CombiForm, type FieldSchema } from '@/components'; import { CombiForm, type FieldSchema } from '@/components';
import { dataScopeOptions } from '@/constants/dataScope'; import { dataScopeOptions } from '@/constants/dataScope';
...@@ -27,8 +27,8 @@ const statusOptions = [ ...@@ -27,8 +27,8 @@ const statusOptions = [
]; ];
export function RoleFormDrawer({ open, roleItem, onClose, onSuccess }: RoleFormDrawerProps) { export function RoleFormDrawer({ open, roleItem, onClose, onSuccess }: RoleFormDrawerProps) {
const message = useUMessage(); const message = useVMessage();
const [form] = UForm.useForm<RoleFormValues>(); const [form] = VForm.useForm<RoleFormValues>();
const isEdit = Boolean(roleItem); const isEdit = Boolean(roleItem);
const saveMutation = useMutation({ const saveMutation = useMutation({
mutationFn: (values: RoleFormValues) => { mutationFn: (values: RoleFormValues) => {
...@@ -125,17 +125,17 @@ export function RoleFormDrawer({ open, roleItem, onClose, onSuccess }: RoleFormD ...@@ -125,17 +125,17 @@ export function RoleFormDrawer({ open, roleItem, onClose, onSuccess }: RoleFormD
]; ];
return ( return (
<UDrawer <VDrawer
open={open} open={open}
title={isEdit ? '编辑角色' : '新增角色'} title={isEdit ? '编辑角色' : '新增角色'}
size={560} size={560}
onClose={onClose} onClose={onClose}
footer={ footer={
<div style={footerStyle}> <div style={footerStyle}>
<UButton type="default" onClick={onClose}>取消</UButton> <VButton type="default" onClick={onClose}>取消</VButton>
<UButton type="primary" loading={saveMutation.isPending} onClick={() => form.submit()}> <VButton type="primary" loading={saveMutation.isPending} onClick={() => form.submit()}>
保存 保存
</UButton> </VButton>
</div> </div>
} }
> >
...@@ -149,7 +149,7 @@ export function RoleFormDrawer({ open, roleItem, onClose, onSuccess }: RoleFormD ...@@ -149,7 +149,7 @@ export function RoleFormDrawer({ open, roleItem, onClose, onSuccess }: RoleFormD
sectionContentStyle={twoColumnStyle} sectionContentStyle={twoColumnStyle}
renderSectionTitle={(title) => <SectionTitle>{title}</SectionTitle>} renderSectionTitle={(title) => <SectionTitle>{title}</SectionTitle>}
/> />
</UDrawer> </VDrawer>
); );
} }
......
import { useMemo, useState } from 'react'; import { useMemo, useState } from 'react';
import { useMutation, useQuery } from '@tanstack/react-query'; import { useMutation, useQuery } from '@tanstack/react-query';
import { UCard, UTag, UText, useUMessage } from '@venus/ui'; import { VCard, VTag, VText, useVMessage } from '@venus/ui';
import { import {
DataTable, DataTable,
DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE,
...@@ -43,7 +43,7 @@ function createRolePageParams( ...@@ -43,7 +43,7 @@ function createRolePageParams(
} }
export default function RoleManage() { export default function RoleManage() {
const message = useUMessage(); const message = useVMessage();
const [params, setParams] = useState<RolePageParams>({ const [params, setParams] = useState<RolePageParams>({
current: 1, current: 1,
size: DEFAULT_PAGE_SIZE, size: DEFAULT_PAGE_SIZE,
...@@ -111,9 +111,9 @@ export default function RoleManage() { ...@@ -111,9 +111,9 @@ export default function RoleManage() {
width: 220, width: 220,
line: 1, line: 1,
render: (v) => ( render: (v) => (
<UText> <VText>
<code className="venus-code">{v}</code> <code className="venus-code">{v}</code>
</UText> </VText>
), ),
}, },
{ title: '账号数', dataIndex: 'userCount' }, { title: '账号数', dataIndex: 'userCount' },
...@@ -121,14 +121,14 @@ export default function RoleManage() { ...@@ -121,14 +121,14 @@ export default function RoleManage() {
{ {
title: '类型', title: '类型',
dataIndex: 'type', dataIndex: 'type',
render: (v) => <UTag color={v === '内置' ? 'geekblue' : 'default'}>{v}</UTag>, render: (v) => <VTag color={v === '内置' ? 'geekblue' : 'default'}>{v}</VTag>,
}, },
{ {
title: '状态', title: '状态',
render: (_, r) => ( render: (_, r) => (
<UTag color={r.status === 1 ? 'green' : 'default'}> <VTag color={r.status === 1 ? 'green' : 'default'}>
● {r.status === 1 ? '启用' : '停用'} ● {r.status === 1 ? '启用' : '停用'}
</UTag> </VTag>
), ),
}, },
]; ];
...@@ -170,7 +170,7 @@ export default function RoleManage() { ...@@ -170,7 +170,7 @@ export default function RoleManage() {
</PermButton> </PermButton>
} }
> >
<UCard className="venus-filter-card" size="small"> <VCard className="venus-filter-card" size="small">
<SearchForm <SearchForm
fields={fields} fields={fields}
initialValues={{ type: '', status: '' }} initialValues={{ type: '', status: '' }}
...@@ -183,8 +183,8 @@ export default function RoleManage() { ...@@ -183,8 +183,8 @@ export default function RoleManage() {
setQueryVersion((version) => version + 1); setQueryVersion((version) => version + 1);
}} }}
/> />
</UCard> </VCard>
<UCard size="small" fill> <VCard size="small" fill>
<DataTable<Row> <DataTable<Row>
rowKey="id" rowKey="id"
fillHeight fillHeight
...@@ -204,7 +204,7 @@ export default function RoleManage() { ...@@ -204,7 +204,7 @@ export default function RoleManage() {
}, },
}} }}
/> />
</UCard> </VCard>
<RoleFormDrawer <RoleFormDrawer
open={roleFormOpen} open={roleFormOpen}
roleItem={editingRole} roleItem={editingRole}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!