@realtek/core-theme-live

中文文档
0.0.481发布于 2026/11/02UNLICENSEDESM + CJS

RealTek CORE-THEME -共享React组件和管理屏幕库(AddFormV1, EditFormV1, ListView, DetailViewV1,…)。

中文使用文档
文档目录4 节
  1. 本地设置和提交检查
  2. 页面的验证处理(内置)
  3. 保护您自己的页面(可选)
  4. 自定义屏幕( AuthGuard / withAuthGuard 道具(所有可选)

核心主题

核心主题1

本地设置和提交检查

克隆repo后,运行:

npm run setup

这将安装依赖项 npm ci 并配置Git使用共享的 .githooks/pre-commit 钩。钩子在每个组件测试之前运行受影响的组件测试 提交。

如果已经安装了依赖项,运行:

npm run install:hooks

npm run dev, npm test, npm run build 同时刷新钩子设置 自动。Git钩子是本地机器设置,所以是CI和分支保护 保留最终执行权。

页面的验证处理(内置)

当这个库中的页面(例如: AdminPage, JobsListPage)被打开 没有登录会话,数据api拒绝使用401和页面 否则将呈现空("no module")而不作任何解释。

这个问题已经解决了 在包装内 -每个导出的页面都已经包装好了 带着一个真正的守卫。主机应用会 没有什么:只是路由到页面,如果 它是在没有会话的情况下打开的,用户看到的是清晰的 “你还没有登录 这个会话。请登录以访问数据。” 屏幕上有 登录 按钮。

import { BrowserRouter, Routes, Route } from 'react-router-dom';
import { AdminPage } from '@realtek/core-theme';
import '@realtek/core-theme/style.css';

export default function App() {
  return (
    <BrowserRouter>
      <Routes>
        {/* opened without login → shows the "not logged in" screen automatically */}
        <Route path="/admin" element={<AdminPage />} />
      </Routes>
    </BrowserRouter>
  );
}

保护您自己的页面(可选)

对于宿主应用构建的任何自定义页面,都会导出相同的保护:

import { AuthGuard, withAuthGuard } from '@realtek/core-theme';

// wrap inline…
<AuthGuard><MyPage /></AuthGuard>

// …or bake it into your own component, like the library does:
const MyGuardedPage = withAuthGuard(MyPage);

自定义屏幕(AuthGuard / withAuthGuard 道具(所有可选)

道具默认的目的
title"You're not logged in"错误屏幕上的标题。
message"You haven't logged into this session. Please login to access the data."到场。
loginPath"/login"其中Login按钮发送用户。
loginLabel"Go to Login"登录按钮文本。
onLogin- - - - - -自定义处理程序的登录按钮(覆盖) loginPath)。
fallback- - - - - -渲染你自己的屏幕,而不是默认的。

守卫重新检查会话的登录、注销、选项卡焦点和 交叉表 storage 更改,因此它显示/隐藏内容而无需重新加载。

谢谢

版本与发布记录

@realtek/core-theme-live 共发布 141 个版本,首次发布于 2026/08/24;过去 12 个月发布了 141 个版本。

版本发布日期距今
0.0.481latest2026/11/021 天前
0.0.4802026/11/021 天前
0.0.4792026/10/295 天前
0.0.4782026/10/285 天前
0.0.4772026/10/285 天前
0.0.4762026/10/286 天前

关于 @realtek/core-theme-live 的常见问题

@realtek/core-theme-live 是什么?

RealTek CORE-THEME -共享React组件和管理屏幕库(AddFormV1, EditFormV1, ListView, DetailViewV1,…)。

如何安装 @realtek/core-theme-live?

在项目目录运行 npm install @realtek/core-theme-live,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=18)、react-dom(>=18)、react-router-dom(>=6)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@realtek/core-theme-live 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/realtek__core-theme-live 是否存在。

@realtek/core-theme-live 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@realtek/core-theme-live 可以商用吗?

@realtek/core-theme-live 使用 UNLICENSED 许可。作者声明为 UNLICENSED,即不授予公开使用许可(与公共领域的 Unlicense 不同)。使用前需获得作者授权。以上为概括,不构成法律意见,请以许可原文为准。

@realtek/core-theme-live 还在维护吗?

最新版本 0.0.481 发布于 2026/11/02(1 天前);至今共发布 141 个版本,其中过去 12 个月发布了 141 个;首次发布于 2026/08/24。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。