提交 8be05b97 作者: 翁进城

使用postcss-pxtorem做全站页面兼容

上级 fbf0bb89
...@@ -3,6 +3,18 @@ ...@@ -3,6 +3,18 @@
"plugins": [ "plugins": [
[ [
"styled-components",{ "ssr":true } "styled-components",{ "ssr":true }
],
[
"styled-components-px2rem",
{
"rootValue": 1,
"unitPrecision": 5,
"propList": ["*"],
"selectorBlackList": [], //排除html样式
"replace": true,
"mediaQuery": false,
"minPixelValue": 0
}
] ]
] ]
} }
\ No newline at end of file
.content{
min-height: 120px;
line-height: 1;
width: 1200px;
position: relative;
margin: 0 auto;
}
\ No newline at end of file
...@@ -3,6 +3,7 @@ import { Layout, Space } from "antd"; ...@@ -3,6 +3,7 @@ import { Layout, Space } from "antd";
import NavHeader from "~/components/NavHeader"; import NavHeader from "~/components/NavHeader";
import FooterView from "~/components/footer"; import FooterView from "~/components/footer";
import {useRouter} from 'next/router' import {useRouter} from 'next/router'
import styles from './index.module.scss';
const { Header, Footer, Content } = Layout; const { Header, Footer, Content } = Layout;
...@@ -58,9 +59,15 @@ export default function LayoutView(props: Props) { ...@@ -58,9 +59,15 @@ export default function LayoutView(props: Props) {
<Header style={headerStyle}> <Header style={headerStyle}>
<NavHeader /> <NavHeader />
</Header> </Header>
<Content style={contentStyle}>{props.children}</Content> <Content className={styles.content}>{props.children}</Content>
{!props.hideFooter && ( {!props.hideFooter && (
<Footer style={router.pathname.includes("home") ? {...footerStyle,...homeStyle} : footerStyle}> <Footer
style={
router.pathname.includes("home")
? { ...footerStyle, ...homeStyle }
: footerStyle
}
>
<FooterView></FooterView> <FooterView></FooterView>
</Footer> </Footer>
)} )}
......
...@@ -2,6 +2,7 @@ import React, { useContext, useEffect, useState } from "react"; ...@@ -2,6 +2,7 @@ import React, { useContext, useEffect, useState } from "react";
import { Modal, Image } from "antd"; import { Modal, Image } from "antd";
import api from "~/api"; import api from "~/api";
import { UserContext } from "~/lib/userProvider"; import { UserContext } from "~/lib/userProvider";
import errImg from "~/assets/errImg";
type Props = { type Props = {
open: boolean; open: boolean;
...@@ -27,6 +28,7 @@ export default function LoginModal(props: Props) { ...@@ -27,6 +28,7 @@ export default function LoginModal(props: Props) {
}); });
} */ } */
if (!props.open) { if (!props.open) {
setQrCode("");
return; return;
} }
...@@ -38,6 +40,8 @@ export default function LoginModal(props: Props) { ...@@ -38,6 +40,8 @@ export default function LoginModal(props: Props) {
.then((res) => { .then((res) => {
if (res.code == "200") { if (res.code == "200") {
setQrCode("data:image/png;base64," + res.result || ""); setQrCode("data:image/png;base64," + res.result || "");
} else {
window.messageApi.error("获取登录二维码失败");
} }
}); });
}, [props.open]); }, [props.open]);
...@@ -97,7 +101,12 @@ export default function LoginModal(props: Props) { ...@@ -97,7 +101,12 @@ export default function LoginModal(props: Props) {
欢迎来到云享飞 欢迎来到云享飞
</div> </div>
<div id="login_container" style={{ margin: "auto", display: "table" }}> <div id="login_container" style={{ margin: "auto", display: "table" }}>
<Image src={qrCode} width={150} height={150}></Image> <Image
src={qrCode}
width={150}
height={150}
fallback={errImg}
></Image>
</div> </div>
<div <div
style={{ style={{
......
...@@ -34,12 +34,14 @@ ...@@ -34,12 +34,14 @@
"@hapi/iron": "^7.0.1", "@hapi/iron": "^7.0.1",
"@types/styled-components": "^5.1.26", "@types/styled-components": "^5.1.26",
"babel-plugin-styled-components": "^2.1.1", "babel-plugin-styled-components": "^2.1.1",
"babel-plugin-styled-components-px2rem": "^1.5.5",
"cookie": "^0.5.0", "cookie": "^0.5.0",
"moment": "^2.29.4", "moment": "^2.29.4",
"next-connect": "^1.0.0", "next-connect": "^1.0.0",
"passport": "^0.6.0", "passport": "^0.6.0",
"passport-local": "^1.0.0", "passport-local": "^1.0.0",
"pinyin-pro": "^3.14.0", "pinyin-pro": "^3.14.0",
"postcss-pxtorem": "^6.0.0",
"react-infinite-scroll-component": "^6.1.0", "react-infinite-scroll-component": "^6.1.0",
"styled-components": "^6.0.0-rc.1", "styled-components": "^6.0.0-rc.1",
"swiper": "^9.3.2", "swiper": "^9.3.2",
......
import '../public/antd.min.css'; import "../public/antd.min.css";
import '../styles/index.scss'; import "../styles/index.scss";
import type { AppProps } from 'next/app'; import type { AppProps } from "next/app";
import withTheme from '../theme'; import withTheme from "../theme";
import { message } from 'antd'; import { message } from "antd";
import { useEffect } from 'react'; import { useEffect } from "react";
import Head from "next/head"; import Head from "next/head";
import Script from 'next/script'; import Script from "next/script";
import UserProvider, { UserContext } from "~/lib/userProvider"; import UserProvider, { UserContext } from "~/lib/userProvider";
export default function App({ Component, pageProps }: AppProps) { export default function App({ Component, pageProps }: AppProps) {
...@@ -13,14 +13,18 @@ export default function App({ Component, pageProps }: AppProps) { ...@@ -13,14 +13,18 @@ export default function App({ Component, pageProps }: AppProps) {
useEffect(() => { useEffect(() => {
//全局消息提示 //全局消息提示
window.messageApi = messageApi; window.messageApi = messageApi;
}, []) //@ts-ignore
window.onresize = function(){
window.document.querySelector('html')!.style.fontSize = (window.innerWidth / 1920) + 'PX';
}
}, []);
return withTheme( return withTheme(
<> <>
<Head> <Head>
<meta <meta
name="viewport" name="viewport"
content="width=device-width,initial-scale=1" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"
></meta> ></meta>
</Head> </Head>
<Script src="https://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js"></Script> <Script src="https://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js"></Script>
......
...@@ -24,7 +24,7 @@ export default class MyDocument extends Document { ...@@ -24,7 +24,7 @@ export default class MyDocument extends Document {
render() { render() {
return ( return (
<Html lang='en'> <Html lang='en' style={{fontSize: 1}}>
<Head /> <Head />
<body> <body>
<Main /> <Main />
......
module.exports = {
plugins: {
"postcss-pxtorem": {
rootValue: 1,
unitPrecision: 5,
propList: ["*"],
selectorBlackList: [], //排除html样式
replace: true,
mediaQuery: false,
minPixelValue: 0,
},
},
};
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论