@realtek/core-theme-live

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

RealTek CORE-THEME — shared React component & admin-screen library (AddFormV1, EditFormV1, ListView, DetailViewV1, ...).

原始使用文档
文档目录4 节
  1. Local setup and commit checks
  2. Auth handling for pages (built in)
  3. Guarding your own pages (optional)
  4. Customizing the screen ( AuthGuard / withAuthGuard props, a…

CORE-THEME

CORE-THEME 1

Local setup and commit checks

After cloning the repo, run:

npm run setup

This installs dependencies with npm ci and configures Git to use the shared .githooks/pre-commit hook. The hook runs impacted component tests before each commit.

If dependencies are already installed, run:

npm run install:hooks

npm run dev, npm test, and npm run build also refresh the hook setup automatically. Git hooks are local machine settings, so CI and branch protection remain the final enforcement.

Auth handling for pages (built in)

When a page from this library (e.g. AdminPage, JobsListPage, …) is opened without a logged-in session, the data APIs reject with a 401 and the page would otherwise render empty ("no module") with no explanation.

This is handled inside the package — every exported page is already wrapped with an auth guard. A host app does nothing: just route to the page, and if it's opened without a session the user sees a clear "You haven't logged into this session. Please login to access the data." screen with a Login button.

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>
  );
}

Guarding your own pages (optional)

The same guard is exported for any custom page the host app builds:

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);

Customizing the screen (AuthGuard / withAuthGuard props, all optional)

PropDefaultPurpose
title"You're not logged in"Heading on the error screen.
message"You haven't logged into this session. Please login to access the data."Sub-text.
loginPath"/login"Where the Login button sends the user.
loginLabel"Go to Login"Login button text.
onLogin—Custom handler for the Login button (overrides loginPath).
fallback—Render your own screen instead of the default one.

The guard re-checks the session live on login, logout, tab focus and cross-tab storage changes, so it reveals/hides content without a reload.

ThankYou

版本与发布记录

@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 和提交记录判断。