@hindom-tech/strapi-shared
v1.1.2
Published
Hindom 系列 Strapi v5 站点共享的后台汉化与通用配置(admin / server)
Readme
@hindom-tech/strapi-shared
Hindom 系列 Strapi v5 站点共享的后台汉化与通用配置,方便快速复用到新网站。
公开发布在 npm(@hindom-tech/strapi-shared),安装零配置、无需 token。
提供的能力
- 后台汉化:补齐 Strapi v5 自带 zh-Hans 语言包缺失的文案(首页、仪表盘小组件、引导教程、内容管理器、个人资料页等)。
- 默认简体中文:首次访问即为
zh-Hans,启用语言['zh-Hans', 'en'],已手动切换语言的用户保留其选择。 - 更干净的界面:关闭视频教程(
tutorials: false)与新版本发布通知(notifications.releases: false)。 - 隐藏「设置」菜单:对非超级管理员隐藏侧边栏「设置」入口。
- 反代支持:
server配置内置url(PUBLIC_URL)与proxy(IS_PROXIED),适配 Cloudflare Tunnel / 反向代理。
安装
npm install @hindom-tech/strapi-shared公共 npm 包,无需
.npmrc、无需 token。
用法
后台 src/admin/app.tsx
import { createAdminConfig } from '@hindom-tech/strapi-shared/admin';
export default createAdminConfig({
brand: {
title: '站点管理后台',
workplace: '内容管理系统',
welcomeTitle: '欢迎回来!',
welcomeSubtitle: '请登录内容管理系统',
homeSubtitle: '欢迎使用管理后台',
},
navRestrictionClassPrefix: 'somesite', // 多站点 CSS / 缓存键隔离,用站点名
});可选参数(均有合理默认):
| 参数 | 默认 | 说明 |
|------|------|------|
| brand | — | 站点品牌文案 |
| locales | ['zh-Hans','en'] | 启用的界面语言 |
| defaultLocale | 'zh-Hans' | 首次访问默认语言 |
| hideSettingsForNonSuperAdmin | true | 对非超管隐藏「设置」菜单 |
| disableTutorials | true | 关闭视频教程 |
| disableReleaseNotifications | true | 关闭版本发布通知 |
| extraTranslations | {} | 站点特有 / 覆盖翻译(按 locale) |
| navRestrictionClassPrefix | 'strapi-shared' | 多站点 CSS / 缓存键隔离前缀 |
服务端 config/server.ts
import type { Core } from '@strapi/strapi';
import { createServerConfig } from '@hindom-tech/strapi-shared/server';
export default ({ env }: Core.Config.Shared.ConfigParams): Core.Config.Server =>
createServerConfig(env, { defaultPort: 1337 });开发
npm install
npm run build # tsc 编译到 dist/(ESM 产物)发布到 npm
需要 @hindom-tech 组织的发布权限。两种方式任选其一:
A. 本地发布
npm login # 登录有 @hindom-tech 组织权限的账号
npm version patch # 升版本号并打 tag
npm publish # publishConfig.access=public,prepare 钩子自动 build
git push && git push --tagsB. GitHub Actions 自动发布(推荐)
在仓库 Settings → Secrets 添加 NPM_TOKEN(npm 自动化令牌,具备发布权限),然后:
git tag v1.1.0 && git push origin v1.1.0工作流(.github/workflows/publish.yml)会自动 build 并发布到 npm。
升级(消费项目)
npm update @hindom-tech/strapi-shared