diff --git a/src/index.ts b/src/index.ts
index fcd3133..c28fb10 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,44 +1,49 @@
-import { Hono } from 'hono'
-import { cors } from 'hono/cors'
-import { Bindings } from './bindings'
-import { LoginView } from './views/login'
-import { AdminView } from './views/admin'
-import { customCors } from './utils/cors'
-import { adminAuth } from './utils/auth'
+import { Hono } from 'hono';
+import { cors } from 'hono/cors';
+import { Bindings } from './bindings';
+import { loginView } from './views/login';
+import { AdminView } from './views/admin';
+import { SettingsView } from './views/settings';
+import { customCors } from './utils/cors';
+import { adminAuth } from './utils/auth';
-import { getComments } from './api/public/getComments'
-import { postComment } from './api/public/postComment'
-import { adminLogin } from './api/admin/login'
-import { deleteComment } from './api/admin/deleteComment'
-import { listComments } from './api/admin/listComments'
-import { updateStatus } from './api/admin/updateStatus'
+import { getComments } from './api/public/getComments';
+import { postComment } from './api/public/postComment';
+import { adminLogin } from './api/admin/login';
+import { deleteComment } from './api/admin/deleteComment';
+import { listComments } from './api/admin/listComments';
+import { updateStatus } from './api/admin/updateStatus';
-const app = new Hono<{ Bindings: Bindings }>()
+const app = new Hono<{ Bindings: Bindings }>();
// 跨域
app.use('/api/*', async (c, next) => {
- const corsMiddleware = customCors(c.env.ALLOW_ORIGIN)
- return corsMiddleware(c, next)
-})
+ const corsMiddleware = customCors(c.env.ALLOW_ORIGIN);
+ return corsMiddleware(c, next);
+});
app.use('/admin/*', async (c, next) => {
- const corsMiddleware = customCors(c.env.ALLOW_ORIGIN)
- return corsMiddleware(c, next)
-})
+ const corsMiddleware = customCors(c.env.ALLOW_ORIGIN);
+ return corsMiddleware(c, next);
+});
// 页面路由
-app.get('/', (c) => c.redirect('/login'))
-app.get('/login', (c) => c.html(LoginView))
-app.get('/admin', (c) => c.html(AdminView))
+app.get('/', (c) => c.redirect('/login'));
+app.get('/login', (c) => {
+ const isDev = new URL(c.req.url).hostname === 'localhost';
+ return c.html(loginView(isDev, c.env.ADMIN_NAME, c.env.ADMIN_PASSWORD));
+});
+app.get('/admin', (c) => c.html(AdminView));
+app.get('/admin/settings', (c) => c.html(SettingsView));
// API
-app.get('/api/comments', getComments)
-app.post('/api/comments', postComment)
+app.get('/api/comments', getComments);
+app.post('/api/comments', postComment);
-app.post('/admin/login', adminLogin)
-app.use('/admin/*', adminAuth)
+app.post('/admin/login', adminLogin);
+app.use('/admin/*', adminAuth);
app.delete('/admin/comments/delete', deleteComment);
app.get('/admin/comments/list', listComments);
app.put('/admin/comments/status', updateStatus);
-export default app
\ No newline at end of file
+export default app;
diff --git a/src/views/admin.ts b/src/views/admin.ts
index 38a268a..e734c26 100644
--- a/src/views/admin.ts
+++ b/src/views/admin.ts
@@ -1,314 +1,339 @@
-import { html } from "hono/html";
+import { html } from 'hono/html';
export const AdminView = html`
-
-
-
-
-
- CWD 评论后台管理系统
-
-
-
-
-
-
+
+
+
+
+
+ CWD 评论后台管理系统
+
+
+
+
+
+
+
+
+
+
+
+ {{ toast.message }}
+
+
-
-
-
-
-
- {{ toast.message }}
-
-
+
+
-
-
-
-
-
-
设置
-
-
-
-
-
-
设置后,文章链接将自动拼接此前缀
-
-
-
-
-
-
-
+
+
+
+
评论管理
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 第 {{ pagination.page }} 页,
- 共 {{ pagination.total }} 页
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+ 第 {{ pagination.page }} 页, 共
+ {{ pagination.total }} 页
+
+
+
+
+
+
+
+
+
+
-
-
-
+ return {
+ ...toRefs(state),
+ fetchComments,
+ updateStatus,
+ confirmDelete,
+ changePage,
+ logout,
+ formatDate,
+ };
+ },
+ }).mount('#app');
+
+
+
`;
diff --git a/src/views/login.ts b/src/views/login.ts
index d63d336..569577e 100644
--- a/src/views/login.ts
+++ b/src/views/login.ts
@@ -1,100 +1,129 @@
-import { html } from "hono/html";
+import { html } from 'hono/html';
-export const LoginView = html`
-
-
-
-
-
- 登录 - CWD 评论后台
-
-
-
-
-
-
+export const loginView = (isDev: boolean, adminName?: string, adminPassword?: string) => html`
+
+
+
+
+
+ 登录 - CWD 评论后台
+
+
+
+
+
+
+
+
+
管理员登录
+
+
{{ error }}
+
+
-
-
-
管理员登录
-
-
{{ error }}
-
-
+
-
-
+ return { ...toRefs(state), handleLogin };
+ },
+ }).mount('#app');
+
+
+
`;
diff --git a/src/views/settings.ts b/src/views/settings.ts
new file mode 100644
index 0000000..390f5b0
--- /dev/null
+++ b/src/views/settings.ts
@@ -0,0 +1,130 @@
+import { html } from 'hono/html';
+
+export const SettingsView = html`
+
+
+
+
+
+ 设置 - CWD 评论后台
+
+
+
+
+
+
+
+
+
+
+
+ {{ toast.message }}
+
+
+
+
+
+
+
+
+ 设置
+
+
+
+
+
设置后,文章链接将自动拼接此前缀
+
+
+
+
+
+
+
+
+
+
+
+`;