From 36feef834e85162dcdd93b47c900a5a7e519a160 Mon Sep 17 00:00:00 2001 From: zhangjianing Date: Fri, 31 Mar 2023 16:23:41 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E6=8E=88=E6=9D=83?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/home.module.scss | 32 ++++++ app/components/home.tsx | 196 ++++++++++++++++++++------------ 2 files changed, 154 insertions(+), 74 deletions(-) diff --git a/app/components/home.module.scss b/app/components/home.module.scss index cef1662b5..5cf12ad19 100644 --- a/app/components/home.module.scss +++ b/app/components/home.module.scss @@ -19,6 +19,38 @@ height: var(--window-height); } +.button { + cursor: pointer; + position: relative; + display: inline-block; + font-weight: 400; + white-space: nowrap; + text-align: center; + background-image: none; + border: 1px solid transparent; + box-shadow: 0 2px #00000004; + cursor: pointer; + transition: all .3s cubic-bezier(.645,.045,.355,1); + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + touch-action: manipulation; + height: 32px; + line-height: 32px; + padding: 4px 15px; + font-size: 17px; + border-radius: 2px; + color: #000000d9; + border-color: #d9d9d9; + background: #fff; + color: #fff; + border-color: #1890ff; + background: #1890ff; + text-shadow: 0 -1px 0 rgba(0,0,0,.12); + box-shadow: 0 2px #0000000b; +} + .container { @include container(); } diff --git a/app/components/home.tsx b/app/components/home.tsx index 2f09aa273..3b49b542c 100644 --- a/app/components/home.tsx +++ b/app/components/home.tsx @@ -608,6 +608,34 @@ export function Home() { // setting const [openSettings, setOpenSettings] = useState(false); const config = useChatStore((state) => state.config); + const [isAllow, setIsAllow] = useState(undefined); + + useEffect(() => { + const urlParams = new URLSearchParams(window.location.search); + const signature = urlParams.get("signature"); + // 不是企业微信环境,拦截 + fetch(`//192.168.5.198/api/check_user_white/?signature=${signature}`) + .then((response) => response.json()) + .then((data) => { + const { code, msg } = data; + setIsAllow(code === 0); // 是否在白名单 + }) + .catch((error) => console.error(error)); + }, []); + + const isWorkWechat = () => { + //获取user-agaent标识头 + const ua = window.navigator.userAgent.toLowerCase(); + //判断ua和微信浏览器的标识头是否匹配 + if ( + ua.match(/micromessenger/i) == "micromessenger" && + ua.match(/wxwork/i) == "wxwork" + ) { + return true; + } else { + return false; + } + }; useSwitchTheme(); @@ -615,6 +643,11 @@ export function Home() { return ; } + const goApply = () => { + location.href = + "http://work-order.zhiketong.net/#/process/create-ticket?processId=117"; + }; + return (
-
-
-
ChatGPT Next
-
- Build your own AI assistant. -
-
- -
-
+ {!isWorkWechat() ? ( +

请在企业微信里使用Gpt~

+ ) : typeof isAllow === "boolean" && !isAllow ? ( +

+ 您不在白名单内,请走工单审批使用Gpt~ + + 去申请 + +

+ ) : ( + <> +
+
+
ChatGPT Next
+
+ Build your own AI assistant. +
+
+ +
+
-
{ - setOpenSettings(false); - setShowSideBar(false); - }} - > - -
- -
-
-
- } - onClick={() => { - if (confirm(Locale.Home.DeleteChat)) { - removeSession(currentIndex); - } - }} - /> -
-
- } - onClick={() => { - setOpenSettings(true); - setShowSideBar(false); - }} - /> -
- -
-
- } - text={Locale.Home.NewChat} +
{ - createNewSession(); + setOpenSettings(false); setShowSideBar(false); }} - /> -
-
-
+ > + +
-
- {openSettings ? ( - { - setOpenSettings(false); - setShowSideBar(true); - }} - /> - ) : ( - setShowSideBar(true)} - sideBarShowing={showSideBar} - /> - )} -
+
+
+
+ } + onClick={() => { + if (confirm(Locale.Home.DeleteChat)) { + removeSession(currentIndex); + } + }} + /> +
+
+ } + onClick={() => { + setOpenSettings(true); + setShowSideBar(false); + }} + /> +
+ +
+
+ } + text={Locale.Home.NewChat} + onClick={() => { + createNewSession(); + setShowSideBar(false); + }} + /> +
+
+
+ +
+ {openSettings ? ( + { + setOpenSettings(false); + setShowSideBar(true); + }} + /> + ) : ( + setShowSideBar(true)} + sideBarShowing={showSideBar} + /> + )} +
+ + )}
); }