Merge branch 'next' into develop

This commit is contained in:
nocobase[bot] 2024-12-15 09:51:01 +00:00
commit f5cec39a03
6 changed files with 51 additions and 7 deletions

View File

@ -31,6 +31,7 @@ import { MobilePageHeader } from '../../pages/dynamic-page';
import { MobilePageContentContainer } from '../../pages/dynamic-page/content/MobilePageContentContainer'; import { MobilePageContentContainer } from '../../pages/dynamic-page/content/MobilePageContentContainer';
import { useStyles } from '../../pages/dynamic-page/header/tabs'; import { useStyles } from '../../pages/dynamic-page/header/tabs';
import { hideDivider } from '../hideDivider'; import { hideDivider } from '../hideDivider';
import { useMobileApp } from '../../mobile';
export const MobileTabsForMobileActionPage: any = observer( export const MobileTabsForMobileActionPage: any = observer(
(props) => { (props) => {
@ -39,6 +40,7 @@ export const MobileTabsForMobileActionPage: any = observer(
const { activeKey: _activeKey, onChange: _onChange } = useTabsContext() || {}; const { activeKey: _activeKey, onChange: _onChange } = useTabsContext() || {};
const [activeKey, setActiveKey] = useState(_activeKey); const [activeKey, setActiveKey] = useState(_activeKey);
const { componentCls, hashId } = useStyles(); const { componentCls, hashId } = useStyles();
const { showBackButton } = useMobileApp();
const { goBack } = useBackButton(); const { goBack } = useBackButton();
const onChange = useCallback( const onChange = useCallback(
@ -83,9 +85,11 @@ export const MobileTabsForMobileActionPage: any = observer(
<> <>
<MobilePageHeader> <MobilePageHeader>
<div className={`${componentCls} ${hashId}`} data-testid="mobile-action-page-tabs"> <div className={`${componentCls} ${hashId}`} data-testid="mobile-action-page-tabs">
<div className="nb-mobile-page-tabs-back-button" onClick={goBack}> {showBackButton && (
<LeftOutline /> <div className="nb-mobile-page-tabs-back-button" onClick={goBack}>
</div> <LeftOutline />
</div>
)}
<DndContext> <DndContext>
<Tabs activeKey={activeKey} onChange={onChange} className="nb-mobile-page-tabs-list"> <Tabs activeKey={activeKey} onChange={onChange} className="nb-mobile-page-tabs-list">
{items} {items}

View File

@ -72,7 +72,7 @@ export class PluginMobileClient extends Plugin {
return `${this.router.getBasename()}m`; // `/m` or `/apps/aaa/m`(多应用) return `${this.router.getBasename()}m`; // `/m` or `/apps/aaa/m`(多应用)
} }
async updateOptions(value: { showTabBar?: boolean }) { async updateOptions(value: { showTabBar?: boolean; showBackButton?: boolean }) {
if (!this.options) { if (!this.options) {
this.options = {}; this.options = {};
} }

View File

@ -9,11 +9,14 @@
import { usePlugin } from '@nocobase/client'; import { usePlugin } from '@nocobase/client';
import React, { FC, createContext } from 'react'; import React, { FC, createContext } from 'react';
import { css } from '@emotion/css';
import { PluginMobileClient } from '../index'; import { PluginMobileClient } from '../index';
interface MobileAppContextProps { interface MobileAppContextProps {
showTabBar?: boolean; showTabBar?: boolean;
setShowTabBar?: (showTabBar: boolean) => void; setShowTabBar?: (showTabBar: boolean) => void;
showBackButton?: boolean;
setShowBackButton?: (showBackButton: boolean) => void;
} }
export const MobileAppContext = createContext<MobileAppContextProps>(undefined); export const MobileAppContext = createContext<MobileAppContextProps>(undefined);
@ -30,8 +33,25 @@ export const MobileAppProvider: FC<MobileAppProviderProps> = ({ children }) => {
_setShowTabBar(showTabBar); _setShowTabBar(showTabBar);
mobilePlugin.updateOptions({ showTabBar }); mobilePlugin.updateOptions({ showTabBar });
}; };
const [showBackButton, _setShowBackButton] = React.useState(mobilePlugin.getPluginOptions()?.showBackButton ?? true);
const setShowBackButton = (showBackButton: boolean) => {
_setShowBackButton(showBackButton);
mobilePlugin.updateOptions({ showBackButton });
};
return <MobileAppContext.Provider value={{ showTabBar, setShowTabBar }}>{children}</MobileAppContext.Provider>; return (
<MobileAppContext.Provider value={{ showTabBar, setShowTabBar, showBackButton, setShowBackButton }}>
<span
className={css`
.nb-message-back-action .adm-nav-bar-left {
visibility: ${showBackButton ? 'visible' : 'hidden'};
}
`}
>
{children}
</span>
</MobileAppContext.Provider>
);
}; };
export const useMobileApp = () => { export const useMobileApp = () => {

View File

@ -46,6 +46,23 @@ export const mobilePageSettings = new SchemaSettings({
}; };
}, },
}, },
{
name: 'enableBackAction',
type: 'switch',
useComponentProps() {
const { t } = usePluginTranslation();
const { showBackButton, setShowBackButton } = useMobileApp();
const { refresh } = useDesignable();
return {
title: t('Display < back button'),
checked: showBackButton,
onChange(v) {
setShowBackButton(v);
refresh();
},
};
},
},
], ],
}, },
{ {

View File

@ -29,5 +29,6 @@
"Select time": "选择时间", "Select time": "选择时间",
"Clear": "清空", "Clear": "清空",
"Confirm": "确认", "Confirm": "确认",
"Cancel": "取消" "Cancel": "取消",
"Display < back button": "显示 < 返回按钮"
} }

View File

@ -100,7 +100,9 @@ const MobileMessagePageInner = () => {
return ( return (
<MobilePageProvider> <MobilePageProvider>
<MobilePageHeader> <MobilePageHeader>
<NavBar onBack={() => navigate('/page/in-app-message')}>{title}</NavBar> <NavBar className="nb-message-back-action" onBack={() => navigate('/page/in-app-message')}>
{title}
</NavBar>
</MobilePageHeader> </MobilePageHeader>
<MobilePageContentContainer> <MobilePageContentContainer>
<div <div