Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
ujia
/
uj-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 3e86458e
authored
Nov 12, 2026
by
liimin
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
优化子系统本地访问方式
1 parent
36e2abf6
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
915 additions
and
296 deletions
ARCHITECTURE.md
apps/web/shell/src/pages/Dashboard/index.tsx
apps/web/shell/src/subapps.ts
apps/web/shell/src/theme/design.css
apps/web/subapps/points/.env.production
docs/DEPLOY.md
docs/ops-deploy-guide.md
packages/ui/src/components/FillTable/index.tsx
packages/ui/src/hooks/useScrollbarRemeasure.ts
packages/ui/src/index.ts
packages/ui/src/styles/injectThinScrollbar.ts
packages/ui/src/styles/ui.css
scripts/dev.mjs
ARCHITECTURE.md
View file @
3e86458
...
@@ -134,7 +134,7 @@ bus 事件(`packages/contracts/src/events.ts`):`<name>:ready`(子→主
...
@@ -134,7 +134,7 @@ bus 事件(`packages/contracts/src/events.ts`):`<name>:ready`(子→主
详见
[
docs/DEPLOY.md
](
./docs/DEPLOY.md
)
。一句话:
**只发一个模块 = 上传该模块产物 + 改运行时 `manifest.json`,host 不重建、不重启、整页刷新即生效**
;回滚 = 清单指回旧版本目录。执行入口是
`pnpm release -- --app system --version 1.2.0`
(
`scripts/release.mjs`
)。
详见
[
docs/DEPLOY.md
](
./docs/DEPLOY.md
)
。一句话:
**只发一个模块 = 上传该模块产物 + 改运行时 `manifest.json`,host 不重建、不重启、整页刷新即生效**
;回滚 = 清单指回旧版本目录。执行入口是
`pnpm release -- --app system --version 1.2.0`
(
`scripts/release.mjs`
)。
`apps/web/shell/src/runtime-manifest.ts`
在
**主壳启动时**
拉一次清单(3s 超时、
`cache: 'no-store'`
、失败静默回落)。
`subapps.ts`
的入口优先级:运行时 manifest >
`
uj.entry`
>
`VITE_<SHORT>_SUBAPP_URL`
;生产环境会拒绝回落到
`uj.entry`
里的 localhost 开发机地址,改为显示「未找到子应用入口」
。
`apps/web/shell/src/runtime-manifest.ts`
在
**主壳启动时**
拉一次清单(3s 超时、
`cache: 'no-store'`
、失败静默回落)。
`subapps.ts`
的入口优先级:运行时 manifest >
`
VITE_<SHORT>_SUBAPP_URL`
(仅
`pnpm dev`
时由 dev.mjs 注入局域网 IP,用于本地共享) >
`uj.entry`
(写死 localhost 的开发默认)。生产环境无 manifest 时回落到
`uj.entry`
里的 localhost,会被判定无效并显示「未找到子应用入口」(绝不会把生产用户送到开发机)
。
清单不只决定入口 URL,还决定
**本次会话的路由表**
:
`main.tsx`
在清单拉取完成后才
`render()`
,
`createRouter()`
用
`collectRouteDefs()`
(构建期
`SUBAPPS`
∪ 运行时
`manifest.subapps`
,纯合并逻辑见
`merge-route-defs.ts`
)生成
`/<route>/*`
。因此
**新增子应用也无需重建 host**
——发版写清单 + 后端配菜单即可。登出广播走同一份集合,动态子应用不会残留旧账号沙箱。详见
[
docs/DEPLOY.md §2.1
](
./docs/DEPLOY.md
)
。
清单不只决定入口 URL,还决定
**本次会话的路由表**
:
`main.tsx`
在清单拉取完成后才
`render()`
,
`createRouter()`
用
`collectRouteDefs()`
(构建期
`SUBAPPS`
∪ 运行时
`manifest.subapps`
,纯合并逻辑见
`merge-route-defs.ts`
)生成
`/<route>/*`
。因此
**新增子应用也无需重建 host**
——发版写清单 + 后端配菜单即可。登出广播走同一份集合,动态子应用不会残留旧账号沙箱。详见
[
docs/DEPLOY.md §2.1
](
./docs/DEPLOY.md
)
。
...
...
apps/web/shell/src/pages/Dashboard/index.tsx
View file @
3e86458
// 工作台 =
欢迎
页。
// 工作台 =
运营驾驶舱首
页。
//
业务概览(KPI / 趋势 / 分布)暂无规划,故不做任何假数据看板:
//
真实数据只来自后端分页接口的 total(待我审批 / 我的提交 / 在架门店),按当前账号权限过滤;
//
只保留「问候 + 账号信息 + 真实快捷入口 + 账号安全入口」,入口全部按当前权限过滤
。
//
不展示任何伪造的 KPI / 趋势 / 分布。所有入口同样按权限过滤后展示
。
import { useNavigate } from 'react-router-dom';
import { useNavigate } from 'react-router-dom';
import { useQuery, type UseQueryResult } from '@tanstack/react-query';
import {
import {
UploadOutlined,
AuditOutlined,
AuditOutlined,
ShopOutlined,
ShopOutlined,
FileDoneOutlined,
UploadOutlined,
TeamOutlined,
TeamOutlined,
UserOutlined,
UserOutlined,
ArrowRightOutlined,
SafetyOutlined,
SafetyOutlined,
ArrowRightOutlined,
CheckCircleOutlined,
DownloadOutlined,
} from '@ant-design/icons';
} from '@ant-design/icons';
import type { ReactNode } from 'react';
import type { KeyboardEvent, ReactNode } from 'react';
import { UCard, UButton, UText } from '@uj/ui';
import { http } from '@/api/core';
import { UButton } from '@uj/ui';
import { useAppStore } from '@/store/useAppStore';
import { useAppStore } from '@/store/useAppStore';
import { useAccess, roleLabels, type ResourceKey } from '@/access';
import { useAccess, type ResourceKey } from '@/access';
/** 后端分页信封只取 total,不引入子应用 DTO 类型(主壳不依赖子应用类型)。 */
interface CountVO {
total: number;
}
/** 按时段给问候语 */
/** 按时段给问候语 */
function greeting(): string {
function greeting(): string {
...
@@ -26,6 +36,15 @@ function greeting(): string {
...
@@ -26,6 +36,15 @@ function greeting(): string {
return '晚上好';
return '晚上好';
}
}
function todayText(): string {
return new Date().toLocaleDateString('zh-CN', {
year: 'numeric',
month: 'long',
day: 'numeric',
weekday: 'long',
});
}
interface QuickLink {
interface QuickLink {
path: string;
path: string;
label: string;
label: string;
...
@@ -34,129 +53,309 @@ interface QuickLink {
...
@@ -34,129 +53,309 @@ interface QuickLink {
resource: ResourceKey;
resource: ResourceKey;
}
}
// 快捷入口:与后端菜单一一对应,展示与否由当前账号权限决定(can)
interface QuickGroup {
const QUICK_LINKS: QuickLink[] = [
title: string;
items: QuickLink[];
}
// 快捷入口按业务域分组;展示与否由当前账号权限决定(can)。
const QUICK_GROUPS: QuickGroup[] = [
{
{
path: '/store/import',
title: '门店上架',
label: '导入门店信息',
items: [
desc: '下载模板、上传并校验,确认后提交审批',
{
icon: <UploadOutlined />,
path: '/store/import',
resource: 'store:import',
label: '导入门店信息',
desc: '下载模板、上传并校验,确认后提交审批',
icon: <UploadOutlined />,
resource: 'store:import',
},
{
path: '/store/approval',
label: '门店审批',
desc: '审核待上架门店,通过或打回',
icon: <AuditOutlined />,
resource: 'store:approve',
},
{
path: '/store/listing',
label: '门店列表',
desc: '查看、筛选与维护已上架门店',
icon: <ShopOutlined />,
resource: 'store:list',
},
],
},
},
{
{
path: '/store/approval',
title: '系统设置',
label: '门店审批',
items: [
desc: '审核待上架门店,通过或打回',
{
icon: <AuditOutlined />,
path: '/system/role',
resource: 'store:approve',
label: '角色管理',
desc: '配置角色权限与菜单可见范围',
icon: <TeamOutlined />,
resource: 'system:role',
},
{
path: '/system/user',
label: '账号管理',
desc: '维护系统账号、重置密码与启停',
icon: <UserOutlined />,
resource: 'system:user',
},
],
},
},
];
type StatTint = 'info' | 'success' | 'neutral';
interface StatDef {
key: 'pending' | 'mine' | 'listing';
label: string;
icon: ReactNode;
path: string;
resource: ResourceKey;
url: string;
tint: StatTint;
}
// 三张真实计数卡片:拉对应分页接口 total。权限门控,无权限不渲染。
const STATS: StatDef[] = [
{
{
path: '/store/listing',
key: 'pending',
label: '门店列表',
label: '待我审批',
desc: '查看、筛选与维护已上架门店',
icon: <AuditOutlined />,
icon: <ShopOutlined />,
path: '/store/approval',
resource: 'store:list',
resource: 'store:approve',
url: '/store/approval/pending',
tint: 'info',
},
},
{
{
path: '/system/role',
key: 'mine',
label: '角色管理',
label: '我的提交',
desc: '配置角色权限与菜单可见范围',
icon: <FileDoneOutlined />,
icon: <TeamOutlined />,
path: '/store/approval?tab=mine',
resource: 'system:role',
resource: 'store:approve',
url: '/store/approval/mine',
tint: 'neutral',
},
},
{
{
path: '/system/user',
key: 'listing',
label: '账号管理',
label: '在架门店',
desc: '维护系统账号、重置密码与启停',
icon: <ShopOutlined />,
icon: <UserOutlined />,
path: '/store/listing',
resource: 'system:user',
resource: 'store:list',
url: '/store/listing/page',
tint: 'success',
},
},
];
];
function useCount(url: string, enabled: boolean): UseQueryResult<CountVO> {
// 注意:http 在 http.ts 末尾被 `as unknown as AxiosInstance` 强制成 axios 形状,
// 故 TS 视 http.get<T> 返回 Promise<AxiosResponse<T>>;但运行时 api-core 已解包信封、直接返回内层 data。
// 这里按「运行时返回内层 CountVO」取数,转型封住类型(与 ApiClient.call 的 .then(res => res.data) 同源)。
return useQuery<CountVO>({
queryKey: ['dashboard', url],
queryFn: () =>
http.get<CountVO>(url, { params: { current: 1, size: 1 } }) as unknown as Promise<CountVO>,
enabled,
staleTime: 30_000,
});
}
/** 可点击卡片:div 承载 role=button,避开 button 嵌套;Enter / Space 触发跳转。 */
function cardActivator(navigate: (p: string) => void, path: string) {
return {
role: 'button',
tabIndex: 0,
onClick: () => navigate(path),
onKeyDown: (e: KeyboardEvent<HTMLDivElement>) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
navigate(path);
}
},
};
}
// 上架流程指引:如实描述四步,不链接到具体计数,仅作新用户引导。
const ONBOARD_STEPS: { title: string; desc: string; icon: ReactNode }[] = [
{ title: '下载模板', desc: '获取标准上架模板(V1.0.1,21 列)', icon: <DownloadOutlined /> },
{ title: '上传校验', desc: '上传文件,系统校验格式与业务规则', icon: <UploadOutlined /> },
{ title: '确认提交', desc: '核对预览,提交进入审批流程', icon: <FileDoneOutlined /> },
{ title: '审批上架', desc: '商务 / 财务依次审批,全部通过生效', icon: <CheckCircleOutlined /> },
];
export default function Dashboard() {
export default function Dashboard() {
const navigate = useNavigate();
const navigate = useNavigate();
const { currentUser } = useAppStore();
const { currentUser } = useAppStore();
const { can, role, roleCodes } = useAccess();
const { can, role, roleCodes } = useAccess();
const dateText = new Date().toLocaleDateString('zh-CN', {
// 三个计数查询固定顺序调用(常量数组,hook 顺序稳定);enabled 跟随权限。
year: 'numeric',
const pending = useCount('/store/approval/pending', can('store:approve'));
month: 'long',
const mine = useCount('/store/approval/mine', can('store:approve'));
day: 'numeric',
const listing = useCount('/store/listing/page', can('store:list'));
weekday: 'long',
const statQuery: Record<StatDef['key'], UseQueryResult<CountVO>> = { pending, mine, listing };
});
const roleText = roleCodes.length ? roleCodes.join(' / ') : roleLabels[role];
const roleText = roleCodes.length ? roleCodes.join(' / ') : role;
const links = QUICK_LINKS.filter((l) => can(l.resource));
const visibleStats = STATS.filter((s) => can(s.resource));
const visibleGroups = QUICK_GROUPS.map((g) => ({
...g,
items: g.items.filter((i) => can(i.resource)),
})).filter((g) => g.items.length > 0);
return (
return (
<div className="uj-d
ash
">
<div className="uj-d
eck
">
{/*
品牌欢迎条:浅色卡片 + 品牌色点睛(不再大面积铺深色,避免压抑)
*/}
{/*
报头:问候 + 身份,左缘品牌光楔点睛
*/}
<
div className="uj-dash-hero
">
<
section className="uj-deck-hero" aria-label="欢迎
">
<div className="uj-d
ash-hero-id
">
<div className="uj-d
eck-hero-main
">
<div className="uj-d
ash-hero
-brand">
<div className="uj-d
eck
-brand">
<span className="uj-d
ash-hero-mark"
/>
<span className="uj-d
eck-brand-mark" aria-hidden
/>
STORE LAUNCH PLATFORM
优加门店上架平台
</div>
</div>
<h1 className="uj-d
ash-hero-title
">
<h1 className="uj-d
eck-greeting
">
{greeting()},{currentUser.name || '欢迎回来'}
{greeting()},{currentUser.name || '欢迎回来'}
</h1>
</h1>
<p className="uj-d
ash-hero-sub">{dateText
} · 欢迎回到优加门店上架系统</p>
<p className="uj-d
eck-sub">{todayText()
} · 欢迎回到优加门店上架系统</p>
</div>
</div>
<div className="uj-d
ash-hero
-meta">
<div className="uj-d
eck
-meta">
<div className="uj-d
ash-meta-item
">
<div className="uj-d
eck-chip
">
<span className="uj-d
ash-meta
-label">账号</span>
<span className="uj-d
eck-chip
-label">账号</span>
<span className="uj-d
ash-meta
-value">{currentUser.account || '-'}</span>
<span className="uj-d
eck-chip
-value">{currentUser.account || '-'}</span>
</div>
</div>
<div className="uj-d
ash-meta-item
">
<div className="uj-d
eck-chip
">
<span className="uj-d
ash-meta
-label">角色</span>
<span className="uj-d
eck-chip
-label">角色</span>
<span className="uj-d
ash-meta
-value">{roleText}</span>
<span className="uj-d
eck-chip
-value">{roleText}</span>
</div>
</div>
</div>
</div>
</
div
>
</
section
>
{/* 快捷入口:按权限过滤,无权限的不出现 */}
{/* 运营概览:真实计数 */}
<div>
{visibleStats.length > 0 && (
<div className="uj-welcome-title">快捷开始</div>
<section className="uj-deck-stats" aria-label="运营概览">
{links.length ? (
{visibleStats.map((s) => {
<div className="uj-welcome-quick">
const q = statQuery[s.key];
{links.map((l) => (
return (
<UCard
<div
key={l.path}
key={s.key}
hoverable
className={`uj-deck-stat uj-deck-stat--${s.tint}`}
className="uj-quick-card"
{...cardActivator(navigate, s.path)}
onClick={() => navigate(l.path)}
styles={{ body: { padding: 18 } }}
>
>
<div className="uj-quick-icon">{l.icon}</div>
<div className="uj-deck-stat-top">
<div className="uj-quick-label">{l.label}</div>
<span className="uj-deck-stat-ico" aria-hidden>
<div className="uj-quick-desc">{l.desc}</div>
{s.icon}
<div className="uj-quick-go">
</span>
进入 <ArrowRightOutlined />
<span className="uj-deck-stat-go">
查看 <ArrowRightOutlined />
</span>
</div>
</div>
</UCard>
<div className="uj-deck-stat-label">{s.label}</div>
))}
{q.isError ? (
</div>
<>
) : (
<div className="uj-deck-stat-value is-error">—</div>
<UCard styles={{ body: { padding: 20 } }}>
<button
<UText type="secondary">暂无可用功能,请联系管理员分配权限。</UText>
type="button"
</UCard>
className="uj-deck-stat-retry"
)}
onClick={(e) => {
</div>
e.stopPropagation();
void q.refetch();
}}
>
加载失败,点击重试
</button>
</>
) : (
<div className={`uj-deck-stat-value${q.isPending ? ' is-loading' : ''}`}>
{q.isPending ? '' : (q.data?.total ?? 0)}
</div>
)}
</div>
);
})}
</section>
)}
{/* 主区:快捷开始 + 右栏 */}
<div className="uj-deck-main">
<section className="uj-deck-launch" aria-label="快捷开始">
{visibleGroups.map((g) => (
<div key={g.title}>
<div className="uj-deck-group-title">{g.title}</div>
<div className="uj-deck-quick-grid">
{g.items.map((l) => (
<div
key={l.path}
className="uj-deck-quick"
{...cardActivator(navigate, l.path)}
>
<span className="uj-deck-quick-ico" aria-hidden>
{l.icon}
</span>
<div className="uj-deck-quick-label">{l.label}</div>
<div className="uj-deck-quick-desc">{l.desc}</div>
<div className="uj-deck-quick-go">
进入 <ArrowRightOutlined />
</div>
</div>
))}
</div>
</div>
))}
{visibleGroups.length === 0 && (
<div className="uj-deck-sec">
<div className="uj-deck-sec-desc">暂无可用功能,请联系管理员分配权限。</div>
</div>
)}
</section>
{/* 账号与安全 */}
<aside className="uj-deck-rail" aria-label="账户与指引">
<UCard styles={{ body: { padding: '14px 18px' } }}>
{/* 账号与安全 */}
<div className="uj-welcome-sec">
<div className="uj-deck-sec uj-deck-sec--security">
<div className="uj-welcome-sec-icon">
<div className="uj-deck-sec-head">
<SafetyOutlined />
<span className="uj-deck-sec-icon" aria-hidden>
<SafetyOutlined />
</span>
<div>
<div className="uj-deck-sec-title">账号与安全</div>
<div className="uj-deck-sec-desc">定期更新密码;如使用初始密码登录,请尽快修改。</div>
</div>
</div>
<div className="uj-deck-sec-body" style={{ textAlign: 'right' }}>
<UButton onClick={() => navigate('/profile')}>前往修改</UButton>
</div>
</div>
</div>
<div style={{ flex: 1, minWidth: 0 }}>
<div style={{ fontSize: 14, fontWeight: 600, color: '#1D2533' }}>账号与安全</div>
{/* 上架流程指引 */}
<UText type="secondary" style={{ fontSize: 12 }}>
<div className="uj-deck-sec">
建议定期更新密码;如使用初始密码登录,请尽快修改。
<div className="uj-deck-sec-head">
</UText>
<span className="uj-deck-sec-icon" aria-hidden style={{ background: 'var(--uj-primary-soft, #eef3ff)', color: 'var(--uj-primary, #2b5ce6)' }}>
<UploadOutlined />
</span>
<div>
<div className="uj-deck-sec-title">上架流程指引</div>
<div className="uj-deck-sec-desc">四步完成一家门店上架</div>
</div>
</div>
<div className="uj-deck-sec-body">
<ol className="uj-deck-steps">
{ONBOARD_STEPS.map((step, idx) => (
<li key={step.title} className="uj-deck-step">
<span className="uj-deck-step-rail">
<span className="uj-deck-step-node" aria-hidden>
{idx + 1}
</span>
</span>
<span>
<span className="uj-deck-step-title">{step.title}</span>
<span className="uj-deck-step-desc">{step.desc}</span>
</span>
</li>
))}
</ol>
</div>
</div>
</div>
<UButton onClick={() => navigate('/profile')}>前往修改</UButton>
</aside>
</div>
</div>
</UCard>
</div>
</div>
);
);
}
}
apps/web/shell/src/subapps.ts
View file @
3e86458
...
@@ -33,7 +33,7 @@ export const SUBAPPS: SubAppMeta[] = Object.values(raw)
...
@@ -33,7 +33,7 @@ export const SUBAPPS: SubAppMeta[] = Object.values(raw)
const
shortName
=
deriveShortName
(
pkg
.
name
);
const
shortName
=
deriveShortName
(
pkg
.
name
);
const
route
=
pkg
.
uj
?.
route
??
shortName
;
const
route
=
pkg
.
uj
?.
route
??
shortName
;
const
envKey
=
`VITE_
${
shortName
.
toUpperCase
()}
_SUBAPP_URL`
;
const
envKey
=
`VITE_
${
shortName
.
toUpperCase
()}
_SUBAPP_URL`
;
const
entry
=
pkg
.
uj
?.
entry
??
env
[
envKey
]
??
''
;
const
entry
=
env
[
envKey
]
||
pkg
.
uj
?.
entry
||
''
;
return
{
name
:
pkg
.
name
,
shortName
,
route
,
entry
};
return
{
name
:
pkg
.
name
,
shortName
,
route
,
entry
};
})
})
.
sort
((
a
,
b
)
=>
a
.
route
.
localeCompare
(
b
.
route
));
.
sort
((
a
,
b
)
=>
a
.
route
.
localeCompare
(
b
.
route
));
...
@@ -53,7 +53,9 @@ for (const key of ['route', 'shortName'] as const) {
...
@@ -53,7 +53,9 @@ for (const key of ['route', 'shortName'] as const) {
}
}
/**
/**
* 入口优先级:运行时 manifest > package.json 的 uj.entry > VITE_<SHORT>_SUBAPP_URL。
* 入口优先级:运行时 manifest > VITE_<SHORT>_SUBAPP_URL(dev.mjs 自动注入局域网 IP)> package.json 的 uj.entry(写死 localhost,开发默认)。
* env 优先于 uj.entry 是故意的:局域网共享时 dev.mjs 用 VITE_<SHORT>_SUBAPP_URL 覆盖写死的 localhost,
* 否则同事打开主壳时 wujie 仍按 localhost 去连他自己的机器,子应用模块(/@fs/...)全打回 localhost。
* 返回 undefined 时 MicroApp 显示「未找到子应用入口」,比静默白屏好查。
* 返回 undefined 时 MicroApp 显示「未找到子应用入口」,比静默白屏好查。
*
*
* ⚠️ 生产环境禁止回落到 uj.entry 里的 localhost dev server。
* ⚠️ 生产环境禁止回落到 uj.entry 里的 localhost dev server。
...
...
apps/web/shell/src/theme/design.css
View file @
3e86458
...
@@ -1155,44 +1155,56 @@
...
@@ -1155,44 +1155,56 @@
color
:
#8a94a6
;
color
:
#8a94a6
;
}
}
/* ============ 工作台 Dashboard ============ */
/* ============ 工作台 Dashboard(重设计 2026-11-12) ============
.uj-dash
{
概念:运营驾驶舱首页。真实数据只来自后端分页接口的 total(待我审批 / 我的提交 / 在架门店),
按权限过滤;不展示任何伪造 KPI / 趋势。视觉沿用全站深蓝企业语言,不在首页铺深色大块。 */
.uj-deck
{
display
:
flex
;
display
:
flex
;
flex-direction
:
column
;
flex-direction
:
column
;
gap
:
var
(
--uj-space-module
,
10px
);
gap
:
var
(
--uj-space-module
,
10px
);
}
}
/* 品牌欢迎条:白卡 + 1px 实描边 + 干脆短影。
/* 报头:白卡 + 1px 实描边 + 干脆短影;左缘一道品牌光楔作「命令台」点睛,不铺满整块。 */
旧版的浅蓝渐变底 + 右上角柔光圆斑是「柔、肉」的主要来源,全部去掉;
.uj-deck-hero
{
品牌感交给「小面积渐变方块」一个点睛位承载。 */
.uj-dash-hero
{
position
:
relative
;
position
:
relative
;
overflow
:
hidden
;
overflow
:
hidden
;
border-radius
:
var
(
--uj-radius-card
,
10px
);
border-radius
:
var
(
--uj-radius-card
,
10px
);
padding
:
1
4px
16
px
;
padding
:
1
6px
18
px
;
display
:
flex
;
display
:
flex
;
align-items
:
center
;
align-items
:
center
;
justify-content
:
space-between
;
justify-content
:
space-between
;
gap
:
1
2
px
;
gap
:
1
6
px
;
background
:
#fff
;
background
:
#fff
;
border
:
1px
solid
var
(
--uj-border
,
#e6ebf2
);
border
:
1px
solid
var
(
--uj-border
,
#e6ebf2
);
box-shadow
:
var
(
--uj-shadow-card
);
box-shadow
:
var
(
--uj-shadow-card
);
}
}
.uj-dash-hero-id
{
.uj-deck-hero
::before
{
content
:
''
;
position
:
absolute
;
left
:
0
;
top
:
16px
;
bottom
:
16px
;
width
:
3px
;
border-radius
:
0
3px
3px
0
;
background
:
linear-gradient
(
180deg
,
var
(
--uj-primary
,
#2b5ce6
),
var
(
--uj-brand-light
,
#5b8def
));
box-shadow
:
0
0
10px
-2px
rgba
(
43
,
92
,
230
,
0.6
);
}
.uj-deck-hero-main
{
position
:
relative
;
position
:
relative
;
z-index
:
1
;
z-index
:
1
;
min-width
:
0
;
min-width
:
0
;
}
}
.uj-d
ash-hero
-brand
{
.uj-d
eck
-brand
{
display
:
flex
;
display
:
flex
;
align-items
:
center
;
align-items
:
center
;
gap
:
8px
;
gap
:
8px
;
font-size
:
12px
;
font-size
:
12px
;
letter-spacing
:
1.
4
px
;
letter-spacing
:
1.
2
px
;
font-weight
:
500
;
font-weight
:
500
;
color
:
#2b5ce6
;
color
:
var
(
--uj-primary
,
#2b5ce6
)
;
}
}
.uj-d
ash-hero
-mark
{
.uj-d
eck-brand
-mark
{
width
:
16px
;
width
:
16px
;
height
:
16px
;
height
:
16px
;
border-radius
:
var
(
--uj-radius-sm
,
4px
);
border-radius
:
var
(
--uj-radius-sm
,
4px
);
...
@@ -1200,79 +1212,82 @@
...
@@ -1200,79 +1212,82 @@
background
:
linear-gradient
(
135deg
,
#2b5ce6
,
#5b8def
);
background
:
linear-gradient
(
135deg
,
#2b5ce6
,
#5b8def
);
box-shadow
:
0
2px
6px
rgba
(
43
,
92
,
230
,
0.3
);
box-shadow
:
0
2px
6px
rgba
(
43
,
92
,
230
,
0.3
);
}
}
.uj-d
ash-hero-title
{
.uj-d
eck-greeting
{
font-size
:
2
0
px
;
font-size
:
2
2
px
;
font-weight
:
700
;
font-weight
:
700
;
color
:
#1d2533
;
color
:
var
(
--uj-text-1
,
#1d2533
)
;
line-height
:
1.25
;
line-height
:
1.25
;
margin
:
10px
0
4px
;
margin
:
10px
0
4px
;
}
}
.uj-d
ash-hero
-sub
{
.uj-d
eck
-sub
{
font-size
:
13px
;
font-size
:
13px
;
color
:
#6b7688
;
color
:
var
(
--uj-text-3
,
#8a94a6
)
;
margin
:
0
;
margin
:
0
;
}
}
.uj-d
ash-hero
-meta
{
.uj-d
eck
-meta
{
position
:
relative
;
position
:
relative
;
z-index
:
1
;
z-index
:
1
;
display
:
flex
;
display
:
flex
;
gap
:
10px
;
gap
:
10px
;
flex
:
none
;
flex
:
none
;
}
}
.uj-d
ash-meta-item
{
.uj-d
eck-chip
{
display
:
flex
;
display
:
flex
;
flex-direction
:
column
;
flex-direction
:
column
;
gap
:
3px
;
gap
:
3px
;
min-width
:
132px
;
min-width
:
132px
;
padding
:
8px
12px
;
padding
:
8px
12px
;
border-radius
:
var
(
--uj-radius-md
,
6px
);
border-radius
:
var
(
--uj-radius-md
,
6px
);
background
:
rgba
(
43
,
92
,
230
,
0.05
);
background
:
var
(
--uj-surface-2
,
#f8fafc
);
border
:
1px
solid
rgba
(
43
,
92
,
230
,
0.08
);
border
:
1px
solid
var
(
--uj-border
,
#e6ebf2
);
}
}
.uj-d
ash-meta
-label
{
.uj-d
eck-chip
-label
{
font-size
:
11px
;
font-size
:
11px
;
color
:
#8a94a6
;
color
:
var
(
--uj-text-3
,
#8a94a6
)
;
}
}
.uj-d
ash-meta
-value
{
.uj-d
eck-chip
-value
{
font-size
:
13px
;
font-size
:
13px
;
font-weight
:
600
;
font-weight
:
600
;
color
:
#1d2533
;
color
:
var
(
--uj-text-1
,
#1d2533
)
;
word-break
:
break-all
;
word-break
:
break-all
;
}
}
/*
KPI 行
*/
/*
运营概览:三张真实计数卡片(权限门控,无权限不出现)
*/
.uj-d
ash-kpi
s
{
.uj-d
eck-stat
s
{
display
:
grid
;
display
:
grid
;
grid-template-columns
:
repeat
(
4
,
1
fr
);
grid-template-columns
:
repeat
(
3
,
1
fr
);
gap
:
var
(
--uj-space-module
,
10px
);
gap
:
var
(
--uj-space-module
,
10px
);
}
}
.uj-
kpi
{
.uj-
deck-stat
{
position
:
relative
;
position
:
relative
;
overflow
:
hidden
;
overflow
:
hidden
;
border-radius
:
var
(
--uj-radius-card
,
10px
);
border-radius
:
var
(
--uj-radius-card
,
10px
);
padding
:
16px
;
background
:
#fff
;
border
:
1px
solid
var
(
--uj-border
,
#e6ebf2
);
box-shadow
:
var
(
--uj-shadow-card
);
cursor
:
pointer
;
transition
:
transition
:
transform
0.2s
ease
,
transform
0.2s
ease
,
box-shadow
0.2s
ease
;
box-shadow
0.2s
ease
,
border-color
0.2s
ease
;
text-align
:
left
;
}
}
.uj-kpi
:hover
{
.uj-deck-stat
:hover
{
/* 只抬 1px:hover 反馈保留,但不再「飘」 */
transform
:
translateY
(
-1px
);
transform
:
translateY
(
-1px
);
box-shadow
:
var
(
--uj-shadow-raise
);
box-shadow
:
var
(
--uj-shadow-raise
);
border-color
:
rgba
(
43
,
92
,
230
,
0.4
);
}
}
.uj-kpi-bar
{
.uj-deck-stat
:focus-visible
{
position
:
absolute
;
outline
:
2px
solid
var
(
--uj-brand-light
,
#5b8def
);
left
:
0
;
outline-offset
:
2px
;
top
:
0
;
bottom
:
0
;
width
:
3px
;
border-radius
:
3px
0
0
3px
;
}
}
.uj-
kpi-head
{
.uj-
deck-stat-top
{
display
:
flex
;
display
:
flex
;
align-items
:
center
;
align-items
:
center
;
justify-content
:
space-between
;
justify-content
:
space-between
;
}
}
.uj-
kpi-icon
{
.uj-
deck-stat-ico
{
width
:
36px
;
width
:
36px
;
height
:
36px
;
height
:
36px
;
border-radius
:
var
(
--uj-radius-md
,
6px
);
border-radius
:
var
(
--uj-radius-md
,
6px
);
...
@@ -1281,92 +1296,127 @@
...
@@ -1281,92 +1296,127 @@
justify-content
:
center
;
justify-content
:
center
;
font-size
:
18px
;
font-size
:
18px
;
}
}
.uj-kpi-label
{
.uj-deck-stat--info
.uj-deck-stat-ico
{
margin-top
:
10px
;
background
:
var
(
--uj-info-soft
,
#eef3ff
);
color
:
var
(
--uj-info
,
#2b5ce6
);
}
.uj-deck-stat--success
.uj-deck-stat-ico
{
background
:
var
(
--uj-success-soft
,
#e9f7ef
);
color
:
var
(
--uj-success
,
#16a34a
);
}
.uj-deck-stat--neutral
.uj-deck-stat-ico
{
background
:
var
(
--uj-neutral-soft
,
#f2f4f8
);
color
:
var
(
--uj-text-2
,
#4a5568
);
}
.uj-deck-stat-go
{
font-size
:
12px
;
color
:
var
(
--uj-primary
,
#2b5ce6
);
display
:
flex
;
align-items
:
center
;
gap
:
2px
;
}
.uj-deck-stat-label
{
margin-top
:
12px
;
font-size
:
13px
;
font-size
:
13px
;
color
:
#8a94a6
;
color
:
var
(
--uj-text-3
,
#8a94a6
)
;
}
}
.uj-
kpi
-value
{
.uj-
deck-stat
-value
{
font-size
:
2
6
px
;
font-size
:
2
8
px
;
font-weight
:
700
;
font-weight
:
700
;
color
:
#1d2533
;
color
:
var
(
--uj-text-1
,
#1d2533
)
;
line-height
:
1.
2
;
line-height
:
1.
15
;
margin-top
:
2px
;
margin-top
:
2px
;
font-variant-numeric
:
tabular-nums
;
}
}
.uj-kpi-delta
{
.uj-deck-stat-value.is-loading
{
color
:
transparent
;
border-radius
:
var
(
--uj-radius-sm
,
4px
);
background
:
linear-gradient
(
90deg
,
#eef1f6
25%
,
#f6f8fb
37%
,
#eef1f6
63%
);
background-size
:
400%
100%
;
animation
:
uj-deck-shimmer
1.3s
ease-in-out
infinite
;
min-height
:
32px
;
max-width
:
120px
;
}
.uj-deck-stat-value.is-error
{
font-size
:
22px
;
color
:
var
(
--uj-text-4
,
#b3bac7
);
}
.uj-deck-stat-retry
{
margin-top
:
6px
;
margin-top
:
6px
;
font-size
:
12px
;
font-size
:
12px
;
font-weight
:
600
;
color
:
var
(
--uj-primary
,
#2b5ce6
);
display
:
flex
;
background
:
none
;
align-items
:
center
;
border
:
none
;
padding
:
0
;
cursor
:
pointer
;
}
@keyframes
uj-deck-shimmer
{
0
%
{
background-position
:
100%
0
;
}
100
%
{
background-position
:
-100%
0
;
}
}
}
/* 主区:
趋势 + 侧栏
*/
/* 主区:
快捷开始(左,2fr) + 右栏(1fr)
*/
.uj-d
ash
-main
{
.uj-d
eck
-main
{
display
:
grid
;
display
:
grid
;
grid-template-columns
:
2
fr
1
fr
;
grid-template-columns
:
2
fr
1
fr
;
gap
:
var
(
--uj-space-module
,
10px
);
gap
:
var
(
--uj-space-module
,
10px
);
align-items
:
stretch
;
align-items
:
start
;
}
.uj-dash-trend
{
border-radius
:
var
(
--uj-radius-card
,
10px
);
}
}
.uj-d
ash-side
{
.uj-d
eck-launch
{
display
:
flex
;
display
:
flex
;
flex-direction
:
column
;
flex-direction
:
column
;
gap
:
var
(
--uj-space-module
,
10px
);
gap
:
16px
;
}
.uj-dash-side
.ant-card
{
border-radius
:
var
(
--uj-radius-card
,
10px
);
}
/* 底部快捷 */
.uj-dash-foot
{
display
:
grid
;
grid-template-columns
:
repeat
(
4
,
1
fr
);
gap
:
var
(
--uj-space-module
,
10px
);
}
}
.uj-d
ash-foot-item
{
.uj-d
eck-group-title
{
display
:
flex
;
display
:
flex
;
align-items
:
center
;
align-items
:
center
;
justify-content
:
space-between
;
gap
:
8px
;
background
:
#fff
;
font-size
:
12px
;
border
:
1px
solid
var
(
--uj-border
,
#e6ebf2
);
border-radius
:
var
(
--uj-radius-card
,
10px
);
padding
:
12px
14px
;
font-size
:
14px
;
color
:
#1d2533
;
cursor
:
pointer
;
transition
:
all
0.2s
ease
;
}
.uj-dash-foot-item
:hover
{
border-color
:
rgba
(
43
,
92
,
230
,
0.4
);
box-shadow
:
0
4px
12px
-8px
rgba
(
43
,
92
,
230
,
0.5
);
}
/* ============ 工作台 · 欢迎页 ============ */
.uj-welcome-title
{
font-size
:
14px
;
font-weight
:
600
;
font-weight
:
600
;
color
:
#1d2533
;
letter-spacing
:
0.5px
;
color
:
var
(
--uj-text-3
,
#8a94a6
);
margin-bottom
:
10px
;
margin-bottom
:
10px
;
}
}
.uj-welcome-quick
{
.uj-deck-group-title
::before
{
content
:
''
;
width
:
3px
;
height
:
12px
;
border-radius
:
2px
;
background
:
var
(
--uj-brand-light
,
#5b8def
);
}
.uj-deck-quick-grid
{
display
:
grid
;
display
:
grid
;
grid-template-columns
:
repeat
(
auto-fill
,
minmax
(
2
2
0px
,
1
fr
));
grid-template-columns
:
repeat
(
auto-fill
,
minmax
(
2
0
0px
,
1
fr
));
gap
:
var
(
--uj-space-module
,
10px
);
gap
:
var
(
--uj-space-module
,
10px
);
}
}
.uj-quick-card
{
.uj-deck-quick
{
position
:
relative
;
border-radius
:
var
(
--uj-radius-card
,
10px
);
border-radius
:
var
(
--uj-radius-card
,
10px
);
padding
:
16px
;
background
:
#fff
;
border
:
1px
solid
var
(
--uj-border
,
#e6ebf2
);
box-shadow
:
var
(
--uj-shadow-card
);
cursor
:
pointer
;
transition
:
transition
:
transform
0.2s
ease
,
transform
0.2s
ease
,
box-shadow
0.2s
ease
;
box-shadow
0.2s
ease
,
border-color
0.2s
ease
;
text-align
:
left
;
}
}
.uj-
quick-card
:hover
{
.uj-
deck-quick
:hover
{
transform
:
translateY
(
-1px
);
transform
:
translateY
(
-1px
);
box-shadow
:
var
(
--uj-shadow-raise
);
box-shadow
:
var
(
--uj-shadow-raise
);
border-color
:
rgba
(
43
,
92
,
230
,
0.4
);
}
.uj-deck-quick
:focus-visible
{
outline
:
2px
solid
var
(
--uj-brand-light
,
#5b8def
);
outline-offset
:
2px
;
}
}
.uj-
quick-icon
{
.uj-
deck-quick-ico
{
width
:
34px
;
width
:
34px
;
height
:
34px
;
height
:
34px
;
border-radius
:
var
(
--uj-radius-md
,
6px
);
border-radius
:
var
(
--uj-radius-md
,
6px
);
...
@@ -1374,33 +1424,50 @@
...
@@ -1374,33 +1424,50 @@
align-items
:
center
;
align-items
:
center
;
justify-content
:
center
;
justify-content
:
center
;
font-size
:
17px
;
font-size
:
17px
;
background
:
#eef3ff
;
background
:
var
(
--uj-primary-soft
,
#eef3ff
)
;
color
:
#2b5ce6
;
color
:
var
(
--uj-primary
,
#2b5ce6
)
;
margin-bottom
:
10px
;
margin-bottom
:
10px
;
}
}
.uj-quick-label
{
.uj-
deck-
quick-label
{
font-size
:
14px
;
font-size
:
14px
;
font-weight
:
600
;
font-weight
:
600
;
color
:
#1d2533
;
color
:
var
(
--uj-text-1
,
#1d2533
)
;
}
}
.uj-quick-desc
{
.uj-
deck-
quick-desc
{
font-size
:
12px
;
font-size
:
12px
;
color
:
#8a94a6
;
color
:
var
(
--uj-text-3
,
#8a94a6
)
;
line-height
:
1.5
;
line-height
:
1.5
;
margin-top
:
4px
;
margin-top
:
4px
;
min-height
:
36px
;
min-height
:
36px
;
}
}
.uj-quick-go
{
.uj-
deck-
quick-go
{
font-size
:
12px
;
font-size
:
12px
;
color
:
#2b5ce6
;
color
:
var
(
--uj-primary
,
#2b5ce6
)
;
margin-top
:
6px
;
margin-top
:
6px
;
display
:
flex
;
align-items
:
center
;
gap
:
2px
;
}
}
.uj-welcome-sec
{
/* 右栏 */
.uj-deck-rail
{
display
:
flex
;
flex-direction
:
column
;
gap
:
var
(
--uj-space-module
,
10px
);
}
.uj-deck-sec
{
border-radius
:
var
(
--uj-radius-card
,
10px
);
padding
:
14px
18px
;
background
:
#fff
;
border
:
1px
solid
var
(
--uj-border
,
#e6ebf2
);
box-shadow
:
var
(
--uj-shadow-card
);
}
.uj-deck-sec-head
{
display
:
flex
;
display
:
flex
;
align-items
:
center
;
align-items
:
center
;
gap
:
1
4
px
;
gap
:
1
0
px
;
}
}
.uj-
welcome
-sec-icon
{
.uj-
deck
-sec-icon
{
width
:
32px
;
width
:
32px
;
height
:
32px
;
height
:
32px
;
border-radius
:
var
(
--uj-radius-md
,
6px
);
border-radius
:
var
(
--uj-radius-md
,
6px
);
...
@@ -1409,8 +1476,111 @@
...
@@ -1409,8 +1476,111 @@
align-items
:
center
;
align-items
:
center
;
justify-content
:
center
;
justify-content
:
center
;
font-size
:
16px
;
font-size
:
16px
;
background
:
#fff7e6
;
}
color
:
#ba7517
;
.uj-deck-sec--security
.uj-deck-sec-icon
{
background
:
var
(
--uj-warning-soft
,
#fdf3e5
);
color
:
var
(
--uj-warning
,
#d97706
);
}
.uj-deck-sec-title
{
font-size
:
14px
;
font-weight
:
600
;
color
:
var
(
--uj-text-1
,
#1d2533
);
}
.uj-deck-sec-desc
{
font-size
:
12px
;
color
:
var
(
--uj-text-3
,
#8a94a6
);
margin-top
:
2px
;
}
.uj-deck-sec-body
{
margin-top
:
12px
;
}
/* 上架流程指引:竖向步骤 */
.uj-deck-steps
{
display
:
flex
;
flex-direction
:
column
;
margin
:
0
;
padding
:
0
;
list-style
:
none
;
}
.uj-deck-step
{
position
:
relative
;
display
:
grid
;
grid-template-columns
:
24px
1
fr
;
gap
:
12px
;
padding-bottom
:
14px
;
}
.uj-deck-step
:last-child
{
padding-bottom
:
0
;
}
.uj-deck-step-rail
{
position
:
relative
;
display
:
flex
;
justify-content
:
center
;
}
.uj-deck-step-node
{
width
:
24px
;
height
:
24px
;
border-radius
:
50%
;
background
:
var
(
--uj-primary-soft
,
#eef3ff
);
color
:
var
(
--uj-primary
,
#2b5ce6
);
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
font-size
:
13px
;
font-weight
:
600
;
z-index
:
1
;
}
.uj-deck-step
:not
(
:last-child
)
.uj-deck-step-rail
::after
{
content
:
''
;
position
:
absolute
;
top
:
24px
;
bottom
:
-2px
;
width
:
1px
;
background
:
var
(
--uj-border
,
#e6ebf2
);
}
.uj-deck-step-title
{
font-size
:
13px
;
font-weight
:
600
;
color
:
var
(
--uj-text-1
,
#1d2533
);
line-height
:
24px
;
}
.uj-deck-step-desc
{
display
:
block
;
font-size
:
12px
;
color
:
var
(
--uj-text-3
,
#8a94a6
);
margin-top
:
2px
;
}
@media
(
max-width
:
1100px
)
{
.uj-deck-main
{
grid-template-columns
:
1
fr
;
}
.uj-deck-stats
{
grid-template-columns
:
repeat
(
2
,
1
fr
);
}
.uj-deck-hero
{
flex-direction
:
column
;
align-items
:
flex-start
;
padding
:
16px
;
}
.uj-deck-meta
{
width
:
100%
;
}
}
@media
(
max-width
:
640px
)
{
.uj-deck-stats
{
grid-template-columns
:
1
fr
;
}
}
@media
(
prefers-reduced-motion
:
reduce
)
{
.uj-deck-stat
,
.uj-deck-quick
{
transition
:
none
;
}
.uj-deck-stat-value.is-loading
{
animation
:
none
;
}
}
}
/* ============ 个人资料页 ============ */
/* ============ 个人资料页 ============ */
...
@@ -1527,21 +1697,6 @@
...
@@ -1527,21 +1697,6 @@
}
}
@media
(
max-width
:
1100px
)
{
@media
(
max-width
:
1100px
)
{
.uj-dash-kpis
,
.uj-dash-foot
{
grid-template-columns
:
repeat
(
2
,
1
fr
);
}
.uj-dash-main
{
grid-template-columns
:
1
fr
;
}
.uj-dash-hero
{
flex-direction
:
column
;
align-items
:
flex-start
;
padding
:
16px
;
}
.uj-dash-hero-meta
{
width
:
100%
;
}
.uj-profile-grid
{
.uj-profile-grid
{
grid-template-columns
:
1
fr
;
grid-template-columns
:
1
fr
;
}
}
...
...
apps/web/subapps/points/.env.production
0 → 100644
View file @
3e86458
# ---------------------------------------------------------------------------
# 积分域生产构建配置(这个文件入库 —— 只写非密钥的部署契约)
#
# 与 shell/.env.production 同款思路:.env 被 .gitignore 排除,CI 上不存在,
# 所以生产构建(vite build, mode=production)需要的「非密钥项」在此固化;
# 「跟环境走的密钥/地址项」由 CI 注入(process.env 优先级最高,会覆盖本文件)。
#
# 本文件只放安全项。下面四项「跟环境走」的值【必须由构建机环境变量注入】,
# 否则积分域构建出来的包缺少网关配置,运行时会抛「未配置 ... 网关地址」直接崩:
# VITE_POINTS_GATEWAY_ORIGIN 生产 scrm 网关地址(https,必填)
# VITE_POINTS_GATEWAY_APP_KEY 网关 appKey(密钥,CI 注入)
# VITE_POINTS_GATEWAY_SECRET 网关 secret(密钥,CI 注入)
# VITE_POINTS_DJ_GATEWAY_ORIGIN 生产 dj 网关地址(https,必填)
# 取值来源:老系统 temp/scrm-micro-points/src/config/env.*.js;
# appKey / secret 据老系统注释两环境一致,只需提供一次;
# origin 必须与「主壳后端签发 loginToken 的环境」一致,否则每个接口都回 code 21。
#
# 参考模板见同目录 .env.example;dev/test 地址示例(非生产,仅供对照):
# VITE_POINTS_GATEWAY_ORIGIN=https://scrm.dev.glsx.com.cn/
# VITE_POINTS_DJ_GATEWAY_ORIGIN=https://dj.dev.glsx.com.cn/
# ---------------------------------------------------------------------------
# 选填、与环境无关的安全项(与 .env.example 默认值一致)
VITE_POINTS_GATEWAY_VERSION=1.0.0
VITE_POINTS_GATEWAY_FORMAT=json
docs/DEPLOY.md
View file @
3e86458
...
@@ -252,7 +252,7 @@ pnpm release:verify -- --serve dist
...
@@ -252,7 +252,7 @@ pnpm release:verify -- --serve dist
`apps/web/shell/src/runtime-manifest.ts`
在
**主壳启动时**
拉一次
`manifest.json`
(3s 超时、
`cache: 'no-store'`
),
`subapps.ts`
的入口优先级是:
`apps/web/shell/src/runtime-manifest.ts`
在
**主壳启动时**
拉一次
`manifest.json`
(3s 超时、
`cache: 'no-store'`
),
`subapps.ts`
的入口优先级是:
```
```
运行时 manifest >
package.json 的 uj.entry > VITE_<SHORT>_SUBAPP_URL
运行时 manifest >
VITE_<SHORT>_SUBAPP_URL(仅 pnpm dev 时由 dev.mjs 注入局域网 IP) > package.json 的 uj.entry(写死 localhost,开发默认)
```
```
所以换版本只需改那份 JSON。
`MicroApp`
把
`entryOf(shortName)`
的结果作为
`<WujieReact url>`
传给
`startApp`
。
所以换版本只需改那份 JSON。
`MicroApp`
把
`entryOf(shortName)`
的结果作为
`<WujieReact url>`
传给
`startApp`
。
...
...
docs/ops-deploy-guide.md
0 → 100644
View file @
3e86458
# UJ-Admin 运维部署操作手册
> 面向运维:只讲"怎么做 + 必查项 + 出事怎么办"。设计细节见 [`DEPLOY.md`](./DEPLOY.md) / [`ARCHITECTURE.md`](./ARCHITECTURE.md)。
---
## 0. 模型
-
主壳 + 各子应用(system/store/points/usedcar)打成不可变版本目录
`/mfe/<app>/<version>/`
,一份
`manifest.json`
记录各自指向。
-
**发版 = 传新版本目录 + 更新 manifest**
;
**回滚 = manifest 指回旧目录**
;用户需
**整页刷新**
生效。
---
## 1. 首次全量部署
前置配置见 §5。
```
bash
pnpm install
pnpm release:all --no-serve --version 1.0.0
# 产物落 dist/
rsync -a dist/ /var/www/console/
# 勿加 --delete(见 §6)
pnpm release:verify -- --base https://<域名>
# 冒烟(§4)
```
---
## 2. 日常增量发版
```
bash
pnpm release:run
# 自动选模式/解析版本,运维不填参数
```
| 目的 | 命令 |
| --- | --- |
| 指定应用+版本 |
`pnpm release -- --app system --version 1.2.0`
|
| 跨域 CDN |
`... --public-base https://cdn.example.com`
|
| 复用已构建 dist |
`... --skip-build`
|
| 演练 | 任意命令加
`--dry-run`
|
并发保护:设
`MFE_REMOTE_MANIFEST=<线上manifest URL>`
做合并基线,或 CI 层串行。
---
## 3. 回滚
```
bash
pnpm release -- --app system --version 1.1.9 --switch-only
rsync -a dist/mfe/manifest.json /var/www/console/mfe/manifest.json
```
前提:旧版本目录未被删。用户整页刷新即回旧版。
---
## 4. 冒烟检查单(任一不过不发布)
-
[
]
`pnpm release:verify -- --base https://<域名>`
退出码 0
-
[
]
首屏
`/system/role`
、
`/store/import`
正常
-
[
]
资源路径是
`/mfe/<app>/<ver>/assets/...`
(不是
`/assets/...`
)
-
[
]
接口不报
`10011`
(签名在主壳统一处理)
-
[
]
积分域不崩、UI 正常、改完 manifest
**整页刷新**
再验一次
---
## 4.5 构建期密钥(部署"运行不起来"的根因)
**`.env` 与 `keys/*.pem` 是构建期密钥,已烧进 `dist/`,部署服务器上不需要它们。**
起不来是因为
**构建机缺文件→打出了坏包**
。
**已入库(不用管)**
:
`shell/.env.production`
、
`points/.env.production`
(非密钥契约)、两份
`.env.example`
。被 gitignore 的本地
`.env`
仅供开发,生产走
`.env.production`
。
**生产构建仍必需、且无入库替代的两样**
:
1.
签名密钥
`shell/keys/*.pem`
→ 缺则接口报
`10011`
2.
积分域网关 origin/appKey/secret → 缺则积分域加载即崩
**获取方式(二选一)**
方案 A(推荐,零文件):在 CI 注入以下变量,构建自动读取,无需任何 gitignored 文件:
| 变量 | 取值 | 来源 |
| --- | --- | --- |
|
`VITE_CLIENT_PRIVATE_KEY`
|
`client_private.pem`
完整内容 | 本地
`shell/keys/`
或旧仓
`uj-store/.../keys/`
|
|
`VITE_SERVER_PUBLIC_KEY`
|
`server_public.pem`
公钥体(Base64 段)或整 PEM | 同上 |
|
`VITE_POINTS_GATEWAY_ORIGIN`
| 生产 scrm 网关(https) | 老系统
`temp/scrm-micro-points/src/config/env.*.js`
取
**prod**
|
|
`VITE_POINTS_GATEWAY_APP_KEY`
| 生产 appKey(密钥) | 同上(各环境一致,给一次) |
|
`VITE_POINTS_GATEWAY_SECRET`
| 生产 secret(密钥) | 同上 |
|
`VITE_POINTS_DJ_GATEWAY_ORIGIN`
| 生产 dj 网关(https,同环境) | 同上 |
方案 B(无 CI):超人带外发值,运维构建前把两个 PEM 放进
`shell/keys/`
、把积分域 4 个值写进
`points/.env`
(由
`.env.example`
派生)。
> ⚠ **静默坏包**:缺密钥只 warn、不中止构建,且告警仅 `pnpm dev` 打印、生产包无提示。交付前必须确认密钥已就位(CI 日志 grep 变量名非空 / 手动 `ls shell/keys` + `cat points/.env`),否则线上签名/积分全失效且零报错。
---
## 5. 前置一次性配置
1.
**nginx**
(模板见下):
`/mfe/manifest.json`
与
`/index.html`
必须
`no-cache`
;
`/mfe/`
用
`^~`
回落 404(漏则白屏)。
2.
**`.env.production` 两份**
已入库,生产契约已固化。
3.
**密钥**
:见 §4.5(推荐 CI 注入,无 CI 则超人带外交付)。
4.
**站点 root**
指向产物树本身(含
`index.html`
与
`mfe/`
)。
```
nginx
server
{
listen
443
ssl
;
server_name
console.example.com
;
root
/var/www/console
;
location
=
/mfe/manifest.json
{
add_header
Cache-Control
"no-cache"
;
try_files
$uri
=
404
;
}
location
=
/index.html
{
add_header
Cache-Control
"no-cache"
;
}
location
^~
/mfe/
{
add_header
Cache-Control
"public,
max-age=31536000,
immutable"
;
try_files
$uri
$uri
/
=
404
;
}
location
/
{
try_files
$uri
$uri
/
/index.html
;
}
}
```
---
## 6. 两条铁律
-
**禁止 `--delete` / 先清空再拷**
:旧版本目录须原样留在线上(回滚依赖)。
-
**上传必含 `manifest.json`**
:只传版本目录 = 发布不生效。
---
## 7. 事故 → 对策
| 现象 | 对策 |
| --- | --- |
| 子应用白屏 | 查资源路径是否
`/mfe/<app>/<ver>/...`
(§4) |
| 发了看不到新功能 | 让用户
**整页刷新**
|
| 改清单无变化 | 确认 no-cache + 强刷 |
| 多子系统白屏 | 重传全量 manifest;配
`MFE_REMOTE_MANIFEST`
|
| 404 / MIME 错 | root 指向产物树本身 |
---
## 8. 与"局域网共享"改动的关系
`scripts/dev.mjs`
+
`subapps.ts`
的改动
**只作用于 `pnpm dev`**
,生产链路不经过,对部署零影响。唯一注意:生产 CI
**不要**
注入
`VITE_*_SUBAPP_URL`
变量。
---
## 9. 命令速查
| 场景 | 命令 |
| --- | --- |
| 首次全量 |
`pnpm release:all --no-serve --version 1.0.0`
|
| 日常发版 |
`pnpm release:run`
|
| 显式发某应用 |
`pnpm release -- --app system --version 1.2.0`
|
| 回滚 |
`pnpm release -- --app system --version 1.1.9 --switch-only`
|
| 线上自检 |
`pnpm release:verify -- --base https://<域名>`
|
| 清旧版本 |
`pnpm release:prune -- --dir /var/www/console --apply --yes`
|
---
_与 `DEPLOY.md`、`ARCHITECTURE.md` 互补;冲突以仓库代码与 DEPLOY.md 为准。_
packages/ui/src/components/FillTable/index.tsx
View file @
3e86458
...
@@ -23,8 +23,9 @@ import { useScrollbarRemeasure } from '../../hooks/useScrollbarRemeasure';
...
@@ -23,8 +23,9 @@ import { useScrollbarRemeasure } from '../../hooks/useScrollbarRemeasure';
*/
*/
export function FillTable<T extends object = Record<string, unknown>>(props: TableProps<T>) {
export function FillTable<T extends object = Record<string, unknown>>(props: TableProps<T>) {
const { wrapRef, size } = useFillHeight();
const { wrapRef, size } = useFillHeight();
// 只在 scroll.y 落地(表格进入最终滚动形态)后再判定重测时机
// 始终准备重测:细滚动条规则是否注入与 scroll.y 无关,去掉 scrollY 门槛,
const remeasureEpoch = useScrollbarRemeasure(Boolean(size?.scrollY));
// 避免 fillHeight 页面因 scrollY 迟迟不来而从不重测(那样规则晚到就永久错位)。
const remeasureEpoch = useScrollbarRemeasure(true);
return (
return (
<div ref={wrapRef} className="uj-table-fill">
<div ref={wrapRef} className="uj-table-fill">
...
...
packages/ui/src/hooks/useScrollbarRemeasure.ts
View file @
3e86458
...
@@ -4,41 +4,49 @@ import { useEffect, useState } from 'react';
...
@@ -4,41 +4,49 @@ import { useEffect, useState } from 'react';
* 修复 wujie 子应用里「表头操作列宽 ≠ 表体」的错位。
* 修复 wujie 子应用里「表头操作列宽 ≠ 表体」的错位。
*
*
* 根因:rc-table 在挂载时的 useLayoutEffect 里只测一次滚动条宽度(getTargetScrollBarSize),
* 根因:rc-table 在挂载时的 useLayoutEffect 里只测一次滚动条宽度(getTargetScrollBarSize),
* 之后永不重测
。我们给表格加了「document 级细滚动条」规则(让表体滚动条收成 8px),
* 之后永不重测
,还会强制覆盖任何传入的 scrollbarSize prop。我们给表格收细了滚动条
*
但 wujie 把 ui.css 异步注入 shadowRoot 的时机可能晚于表格首次挂载
——
*
(8px),但 dev 模式下 Vite 把细滚动条 CSS 异步注入 <head>,可能晚于 rc-table 首次测量
——
* 于是
测量探针量到的是浏览器原生滚动条(Windows 约 15px),表头据此多预留约 7
px,
* 于是
首次测量量到浏览器原生宽(Windows 约 15px),表头据此预留、而表体随后被收成 8
px,
*
而表体随后被规则收成 8px,表头比表体宽、且不会自愈。CSS 已就位的页面一次量准就对齐,
*
永久差约 5px 且不自愈。CSS 已就位的页面一次量准就对齐,晚到的页面就错位
*
晚到的页面就错位(同一子应用内部分页对齐、部分不对齐,正是路由/分包
加载时序不同)。
*
(同一子应用内部分页对齐、部分不对齐,正是
加载时序不同)。
*
*
* 修法:等细滚动条规则确实进入当前文档(shadowRoot)后,把表格重挂载一次,
* 主修复见 styles/injectThinScrollbar.ts:细滚动条规则改为「模块求值时同步注入」,
* 触发 rc-table 重新测量,此时探针量到的就是 8px,表头/表体一致。
* 必然早于任何表格 render,rc-table 首次测量即量到 8px,从根上消除竞态,通常无需重挂载。
* 已就位的页面重测后仍是 8px(无副作用);规则永远不进文档的极端情况两者都是原生宽也一致。
*
*
* 只在首次挂载后触发一次,之后不再干预,避免无限重挂。
* 本 hook 是「兜底」:处理主修复之外的边缘情况(如 dev HMR 在表格已挂载后才应用样式)。
* 探测信号用 CSS 自定义属性 --uj-scrollbar-injected(injectThinScrollbar 写入 html),
* 而不是去读 ::-webkit-scrollbar 伪元素宽度——后者在无实际滚动内容时浏览器常返回 'auto',
* 会让探测永远 false、重挂载从不触发(这正是上一版不稳定的真因)。
*
* 逻辑:表格挂载后,若规则已就位(首帧即命中)——rc-table 首次测量已是 8px,直接结束不重挂;
* 否则轮询(rAF)直到 --uj-scrollbar-injected=1 就重挂一次,触发 rc-table 重新测量。
* 只在首次挂载后触发一次,之后不再干预。
*/
*/
const
MAX_WAIT_MS
=
5000
;
export
function
useScrollbarRemeasure
(
ready
:
boolean
):
number
{
export
function
useScrollbarRemeasure
(
ready
:
boolean
):
number
{
const
[
epoch
,
setEpoch
]
=
useState
(
0
);
const
[
epoch
,
setEpoch
]
=
useState
(
0
);
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
!
ready
||
epoch
!==
0
)
return
;
if
(
!
ready
||
epoch
!==
0
)
return
;
let
raf1
=
0
;
let
raf
=
0
;
let
raf2
=
0
;
let
timer
=
0
;
let
timer
=
0
;
let
fired
=
false
;
let
fired
=
false
;
const
start
=
Date
.
now
();
const
ruleIsInDocument
=
():
boolean
=>
{
// 可靠信号:injectThinScrollbar 在注入规则的同时给 html 写了 --uj-scrollbar-injected:1。
// 探针一个普通 div,读它的 ::-webkit-scrollbar 宽度(有细滚动条规则则非空,如 "8px");
// 读自定义属性不受「伪元素在计算样式里返回 auto」的干扰,干净可靠。
// Firefox 走 scrollbar-width: thin。两者任一命中即说明规则已进入当前文档。
const
ruleReady
=
():
boolean
=>
{
const
probe
=
document
.
createElement
(
'div'
);
try
{
probe
.
style
.
cssText
=
return
(
'position:absolute;left:-9999px;top:-9999px;width:100px;height:100px;overflow:scroll;'
;
getComputedStyle
(
document
.
documentElement
)
document
.
body
.
appendChild
(
probe
);
.
getPropertyValue
(
'--uj-scrollbar-injected'
)
const
cs
=
getComputedStyle
(
probe
,
'::-webkit-scrollbar'
);
.
trim
()
===
'1'
const
webkitW
=
cs
.
width
;
)
;
const
firefoxW
=
getComputedStyle
(
probe
).
scrollbarWidth
;
}
catch
{
document
.
body
.
removeChild
(
probe
)
;
return
false
;
return
(
!!
webkitW
&&
webkitW
!==
'0px'
&&
webkitW
!==
'auto'
)
||
firefoxW
===
'thin'
;
}
};
};
const
remeasure
=
()
=>
{
const
remeasure
=
()
=>
{
...
@@ -47,18 +55,27 @@ export function useScrollbarRemeasure(ready: boolean): number {
...
@@ -47,18 +55,27 @@ export function useScrollbarRemeasure(ready: boolean): number {
setEpoch
(
1
);
setEpoch
(
1
);
};
};
// 双 rAF:等 wujie 把 shadowRoot 样式注入完成后再判定;再兜底一个超时,
// 首帧即已就位(同步注入已先于表格 render,这是常态):无需重挂,直接结束。
// 防止注入极慢时永远不触发(届时两者都是原生宽,本就一致,重挂无副作用)。
if
(
ruleReady
())
return
;
raf1
=
requestAnimationFrame
(()
=>
{
raf2
=
requestAnimationFrame
(()
=>
{
// 边缘情况(如 HMR 后样式晚到):轮询到信号即重挂载一次,让 rc-table 重新测量。
if
(
ruleIsInDocument
())
remeasure
();
const
tick
=
()
=>
{
});
if
(
ruleReady
())
{
});
remeasure
();
timer
=
window
.
setTimeout
(
remeasure
,
400
);
return
;
}
if
(
Date
.
now
()
-
start
>
MAX_WAIT_MS
)
return
;
// 极端慢加载:放弃,原生=原生已一致
raf
=
requestAnimationFrame
(
tick
);
};
raf
=
requestAnimationFrame
(
tick
);
// 兜底:后台标签 rAF 不触发时,用定时器也推进一次判定。
timer
=
window
.
setTimeout
(()
=>
{
if
(
!
fired
&&
ruleReady
())
remeasure
();
},
MAX_WAIT_MS
);
return
()
=>
{
return
()
=>
{
cancelAnimationFrame
(
raf1
);
cancelAnimationFrame
(
raf
);
cancelAnimationFrame
(
raf2
);
clearTimeout
(
timer
);
clearTimeout
(
timer
);
};
};
},
[
ready
,
epoch
]);
},
[
ready
,
epoch
]);
...
...
packages/ui/src/index.ts
View file @
3e86458
...
@@ -8,6 +8,11 @@
...
@@ -8,6 +8,11 @@
// 样式层:精致度与布局的公共规则。CSS 会随各应用打包进自己的 style-*.css,
// 样式层:精致度与布局的公共规则。CSS 会随各应用打包进自己的 style-*.css,
// 在 wujie 的 shadowRoot 内生效;主壳文档样式表穿不进 shadow DOM,别把规则写回 shell。
// 在 wujie 的 shadowRoot 内生效;主壳文档样式表穿不进 shadow DOM,别把规则写回 shell。
//
// 细滚动条规则改由 injectThinScrollbar 在模块求值时「同步」注入 document.head——
// 因为 Vite dev 下 CSS import 是异步的,会晚于 rc-table 首次滚动条测量,造成表头/表体错位。
// 详见该文件注释。
import
'./styles/injectThinScrollbar'
;
import
'./styles/ui.css'
;
import
'./styles/ui.css'
;
export
{
UApp
}
from
'./components/App'
;
export
{
UApp
}
from
'./components/App'
;
...
...
packages/ui/src/styles/injectThinScrollbar.ts
0 → 100644
View file @
3e86458
/**
* 细滚动条规则「同步注入」。
*
* 为什么不用 CSS import:@uj/ui 的 ui.css 原本通过 `import './styles/ui.css'` 注入,
* 但在 Vite **dev 模式**下 CSS 是异步插入 <head> 的,时机可能晚于 rc-table 首次测量
* —— 于是表格体滚动条被收成 8px、表头却按原生 ~15px 预留,永久错位,且每次刷新随
* 加载时序漂移(同子应用部分页对齐、部分不对齐)。
*
* 这里改为在模块求值(必然早于任何表格组件 render)时同步 append 一条 <style>,
* 让规则在 rc-table 测量前就已落进 document.head,首次测量即量到 8px,从根上消除竞态。
* --uj-scrollbar-injected 是给 useScrollbarRemeasure 的可靠信号(HMR 等边缘情况的兜底)。
*/
const
STYLE_ID
=
'uj-thin-scrollbar'
;
const
RULE
=
`
* {
scrollbar-width: thin;
scrollbar-color: var(--uj-border-strong) transparent;
}
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-thumb {
border-radius: 4px;
background: var(--uj-border-strong);
}
::-webkit-scrollbar-thumb:hover {
background: var(--uj-border-strong);
}
::-webkit-scrollbar-track {
background: transparent;
}
html {
--uj-scrollbar-injected: 1;
}
`
;
export
function
injectThinScrollbar
():
void
{
if
(
typeof
document
===
'undefined'
)
return
;
if
(
document
.
getElementById
(
STYLE_ID
))
return
;
const
style
=
document
.
createElement
(
'style'
);
style
.
id
=
STYLE_ID
;
style
.
setAttribute
(
'data-uj'
,
'thin-scrollbar'
);
style
.
textContent
=
RULE
;
// 同步插入 <head>,早于后续 React 渲染 —— 这是消除竞态的关键。
document
.
head
.
appendChild
(
style
);
}
injectThinScrollbar
();
packages/ui/src/styles/ui.css
View file @
3e86458
...
@@ -415,37 +415,6 @@ body {
...
@@ -415,37 +415,6 @@ body {
min-height
:
var
(
--uj-table-body-h
,
0px
);
min-height
:
var
(
--uj-table-body-h
,
0px
);
overflow-y
:
auto
!important
;
overflow-y
:
auto
!important
;
}
}
/* 表体滚动条收细:默认 15px 的槽在密集表格里太抢眼。
关键:这条规则必须是「document 级、不依赖 .ant-table-body 祖先类」的全局形态,
不能只写在 .uj-table-fill .ant-table-body 上 —— 否则会复现「表头操作列宽 ≠ 表体」错位。
真正的根因(已用 antd 真实 Table headless 复现 + 实测验证):rc-table 在挂载时
用 useLayoutEffect([]) 只测一次滚动条宽度(getTargetScrollBarSize),之后永不重测,
还会强制覆盖任何传入的 scrollbarSize prop。wujie 把 ui.css 注入子应用 shadowRoot 是异步的,
时机受路由/分包影响,可能晚于表格首次挂载 —— 于是首次测量量到浏览器原生宽(Windows 约 15px),
表头据此预留、而表体随后被本规则收成 8px,永久差约 5px 且不自愈。同子应用内 CSS 早到的页
一次量准就对齐,晚到的页错位。
配套修复见 packages/ui/src/hooks/useScrollbarRemeasure.ts:等本规则确实进入文档后强制表格
重挂载一次、触发 rc-table 重测。本规则必须写成全局(而非 scoped),因为 rc-table 的测量探针
是挂在 document.body 上的普通 div,匹配不到 .uj-table-fill .ant-table-body 这类选择器,
只有全局规则才能在重测时让它读到的宽度(8px)= 真实表体的宽度(8px)。 */
*
{
scrollbar-width
:
thin
;
scrollbar-color
:
var
(
--uj-border-strong
)
transparent
;
}
::-webkit-scrollbar
{
width
:
8px
;
height
:
8px
;
}
::-webkit-scrollbar-thumb
{
border-radius
:
4px
;
background
:
var
(
--uj-border-strong
);
}
::-webkit-scrollbar-thumb:hover
{
background
:
var
(
--uj-border-strong
);
}
::-webkit-scrollbar-track
{
background
:
transparent
;
}
/* 工具条:左计数、右动作。原 DataTable 用内联 style 写死 padding/gap,
/* 工具条:左计数、右动作。原 DataTable 用内联 style 写死 padding/gap,
现在收成一个类,三处列表页共用同一套间距。 */
现在收成一个类,三处列表页共用同一套间距。 */
...
...
scripts/dev.mjs
View file @
3e86458
import { spawn, spawnSync } from 'node:child_process';
import { spawn, spawnSync } from 'node:child_process';
import fs from 'node:fs';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { fileURLToPath } from 'node:url';
...
@@ -128,6 +129,48 @@ const GUTTER = ' ';
...
@@ -128,6 +129,48 @@ const GUTTER = ' ';
const entry = apps.find((a) => a.short === 'shell') ?? null;
const entry = apps.find((a) => a.short === 'shell') ?? null;
const entryUrl = entry?.url ?? (entry?.port ? `http://localhost:${entry.port}/` : null);
const entryUrl = entry?.url ?? (entry?.port ? `http://localhost:${entry.port}/` : null);
// ─── 局域网共享模式 ─────────────────────────────────────────────────
// 默认自动探测本机物理网卡 IPv4,把子应用入口通过 VITE_<SHORT>_SUBAPP_URL 注入主壳,
// 覆盖 package.json 里写死的 http://localhost:<port>/(开发默认)。这样同事用
// http://<IP>:5173/ 开主壳时,wujie 会按同一 IP 去拉子应用,而不是连他自己机器。
// · 关闭(纯本地):UJ_DEV_LAN=0
// · 手动指定 IP:UJ_DEV_HOST=192.168.1.50 (跳过自动探测,适合多网卡/ VPN 环境)
const lanRaw = (process.env.UJ_DEV_LAN ?? '1').toLowerCase();
const lanEnabled = lanRaw !== '0' && lanRaw !== 'false' && lanRaw !== 'no';
function getLanIp() {
if (process.env.UJ_DEV_HOST) return process.env.UJ_DEV_HOST;
// 跳过虚拟网卡(WSL / Docker / VMware / VPN / 隧道等),避免选到同事访问不了的地址。
const skipNic =
/wsl|docker|vmnet|virtualbox|vethernet|hyper-?v|tap|tun|wireguard|tailscale|openvpn|zero?tier|utun|ppp|loopback|isatap|teredo|6to4/i;
const cands = [];
for (const [name, list] of Object.entries(os.networkInterfaces())) {
if (!list || skipNic.test(name)) continue;
for (const ni of list) {
if (ni.family !== 'IPv4' || ni.internal) continue;
if (ni.address.startsWith('169.254.')) continue; // link-local,不是真实 LAN
let rank = 3;
if (ni.address.startsWith('192.168.')) rank = 0;
else if (ni.address.startsWith('10.')) rank = 1;
else if (/^172\.(1[6-9]|2\d|3[01])\./.test(ni.address)) rank = 2;
cands.push({ ip: ni.address, rank });
}
}
cands.sort((a, b) => a.rank - b.rank);
return cands[0]?.ip ?? null;
}
const lanHost = lanEnabled ? getLanIp() : null;
const lanEntryUrl = lanHost ? `http://${lanHost}:${entry?.port ?? 5173}/` : null;
// 只给主壳进程注入:subapps.ts 在主壳里读这些 env 推导子应用入口(package.json 优先级低于 env)。
const lanEnv = lanHost
? Object.fromEntries(
apps
.filter((a) => a.short !== 'shell' && a.port)
.map((a) => [`VITE_${a.short.toUpperCase()}_SUBAPP_URL`, `http://${lanHost}:${a.port}/`]),
)
: {};
// ─── 就绪报告面板 ────────────────────────────────────────────────────
// ─── 就绪报告面板 ────────────────────────────────────────────────────
/** 一个应用一种颜色,让日志前缀与面板里的名字对得上。 */
/** 一个应用一种颜色,让日志前缀与面板里的名字对得上。 */
const APP_COLORS = ['36', '35', '32', '34', '33'];
const APP_COLORS = ['36', '35', '32', '34', '33'];
...
@@ -165,6 +208,7 @@ function buildRows(withDir) {
...
@@ -165,6 +208,7 @@ function buildRows(withDir) {
}
}
rows.push('');
rows.push('');
rows.push(`${cyan('▸')} ${bold(entryUrl ?? '(本次未启动 shell,直接访问各应用端口)')}`);
rows.push(`${cyan('▸')} ${bold(entryUrl ?? '(本次未启动 shell,直接访问各应用端口)')}`);
if (lanEntryUrl) rows.push(`${cyan(lanEntryUrl)}`);
rows.push(dim(' Ctrl+C 停止全部进程'));
rows.push(dim(' Ctrl+C 停止全部进程'));
rows.push('');
rows.push('');
return rows;
return rows;
...
@@ -211,7 +255,8 @@ setTimeout(renderPanel, PANEL_TIMEOUT).unref();
...
@@ -211,7 +255,8 @@ setTimeout(renderPanel, PANEL_TIMEOUT).unref();
console.log('');
console.log('');
console.log(
console.log(
`${GUTTER}${dim('▎')} ${dim(`正在启动 ${apps.length} 个 dev server…`)}` +
`${GUTTER}${dim('▎')} ${dim(`正在启动 ${apps.length} 个 dev server…`)}` +
(entryUrl ? ` ${dim('→')} ${cyan(entryUrl)}` : ''),
(entryUrl ? ` ${dim('→')} ${cyan(entryUrl)}` : '') +
(lanEntryUrl ? ` ${dim('· 局域网')} ${cyan(lanEntryUrl)}` : ''),
);
);
const children = [];
const children = [];
...
@@ -222,7 +267,7 @@ for (const a of apps) {
...
@@ -222,7 +267,7 @@ for (const a of apps) {
cwd: ROOT,
cwd: ROOT,
shell: true,
shell: true,
stdio: ['ignore', 'pipe', 'pipe'],
stdio: ['ignore', 'pipe', 'pipe'],
env: { ...process.env, FORCE_COLOR: COLOR ? '1' : '0' },
env: { ...process.env, FORCE_COLOR: COLOR ? '1' : '0'
, ...(a.short === 'shell' ? lanEnv : {})
},
});
});
const tint = colorOf.get(a.short);
const tint = colorOf.get(a.short);
const rail = `${GUTTER}${tint(padEnd(a.short, nameW))} ${dim('│')} `;
const rail = `${GUTTER}${tint(padEnd(a.short, nameW))} ${dim('│')} `;
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment