mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-09 15:39:24 +08:00
Merge branch 'next' into develop
This commit is contained in:
commit
f5cec39a03
@ -31,6 +31,7 @@ import { MobilePageHeader } from '../../pages/dynamic-page';
|
||||
import { MobilePageContentContainer } from '../../pages/dynamic-page/content/MobilePageContentContainer';
|
||||
import { useStyles } from '../../pages/dynamic-page/header/tabs';
|
||||
import { hideDivider } from '../hideDivider';
|
||||
import { useMobileApp } from '../../mobile';
|
||||
|
||||
export const MobileTabsForMobileActionPage: any = observer(
|
||||
(props) => {
|
||||
@ -39,6 +40,7 @@ export const MobileTabsForMobileActionPage: any = observer(
|
||||
const { activeKey: _activeKey, onChange: _onChange } = useTabsContext() || {};
|
||||
const [activeKey, setActiveKey] = useState(_activeKey);
|
||||
const { componentCls, hashId } = useStyles();
|
||||
const { showBackButton } = useMobileApp();
|
||||
const { goBack } = useBackButton();
|
||||
|
||||
const onChange = useCallback(
|
||||
@ -83,9 +85,11 @@ export const MobileTabsForMobileActionPage: any = observer(
|
||||
<>
|
||||
<MobilePageHeader>
|
||||
<div className={`${componentCls} ${hashId}`} data-testid="mobile-action-page-tabs">
|
||||
<div className="nb-mobile-page-tabs-back-button" onClick={goBack}>
|
||||
<LeftOutline />
|
||||
</div>
|
||||
{showBackButton && (
|
||||
<div className="nb-mobile-page-tabs-back-button" onClick={goBack}>
|
||||
<LeftOutline />
|
||||
</div>
|
||||
)}
|
||||
<DndContext>
|
||||
<Tabs activeKey={activeKey} onChange={onChange} className="nb-mobile-page-tabs-list">
|
||||
{items}
|
||||
|
@ -72,7 +72,7 @@ export class PluginMobileClient extends Plugin {
|
||||
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) {
|
||||
this.options = {};
|
||||
}
|
||||
|
@ -9,11 +9,14 @@
|
||||
|
||||
import { usePlugin } from '@nocobase/client';
|
||||
import React, { FC, createContext } from 'react';
|
||||
import { css } from '@emotion/css';
|
||||
import { PluginMobileClient } from '../index';
|
||||
|
||||
interface MobileAppContextProps {
|
||||
showTabBar?: boolean;
|
||||
setShowTabBar?: (showTabBar: boolean) => void;
|
||||
showBackButton?: boolean;
|
||||
setShowBackButton?: (showBackButton: boolean) => void;
|
||||
}
|
||||
|
||||
export const MobileAppContext = createContext<MobileAppContextProps>(undefined);
|
||||
@ -30,8 +33,25 @@ export const MobileAppProvider: FC<MobileAppProviderProps> = ({ children }) => {
|
||||
_setShowTabBar(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 = () => {
|
||||
|
@ -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();
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
@ -29,5 +29,6 @@
|
||||
"Select time": "选择时间",
|
||||
"Clear": "清空",
|
||||
"Confirm": "确认",
|
||||
"Cancel": "取消"
|
||||
"Cancel": "取消",
|
||||
"Display < back button": "显示 < 返回按钮"
|
||||
}
|
||||
|
@ -100,7 +100,9 @@ const MobileMessagePageInner = () => {
|
||||
return (
|
||||
<MobilePageProvider>
|
||||
<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>
|
||||
<MobilePageContentContainer>
|
||||
<div
|
||||
|
Loading…
x
Reference in New Issue
Block a user