mirror of https://gitee.com/answerdev/answer.git
Merge branch 'feat/1.1.2/ui' of github.com:answerdev/answer into feat/1.1.2/ui
This commit is contained in:
commit
1402d9e5dc
|
@ -1,6 +1,9 @@
|
|||
const pattern = {
|
||||
email:
|
||||
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/,
|
||||
wx: /micromessenger/,
|
||||
wxwork: /wxwork/,
|
||||
dingtalk: /dingtalk/,
|
||||
};
|
||||
|
||||
export default pattern;
|
||||
|
|
|
@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next';
|
|||
import QrCode from 'qrcode';
|
||||
|
||||
import { userCenterStore } from '@/stores';
|
||||
import { guard } from '@/utils';
|
||||
import { guard, getUserAgentType } from '@/utils';
|
||||
|
||||
import { getLoginConf, checkLoginResult } from './wecom.service';
|
||||
|
||||
|
@ -47,7 +47,11 @@ const Index: FC = () => {
|
|||
return;
|
||||
}
|
||||
getLoginConf().then((res) => {
|
||||
handleQrCode(res?.redirect_url);
|
||||
if (getUserAgentType() === 'wxwork') {
|
||||
window.location.replace(res?.redirect_url);
|
||||
} else {
|
||||
handleQrCode(res?.redirect_url);
|
||||
}
|
||||
handleLoginResult(res?.key);
|
||||
});
|
||||
}, [agentName]);
|
||||
|
@ -56,7 +60,7 @@ const Index: FC = () => {
|
|||
clearTimeout(checkTimer);
|
||||
};
|
||||
}, []);
|
||||
if (/WeCom/i.test(agentName)) {
|
||||
if (/WeCom/i.test(agentName) && getUserAgentType() !== 'wxwork') {
|
||||
return (
|
||||
<Card className="text-center">
|
||||
<Card.Body>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import React, { memo, FC } from 'react';
|
||||
import { memo, FC } from 'react';
|
||||
import { Button } from 'react-bootstrap';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import i18next from 'i18next';
|
||||
|
||||
import pattern from '@/common/pattern';
|
||||
|
||||
const Diff = require('diff');
|
||||
|
||||
function thousandthDivision(num) {
|
||||
|
@ -254,6 +256,23 @@ function base64ToSvg(base64: string) {
|
|||
return str;
|
||||
}
|
||||
|
||||
// Determine whether the user is in WeChat or Enterprise WeChat or DingTalk, and return the corresponding type
|
||||
|
||||
function getUserAgentType() {
|
||||
const ua = navigator.userAgent.toLowerCase();
|
||||
if (pattern.wxwork.test(ua)) {
|
||||
return 'wxwork';
|
||||
}
|
||||
// if (pattern.wx.test(ua)) {
|
||||
// return 'weixin';
|
||||
// }
|
||||
|
||||
// if (pattern.dingtalk.test(ua)) {
|
||||
// return 'dingtalk';
|
||||
// }
|
||||
return null;
|
||||
}
|
||||
|
||||
export {
|
||||
thousandthDivision,
|
||||
formatCount,
|
||||
|
@ -270,4 +289,5 @@ export {
|
|||
handleFormError,
|
||||
diffText,
|
||||
base64ToSvg,
|
||||
getUserAgentType,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue