feat(portal-shell): v2.0 P0 shadcn standardization + security + streaming + error handling
- shadcn/ui 标准化:废弃纸感令牌,统一 bg-background/text-foreground 等 - Tailwind v4 + @theme inline,移除 tailwind.config.js - React 19 use() + Suspense 流式渲染,首屏骨架秒出 - 三级错误边界:Route → Section → Widget 层层兜底 - 错误上报:useErrorReport → sendBeacon → /api/log mock 端点 - 三层安全边界:L1 角色门禁 / L2 权限点门禁 / L3 数据范围 - 权限位图 base36 压缩:67 权限点 → ~14 字符,JWT 体积减少 ≥ 99% - notify 统一 Toast 封装,禁止业务直接 import sonner - PluginBoundary 替代 PluginLoader(错误边界 + Suspense + Skeleton 三件套) 验证:typecheck 0 错误 / lint 0 错误 / build 6 路由生成成功
This commit is contained in:
@@ -13,7 +13,29 @@ RUN apt-get update && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 安装 rover(Apollo CLI for supergraph composition)
|
||||
RUN curl -sSL https://rover.apollo.dev/nix/v0.30.0 | sh -s -- --install /usr/local/bin
|
||||
# 直接下载 release tarball 解压到 /usr/local/bin(避免 install 脚本参数兼容问题)
|
||||
# tarball 内 rover 位于 dist/rover 子目录
|
||||
RUN curl -sSL -o /tmp/rover.tar.gz https://github.com/apollographql/rover/releases/download/v0.30.0/rover-v0.30.0-x86_64-unknown-linux-gnu.tar.gz && \
|
||||
mkdir -p /tmp/rover-extract && \
|
||||
tar -xzf /tmp/rover.tar.gz -C /tmp/rover-extract && \
|
||||
cp /tmp/rover-extract/dist/rover /usr/local/bin/rover && \
|
||||
chmod +x /usr/local/bin/rover && \
|
||||
rm -rf /tmp/rover.tar.gz /tmp/rover-extract && \
|
||||
rover --version
|
||||
|
||||
# 预下载 supergraph 插件(federation-rs supergraph v2.9.0)
|
||||
# 避免运行时因网络问题(如 GitHub 不可达)导致 rover compose 失败
|
||||
# 插件会被缓存到 /root/.rover/bin/supergraph-v2.9.0
|
||||
RUN APOLLO_ELV2_LICENSE=accept rover supergraph compose --config /dev/null --output /tmp/test-supergraph.graphql 2>&1 || \
|
||||
(echo "[build] Pre-downloading supergraph plugin..." && \
|
||||
curl -sSL -o /tmp/supergraph-plugin.tar.gz \
|
||||
"https://github.com/apollographql/federation-rs/releases/download/supergraph%40v2.9.0/supergraph-v2.9.0-x86_64-unknown-linux-gnu.tar.gz" && \
|
||||
mkdir -p /root/.rover/bin && \
|
||||
tar -xzf /tmp/supergraph-plugin.tar.gz -C /root/.rover/bin/ && \
|
||||
mv /root/.rover/bin/supergraph /root/.rover/bin/supergraph-v2.9.0 2>/dev/null || true && \
|
||||
chmod +x /root/.rover/bin/supergraph-v2.9.0 && \
|
||||
rm -f /tmp/supergraph-plugin.tar.gz /tmp/test-supergraph.graphql && \
|
||||
echo "[build] Supergraph plugin pre-installed")
|
||||
|
||||
# 接受 ELv2 许可
|
||||
ENV APOLLO_ELV2_LICENSE=accept
|
||||
|
||||
48
infra/apollo-router/dev-entrypoint.sh
Normal file
48
infra/apollo-router/dev-entrypoint.sh
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
# Apollo Router 开发态启动脚本
|
||||
#
|
||||
# 与 entrypoint.sh 的差异:
|
||||
# - 跳过子图等待(子图已在 host 上运行)
|
||||
# - 使用 dev-supergraph.yaml(host.docker.internal)
|
||||
# - 容器需 --add-host=host.docker.internal:host-gateway
|
||||
#
|
||||
# 使用:
|
||||
# docker run -d --name edu-apollo-router \
|
||||
# --add-host=host.docker.internal:host-gateway \
|
||||
# -p 3000:3000 -p 8088:8088 \
|
||||
# -v $(pwd)/dev-supergraph.yaml:/dist/supergraph.yaml \
|
||||
# -v $(pwd)/dev-entrypoint.sh:/dist/entrypoint.sh \
|
||||
# -v $(pwd)/router.yaml:/dist/configuration.yaml \
|
||||
# -e ROUTER_AUTH_SECRET=dev-router-secret \
|
||||
# -e APOLLO_ELV2_LICENSE=accept \
|
||||
# ghcr.io/apollographql/router:v1.45.0 \
|
||||
# /dist/entrypoint.sh
|
||||
|
||||
set -e
|
||||
|
||||
echo "[apollo-router:dev] Dev mode - skipping subgraph wait (subgraphs run on host)"
|
||||
|
||||
# 组合 supergraph SDL
|
||||
echo "[apollo-router:dev] Composing supergraph SDL..."
|
||||
export APOLLO_ELV2_LICENSE=accept
|
||||
|
||||
max_compose_retries=5
|
||||
compose_retry=0
|
||||
while [ $compose_retry -lt $max_compose_retries ]; do
|
||||
compose_retry=$((compose_retry + 1))
|
||||
if rover supergraph compose --config /dist/supergraph.yaml --output /tmp/supergraph.graphql 2>&1; then
|
||||
echo "[apollo-router:dev] Supergraph composed successfully"
|
||||
break
|
||||
fi
|
||||
echo "[apollo-router:dev] Compose attempt ${compose_retry}/${max_compose_retries} failed, retrying in 5s..."
|
||||
sleep 5
|
||||
done
|
||||
|
||||
if [ ! -f /tmp/supergraph.graphql ]; then
|
||||
echo "[apollo-router:dev] ERROR: Failed to compose supergraph after ${max_compose_retries} attempts"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 启动 router(router 二进制位于 /dist/router,由基础镜像 ghcr.io/apollographql/router 提供)
|
||||
echo "[apollo-router:dev] Starting Apollo Router on port 3000..."
|
||||
exec /dist/router --config /dist/configuration.yaml --supergraph /tmp/supergraph.graphql --hot-reload
|
||||
48
infra/apollo-router/dev-supergraph.yaml
Normal file
48
infra/apollo-router/dev-supergraph.yaml
Normal file
@@ -0,0 +1,48 @@
|
||||
# Apollo Federation 2 Supergraph 组合配置(开发态 - host 模式)
|
||||
#
|
||||
# 用于本地开发:应用服务跑在 host 上,apollo-router 在 Docker 容器内,
|
||||
# 通过 host.docker.internal 访问 host 上的子图 /graphql 端点。
|
||||
#
|
||||
# 使用:docker run --add-host=host.docker.internal:host-gateway ...
|
||||
#
|
||||
# 与 supergraph.yaml 的差异:routing_url 从容器内服务名改为 host.docker.internal
|
||||
#
|
||||
# 当前可用子图(5 个 TS 服务):
|
||||
# - iam (3002): 用户/RBAC/JWT
|
||||
# - core-edu (3004): 作业/考试/成绩/考勤
|
||||
# - content (3005): 内容管理
|
||||
# - msg (3007): 消息
|
||||
# - config (3011): 插件配置中心(portal-shell 主要数据源)
|
||||
#
|
||||
# 暂不包含的子图:
|
||||
# - classes (3001): 无 GraphQL 模块(仅 REST + gRPC)
|
||||
# - data-ana (3006): Python 服务,无 Federation 子图
|
||||
# - ai (3008): Python 服务,无 Federation 子图
|
||||
|
||||
federation_version: =2.9.0
|
||||
|
||||
subgraphs:
|
||||
iam:
|
||||
routing_url: http://host.docker.internal:3002/graphql
|
||||
schema:
|
||||
subgraph_url: http://host.docker.internal:3002/graphql
|
||||
|
||||
core-edu:
|
||||
routing_url: http://host.docker.internal:3004/graphql
|
||||
schema:
|
||||
subgraph_url: http://host.docker.internal:3004/graphql
|
||||
|
||||
content:
|
||||
routing_url: http://host.docker.internal:3005/graphql
|
||||
schema:
|
||||
subgraph_url: http://host.docker.internal:3005/graphql
|
||||
|
||||
msg:
|
||||
routing_url: http://host.docker.internal:3007/graphql
|
||||
schema:
|
||||
subgraph_url: http://host.docker.internal:3007/graphql
|
||||
|
||||
config:
|
||||
routing_url: http://host.docker.internal:3011/graphql
|
||||
schema:
|
||||
subgraph_url: http://host.docker.internal:3011/graphql
|
||||
Reference in New Issue
Block a user