Skip to content

美化管理前端,修改服务端默认数据库为SQLite || Beautify the management front-end and modify the default database of the server to SQLite#3602

Closed
zjhcx wants to merge 4 commits into
walinejs:mainfrom
zjhcx:main

Conversation

@zjhcx
Copy link
Copy Markdown

@zjhcx zjhcx commented May 19, 2026

概述

美化 Waline 的管理前端,优化服务端的本地开发体验。本地未配置任何存储环境变量时,服务端会自动回退并使用本地 SQLite 数据库

详情

1. 美化管理前端

重构了管理后端的顶栏,加入了更现代的用户头像显示。移除了硬编码的 /ui 前缀,引入 getUiPath 工具函数来动态计算基础路径,使管理前端更稳定。重构了头像构建逻辑,当检测到默认或无效头像时,会自动生成一个优雅的、带有用户首字母的 SVG 渐变数据占位图,提升视觉一致性。将原先的分散代理合并为统一的 /api 代理,切换样式引入方式(从 .scss 改为原生的 .css)。

2. 服务端默认数据库优化

packages/server/development.js 中增加了环境变量检测。本地开发(pnpm run server:dev)若未检测到任何主流数据库配置,将默认启用本地 SQLite(路径为 ../../data),并自动提供默认的 JWT_TOKEN。同步更新了中英文的贡献指南(contribution.md)提示信息,并在 .env.example 中补充了 SQLite 的配置示例,同时在 .gitignore 中忽略了本地自动生成的 data/ 目录。

3. 其他

  • 修复了 akismetmathjax 服务中的部分插件加载与函数命名规范问题。

截图

截屏2026-05-19 21 55 48 截屏2026-05-19 21 56 41

Overview

Beautify the management front-end of Waline and optimize the local development experience on the server side. When no storage environment variables are configured locally, the server will automatically fall back and use the local SQLite database.

Details

1. Beautify the management front-end

The top bar of the admin backend has been restructured and a more modern user avatar display has been added. The hard-coded /ui prefix is ​​removed, and the getUiPath utility function is introduced to dynamically calculate the base path, making the management front-end more stable. The avatar construction logic has been restructured. When a default or invalid avatar is detected, an elegant SVG gradient data placeholder image with the user's initials will be automatically generated to improve visual consistency. Merge the original distributed agents into a unified /api agent, and switch the style import method (from .scss to native .css).

2. Server-side default database optimization

Added environment variable detection in packages/server/development.js. If no mainstream database configuration is detected for local development (pnpm run server:dev), local SQLite will be enabled by default (path is ../../data) and the default JWT_TOKEN will be automatically provided. Synchronously updated the Chinese and English contribution guide (contribution.md) prompt information, and added SQLite configuration examples in .env.example, while ignoring the locally automatically generated data/ directory in .gitignore.

3. Others

  • Fixed some plug-in loading and function naming convention issues in akismet and mathjax services.

Screenshot

Screenshot 2026-05-19 21 55 48 Screenshot 2026-05-19 21 56 41

@github-actions github-actions Bot changed the title 美化管理前端,修改服务端默认数据库为SQLite 美化管理前端,修改服务端默认数据库为SQLite || Beautify the management front-end and modify the default database of the server to SQLite May 19, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes Waline’s admin UI and improves local server development by auto-falling back to SQLite when no storage backend is configured.

Changes:

  • Refactors admin UI routing to avoid hard-coded /ui paths and refreshes the header/avatar UI styling.
  • Updates the server dashboard middleware to optionally serve a local admin bundle and adjusts avatar proxying to skip data: URIs.
  • Enhances local dev (server:dev) to default to SQLite + a dev JWT token, and updates docs/examples/ignores accordingly.

Reviewed changes

