feat: Update build scripts and configurations for client and server environments

This commit is contained in:
2026-01-05 22:54:49 +07:00
parent 0042fd1951
commit 92608b52e2
5 changed files with 34 additions and 23 deletions

View File

@@ -9,13 +9,16 @@ import { cors } from "hono/cors";
import { jwtRpc, rpcServer } from './api/rpc';
import isMobile from 'is-mobile';
import { useAuthStore } from './stores/auth';
import { serveStatic } from "hono/bun";
// import { serveStatic } from "hono/bun";
import { serveStatic } from "hono/serve-static";
import { cssContent } from './lib/primeCssContent';
import { styleTags } from './lib/primePassthrough';
// @ts-ignore
import Base from '@primevue/core/base';
const app = new Hono()
const defaultNames = ['primitive', 'semantic', 'global', 'base', 'ripple-directive']
const isDev = import.meta.env.DEV;
console.log("process.versions?.bun:", (process as any).versions?.bun);
// app.use(renderer)
app.use('*', contextStorage());
app.use(cors(), async (c, next) => {
@@ -27,7 +30,12 @@ app.use(cors(), async (c, next) => {
c.set("isMobile", isMobile({ ua }));
await next();
}, rpcServer);
app.use(serveStatic({ root: "./public" }))
if (!isDev) {
if ((process as any).versions?.bun) {
const { serveStatic } = await import("hono/bun");
app.use(serveStatic({ root: "./dist/client" }))
}
}
app.get("/.well-known/*", (c) => {
return c.json({ ok: true });
});

View File

@@ -1,8 +1,8 @@
<template>
<div class="w-full">
<Toast />
<Form v-slot="$form" :resolver="resolver" :initialValues="initialValues" @submit="onFormSubmit"
class="flex flex-col gap-4 w-full">
<Message v-if="auth.error" severity="error">Failed to sign in. Please check your credentials or try again later.</Message>
<div class="flex flex-col gap-1">
<label for="email" class="text-sm font-medium text-gray-700">Email or Username</label>
<InputText name="email" type="text" placeholder="admin or user@example.com" fluid
@@ -75,23 +75,18 @@ import { Form, type FormSubmitEvent } from '@primevue/forms';
import { zodResolver } from '@primevue/forms/resolvers/zod';
import { z } from 'zod';
import { useAuthStore } from '@/stores/auth';
import Toast from 'primevue/toast';
import { useToast } from "primevue/usetoast";
const t = useToast();
const auth = useAuthStore();
// const $form = Form.useFormContext();
watch(() => auth.error, (newError) => {
if (newError) {
t.add({ severity: 'error', summary: String(auth.error), detail: newError, life: 5000 });
}
});
const initialValues = reactive({
email: '',
password: '',
rememberMe: false
});
watch(() => initialValues, (newValues) => {
auth.error = null;
// console.log('Form values changed:', newValues);
});
const resolver = zodResolver(
z.object({
email: z.string().min(1, { message: 'Email or username is required.' }),