wjx 1 vuosi sitten
vanhempi
commit
238e004eef

+ 1 - 1
index.html

@@ -1,5 +1,5 @@
 <!DOCTYPE html>
-<html lang="en">
+<html lang="zh">
   <head>
     <meta charset="UTF-8" />
     <link rel="icon" type="image/svg+xml" href="/vite.svg" />

+ 3 - 3
src/App.tsx

@@ -11,7 +11,7 @@ import PwdPop from './pages/pwdPop'
 import useConfig, { Action, State } from './models/useConfig'
 import LoginSucc from './pages/loginSucc'
 import React from 'react'
-import { getRedirectUrl } from './utils'
+import { getRedirectUrl, isWx } from './utils'
 
 
 export const DispatchContext = React.createContext<{ dispatch: React.Dispatch<Action>, state: State, getDetails: () => void } | null>(null);
@@ -83,7 +83,7 @@ function App() {
 		} else {
 			console.log(gameId)
 			if (gameId) {
-				if (searchParams.get('code')) {
+				if (searchParams.get('code') && isWx()) {
 					weChatLogin.run({ code: searchParams.get('code') }).then(res => {
 						console.log('1111', res)
 						if (+res.code === 200) {
@@ -112,7 +112,7 @@ function App() {
 					let iconLink: any = document.querySelector('link[rel="icon"]');
 					iconLink.href = res.data?.h5GameConfigDTO?.h5SignLogo
 				}
-				if (!searchParams.get('code') && res.data.isPut && res.data.appId) {
+				if (!searchParams.get('code') && res.data.isPut && res.data.appId && isWx()) {
 					setIsShowLogin(false)
 					window.location.replace(`https://open.weixin.qq.com/connect/oauth2/authorize?appid=${res.data.appId}&redirect_uri=${encodeURIComponent(location.href)}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`)
 				} else {

+ 14 - 2
src/components/floatingWindow.tsx

@@ -17,6 +17,7 @@ const FloatingWindow: React.FC<Props> = ({ isVer, onClick }) => {
     /**********************************/
     const { state: { initData: { h5SignLogo } } } = useContext(DispatchContext)!;
     const [isDragging, setIsDragging] = useState(false);
+    const [nowTimer, setNowTimer] = useState<number>(0)
     const [position, setPosition] = useState({ x: 0, y: 200 });
     const ref = useRef(null);
     const size = useSize(ref);
@@ -36,6 +37,7 @@ const FloatingWindow: React.FC<Props> = ({ isVer, onClick }) => {
 
     const handleMouseDown = (event: React.MouseEvent<HTMLDivElement>) => {
         event.stopPropagation()
+        setNowTimer(new Date().getTime())
         setIsDragging(true);
         setPosition({ x: event.clientX, y: event.clientY });
     };
@@ -46,8 +48,14 @@ const FloatingWindow: React.FC<Props> = ({ isVer, onClick }) => {
         }
     };
 
-    const handleMouseUp = () => {
+    const handleMouseUp = (e: any) => {
         setIsDragging(false);
+        if (new Date().getTime() - nowTimer < 200) {
+            setNowTimer(0)
+            onClick?.(e)
+            return
+        }
+        setNowTimer(0)
         let drawW = size?.width || 0;
         let bodyW = document.body.clientWidth;
         let bodyH = document.body.clientHeight;
@@ -94,6 +102,10 @@ const FloatingWindow: React.FC<Props> = ({ isVer, onClick }) => {
         setPosition({ x: touch.clientX, y: touch.clientY });
     };
 
+    // const clickHandle = (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
+    //     // if (!isDragging) onClick?.(e)
+    // }
+
     return (
         <div
             ref={ref}
@@ -111,7 +123,7 @@ const FloatingWindow: React.FC<Props> = ({ isVer, onClick }) => {
             onTouchStart={onTouchStart}
             onTouchMove={onTouchMove}
             onTouchEnd={handleMouseUp}
-            onClick={(e) => { e.stopPropagation(); if (!isDragging) onClick?.(e) }}
+            // onClick={(e) => { e.stopPropagation(); clickHandle(e) }}
         />
     );
 };

+ 2 - 1
src/pages/loginSucc/index.tsx

@@ -165,6 +165,7 @@ const LoginSucc: React.FC = () => {
         let os = isOs()
         payResult(orderId)
         if (os === 'windows' || os === 'mac') { // pc
+            setIsLoading(false)
             if (payWay === '1') { // 支付宝
                 document.querySelector('[name="punchout_form"]')?.remove();
                 setHtmlPay(data.data.replace('<script>document.forms[0].submit();</script>'))
@@ -294,7 +295,7 @@ const LoginSucc: React.FC = () => {
             {openModify && <Modify open={openModify} onClose={() => setOpenModify(false)} onChange={() => { getDetails(); setOpenModify(false) }} />}
             {/* 悬浮球 */}
             {h5SignShow !== 'SIGN_SHOW_NONE' && <>
-                {(h5SignShow === 'SIGN_SHOW_ALL' || (h5SignShow === 'SIGN_SHOW_WX_NONE' && !isWx()) || (h5SignShow === 'SIGN_SHOW_H5_NONE' && (isOs() === 'windows' || isOs() === 'mac'))) && <FloatingWindow isVer={isVer}  onClick={() => setOpen(true)} />}
+                {(h5SignShow === 'SIGN_SHOW_ALL' || ((h5SignShow === 'SIGN_SHOW_WX_NONE' && !isWx()) || (isOs() === 'windows' || isOs() === 'mac')) || (h5SignShow === 'SIGN_SHOW_H5_NONE' && (isOs() === 'windows' || isOs() === 'mac'))) && <FloatingWindow isVer={isVer}  onClick={() => setOpen(true)} />}
             </>}
             {/* 支付选择组件 */}
             {payConfig.open && <PayPop isVer={isVer} {...payConfig} onClose={() => setPayConfig({ open: false, data: {} })} onChange={preOrderSucc} />}

+ 3 - 3
src/pages/loginSucc/userManage.tsx

@@ -9,7 +9,7 @@ import AuthImg from '../../assets/image/icon_shimingrenzheng.png'
 import LeftImg from '../../assets/image/personal_core_back.png'
 import CopyImg from '../../assets/image/icon_fz@2x.png'
 import EditImg from '../../assets/image/icon_bj@2x.png'
-import { copy } from "../../utils";
+import { copy, isWx } from "../../utils";
 
 interface Props {
     isVer: boolean
@@ -117,7 +117,7 @@ const UserManage: React.FC<Props> = ({ onClose, open, handle, isVer }) => {
                     </div>
 
                     <div className="um_bottom">
-                        {!isPut && <Button icon={<PoweroffOutlined />} danger type="text" onClick={() => { handle?.('LOGOUT') }}>退出登录</Button>}
+                        {(!isPut || !isWx()) && <Button icon={<PoweroffOutlined />} danger type="text" onClick={() => { handle?.('LOGOUT') }}>退出登录</Button>}
                         <Button icon={<SyncOutlined />} type="text" onClick={() => { window.location.reload() }}>刷新游戏</Button>
                     </div>
                 </div>
@@ -196,7 +196,7 @@ const UserManage: React.FC<Props> = ({ onClose, open, handle, isVer }) => {
                     </div>
                 </div>
                 <div className="um_bottom">
-                    {!isPut && <Button icon={<PoweroffOutlined />} danger type="text" onClick={() => { handle?.('LOGOUT') }}>退出登录</Button>}
+                    {(!isPut || !isWx()) && <Button icon={<PoweroffOutlined />} danger type="text" onClick={() => { handle?.('LOGOUT') }}>退出登录</Button>}
                     <Button icon={<SyncOutlined />} type="text" onClick={() => { window.location.reload() }}>刷新游戏</Button>
                 </div>
             </Drawer>