diff --git a/admin-views/public/scripts/loading.js b/admin-views/public/scripts/loading.js
index 49464ad6..f6391efd 100644
--- a/admin-views/public/scripts/loading.js
+++ b/admin-views/public/scripts/loading.js
@@ -6,31 +6,31 @@ window.$owl.appLoader = () => {
const color = settings?.system_theme_setting?.themeColor || '#1C1C1C'
const loader = `
-
`
diff --git a/admin-views/src/lang/en/index.ts b/admin-views/src/lang/en/index.ts
index 94e30a3f..2dcc4dfb 100644
--- a/admin-views/src/lang/en/index.ts
+++ b/admin-views/src/lang/en/index.ts
@@ -25,5 +25,6 @@ export default {
need_save: 'Current configuration is not saved',
save_btn: 'Save Configuration',
cancel_btn: 'Cancel',
+ save_success: 'Save success',
}
}
diff --git a/admin-views/src/lang/zh_CN/index.ts b/admin-views/src/lang/zh_CN/index.ts
index 5c6fe91a..6749afe5 100644
--- a/admin-views/src/lang/zh_CN/index.ts
+++ b/admin-views/src/lang/zh_CN/index.ts
@@ -25,5 +25,6 @@ export default {
need_save: '当前配置未保存',
save_btn: '保存配置',
cancel_btn: '取消',
+ save_success: '保存成功',
}
}
diff --git a/admin-views/src/layouts/DoubleLayout/index.tsx b/admin-views/src/layouts/DoubleLayout/index.tsx
index 466b44cb..5c0c38b5 100644
--- a/admin-views/src/layouts/DoubleLayout/index.tsx
+++ b/admin-views/src/layouts/DoubleLayout/index.tsx
@@ -16,17 +16,15 @@ const {Header, Sider, Content} = Layout
export const DoubleLayout = () => {
const [collapsed, setCollapsed] = useState(false)
- const {routes} = useRoute()
+ const {routes, getCurrentRoute} = useRoute()
const history = useHistory()
const pathname = history.location.pathname
const [selectedKeys, setSelectedKeys] = useState([])
const [childrenRoutes, setChildrenRoutes] = useState()
- const flattenRoutes = useMemo(() => getFlattenRoutes(routes) || [], [routes])
-
function updateMenuStatus() {
- const current = flattenRoutes.find((r) => r.path.replace(/\?.*$/, '') === history.location.pathname)
+ const current = getCurrentRoute()
if (!current) {
return
@@ -52,7 +50,7 @@ export const DoubleLayout = () => {
}
const initChildrenRoutes = () => {
- const currentRoute = flattenRoutes.find((r) => r.path === pathname)
+ const currentRoute = getCurrentRoute()
if (currentRoute?.meta.parents.length) {
setChildrenRoutes(getTopRoute(currentRoute).children)
} else {
diff --git a/admin-views/src/layouts/TopLayout/index.tsx b/admin-views/src/layouts/TopLayout/index.tsx
index 778db2ea..dc7f169f 100644
--- a/admin-views/src/layouts/TopLayout/index.tsx
+++ b/admin-views/src/layouts/TopLayout/index.tsx
@@ -5,7 +5,7 @@ import LayoutContent from '@/layouts/components/LayoutContent'
import LayoutFooter from '@/layouts/components/LayoutFooter'
import LayoutTopBar from '@/layouts/components/LayoutTopBar'
-const {Header, Footer, Content} = Layout
+const {Header, Content} = Layout
const TopLayout = () => {
return (
diff --git a/admin-views/src/layouts/components/LayoutMenu/index.tsx b/admin-views/src/layouts/components/LayoutMenu/index.tsx
index 74c618d0..954a1177 100644
--- a/admin-views/src/layouts/components/LayoutMenu/index.tsx
+++ b/admin-views/src/layouts/components/LayoutMenu/index.tsx
@@ -23,7 +23,7 @@ const LayoutMenu = (
const pathname = history.location.pathname
const currentComponent = qs.parseUrl(pathname).url.slice(1)
- const {routes, defaultRoute} = useRoute()
+ const {routes, defaultRoute, getCurrentRoute} = useRoute()
const defaultSelectedKeys = [currentComponent || defaultRoute]
const paths = (currentComponent || defaultRoute)?.split('/')
const defaultOpenKeys = paths?.slice(0, paths.length - 1)
@@ -36,7 +36,7 @@ const LayoutMenu = (
const flattenRoutes = useMemo(() => getFlattenRoutes(customRoutes) || [], [customRoutes])
function updateMenuStatus() {
- const current = flattenRoutes.find((r) => r.path.replace(/\?.*$/, '') === pathname)
+ const current = getCurrentRoute()
if (!current) {
return
@@ -44,7 +44,9 @@ const LayoutMenu = (
const _parents = current.meta.parents.map((p) => p.path)
- setSelectedKeys([current.path, ..._parents])
+ const getListPath = (path: string) => path.replace(/\/create$|\/:id\/edit$|\/:id$/g, '')
+
+ setSelectedKeys([current.path, getListPath(current.path), ..._parents])
if (mode == 'inline') {
setOpenKeys([...openKeys, ..._parents])
diff --git a/admin-views/src/layouts/components/SettingPanel/index.tsx b/admin-views/src/layouts/components/SettingPanel/index.tsx
index 7d592ee1..2fb47ae0 100644
--- a/admin-views/src/layouts/components/SettingPanel/index.tsx
+++ b/admin-views/src/layouts/components/SettingPanel/index.tsx
@@ -1,4 +1,4 @@
-import {Alert, Button, ColorPicker, Drawer, Form, Space} from 'antd'
+import {Alert, Button, ColorPicker, Drawer, Form, message, Space} from 'antd'
import useStore from '@/hooks/useStore'
import {useLang} from '@/hooks/useLang'
import SelectLayout from '@/layouts/components/SettingPanel/components/SelectLayout'
@@ -6,6 +6,8 @@ import useTheme from '@/hooks/useTheme'
import useSetting from '@/hooks/useSetting'
import {useHistory} from 'react-router-dom'
import {appLoaded, getCacheKey} from '@/utils/common'
+import {useRequest} from 'ahooks'
+import {saveSettings} from '@/service/api'
const SettingPanel = () => {
const history = useHistory()
@@ -44,8 +46,15 @@ const SettingPanel = () => {
}
}
- const save = () => {
- // localStorage.setItem(getCacheKey('settings'), JSON.stringify(res.data))
+ const save = useRequest(saveSettings, {
+ manual: true,
+ onSuccess: () => {
+ message.success(t('theme_setting.save_success'))
+ }
+ })
+
+ const submit = () => {
+ save.run({system_theme_setting: settings.system_theme_setting})
}
return (
@@ -55,7 +64,7 @@ const SettingPanel = () => {
title={t('theme_setting.title')}
footer={(
-
+
)}>
diff --git a/admin-views/src/layouts/index.tsx b/admin-views/src/layouts/index.tsx
index b879285a..0f5a03db 100644
--- a/admin-views/src/layouts/index.tsx
+++ b/admin-views/src/layouts/index.tsx
@@ -1,6 +1,5 @@
import React, {useEffect, useState} from 'react'
import useRoute from '@/routes'
-import {getFlattenRoutes} from '@/routes/helpers'
import {useHistory} from 'react-router'
import DefaultLayout from '@/layouts/DefaultLayout'
import LayoutContent from '@/layouts/components/LayoutContent'
@@ -14,14 +13,14 @@ import useSetting from '@/hooks/useSetting'
import {appLoaded} from '@/utils/common'
const Layout = () => {
- const {routes} = useRoute()
+ const {getCurrentRoute} = useRoute()
const history = useHistory()
const pathname = history.location.pathname
const isSmallScreen = useSmallScreen()
const [isSm, setIsSm] = useState(isSmallScreen)
const {getSetting} = useSetting()
- const currentRoute = getFlattenRoutes(routes).find((route) => route.path.replace(/\?.*$/, '') === history.location.pathname)
+ const currentRoute = getCurrentRoute()
if (currentRoute?.is_full) {
return (
@@ -31,7 +30,7 @@ const Layout = () => {
)
}
- const RenderLayout = (mode: string) => {
+ const RenderLayout = (mode:string) => {
switch (mode) {
case 'default':
return