Copilot reviewed 28 out of 31 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
pnpm-lock.yaml Lockfile updates (patchedDependencies structure + Node types peer changes).
packages/server/src/service/markdown/mathjax.js Registers MathJax HTML handler for proper adaptor behavior.
packages/server/src/service/avatar.js Changes default avatar generation and adds SVG data-URI fallback.
packages/server/src/service/akismet.js Refactors Akismet export to a named function.
packages/server/src/middleware/dashboard.js Adds local admin bundle serving and dynamic script injection.
packages/server/src/logic/base.js Avoids proxying data: avatar URLs.
packages/server/src/controller/user.js Avoids proxying data: avatar URLs in user listing paths.
packages/server/src/controller/token.js Avoids proxying data: avatar URLs in token responses.
packages/server/src/controller/comment.js Avoids proxying data: avatar URLs when formatting comments.
packages/server/development.js Adds storage env detection + default SQLite/JWT_TOKEN for local dev.
packages/admin/vite.config.ts Simplifies dev proxy to a unified /api backend and binds host.
packages/admin/src/utils/ui.js Introduces getUiPath helper to compute UI base paths dynamically.
packages/admin/src/style/style.css Tweaks legacy style rules used by admin UI.
packages/admin/src/style/index.css Adds CSS entry file that imports normalize/grid/style/custom.
packages/admin/src/style/custom.css Adds modernized admin UI styling (header/layout/forms/tables).
packages/admin/src/pages/user/index.jsx Updates avatar rendering to use the new buildAvatar signature.
packages/admin/src/pages/register/index.jsx Removes hard-coded /ui navigation/routes via getUiPath.
packages/admin/src/pages/profile/index.jsx Uses buildAvatar for profile avatar and improves avatar button markup.
packages/admin/src/pages/manage-comments/utils.js Replaces gravatar hashing with SVG fallback avatar builder.
packages/admin/src/pages/manage-comments/index.jsx Updates comment avatar rendering to use new buildAvatar signature.
packages/admin/src/pages/login/index.jsx Switches auth navigation links to getUiPath and adds captcha hook usage.
packages/admin/src/pages/forgot/index.jsx Switches navigation links to getUiPath.
packages/admin/src/index.jsx Switches style entry to CSS and adds root/body classes for layout.
packages/admin/src/components/icon/index.js Replaces SVG React imports with inline SVG strings rendered via dangerouslySetInnerHTML.
packages/admin/src/components/Header.jsx Rebuilds the top bar/nav, uses getUiPath, and adds avatar display.
packages/admin/src/App.jsx Reworks routes to use getUiPath and improves auth redirect handling.
packages/admin/index.html Sets default serverURL to /api/ and initializes oauthServices.
docs/src/en/advanced/contribution.md Documents SQLite fallback behavior for server:dev.
docs/src/advanced/contribution.md Documents SQLite fallback behavior for server:dev (ZH).
.gitignore Ignores local data/ directory and error.log.
.env.example Adds SQLite/JWT examples and fixes PostgreSQL env var typos.
Files not reviewed (2)
  • packages/admin/src/components/icon/index.js: Language not supported
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +13
const buildFallbackAvatarDataUri = (name = '', size = 40) => {
const label = (typeof name === 'string' ? name.trim().charAt(0) : '').toUpperCase() || 'W';
const fontSize = Math.round(size * 0.42);
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" viewBox="0 0 ${size} ${size}">
<defs>
<linearGradient id="walineAvatarGradient" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" stop-color="#0f6bff" />
<stop offset="100%" stop-color="#55b1ff" />
</linearGradient>
</defs>
<circle cx="${size / 2}" cy="${size / 2}" r="${size / 2}" fill="url(#walineAvatarGradient)" />
<text x="50%" y="50%" fill="#ffffff" font-family="Avenir Next, SF Pro Display, Segoe UI, PingFang SC, sans-serif" font-size="${fontSize}" font-weight="700" text-anchor="middle" dominant-baseline="central">${label}</text>
</svg>`;
Comment on lines +50 to 55
if (GRAVATAR_STR) {
return env.renderString(GRAVATAR_STR, comment);
}

return env.renderString(gravatarStr, comment);
return buildFallbackAvatarDataUri(comment?.nick);
}
const adminBundlePath = path.resolve(__dirname, '../../../admin/dist/admin.js');

const getUiBasePath = (requestPath = '') =>
requestPath.match(/^(.*?\/ui)(?:\/.*)?$/u)?.[1] || '/ui';
Comment on lines +12 to +25
const uiBasePath = getUiBasePath(ctx.path);
const localAdminAssetPath = `${uiBasePath}/assets/admin.js`;
const localAdminBundleAvailable = fs.existsSync(adminBundlePath);

if (ctx.path === localAdminAssetPath) {
if (!localAdminBundleAvailable) {
ctx.status = 404;
ctx.body = 'Local admin bundle not found';
return;
}

ctx.type = 'js';
ctx.body = fs.createReadStream(adminBundlePath);
return;
Comment thread .env.example
@@ -1,7 +1,11 @@
SQLITE_PATH=./data
JWT_TOKEN=waline-dev-jwt-token
@lizheming
Copy link
Copy Markdown
Collaborator

lizheming commented May 20, 2026

建议这个 PR 能不能辛苦拆分一下,拆成:

  1. 后台前端优化
  2. SQLite 默认改造
  3. 头像处理
  4. 问题修复

拆分一下方便 CR,2和3的改造感觉需要待讨论。现在这个混在一起感觉 CR 的难度比较高


I suggest you split this PR into:

  1. Backend and front-end optimization
  2. SQLite default modification
  3. Avatar processing
  4. Bug fixes

Split it to facilitate CR. The transformation of 2 and 3 feels like it needs to be discussed. Now it feels like CR is more difficult when mixed together

@zjhcx
Copy link
Copy Markdown
Author

zjhcx commented May 20, 2026

建议这个PR不能辛苦拆分一下,拆成:

  1. 后台前端优化
  2. SQLite默认改造
  3. 头像处理
  4. 问题修复

拆分一下方便CR,2和3的改造感觉需要讨论。现在这个混在一起感觉CR的重要性比较高

我建议你将这个 PR 拆分成:

  1. 后端和前端优化
  2. SQLite 默认值修改
  3. 头像处理
  4. 错误修复

将其拆分以方便CR。第2点和第3点的转换感觉需要讨论。现在感觉把它们混合在一起后,CR更难了。

好的


It is recommended that this PR should not be split into two parts:

  1. Backend and front-end optimization
  2. SQLite default modification
  3. Avatar processing
  4. Bug fixes

Split it to facilitate CR. I feel that the transformation of 2 and 3 needs to be discussed. Now when this is mixed together, I feel that CR is more important.

I suggest you split this PR into:

  1. Back-end and front-end optimization
  2. SQLite default value modification
  3. Avatar processing
  4. Bug fixes

Split it to facilitate CR. The conversion between points 2 and 3 feels like it needs to be discussed. Now it feels like after mixing them together, CR becomes more difficult.

Okay

@zjhcx
Copy link
Copy Markdown
Author

zjhcx commented May 20, 2026

建议这个 PR 能不能辛苦拆分一下,拆成:

  1. 后台前端优化
  2. SQLite 默认改造
  3. 头像处理
  4. 问题修复

拆分一下方便 CR,2和3的改造感觉需要待讨论。现在这个混在一起感觉 CR 的难度比较高

I suggest you split this PR into:

  1. Backend and front-end optimization
  2. SQLite default modification
  3. Avatar processing
  4. Bug fixes

Split it to facilitate CR. The transformation of 2 and 3 feels like it needs to be discussed. Now it feels like CR is more difficult when mixed together

已经将后台前端优化拆分到#3603

@zjhcx zjhcx closed this May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants