feat: 新增授权逻辑
This commit is contained in:
parent
61eb356fd9
commit
36feef834e
|
@ -19,6 +19,38 @@
|
||||||
height: var(--window-height);
|
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 {
|
.container {
|
||||||
@include container();
|
@include container();
|
||||||
}
|
}
|
||||||
|
|
|
@ -608,6 +608,34 @@ export function Home() {
|
||||||
// setting
|
// setting
|
||||||
const [openSettings, setOpenSettings] = useState(false);
|
const [openSettings, setOpenSettings] = useState(false);
|
||||||
const config = useChatStore((state) => state.config);
|
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();
|
useSwitchTheme();
|
||||||
|
|
||||||
|
@ -615,6 +643,11 @@ export function Home() {
|
||||||
return <Loading />;
|
return <Loading />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const goApply = () => {
|
||||||
|
location.href =
|
||||||
|
"http://work-order.zhiketong.net/#/process/create-ticket?processId=117";
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={`${
|
className={`${
|
||||||
|
@ -623,8 +656,21 @@ export function Home() {
|
||||||
: styles.container
|
: styles.container
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
|
{!isWorkWechat() ? (
|
||||||
|
<h2 className="not-wx-work">请在企业微信里使用Gpt~</h2>
|
||||||
|
) : typeof isAllow === "boolean" && !isAllow ? (
|
||||||
|
<h2 className="not-allow">
|
||||||
|
<span className="text">您不在白名单内,请走工单审批使用Gpt~</span>
|
||||||
|
<span onClick={goApply} className={styles["button"]}>
|
||||||
|
去申请
|
||||||
|
</span>
|
||||||
|
</h2>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
<div
|
<div
|
||||||
className={styles.sidebar + ` ${showSideBar && styles["sidebar-show"]}`}
|
className={
|
||||||
|
styles.sidebar + ` ${showSideBar && styles["sidebar-show"]}`
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<div className={styles["sidebar-header"]}>
|
<div className={styles["sidebar-header"]}>
|
||||||
<div className={styles["sidebar-title"]}>ChatGPT Next</div>
|
<div className={styles["sidebar-title"]}>ChatGPT Next</div>
|
||||||
|
@ -702,6 +748,8 @@ export function Home() {
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue