fix: display on the PC side of moblie access is incomplete (#2039)
* fix: display on the PC side of moblie access is incomplete * fix: need refresh should work * fix: again * fix: keep 0.1
This commit is contained in:
parent
af37e26640
commit
3332a488ca
@ -2,7 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0, shrink-to-fit=no">
|
<meta name="viewport" content="initial-scale=0.1">
|
||||||
<title>Loading...</title>
|
<title>Loading...</title>
|
||||||
<link rel="apple-touch-icon" sizes="180x180" href="/favicon/apple-touch-icon.png">
|
<link rel="apple-touch-icon" sizes="180x180" href="/favicon/apple-touch-icon.png">
|
||||||
<link rel="icon" type="image/png" sizes="32x32" href="/favicon/favicon-32x32.png">
|
<link rel="icon" type="image/png" sizes="32x32" href="/favicon/favicon-32x32.png">
|
||||||
|
@ -11,7 +11,7 @@ import React, {
|
|||||||
import { css } from '@emotion/css';
|
import { css } from '@emotion/css';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useHistory, useLocation } from 'react-router-dom';
|
import { useHistory, useLocation } from 'react-router-dom';
|
||||||
import { useAPIClient, useCurrentDocumentTitle, useRequest } from '..';
|
import { useAPIClient, useCurrentDocumentTitle, useRequest, useViewport } from '..';
|
||||||
import { useSigninPageExtension } from './SigninPageExtension';
|
import { useSigninPageExtension } from './SigninPageExtension';
|
||||||
import { useForm } from '@formily/react';
|
import { useForm } from '@formily/react';
|
||||||
|
|
||||||
@ -72,6 +72,7 @@ export const useSignIn = (authenticator) => {
|
|||||||
export const SigninPage = () => {
|
export const SigninPage = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
useCurrentDocumentTitle('Signin');
|
useCurrentDocumentTitle('Signin');
|
||||||
|
useViewport();
|
||||||
const signInPages = useContext(SigninPageContext);
|
const signInPages = useContext(SigninPageContext);
|
||||||
const api = useAPIClient();
|
const api = useAPIClient();
|
||||||
const [authenticators, setAuthenticators] = useState<Authenticator[]>([]);
|
const [authenticators, setAuthenticators] = useState<Authenticator[]>([]);
|
||||||
|
@ -2,7 +2,7 @@ import { message } from 'antd';
|
|||||||
import React, { useContext, createContext, FunctionComponent, createElement } from 'react';
|
import React, { useContext, createContext, FunctionComponent, createElement } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Link, useHistory, useLocation, useParams } from 'react-router-dom';
|
import { Link, useHistory, useLocation, useParams } from 'react-router-dom';
|
||||||
import { useAPIClient, useCurrentDocumentTitle } from '..';
|
import { useAPIClient, useCurrentDocumentTitle, useViewport } from '..';
|
||||||
import { useForm } from '@formily/react';
|
import { useForm } from '@formily/react';
|
||||||
|
|
||||||
export const SignupPageContext = createContext<{
|
export const SignupPageContext = createContext<{
|
||||||
@ -58,6 +58,7 @@ function useQuery() {
|
|||||||
|
|
||||||
export const SignupPage = () => {
|
export const SignupPage = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
useViewport();
|
||||||
useCurrentDocumentTitle('Signup');
|
useCurrentDocumentTitle('Signup');
|
||||||
const query = useQuery();
|
const query = useQuery();
|
||||||
const authType = query.get('authType');
|
const authType = query.get('authType');
|
||||||
|
1
packages/core/client/src/hooks/index.ts
Normal file
1
packages/core/client/src/hooks/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from './useViewport';
|
44
packages/core/client/src/hooks/useViewport.ts
Normal file
44
packages/core/client/src/hooks/useViewport.ts
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import { useEffect, useRef } from 'react';
|
||||||
|
|
||||||
|
const useViewportMeta = () => {
|
||||||
|
const contentRef = useRef<string>('initial-scale=0.1');
|
||||||
|
const metaRef = useRef<HTMLMetaElement>();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let meta = document.querySelector<HTMLMetaElement>('meta[name="viewport"]');
|
||||||
|
if (meta) {
|
||||||
|
contentRef.current = meta.content;
|
||||||
|
} else {
|
||||||
|
meta = document.createElement('meta');
|
||||||
|
meta.name = 'viewport';
|
||||||
|
}
|
||||||
|
if (meta) {
|
||||||
|
meta.content = 'width=device-width, initial-scale=1, user-scalable=0';
|
||||||
|
metaRef.current = meta;
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const restore = () => {
|
||||||
|
if (metaRef.current) {
|
||||||
|
metaRef.current.content = contentRef.current;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
metaRef,
|
||||||
|
restore,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export function useViewport() {
|
||||||
|
const { metaRef, restore } = useViewportMeta();
|
||||||
|
useEffect(() => {
|
||||||
|
if (!metaRef.current) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
document.head.insertBefore(metaRef.current, document.head.firstChild);
|
||||||
|
return () => {
|
||||||
|
restore();
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
}
|
@ -29,3 +29,4 @@ export * from './schema-items';
|
|||||||
export * from './settings-form';
|
export * from './settings-form';
|
||||||
export * from './system-settings';
|
export * from './system-settings';
|
||||||
export * from './user';
|
export * from './user';
|
||||||
|
export * from './hooks';
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { ActionContextProvider, AdminProvider, RemoteSchemaComponent, useRoute } from '@nocobase/client';
|
import { ActionContextProvider, AdminProvider, RemoteSchemaComponent, useRoute, useViewport } from '@nocobase/client';
|
||||||
import { css, cx } from '@emotion/css';
|
import { css, cx } from '@emotion/css';
|
||||||
import { useInterfaceContext } from './InterfaceProvider';
|
import { useInterfaceContext } from './InterfaceProvider';
|
||||||
import { DrawerProps, ModalProps } from 'antd';
|
import { DrawerProps, ModalProps } from 'antd';
|
||||||
@ -73,6 +73,9 @@ const MApplication: React.FC = (props) => {
|
|||||||
const Provider = useMemo(() => {
|
const Provider = useMemo(() => {
|
||||||
return interfaceContext ? React.Fragment : AdminProvider;
|
return interfaceContext ? React.Fragment : AdminProvider;
|
||||||
}, [interfaceContext]);
|
}, [interfaceContext]);
|
||||||
|
|
||||||
|
useViewport();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Provider>
|
<Provider>
|
||||||
<MobileCore>
|
<MobileCore>
|
||||||
|
Loading…
Reference in New Issue
Block a user