Commit b0aaf81e by liimin

优化视觉

1 parent 200c7e6c
Pipeline #435 for b0aaf81e failed in 0 seconds
{ {
"name": "@uj/web-shell", "name": "@uj/web-shell",
"version": "1.0.2", "version": "0.0.1",
"private": true, "private": true,
"type": "module", "type": "module",
"scripts": { "scripts": {
......
...@@ -11,6 +11,7 @@ import { themeConfig } from '@/theme/themeConfig'; ...@@ -11,6 +11,7 @@ import { themeConfig } from '@/theme/themeConfig';
import { AccessProvider } from '@/access'; import { AccessProvider } from '@/access';
import { initSign, setUnauthorizedHandler, http } from '@/api'; import { initSign, setUnauthorizedHandler, http } from '@/api';
import { DownloadCenterProvider } from '@uj/download-center'; import { DownloadCenterProvider } from '@uj/download-center';
import { installGlobalUnhandledRejectionHandler } from '@uj/ui';
import type { RemoteRequestFn } from '@uj/contracts'; import type { RemoteRequestFn } from '@uj/contracts';
import { loadRuntimeManifest } from './runtime-manifest'; import { loadRuntimeManifest } from './runtime-manifest';
import '@uj/design-tokens/tokens.css'; import '@uj/design-tokens/tokens.css';
...@@ -22,6 +23,9 @@ import './theme/mfe.css'; ...@@ -22,6 +23,9 @@ import './theme/mfe.css';
// logout 会双清 uj_token 与 session 并把 loggedIn 置 false,RequireAuth 随即重定向。 // logout 会双清 uj_token 与 session 并把 loggedIn 置 false,RequireAuth 随即重定向。
setUnauthorizedHandler(() => useAppStore.getState().logout()); setUnauthorizedHandler(() => useAppStore.getState().logout());
// 全应用未处理 promise rejection 兜底:async 调用漏 catch 时弹红色错误 toast。
installGlobalUnhandledRejectionHandler();
// 拉服务端公钥用于响应验签;失败仅告警,真正的阻断由调用方 ensureSignReady 判断。 // 拉服务端公钥用于响应验签;失败仅告警,真正的阻断由调用方 ensureSignReady 判断。
void initSign().catch(() => {}); void initSign().catch(() => {});
......
...@@ -115,16 +115,15 @@ ...@@ -115,16 +115,15 @@
left: 0; left: 0;
right: 0; right: 0;
bottom: 0; bottom: 0;
height: 52%;
z-index: 0; z-index: 0;
pointer-events: none; pointer-events: none;
/* 顶部渐隐,使点阵带自然融入上方墙面,不出现硬边 */ /* 顶部渐隐,使点阵带自然融入上方墙面,不出现硬边 */
-webkit-mask-image: linear-gradient(to top, #000 58%, transparent 100%); -webkit-mask-image: linear-gradient(to top, #000 70%, transparent 100%);
mask-image: linear-gradient(to top, #000 58%, transparent 100%); mask-image: linear-gradient(to top, #000 70%, transparent 100%);
} }
.uj-login-coverage svg { .uj-login-coverage svg {
display: block; display: block;
/* 等比完整显示(meet),禁止任何拉伸,保证网点/连线清晰不发糊 */ /* width:100% + height:auto:高度由 viewBox 宽高比(600×340)决定,永远不拉伸、不裁切、左右到边 */
shape-rendering: geometricPrecision; shape-rendering: geometricPrecision;
} }
/* 点阵中 1–2 个活跃节点的光晕扩散(雷达 ping),克制不抢戏;尊重 reduced-motion */ /* 点阵中 1–2 个活跃节点的光晕扩散(雷达 ping),克制不抢戏;尊重 reduced-motion */
...@@ -152,6 +151,24 @@ ...@@ -152,6 +151,24 @@
opacity: 0; opacity: 0;
} }
} }
/* 右上留白楔形区点缀星点的轻微闪烁,克制不抢戏;尊重 reduced-motion */
@keyframes cov-twinkle {
0%,
100% {
opacity: 0.45;
}
50% {
opacity: 0.95;
}
}
.uj-cov-star-tw {
animation: cov-twinkle 2.8s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
.uj-cov-star-tw {
animation: none;
}
}
/* ---- 底部主张区(主张标题) ---- */ /* ---- 底部主张区(主张标题) ---- */
/* margin-top:auto 把 brand+greet 顶到上方、hero+foot 整体下沉到底部,中部留白 */ /* margin-top:auto 把 brand+greet 顶到上方、hero+foot 整体下沉到底部,中部留白 */
.uj-login-hero { .uj-login-hero {
......
{ {
"name": "@uj/web-points", "name": "@uj/web-points",
"version": "1.0.0.2", "version": "0.0.1",
"private": true, "private": true,
"type": "module", "type": "module",
"scripts": { "scripts": {
......
...@@ -2,12 +2,16 @@ import { StrictMode } from 'react'; ...@@ -2,12 +2,16 @@ import { StrictMode } from 'react';
import { createRoot, type Root } from 'react-dom/client'; import { createRoot, type Root } from 'react-dom/client';
import { BrowserRouter } from 'react-router-dom'; import { BrowserRouter } from 'react-router-dom';
import { App } from './App'; import { App } from './App';
import { installGlobalUnhandledRejectionHandler } from '@uj/ui';
import '@uj/design-tokens/tokens.css'; import '@uj/design-tokens/tokens.css';
import './index.css'; import './index.css';
// 本域特有样式(统计条 / 详情网格 / 标签树 / 身份证 / 协议 iframe / 失败原因行)。 // 本域特有样式(统计条 / 详情网格 / 标签树 / 身份证 / 协议 iframe / 失败原因行)。
// 之前漏引入,导致这些组件运行时完全无样式 —— 累计结算金额面板"乱的"根因在此。 // 之前漏引入,导致这些组件运行时完全无样式 —— 累计结算金额面板"乱的"根因在此。
import './features/shared/page.css'; import './features/shared/page.css';
// 全应用未处理 promise rejection 兜底:async 调用漏 catch 时弹红色错误 toast。
installGlobalUnhandledRejectionHandler();
let root: Root | null = null; let root: Root | null = null;
/** /**
......
{ {
"name": "@uj/web-store", "name": "@uj/web-store",
"version": "1.0.0", "version": "0.0.1",
"private": true, "private": true,
"type": "module", "type": "module",
"scripts": { "scripts": {
......
...@@ -2,9 +2,13 @@ import { StrictMode } from 'react'; ...@@ -2,9 +2,13 @@ import { StrictMode } from 'react';
import { createRoot, type Root } from 'react-dom/client'; import { createRoot, type Root } from 'react-dom/client';
import { BrowserRouter } from 'react-router-dom'; import { BrowserRouter } from 'react-router-dom';
import { App } from './App'; import { App } from './App';
import { installGlobalUnhandledRejectionHandler } from '@uj/ui';
import '@uj/design-tokens/tokens.css'; import '@uj/design-tokens/tokens.css';
import './index.css'; import './index.css';
// 全应用未处理 promise rejection 兜底:async 调用漏 catch 时弹红色错误 toast。
installGlobalUnhandledRejectionHandler();
let root: Root | null = null; let root: Root | null = null;
function render(): void { function render(): void {
......
{ {
"name": "@uj/web-system", "name": "@uj/web-system",
"version": "1.0.0.1", "version": "0.0.1",
"private": true, "private": true,
"type": "module", "type": "module",
"scripts": { "scripts": {
......
...@@ -2,9 +2,13 @@ import { StrictMode } from 'react'; ...@@ -2,9 +2,13 @@ import { StrictMode } from 'react';
import { createRoot, type Root } from 'react-dom/client'; import { createRoot, type Root } from 'react-dom/client';
import { BrowserRouter } from 'react-router-dom'; import { BrowserRouter } from 'react-router-dom';
import { App } from './App'; import { App } from './App';
import { installGlobalUnhandledRejectionHandler } from '@uj/ui';
import '@uj/design-tokens/tokens.css'; import '@uj/design-tokens/tokens.css';
import './index.css'; import './index.css';
// 全应用未处理 promise rejection 兜底:async 调用漏 catch 时弹红色错误 toast。
installGlobalUnhandledRejectionHandler();
let root: Root | null = null; let root: Root | null = null;
/** /**
......
{ {
"name": "@uj/web-usedcar", "name": "@uj/web-usedcar",
"version": "1.0.0", "version": "0.0.1",
"private": true, "private": true,
"type": "module", "type": "module",
"scripts": { "scripts": {
......
...@@ -2,9 +2,13 @@ import { StrictMode } from 'react'; ...@@ -2,9 +2,13 @@ import { StrictMode } from 'react';
import { createRoot, type Root } from 'react-dom/client'; import { createRoot, type Root } from 'react-dom/client';
import { BrowserRouter } from 'react-router-dom'; import { BrowserRouter } from 'react-router-dom';
import { App } from './App'; import { App } from './App';
import { installGlobalUnhandledRejectionHandler } from '@uj/ui';
import '@uj/design-tokens/tokens.css'; import '@uj/design-tokens/tokens.css';
import './index.css'; import './index.css';
// 全应用未处理 promise rejection 兜底:async 调用漏 catch 时弹红色错误 toast。
installGlobalUnhandledRejectionHandler();
let root: Root | null = null; let root: Root | null = null;
/** /**
......
...@@ -33,8 +33,13 @@ export default function ContractTab() { ...@@ -33,8 +33,13 @@ export default function ContractTab() {
permission: UC.CONTRACT_DOWNLOAD, permission: UC.CONTRACT_DOWNLOAD,
visible: (r) => Number(r.electronicContractStatus) === 2, visible: (r) => Number(r.electronicContractStatus) === 2,
onClick: async (r) => { onClick: async (r) => {
const x = await operationApi.contractFile(r.id); try {
if (x.url) window.open(x.url, '_blank'); const x = await operationApi.contractFile(r.id);
if (x.url) window.open(x.url, '_blank');
else msg.warning('未获取到合同文件地址');
} catch (e) {
msg.error(e instanceof Error ? e.message : '合同文件获取失败');
}
}, },
}, },
{ {
......
import { useMemo, useState } from 'react'; import { useMemo, useState } from 'react';
import { Badge, Button, Empty, Popover, Tag, message } from 'antd'; import { Badge, Button, Empty, Popover, Tag } from 'antd';
import { DownloadOutlined, ClearOutlined } from '@ant-design/icons'; import { DownloadOutlined, ClearOutlined } from '@ant-design/icons';
import { useDownloadCenterStore } from './store'; import { useDownloadCenterStore } from './store';
import { cancelTask, redownload } from './engine'; import { cancelTask, redownload } from './engine';
...@@ -99,7 +99,6 @@ export function DownloadCenterButton() { ...@@ -99,7 +99,6 @@ export function DownloadCenterButton() {
const panel = ( const panel = (
<div style={{ width: 340 }}> <div style={{ width: 340 }}>
<style>{`.dc-row{cursor:default}.dc-row.is-done{cursor:pointer}.dc-row.is-done:hover{background:#f5f5f5}`}</style>
{/* 头部:固定不滚动 */} {/* 头部:固定不滚动 */}
<div style={{ marginBottom: 8 }}> <div style={{ marginBottom: 8 }}>
<div <div
...@@ -148,20 +147,11 @@ export function DownloadCenterButton() { ...@@ -148,20 +147,11 @@ export function DownloadCenterButton() {
<ul style={{ listStyle: 'none', margin: 0, padding: 0 }}> <ul style={{ listStyle: 'none', margin: 0, padding: 0 }}>
{filteredTasks.map((t) => { {filteredTasks.map((t) => {
const meta = STATUS_META[t.status]; const meta = STATUS_META[t.status];
const isDone = t.status === 'done';
return ( return (
<li <li
key={t.id} key={t.id}
className={`dc-row${isDone ? ' is-done' : ''}`} className="dc-row"
style={{ padding: '8px 0', borderBottom: '1px solid #f0f0f0' }} style={{ padding: '8px 0', borderBottom: '1px solid #f0f0f0' }}
title={isDone ? '文件已保存到浏览器下载目录,点击查看位置' : undefined}
onClick={() => {
if (isDone) {
message.info(
`文件「${t.fileName ?? t.label}」已保存到浏览器下载目录,可在下载管理中查看`,
);
}
}}
> >
<div style={{ display: 'flex', justifyContent: 'space-between', gap: 8 }}> <div style={{ display: 'flex', justifyContent: 'space-between', gap: 8 }}>
<span <span
......
...@@ -60,21 +60,21 @@ export function DownloadCenterProvider({ ...@@ -60,21 +60,21 @@ export function DownloadCenterProvider({
fired.add(t.id); fired.add(t.id);
if (t.input.silent) return; if (t.input.silent) return;
// 仅异步导出(长任务、需「稍后查看」)弹完成/失败通知;
// 直链 / 文件流 / 本地文件等即时落地的,一律不再弹「下载完成」提示。
if (t.kind !== 'async-export') return;
if (t.status === 'done') { if (t.status === 'done') {
// 仅异步导出(长任务、需「稍后查看」)弹完成通知;
// 直链 / 文件流 / 本地文件等即时落地的,不再弹「下载完成」提示。
if (t.kind !== 'async-export') return;
notification.success({ notification.success({
message: '导出完成', message: '导出完成',
description: `${t.label}${t.fileName ? ` · ${t.fileName}` : ''}`, description: `${t.label}${t.fileName ? ` · ${t.fileName}` : ''}`,
placement: 'topRight', placement: 'top',
}); });
} else { } else {
// 失败:不论来源(points/usedcar/store…)、不论是否有链接,一律弹失败通知。
notification.error({ notification.error({
message: '导出失败', message: t.kind === 'async-export' ? '导出失败' : '下载失败',
description: t.error || t.label, description: t.error || t.label,
placement: 'topRight', placement: 'top',
}); });
} }
}); });
......
import { message } from 'antd';
let installed = false;
const seen = new Map<string, number>();
const DEDUPE_MS = 3000;
/** 从 rejection reason 里尽量取出可读错误信息。 */
function extractErrorMessage(reason: unknown): string {
if (!reason) return '请求失败,请稍后重试';
if (reason instanceof Error) return reason.message || reason.name || '请求失败,请稍后重试';
if (typeof reason === 'string') return reason;
if (typeof reason === 'object') {
const m =
(reason as { message?: unknown }).message ?? (reason as { msg?: unknown }).msg;
if (typeof m === 'string' && m) return m;
}
return '请求失败,请稍后重试';
}
/**
* 全应用未处理 promise rejection 兜底。
*
* 任何 async 调用漏 catch 而抛出的异常(如「合同编号不存在」这类后端业务错误),
* 都会被这里接住并弹红色错误 toast,避免「只在 console 报错、用户毫无感知」。
*
* 设计取舍:
* - 用 antd 静态 message(非 App 上下文实例)。兜底场景下可接受:
* 1) 不依赖 React 渲染时机,全局监听即装即用;
* 2) 静态 message 挂载到 host document.body,能越过 wujie shadow DOM 始终可见;
* 3) 代价是拿不到 ConfigProvider 主题/locale,但错误文案本就是中文,样式差异可忽略。
* - 同一文案 3s 内只弹一次,避免循环/并发失败时刷屏。
*
* ⚠️ 各子应用在主壳不同的 wujie 沙箱 realm 内运行,window 是独立代理,
* 因此每个子应用入口与主壳入口都要各自装一次,才能兜住各自 realm 的 rejection。
*/
export function installGlobalUnhandledRejectionHandler(): void {
if (installed) return;
installed = true;
window.addEventListener('unhandledrejection', (event: PromiseRejectionEvent) => {
const text = extractErrorMessage(event.reason);
const now = Date.now();
const last = seen.get(text) ?? 0;
if (now - last < DEDUPE_MS) return;
seen.set(text, now);
message.error(text);
// 阻止浏览器默认处理(避免控制台再抛一次 Uncaught),但不阻断其他监听。
event.preventDefault?.();
});
}
...@@ -14,10 +14,12 @@ ...@@ -14,10 +14,12 @@
// 详见该文件注释。 // 详见该文件注释。
import './styles/injectThinScrollbar'; import './styles/injectThinScrollbar';
import './styles/ui.css'; import './styles/ui.css';
import './styles/feedback.css';
export { UApp } from './components/App'; export { UApp } from './components/App';
export type { UAppProps } from './components/App'; export type { UAppProps } from './components/App';
export { useUApp, useUMessage } from './components/App/hooks'; export { useUApp, useUMessage } from './components/App/hooks';
export { installGlobalUnhandledRejectionHandler } from './components/App/globalError';
export { UButton } from './components/Button'; export { UButton } from './components/Button';
export type { UButtonProps } from './components/Button'; export type { UButtonProps } from './components/Button';
......
/* ---------------------------------------------------------------------------
* 统一反馈层(message / notification)—— 站点化设计
*
* 背景:项目用 antd v6,其 message 结构为
* .ant-message-notice (卡片本体,自带 bg / radius / shadow)
* > .ant-message-notice-icon + .ant-message-notice-icon-<type> (图标)
* > .ant-message-notice-title (文案)
* notification 为 .ant-notification-notice (卡片) + ...-icon-<type> + ...-title + ...-description,
* 且类型类直接挂在卡片上(.ant-notification-notice-<type>)。
* v5 的 .ant-message-notice-content / .ant-message-custom-content / .ant-notification-notice-message
* 在 v6 均不存在,旧版选择器全部失效——本文件按 v6 真实 DOM 重写。
*
* 设计主张:把「语义类型」做成可一眼辨认的信号,而非一行小字——
* 1) 实心图标芯片(hero):语义色填满的圆角方块 + 白色字形;
* 2) 按类型染色的卡片底(notification 用类型类,message 用 :has() 同源染色);
* 3) 芯片入场轻微回弹 pop(仅作用于芯片自身,不动 antd 的定位 transform);
* 4) 位置统一顶部居中,卡形 / 影 / 描边沿用 .uj-card 同族 token,不另造色值。
*
* 选择器用 .ant-message / .ant-notification 前缀把特异性提到 (0,2,0),
* 既能压过 antd 自带样式,又能同时覆盖「App 上下文实例」与「静态实例」
* (全局兜底用的静态 message 也挂在 .ant-message 容器内)。
* ------------------------------------------------------------------------- */
/* ============================== MESSAGE ============================== */
/* 卡片本体:收口为品牌白卡(v6 里 .ant-message-notice 即卡片,自带 bg/radius/shadow)。 */
.ant-message .ant-message-notice {
padding: 12px 16px;
border: 1px solid var(--uj-border);
border-radius: var(--uj-radius-card);
background: var(--uj-surface);
box-shadow: var(--uj-shadow-card);
color: var(--uj-text-1);
}
/* 按类型染色:v6 类型类只挂在图标上,用 :has() 让整张卡片同源染色(wordless 识别)。 */
.ant-message .ant-message-notice:has(.ant-message-notice-icon-success) {
background: var(--uj-success-soft);
border-color: var(--uj-success-border);
}
.ant-message .ant-message-notice:has(.ant-message-notice-icon-error) {
background: var(--uj-error-soft);
border-color: var(--uj-error-border);
}
.ant-message .ant-message-notice:has(.ant-message-notice-icon-warning) {
background: var(--uj-warning-soft);
border-color: var(--uj-warning-border);
}
.ant-message .ant-message-notice:has(.ant-message-notice-icon-info),
.ant-message .ant-message-notice:has(.ant-message-notice-icon-loading) {
background: var(--uj-info-soft);
border-color: var(--uj-info-border);
}
.ant-message .ant-message-notice-title {
color: var(--uj-text-1);
font-weight: 600;
}
/* 图标芯片(hero):语义色填满的圆角方块 + 白色字形,替换 antd 默认彩色透明图标。 */
.ant-message .ant-message-notice-icon {
display: inline-flex;
align-items: center;
justify-content: center;
width: 22px;
height: 22px;
border-radius: var(--uj-radius-md);
font-size: 13px;
color: #fff;
box-shadow: 0 1px 2px rgba(16, 24, 40, 0.18);
animation: uj-feedback-chip-in 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.ant-message .ant-message-notice-icon-success {
background: var(--uj-success);
}
.ant-message .ant-message-notice-icon-error {
background: var(--uj-error);
}
.ant-message .ant-message-notice-icon-warning {
background: var(--uj-warning);
}
.ant-message .ant-message-notice-icon-info,
.ant-message .ant-message-notice-icon-loading {
background: var(--uj-primary);
}
/* ============================ NOTIFICATION ============================ */
/* 卡片本体。 */
.ant-notification .ant-notification-notice {
padding: 14px 16px;
border: 1px solid var(--uj-border);
border-radius: var(--uj-radius-card);
background: var(--uj-surface);
box-shadow: var(--uj-shadow-card);
}
/* 按类型染色:v6 类型类直接挂在卡片上,比 :has() 更稳。 */
.ant-notification .ant-notification-notice-success {
background: var(--uj-success-soft);
border-color: var(--uj-success-border);
}
.ant-notification .ant-notification-notice-error {
background: var(--uj-error-soft);
border-color: var(--uj-error-border);
}
.ant-notification .ant-notification-notice-warning {
background: var(--uj-warning-soft);
border-color: var(--uj-warning-border);
}
.ant-notification .ant-notification-notice-info,
.ant-notification .ant-notification-notice-open {
background: var(--uj-info-soft);
border-color: var(--uj-info-border);
}
.ant-notification .ant-notification-notice-title {
color: var(--uj-text-1);
font-weight: 600;
}
.ant-notification .ant-notification-notice-description {
color: var(--uj-text-2);
}
/* 图标芯片(hero),比 message 略大以匹配通知卡的体量。 */
.ant-notification .ant-notification-notice-icon {
display: inline-flex;
align-items: center;
justify-content: center;
width: 26px;
height: 26px;
border-radius: var(--uj-radius-md);
font-size: 15px;
color: #fff;
box-shadow: 0 1px 2px rgba(16, 24, 40, 0.18);
animation: uj-feedback-chip-in 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.ant-notification .ant-notification-notice-icon-success {
background: var(--uj-success);
}
.ant-notification .ant-notification-notice-icon-error {
background: var(--uj-error);
}
.ant-notification .ant-notification-notice-icon-warning {
background: var(--uj-warning);
}
.ant-notification .ant-notification-notice-icon-info,
.ant-notification .ant-notification-notice-icon-loading {
background: var(--uj-primary);
}
/* ============================ 动效 ============================ */
/* 芯片入场轻微回弹:只作用于芯片自身,不影响 antd 对 .ant-*-notice 的定位 transform。 */
@keyframes uj-feedback-chip-in {
0% {
transform: scale(0.4);
opacity: 0;
}
60% {
transform: scale(1.12);
opacity: 1;
}
100% {
transform: scale(1);
}
}
/* 尊重减少动效偏好:关闭芯片回弹,提示照常出现。 */
@media (prefers-reduced-motion: reduce) {
.ant-message .ant-message-notice-icon,
.ant-notification .ant-notification-notice-icon {
animation: none;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!