Skip to content

Commit

Permalink
fix bdid'
Browse files Browse the repository at this point in the history
  • Loading branch information
zjy365 committed Nov 7, 2023
1 parent ee56b1e commit 334eadd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions docs/website/src/hooks/useUploadData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import useIsBrowser from '@docusaurus/useIsBrowser';

export default function useUploadData() {
const isBrowser = useIsBrowser();
const [id, setId] = useState('');
const [bd_vid, setBdId] = useState('');
const {
siteConfig: { customFields }
} = useDocusaurusContext();
Expand All @@ -13,15 +13,15 @@ export default function useUploadData() {
if (!isBrowser) return;
console.log(customFields);
let bd_vid = sessionStorage.getItem('bd_vid');
if (bd_vid) setId(bd_vid);
if (bd_vid) setBdId(bd_vid);
}, [isBrowser]);

async function uploadConvertData(params: { newType: number }[]) {
if (!isBrowser || !customFields?.BD_TOKEN || !id) return;
if (!isBrowser || !customFields?.BD_TOKEN || !bd_vid) return;
const url = 'https://ocpc.baidu.com/ocpcapi/api/uploadConvertData';
const logidUrl = `${window.location.origin}?bd_vid=${id}`;
const logidUrl = `${window.location.origin}?bd_vid=${bd_vid}`;

console.log(customFields, id, '========', logidUrl);
console.log(customFields, bd_vid, logidUrl);

const data = {
token: customFields?.BD_TOKEN,
Expand All @@ -38,7 +38,7 @@ export default function useUploadData() {
}

return {
id,
bd_vid,
uploadConvertData
};
}
6 changes: 3 additions & 3 deletions docs/website/src/pages/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const HomeHeader = ({ isPc }: { isPc: boolean }) => {
const [stars, setStars] = useState(10000);
const isBrowser = useIsBrowser();
const { cloudUrl } = useWindow();
const { uploadConvertData } = useUploadData();
const { uploadConvertData, bd_vid } = useUploadData();

const i18nMap: { [key: string]: { label: string; link: string } } = {
en: { label: '中', link: '/zh-Hans/' },
Expand Down Expand Up @@ -133,7 +133,7 @@ const HomeHeader = ({ isPc }: { isPc: boolean }) => {
一样使用 Sealos!
</h3>
)}
<a className="start-now-button" href={cloudUrl} target="_blank">
<a className="start-now-button" href={`${cloudUrl}?bd_vid=${bd_vid}`} target="_blank">
{i18nObj.startNow}
<div className="start-now-button-wrap"></div>
</a>
Expand Down Expand Up @@ -200,7 +200,7 @@ const HomeHeader = ({ isPc }: { isPc: boolean }) => {
</Link>
</div>
)}
<a className="start-now-button" href={cloudUrl} target="_blank">
<a className="start-now-button" href={`${cloudUrl}?bd_vid=${bd_vid}`} target="_blank">
{i18nObj.startNow}
<div className="start-now-button-wrap"></div>
</a>
Expand Down

0 comments on commit 334eadd

Please sign in to comment.