diff --git a/packages/core/client/src/acl/Configuration/ConfigureCenter.tsx b/packages/core/client/src/acl/Configuration/ConfigureCenter.tsx index e16349098d..dfb491ec0a 100644 --- a/packages/core/client/src/acl/Configuration/ConfigureCenter.tsx +++ b/packages/core/client/src/acl/Configuration/ConfigureCenter.tsx @@ -54,7 +54,6 @@ export const SettingsCenterConfigure = () => { const api = useAPIClient(); const compile = useCompile(); const settings = app.pluginSettingsManager.getList(false); - console.log(settings); const allAclSnippets = app.pluginSettingsManager.getAclSnippets(); const [snippets, setSnippets] = useState([]); const allChecked = useMemo( diff --git a/packages/core/client/src/application/PluginSettingsManager.ts b/packages/core/client/src/application/PluginSettingsManager.ts index d50d3d2c21..38c575e3d2 100644 --- a/packages/core/client/src/application/PluginSettingsManager.ts +++ b/packages/core/client/src/application/PluginSettingsManager.ts @@ -33,6 +33,7 @@ export interface PluginSettingOptions { sort?: number; aclSnippet?: string; link?: string; + isTopLevel?: boolean; [index: string]: any; } @@ -147,6 +148,7 @@ export class PluginSettingsManager { .sort((a, b) => (a.sort || 0) - (b.sort || 0)); const { title, icon, aclSnippet, ...others } = pluginSetting; return { + isTopLevel: name === pluginSetting.topLevelName, ...others, aclSnippet: this.getAclSnippet(name), title, diff --git a/packages/core/client/src/pm/PluginSetting.tsx b/packages/core/client/src/pm/PluginSetting.tsx index 96577e8a63..c97404ab33 100644 --- a/packages/core/client/src/pm/PluginSetting.tsx +++ b/packages/core/client/src/pm/PluginSetting.tsx @@ -81,11 +81,24 @@ export const AdminSettingsLayout = () => { if (!settings || !settings.length) { return '/admin'; } - const first = settings[0]; - if (first.children?.length) { - return getFirstDeepChildPath(first.children); + + if (settings.filter((item) => item.isTopLevel).length === 1) { + // 如果是外链类型的,需要跳转外链,如果是内页则返回内页 path + const pluginSetting = settings.find((item) => item.isTopLevel); + // 如果仅有 1 个,且是外链类型的,跳转到 /admin + // @see https://nocobase.height.app/inbox/T-5038 + return pluginSetting.link ? '/admin' : pluginSetting.path; } - return first.path; + + function find(settings: PluginSettingsPageType[]) { + const first = settings.find((item) => !item.link); // 找到第一个非外链类型的 + if (first.children?.length) { + return getFirstDeepChildPath(first.children); + } + return first; + } + + return find(settings).path; }, []); const settingsMapByPath = useMemo>(() => { @@ -120,6 +133,12 @@ export const AdminSettingsLayout = () => { if (location.pathname === currentTopLevelSetting.path && currentTopLevelSetting.children?.length > 0) { return ; } + + // 如果是外链类型的,需要跳转并返回到上一个页面 + if (currentSetting.link) { + return ; + } + return (
diff --git a/packages/plugins/@nocobase/plugin-mobile/src/client/mobile-layout/mobile-tab-bar/MobileTabBar.tsx b/packages/plugins/@nocobase/plugin-mobile/src/client/mobile-layout/mobile-tab-bar/MobileTabBar.tsx index e4daa8de1a..56420cae82 100644 --- a/packages/plugins/@nocobase/plugin-mobile/src/client/mobile-layout/mobile-tab-bar/MobileTabBar.tsx +++ b/packages/plugins/@nocobase/plugin-mobile/src/client/mobile-layout/mobile-tab-bar/MobileTabBar.tsx @@ -10,13 +10,14 @@ import React, { FC, useCallback } from 'react'; import { SafeArea } from 'antd-mobile'; import 'antd-mobile/es/components/tab-bar/tab-bar.css'; +import { Navigate } from 'react-router-dom'; import { useStyles } from './styles'; import { useMobileRoutes } from '../../mobile-providers'; import { getMobileTabBarItemSchema, MobileTabBarItem } from './MobileTabBar.Item'; import { MobileTabBarPage, MobileTabBarLink } from './types'; -import { cx, DndContext, DndContextProps, SchemaComponent, useDesignable, css } from '@nocobase/client'; +import { cx, DndContext, DndContextProps, SchemaComponent, useDesignable, css, useApp } from '@nocobase/client'; import { MobileTabBarInitializer } from './initializer'; import { isInnerLink } from '../../utils'; @@ -32,6 +33,8 @@ export const MobileTabBar: FC & { Page: typeof MobileTabBarPage; Link: typeof MobileTabBarLink; } = ({ enableTabBar = true }) => { + const app = useApp(); + const hasAuth = app.pluginSettingsManager.hasAuth('mobile'); const { styles } = useStyles(); const { designable } = useDesignable(); const { routeList, activeTabBarItem, resource, refresh } = useMobileRoutes(); @@ -53,6 +56,10 @@ export const MobileTabBar: FC & { [resource, refresh], ); + if (!hasAuth) { + return ; + } + if (!enableTabBar) { return null; } diff --git a/packages/plugins/@nocobase/plugin-mobile/src/server/collections/mobileRoutes.ts b/packages/plugins/@nocobase/plugin-mobile/src/server/collections/mobileRoutes.ts index e31e47ffd7..e5592e20a0 100644 --- a/packages/plugins/@nocobase/plugin-mobile/src/server/collections/mobileRoutes.ts +++ b/packages/plugins/@nocobase/plugin-mobile/src/server/collections/mobileRoutes.ts @@ -10,8 +10,8 @@ import { defineCollection } from '@nocobase/database'; export default defineCollection({ - key: 'd1za29o7irk', name: 'mobileRoutes', + dumpRules: 'required', title: 'mobileRoutes', inherit: false, hidden: false, diff --git a/packages/plugins/@nocobase/plugin-mobile/src/server/plugin.ts b/packages/plugins/@nocobase/plugin-mobile/src/server/plugin.ts index f017972026..8b01c3274f 100644 --- a/packages/plugins/@nocobase/plugin-mobile/src/server/plugin.ts +++ b/packages/plugins/@nocobase/plugin-mobile/src/server/plugin.ts @@ -10,19 +10,12 @@ import { Plugin } from '@nocobase/server'; export class PluginMobileServer extends Plugin { - async afterAdd() {} - - async beforeLoad() {} - - async load() {} - - async install() {} - - async afterEnable() {} - - async afterDisable() {} - - async remove() {} + async load() { + this.app.acl.registerSnippet({ + name: `pm.${this.name}`, + actions: ['mobileRoutes:*'], + }); + } } export default PluginMobileServer;