账户登录
This commit is contained in:
1 parent
d8e17fce1d
commit
7dea19f2db
12 files changed
+331
-14
No files matched your search
+18
-5
@@ -6,9 +6,11 @@ import {
|
||||
ChevronDown,
|
||||
FileText,
|
||||
FolderTree,
|
||||
Globe2,
|
||||
HelpCircle,
|
||||
Image,
|
||||
Mail,
|
||||
Menu,
|
||||
Newspaper,
|
||||
PanelsTopLeft,
|
||||
Paintbrush,
|
||||
@@ -30,11 +32,12 @@ import MediaCenter from "./MediaCenter";
|
||||
import LoginPage, { type Account } from "./LoginPage";
|
||||
import SettingsPage from "./SettingsPage";
|
||||
import SeoSettingsPage from "./SeoSettingsPage";
|
||||
import NavigationManager from "./NavigationManager";
|
||||
import { apiPost } from "./api";
|
||||
|
||||
const SITE_WEB = window.location.hostname === "admin.steliro.com" ? "https://site.steliro.com" : "http://localhost:5174";
|
||||
const SITE = "SIT0000000000001";
|
||||
type Section = "products" | "product-categories" | "NEWS" | "NEWS-categories" | "CASE" | "CASE-categories" | "HELP" | "HELP-categories" | "pages" | "seo-settings" | "decoration" | "custom-code" | "media" | "inquiries" | "inquiry-settings" | "settings";
|
||||
type Section = "products" | "product-categories" | "NEWS" | "NEWS-categories" | "CASE" | "CASE-categories" | "HELP" | "HELP-categories" | "pages" | "navigation" | "seo-settings" | "decoration" | "custom-code" | "media" | "inquiries" | "inquiry-settings" | "settings";
|
||||
type EditorialSection = "NEWS" | "CASE" | "HELP";
|
||||
type ContentEditorState = { contentType: EditorialSection; contentCode: string };
|
||||
type Item = {
|
||||
@@ -76,17 +79,21 @@ async function post(path: string, body: unknown) {
|
||||
return apiPost(path, body);
|
||||
}
|
||||
|
||||
const menus = [
|
||||
const frontSiteMenus = [
|
||||
{ key: "pages" as Section, label: "页面", icon: FileText },
|
||||
{ key: "navigation" as Section, label: "菜单导航", icon: Menu },
|
||||
{ key: "decoration" as Section, label: "店铺装修", icon: Paintbrush },
|
||||
{ key: "custom-code" as Section, label: "自定义代码", icon: Code2 },
|
||||
{ key: "seo-settings" as Section, label: "页面 SEO", icon: Search },
|
||||
];
|
||||
const menus = [
|
||||
{ key: "media" as Section, label: "素材中心", icon: Image },
|
||||
{ key: "inquiries" as Section, label: "询盘", icon: Mail },
|
||||
];
|
||||
const sectionLabels: Record<Section, string> = {
|
||||
products: "产品", "product-categories": "产品分类", NEWS: "新闻", "NEWS-categories": "新闻分类",
|
||||
CASE: "案例", "CASE-categories": "案例分类", HELP: "帮助", "HELP-categories": "帮助分类",
|
||||
pages: "页面", decoration: "店铺装修", "custom-code": "自定义代码", media: "素材中心", inquiries: "询盘", "inquiry-settings": "询盘设置",
|
||||
pages: "页面", navigation: "菜单导航", decoration: "店铺装修", "custom-code": "自定义代码", media: "素材中心", inquiries: "询盘", "inquiry-settings": "询盘设置",
|
||||
"seo-settings": "页面 SEO",
|
||||
settings: "系统设置",
|
||||
};
|
||||
@@ -122,6 +129,7 @@ function App({ account, onAccount, onLogout }: { account: Account; onAccount: (v
|
||||
const [editingPage, setEditingPage] = useState<string | null>(resolvePageRoute);
|
||||
const [productMenuOpen, setProductMenuOpen] = useState(true);
|
||||
const [contentMenuOpen, setContentMenuOpen] = useState(true);
|
||||
const [frontSiteMenuOpen, setFrontSiteMenuOpen] = useState(true);
|
||||
const navigateSection = (next: Section) => {
|
||||
setEditingProduct(null);
|
||||
setEditingContent(null);
|
||||
@@ -145,6 +153,8 @@ function App({ account, onAccount, onLogout }: { account: Account; onAccount: (v
|
||||
? { items: [] }
|
||||
: section === "settings"
|
||||
? { items: [] }
|
||||
: section === "navigation"
|
||||
? { items: [] }
|
||||
: section === "products"
|
||||
? await post("/products/list", { siteCode: SITE })
|
||||
: section === "pages"
|
||||
@@ -310,6 +320,10 @@ function App({ account, onAccount, onLogout }: { account: Account; onAccount: (v
|
||||
<button className={["NEWS", "NEWS-categories", "CASE", "CASE-categories", "HELP", "HELP-categories"].includes(section) ? "group-active" : ""} onClick={() => setContentMenuOpen(!contentMenuOpen)}><FolderTree size={18}/>内容<ChevronDown className={contentMenuOpen ? "expanded" : ""} size={16}/></button>
|
||||
{contentMenuOpen && <div className="nav-children content-children"><button className={["NEWS", "NEWS-categories"].includes(section) ? "active" : ""} onClick={() => navigateSection("NEWS")}><Newspaper size={15}/>新闻</button><button className={["CASE", "CASE-categories"].includes(section) ? "active" : ""} onClick={() => navigateSection("CASE")}><PanelsTopLeft size={15}/>案例</button><button className={["HELP", "HELP-categories"].includes(section) ? "active" : ""} onClick={() => navigateSection("HELP")}><HelpCircle size={15}/>帮助</button></div>}
|
||||
</div>
|
||||
<div className="nav-group">
|
||||
<button className={frontSiteMenus.some((item) => item.key === section) ? "group-active" : ""} onClick={() => setFrontSiteMenuOpen(!frontSiteMenuOpen)}><Globe2 size={18}/>前台站<ChevronDown className={frontSiteMenuOpen ? "expanded" : ""} size={16}/></button>
|
||||
{frontSiteMenuOpen && <div className="nav-children front-site-children">{frontSiteMenus.map((item) => <button key={item.key} className={section === item.key ? "active" : ""} onClick={() => navigateSection(item.key)}><item.icon size={15}/>{item.label}</button>)}</div>}
|
||||
</div>
|
||||
{menus.map((m) => (
|
||||
<button
|
||||
key={m.key}
|
||||
@@ -320,7 +334,6 @@ function App({ account, onAccount, onLogout }: { account: Account; onAccount: (v
|
||||
{m.label}
|
||||
</button>
|
||||
))}
|
||||
<button className={section === "seo-settings" ? "active" : ""} onClick={() => navigateSection("seo-settings")}><Search size={18}/>页面 SEO</button>
|
||||
</nav>
|
||||
<div className="aside-bottom">
|
||||
<button>
|
||||
@@ -338,7 +351,7 @@ function App({ account, onAccount, onLogout }: { account: Account; onAccount: (v
|
||||
</div>
|
||||
</aside>
|
||||
<main>
|
||||
{section === "settings" ? <SettingsPage account={account} onAccount={onAccount} onLogout={onLogout}/> : section === "seo-settings" ? <SeoSettingsPage/> : section === "decoration" ? <DecorationEditor onBack={() => navigateSection("pages")}/> : section === "custom-code" ? <CustomCodeManager/> : section === "media" ? <MediaCenter/> : editingProduct !== null ? <ProductEditor productCode={editingProduct || undefined} onBack={closeProductEditor} /> : editingContent !== null ? <ContentEditor contentType={editingContent.contentType} contentCode={editingContent.contentCode || undefined} onBack={closeContentEditor} /> : editingPage !== null ? <PageEditor pageCode={editingPage || undefined} onBack={closePageEditor}/> : <>
|
||||
{section === "settings" ? <SettingsPage account={account} onAccount={onAccount} onLogout={onLogout}/> : section === "seo-settings" ? <SeoSettingsPage/> : section === "navigation" ? <NavigationManager/> : section === "decoration" ? <DecorationEditor onBack={() => navigateSection("pages")}/> : section === "custom-code" ? <CustomCodeManager/> : section === "media" ? <MediaCenter/> : editingProduct !== null ? <ProductEditor productCode={editingProduct || undefined} onBack={closeProductEditor} /> : editingContent !== null ? <ContentEditor contentType={editingContent.contentType} contentCode={editingContent.contentCode || undefined} onBack={closeContentEditor} /> : editingPage !== null ? <PageEditor pageCode={editingPage || undefined} onBack={closePageEditor}/> : <>
|
||||
{section.endsWith("-categories") ? <CategoryManager contentType={section === "NEWS-categories" ? "NEWS" : section === "CASE-categories" ? "CASE" : section === "HELP-categories" ? "HELP" : undefined}/> : <>
|
||||
<header>
|
||||
<div>
|
||||
|
||||
Reference in new issue
Block a user