首页添加了迁移管理入口按钮, 无需登录即可访问

This commit is contained in:
yourname
2025-05-13 02:38:21 +00:00
parent 224dd72bb8
commit 87682bb7ce
3 changed files with 134 additions and 8 deletions

View File

@@ -347,6 +347,14 @@ export default function({ apiClient, app, moduleDir }: ModuleParams) {
</a>
{/* 迁移管理入口按钮 */}
<a
href="/migrations"
className="w-full flex justify-center py-3 px-4 border border-blue-600 rounded-md shadow-sm text-lg font-medium text-blue-600 bg-white hover:bg-blue-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
>
</a>
{/* 移动端入口按钮 */}
<a
href="/mobile"
@@ -366,21 +374,25 @@ export default function({ apiClient, app, moduleDir }: ModuleParams) {
const createHtmlWithConfig = (scriptConfig: EsmScriptConfig, title = '应用Starter') => {
return (c: HonoContext) => {
const isProd = GLOBAL_CONFIG.ENV === 'production';
const isLocalDeploy = Deno.env.get('IS_LOCAL_DEPLOY') === 'true';
return c.html(
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
{isProd && <meta name="version" content={Deno.env.get('VERSION') || '0.1.0'} />}
<title>{title}</title>
{isProd ? (
{isLocalDeploy ? (
<script type="module" src={scriptConfig.prodSrc || `/client_dist/${scriptConfig.prodPath}`}></script>
) : (
<script src={scriptConfig.src} href={scriptConfig.href} deno-json={scriptConfig.denoJson} refresh={scriptConfig.refresh}></script>
<script src={scriptConfig.src} href={scriptConfig.href} deno-json={scriptConfig.denoJson}
{...isProd ? {}:{ refresh: true }}
></script>
)}
{isProd ? (<script src="/tailwindcss@3.4.16/index.js"></script>) : (<script src="https://cdn.tailwindcss.com"></script>)}
{isLocalDeploy ? (<script src="/tailwindcss@3.4.16/index.js"></script>) : (<script src="https://cdn.tailwindcss.com"></script>)}
<script dangerouslySetInnerHTML={{ __html: `window.CONFIG = ${JSON.stringify(GLOBAL_CONFIG)};` }} />
@@ -436,14 +448,31 @@ export default function({ apiClient, app, moduleDir }: ModuleParams) {
}, GLOBAL_CONFIG.APP_NAME))
honoApp.get('/mobile/*', createHtmlWithConfig({
src: "https://esm.d8d.fun/xb",
href: "/client/mobile/mobile_app.tsx",
denoJson: "/deno.json",
refresh: true,
src: "https://esm.d8d.fun/xb",
href: "/client/mobile/mobile_app.tsx",
denoJson: "/deno.json",
refresh: true,
prodPath: "mobile/mobile_app.js"
}, GLOBAL_CONFIG.APP_NAME))
const staticRoutes = serveStatic({
// 迁移管理路由
honoApp.get('/migrations', createHtmlWithConfig({
src: "https://esm.d8d.fun/xb",
href: "/client/migrations/migrations_app.tsx",
denoJson: "/deno.json",
refresh: true,
prodPath: "migrations/migrations_app.js"
}, GLOBAL_CONFIG.APP_NAME))
honoApp.get('/migrations/*', createHtmlWithConfig({
src: "https://esm.d8d.fun/xb",
href: "/client/migrations/migrations_app.tsx",
denoJson: "/deno.json",
refresh: true,
prodPath: "migrations/migrations_app.js"
}, GLOBAL_CONFIG.APP_NAME))
const staticRoutes = serveStatic({
root: moduleDir,
onFound: async (path: string, c: HonoContext) => {
const fileExt = path.split('.').pop()?.toLowerCase()