Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/components/SiteNav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const navMenu = computed<DropdownOption[]>(() => [
{
key: "logout",
label: t("nav.logout"),
show: statusStore.loginStatus,
show: statusStore.loginStatus && config.public.hasPassword,
icon: renderIcon("icon:logout"),
props: {
onClick: () => {
Expand Down
1 change: 1 addition & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const siteConfig = {
showLink: process.env.SHOW_LINK === "true" || true,
platform: process.env.DEPLOYMENT_PLATFORM || "cloudflare",
version: pkg.version,
hasPassword: !!process.env.SITE_PASSWORD,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

当前 !!process.env.SITE_PASSWORD 的逻辑在 SITE_PASSWORD 环境变量仅包含空格(例如 " ")时,hasPassword 会被设为 true。这可能不是预期的行为,因为一个只包含空格的密码通常被认为是无效的。建议在检查之前先对字符串进行 trim() 操作,以处理这种边缘情况,增强代码的健壮性。

Suggested change
hasPassword: !!process.env.SITE_PASSWORD,
hasPassword: !!process.env.SITE_PASSWORD?.trim(),

};

export default defineNuxtConfig({
Expand Down