Skip to content

Commit 0f91ab6

Browse files
authored
feat(web): add laf web site settings (#1526)
1 parent a3d8fc1 commit 0f91ab6

File tree

12 files changed

+156
-229
lines changed

12 files changed

+156
-229
lines changed

web/src/constants/index.ts

-6
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,6 @@ export const Routes = {
7070

7171
export const site_url = {
7272
laf_doc: "https://doc.laf.run/guide/",
73-
laf_forum: "https://forum.laf.run",
74-
laf_business: "https://www.wenjuan.com/s/I36ZNbl",
75-
laf_discord: "https://discord.com/channels/1061659231599738901/1098516786170839050",
76-
laf_wechat: "https://w4mci7-images.oss.laf.run/wechat.png",
77-
laf_status: "https://hnpsxzqqtavv.cloud.sealos.cn/status/laf",
78-
laf_pilot: "https://htr4n1.laf.run/laf-gpt",
7973
laf_github: "https://github.com/labring/laf",
8074
laf_index_video: "https://itceb8-video.oss.laf.run/laf-website.mp4",
8175
};

web/src/layouts/Header/index.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ const Header = (props: { className?: string }) => {
3131
const navList_right = [
3232
{
3333
text: t("HomePage.NavBar.docs"),
34-
ref: siteSettings.site_url?.metadata.laf_doc || site_url.laf_doc,
34+
ref: site_url.laf_doc,
3535
icon: <DocIcon boxSize={5} />,
3636
},
3737
{
3838
text: t("HomePage.NavBar.forum"),
39-
ref: siteSettings.site_url?.metadata.laf_forum || site_url.laf_forum,
39+
ref: siteSettings.laf_forum_url?.value,
4040
icon: <ChatIcon boxSize={5} />,
4141
},
4242
];
@@ -77,6 +77,7 @@ const Header = (props: { className?: string }) => {
7777

7878
<HStack spacing={4}>
7979
{navList_right.map((item) => {
80+
if (!item.ref) return null;
8081
return (
8182
<span
8283
key={item.text}

web/src/pages/app/functions/mods/AIChatPanel/index.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { v4 as uuidv4 } from "uuid";
88

99
import { LafAILogoIcon } from "@/components/CommonIcon";
1010
import Markdown from "@/components/Markdown";
11-
import { site_url } from "@/constants";
1211

1312
import useSiteSettingStore from "@/pages/siteSetting";
1413

@@ -79,7 +78,7 @@ export default function AIChatPanel() {
7978
const { data: generateCodeRes, ...generateCode } = useMutation((params: any) => {
8079
inputRef.current?.focus();
8180
return axios({
82-
url: siteSettings.site_url?.metadata.laf_pilot || site_url.laf_pilot,
81+
url: siteSettings.ai_pilot_url?.value,
8382
method: "POST",
8483
data: params,
8584
cancelToken: source.token,

web/src/pages/app/functions/mods/DebugPanel/index.tsx

+29-13
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import useFunctionCache from "@/hooks/useFunctionCache";
3636
import useHotKey, { DEFAULT_SHORTCUTS } from "@/hooks/useHotKey";
3737
import useCustomSettingStore from "@/pages/customSetting";
3838
import useGlobalStore from "@/pages/globalStore";
39+
import useSiteSettingStore from "@/pages/siteSetting";
3940

4041
const HAS_BODY_PARAMS_METHODS: (TMethod | undefined)[] = ["POST", "PUT", "PATCH", "DELETE"];
4142

@@ -45,6 +46,8 @@ export default function DebugPanel(props: { containerRef: any }) {
4546
useFunctionStore((state: any) => state);
4647
const updateDebugFunctionMutation = useUpdateDebugFunctionMutation();
4748
const globalStore = useGlobalStore((state) => state);
49+
const siteSettings = useSiteSettingStore((state) => state.siteSettings);
50+
console.log(siteSettings);
4851

4952
const functionCache = useFunctionCache();
5053

@@ -71,12 +74,6 @@ export default function DebugPanel(props: { containerRef: any }) {
7174
},
7275
);
7376

74-
const tabContent = [
75-
{ text: t("FunctionPanel.InterfaceDebug") },
76-
{ text: "Laf Pilot" },
77-
{ text: t("FunctionPanel.versionHistory") },
78-
];
79-
8077
const methods_tab = [
8178
{
8279
label: "Query",
@@ -170,18 +167,35 @@ export default function DebugPanel(props: { containerRef: any }) {
170167
mx={3}
171168
borderBottom={darkMode ? "" : "2px solid #F6F8F9"}
172169
>
173-
{tabContent.map((tab, index) => (
170+
<Tab
171+
_selected={{
172+
borderColor: "primary.500",
173+
color: darkMode ? "white !important" : "#262A32 !important",
174+
}}
175+
style={{ color: "#7B838B", margin: "-1px 8px", padding: "0 0", fontWeight: 500 }}
176+
>
177+
{t("FunctionPanel.InterfaceDebug")}
178+
</Tab>
179+
{!!siteSettings.ai_pilot_url?.value && (
174180
<Tab
175-
key={index}
176181
_selected={{
177182
borderColor: "primary.500",
178183
color: darkMode ? "white !important" : "#262A32 !important",
179184
}}
180185
style={{ color: "#7B838B", margin: "-1px 8px", padding: "0 0", fontWeight: 500 }}
181186
>
182-
{tab.text}
187+
Laf Pilot
183188
</Tab>
184-
))}
189+
)}
190+
<Tab
191+
_selected={{
192+
borderColor: "primary.500",
193+
color: darkMode ? "white !important" : "#262A32 !important",
194+
}}
195+
style={{ color: "#7B838B", margin: "-1px 8px", padding: "0 0", fontWeight: 500 }}
196+
>
197+
{t("FunctionPanel.versionHistory")}
198+
</Tab>
185199
</TabList>
186200

187201
<TabPanels flex={1} className="overflow-hidden">
@@ -321,9 +335,11 @@ export default function DebugPanel(props: { containerRef: any }) {
321335
</Panel>
322336
</Row>
323337
</TabPanel>
324-
<TabPanel padding={0} h="full">
325-
<AIChatPanel />
326-
</TabPanel>
338+
{!!siteSettings.ai_pilot_url?.value && (
339+
<TabPanel padding={0} h="full">
340+
<AIChatPanel />
341+
</TabPanel>
342+
)}
327343
<TabPanel padding={0} h="full">
328344
<VersionHistoryPanel />
329345
</TabPanel>

web/src/pages/app/setting/UserSetting/index.tsx

+45-45
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {
2121
WalletIcon,
2222
WechatIcon,
2323
} from "@/components/CommonIcon";
24-
import { site_url } from "@/constants";
2524

2625
import useTabMatch from "./useTabMatch";
2726

@@ -131,54 +130,55 @@ export default function UserSetting(props: { name: string; avatar?: string; widt
131130
</SettingModal>
132131
</div>
133132
<Divider />
134-
<div
135-
className={clsx(
136-
"flex h-[42px] w-full cursor-pointer items-center justify-between rounded px-[9px] text-lg",
137-
darkMode
138-
? "!text-white hover:bg-grayModern-600"
139-
: "!text-grayModern-600 hover:bg-[#F4F6F8]",
140-
)}
141-
onClick={() => {
142-
window.open(
143-
siteSettings.site_url?.metadata.laf_business || site_url.laf_business,
144-
"_blank",
145-
);
146-
}}
147-
>
148-
<span className="flex items-center">
149-
<ContactIcon fontSize={20} mr={3} />
150-
{t("HomePage.NavBar.contact")}
151-
</span>
152-
<ChevronRightIcon />
153-
</div>
154-
<div className="flex h-[42px] w-full items-center justify-between px-[9px] text-lg">
155-
<span
133+
{siteSettings.laf_business_url?.value && (
134+
<div
156135
className={clsx(
157-
"flex items-center",
158-
darkMode ? "!text-white" : "!text-grayModern-600",
136+
"flex h-[42px] w-full cursor-pointer items-center justify-between rounded px-[9px] text-lg",
137+
darkMode
138+
? "!text-white hover:bg-grayModern-600"
139+
: "!text-grayModern-600 hover:bg-[#F4F6F8]",
159140
)}
141+
onClick={() => {
142+
window.open(siteSettings.laf_business_url?.value, "_blank");
143+
}}
160144
>
161-
<GroupIcon fontSize={20} mr={3} />
162-
{t("HomePage.NavBar.community")}
163-
</span>
164-
<span>
165-
<a
166-
href={siteSettings.site_url?.metadata.laf_wechat || site_url.laf_wechat}
167-
target="_blank"
168-
rel="noreferrer"
169-
className="mr-2.5"
170-
>
171-
<WechatIcon className="cursor-pointer !text-grayModern-400" fontSize={20} />
172-
</a>
173-
<a
174-
href={siteSettings.site_url?.metadata.laf_discord || site_url.laf_discord}
175-
target="_blank"
176-
rel="noreferrer"
145+
<span className="flex items-center">
146+
<ContactIcon fontSize={20} mr={3} />
147+
{t("HomePage.NavBar.contact")}
148+
</span>
149+
<ChevronRightIcon />
150+
</div>
151+
)}
152+
{(siteSettings.laf_wechat_url?.value || siteSettings.laf_discord_url?.value) && (
153+
<div className="flex h-[42px] w-full items-center justify-between px-[9px] text-lg">
154+
<span
155+
className={clsx(
156+
"flex items-center",
157+
darkMode ? "!text-white" : "!text-grayModern-600",
158+
)}
177159
>
178-
<DiscordIcon className="cursor-pointer !text-grayModern-400" fontSize={20} />
179-
</a>
180-
</span>
181-
</div>
160+
<GroupIcon fontSize={20} mr={3} />
161+
{t("HomePage.NavBar.community")}
162+
</span>
163+
<span>
164+
{siteSettings.laf_wechat_url?.value && (
165+
<a
166+
href={siteSettings.laf_wechat_url?.value}
167+
target="_blank"
168+
rel="noreferrer"
169+
className="mr-2.5"
170+
>
171+
<WechatIcon className="cursor-pointer !text-grayModern-400" fontSize={20} />
172+
</a>
173+
)}
174+
{siteSettings.laf_discord_url?.value && (
175+
<a href={siteSettings.laf_discord_url?.value} target="_blank" rel="noreferrer">
176+
<DiscordIcon className="cursor-pointer !text-grayModern-400" fontSize={20} />
177+
</a>
178+
)}
179+
</span>
180+
</div>
181+
)}
182182
</VStack>
183183
</PopoverBody>
184184
</PopoverContent>

web/src/pages/homepage/contact.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import React from "react";
22
import { useTranslation } from "react-i18next";
33

4-
import { site_url } from "@/constants";
5-
64
import useSiteSettingStore from "../siteSetting";
75

86
type Props = {};
@@ -13,7 +11,7 @@ const Contact = (props: Props) => {
1311
return (
1412
<div className="py-12 pb-2 text-center lg:pb-24 lg:pt-0">
1513
<a
16-
href={siteSettings.site_url?.metadata.laf_business || site_url.laf_business}
14+
href={siteSettings.laf_business_url?.value}
1715
target="_blank"
1816
className=" bg-primary rounded px-16 py-5 text-2xl text-white"
1917
rel="noreferrer"

0 commit comments

Comments
 (0)