diff --git a/src/css/custom.css b/src/css/custom.css index b2c2f37630e471b63a7d927c3da0a8d74b2f8ded..4473951e9539386cf44ccd716564c44c333b107d 100644 --- a/src/css/custom.css +++ b/src/css/custom.css @@ -22,10 +22,10 @@ --ifm-navbar-second-background-color: rgba(248, 250, 252, 1); --ifm-navbar-button-border-color: rgba(226, 232, 240, 1); --ifm-navbar-button-color: rgba(15, 23, 41, 1); - --ifm-font-family-base: ui-sans-serif, system-ui, -apple-system, - BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', - sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', - 'Noto Color Emoji'; + --ifm-font-family-base: + ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', + Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, + 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; } /* For readability concerns, you should choose a lighter palette in dark mode. */ @@ -91,18 +91,19 @@ input[type='number'] { .navbar__item.navbar__link, .navbar__items .navbar__link { font-size: 10.5pt; - padding: var(--ifm-navbar-item-padding-vertical) var(--ifm-navbar-item-padding-horizontal); + padding: var(--ifm-navbar-item-padding-vertical) + var(--ifm-navbar-item-padding-horizontal); } .navbar__items .navbar__link { display: block; } -.navbar__items>a:nth-of-type(2) { +.navbar__items > a:nth-of-type(2) { margin-left: auto; } -.navbar__items>a:last-child { +.navbar__items > a:last-child { margin-right: auto; } @@ -131,7 +132,7 @@ input[type='number'] { } article { - font-size: 0.96em + font-size: 0.96em; } article h1 { @@ -215,10 +216,12 @@ div[id^='headlessui-disclosure-panel'] tr td.relative:nth-child(2) { } .theme-doc-toc-desktop { - top: calc(var(--ifm-navbar-height) + 1rem + var(--ifm-navbar-height)) !important; + top: calc( + var(--ifm-navbar-height) + 1rem + var(--ifm-navbar-height) + ) !important; } -.dropdown>.navbar__link:after { +.dropdown > .navbar__link:after { width: 4px; height: 4px; border-width: 1px 1px 0 0; @@ -299,7 +302,7 @@ div[id^='headlessui-disclosure-panel'] tr td.relative:nth-child(2) { margin-top: calc(-1 * var(--ifm-navbar-height) * 2) !important; } -.theme-doc-sidebar-container>div>div { +.theme-doc-sidebar-container > div > div { padding-top: calc(var(--ifm-navbar-height) * 2) !important; } @@ -380,4 +383,9 @@ table.serverless-api-services tr:nth-child(2n) { table.serverless-api-services tr:hover td { background-color: var(--ifm-table-stripe-background); -} \ No newline at end of file +} + +/* 客服 */ +#udesk_btn .udesk-client-btn { + display: none !important; +} diff --git a/src/theme/Navbar/feedback/index.tsx b/src/theme/Navbar/feedback/index.tsx new file mode 100644 index 0000000000000000000000000000000000000000..967c26083b45f9dccf17f355e42f9e282c350651 --- /dev/null +++ b/src/theme/Navbar/feedback/index.tsx @@ -0,0 +1,76 @@ +import { useEffect, useRef, useState } from 'react'; +import initUdesk, { InitUdesk } from './udeskApi'; + +const GlobalFeedback = () => { + const [show, setShow] = useState(false); + const udeskRef = useRef(() => {}); + useEffect(() => { + udeskRef.current = initUdesk(setShow); + }, []); + return ( + <> +
{ + udeskRef.current(!show); + setShow(!show); + }} + > + feedback +
+ + feedback + + + ); +}; + +export default GlobalFeedback; diff --git a/src/theme/Navbar/feedback/udeskApi.ts b/src/theme/Navbar/feedback/udeskApi.ts new file mode 100644 index 0000000000000000000000000000000000000000..c95541aaabe191acf22c1ea7149bfa434b0d7291 --- /dev/null +++ b/src/theme/Navbar/feedback/udeskApi.ts @@ -0,0 +1,56 @@ +'use client'; + +declare global { + interface Window { + ud: (...args: any[]) => void; + UdeskApiObject: any; + } +} + +function initUdesk(setShow: (value: boolean) => void) { + (function (a: any, h: Document, c: any, b: string, f: 'ud', g?: any) { + a['UdeskApiObject'] = f; + a[f] = + a[f] || + function () { + (a[f].d = a[f].d || []).push(arguments); + }; + g = h.createElement(c); + g.async = 1; + g.charset = 'utf-8'; + g.src = b; + c = h.getElementsByTagName(c)[0]; + c.parentNode.insertBefore(g, c); + })( + window, + document, + 'script', + 'https://assets-cli.s4.udesk.cn/im_client/js/udeskApi.js', + 'ud', + ); + window.ud({ + code: '1hhcdjh', + link: 'https://1588039.s4.udesk.cn/im_client/?web_plugin_id=75481', + language: 'zh-cn', + panel: { + css: { + right: '12px', + }, + onToggle(data: { visible: boolean }) { + if (!data.visible) { + setShow(false); + } + }, + }, + }); + + return (show: boolean) => { + if (!window.ud) { + return; + } + window.ud(show ? 'showPanel' : 'hidePanel'); + }; +} + +export type InitUdesk = ReturnType; +export default initUdesk; diff --git a/src/theme/Navbar/index.tsx b/src/theme/Navbar/index.tsx index 915cc117140e0b0df97a8677ea552be7066fc8e8..5110933c28945b442a8201795b04fd8b2ff3540f 100644 --- a/src/theme/Navbar/index.tsx +++ b/src/theme/Navbar/index.tsx @@ -5,40 +5,8 @@ import clsx from 'clsx'; import { useLocation } from 'react-router-dom'; import { translate } from '@docusaurus/Translate'; import style from './style.module.css'; +import GlobalFeedback from './feedback'; -const GlobalFeedback = () => { - return ( - - feedback - - ); -}; export default function NavBar() { const location = useLocation();