yggdrasil/pages/admin/settings/
site_section.rs1use leptos::prelude::*;
6
7use super::kit::{use_section, SettingRow, SettingsCard};
8use super::SettingsSection;
9use crate::api::settings::{get_site_settings, update_site_settings};
10use crate::components::forms::FormInput;
11use crate::models::settings::{
12 DEFAULT_HOME_INTRO, DEFAULT_HOME_SUBTITLE, DEFAULT_HOME_TITLE, DEFAULT_SITE_DESCRIPTION,
13};
14
15#[component]
17pub fn SiteSection() -> impl IntoView {
18 let st = use_section(
19 SettingsSection::Site,
20 get_site_settings,
21 update_site_settings,
22 );
23 view! {
24 <SettingsCard
25 section=SettingsSection::Site
26 description="页脚链接、首页开场标语与站点简介,保存后前台立即生效。"
27 ready=st.ready()
28 load_failed=st.load_failed()
29 failed=st.failed()
30 >
31 <SettingRow
32 label="GitHub 链接"
33 html_for="site-github-url"
34 hint="页脚右侧的 GitHub 图标,留空则不展示。可省略 https:// 前缀,保存时自动补全。"
35 >
36 <FormInput
37 id="site-github-url"
38 class="field settings-mono"
39 placeholder="github.com/你的用户名"
40 value=st.field(|d| d.github_url.clone())
41 oninput=move |v: String| st.edit(|d| d.github_url = v)
42 />
43 </SettingRow>
44 <SettingRow label="标语第一行" html_for="site-home-title">
45 <FormInput
46 id="site-home-title"
47 maxlength=40
48 placeholder=DEFAULT_HOME_TITLE
49 value=st.field(|d| d.home_title.clone())
50 oninput=move |v: String| st.edit(|d| d.home_title = v)
51 />
52 </SettingRow>
53 <SettingRow
54 label="标语第二行"
55 html_for="site-home-subtitle"
56 hint="首页开场的两行标题,第二行为浅色。标题留空时使用默认文案;只填第一行则只显示一行。"
57 >
58 <FormInput
59 id="site-home-subtitle"
60 maxlength=40
61 placeholder=DEFAULT_HOME_SUBTITLE
62 value=st.field(|d| d.home_subtitle.clone())
63 oninput=move |v: String| st.edit(|d| d.home_subtitle = v)
64 />
65 </SettingRow>
66 <SettingRow
67 label="首页简介"
68 html_for="site-home-intro"
69 hint="最多 200 字,换行会合并为空格。"
70 >
71 <FormInput
72 id="site-home-intro"
73 maxlength=200
74 placeholder=DEFAULT_HOME_INTRO
75 value=st.field(|d| d.home_intro.clone())
76 oninput=move |v: String| st.edit(|d| d.home_intro = v)
77 />
78 </SettingRow>
79 <SettingRow
80 label="站点简介"
81 html_for="site-description"
82 hint="一句话介绍本站,显示在友链页的「交换友链」信息里。"
83 >
84 <FormInput
85 id="site-description"
86 maxlength=200
87 placeholder=DEFAULT_SITE_DESCRIPTION
88 value=st.field(|d| d.site_description.clone())
89 oninput=move |v: String| st.edit(|d| d.site_description = v)
90 />
91 </SettingRow>
92 </SettingsCard>
93 }
94}