diff --git a/docs/website/docusaurus.config.js b/docs/website/docusaurus.config.js
index e3ea1c625c0..f4e838b5b71 100644
--- a/docs/website/docusaurus.config.js
+++ b/docs/website/docusaurus.config.js
@@ -1,6 +1,5 @@
// @ts-check
const generateAlgoliKey = () => "ce5b8e1e4d0d35ff587caf75ac404df4"
-require('dotenv').config()
/** @type {import('@docusaurus/types').Config} */
const config = {
@@ -11,9 +10,6 @@ const config = {
onBrokenLinks: "warn",
onBrokenMarkdownLinks: "warn",
favicon: "img/favicon.ico",
- customFields: {
- BD_TOKEN: process.env.BD_TOKEN,
- },
// GitHub pages deployment config.
// If you aren't using GitHub pages, you don't need these.
organizationName: "labring", // Usually your GitHub org/user name.
diff --git a/docs/website/package.json b/docs/website/package.json
index 14812c1413b..cbbd8db33d5 100644
--- a/docs/website/package.json
+++ b/docs/website/package.json
@@ -24,7 +24,6 @@
"@mdx-js/react": "^1.6.22",
"autoprefixer": "^10.4.16",
"docusaurus-plugin-sass": "^0.2.2",
- "dotenv": "^16.3.1",
"postcss": "^8.4.31",
"prism-react-renderer": "^1.3.5",
"prismjs": "^1.29.0",
diff --git a/docs/website/src/hooks/useUploadData.ts b/docs/website/src/hooks/useUploadData.ts
deleted file mode 100644
index 6f32ef5fe58..00000000000
--- a/docs/website/src/hooks/useUploadData.ts
+++ /dev/null
@@ -1,44 +0,0 @@
-import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
-import { useEffect, useState } from 'react';
-import useIsBrowser from '@docusaurus/useIsBrowser';
-
-export default function useUploadData() {
- const isBrowser = useIsBrowser();
- const [bd_vid, setBdId] = useState('');
- const {
- siteConfig: { customFields }
- } = useDocusaurusContext();
-
- useEffect(() => {
- if (!isBrowser) return;
- console.log(customFields);
- let bd_vid = sessionStorage.getItem('bd_vid');
- if (bd_vid) setBdId(bd_vid);
- }, [isBrowser]);
-
- async function uploadConvertData(params: { newType: number }[]) {
- if (!isBrowser || !customFields?.BD_TOKEN || !bd_vid) return;
- const url = 'https://ocpc.baidu.com/ocpcapi/api/uploadConvertData';
- const logidUrl = `${window.location.origin}?bd_vid=${bd_vid}`;
-
- console.log(customFields, bd_vid, logidUrl);
-
- const data = {
- token: customFields?.BD_TOKEN,
- conversionTypes: params.map((newType) => ({ logidUrl: logidUrl, newType: newType }))
- };
-
- return fetch(url, {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify(data)
- });
- }
-
- return {
- bd_vid,
- uploadConvertData
- };
-}
diff --git a/docs/website/src/hooks/useWindow.ts b/docs/website/src/hooks/useWindow.ts
index ac3eb1031c7..133a7b7d5fe 100644
--- a/docs/website/src/hooks/useWindow.ts
+++ b/docs/website/src/hooks/useWindow.ts
@@ -8,6 +8,13 @@ export default function () {
isBrowser ? document.documentElement.lang : 'en'
);
const [cloudUrl, setCloudUrl] = useState('https://cloud.sealos.io');
+ const [bd_vid, setBdId] = useState('');
+
+ useEffect(() => {
+ if (!isBrowser) return;
+ let bd_vid = sessionStorage.getItem('bd_vid');
+ if (bd_vid) setBdId(bd_vid);
+ }, [isBrowser]);
useEffect(() => {
if (!isBrowser) return;
@@ -20,7 +27,7 @@ export default function () {
setCurrentLanguage(document.documentElement.lang);
setCloudUrl(
- document.documentElement.lang === 'en'
+ window.location.hostname === 'sealos.io'
? 'https://cloud.sealos.io'
: 'https://cloud.sealos.top'
);
@@ -33,6 +40,7 @@ export default function () {
return {
screenWidth,
currentLanguage,
- cloudUrl
+ cloudUrl,
+ bd_vid
};
}
diff --git a/docs/website/src/pages/components/Banner/index.tsx b/docs/website/src/pages/components/Banner/index.tsx
index 85656a6f64d..03fb5b12edc 100644
--- a/docs/website/src/pages/components/Banner/index.tsx
+++ b/docs/website/src/pages/components/Banner/index.tsx
@@ -7,7 +7,7 @@ import useWindow from '@site/src/hooks/useWindow';
export default function Banner() {
const [isBannerVisible, setIsBannerVisible] = useState(false);
- const { screenWidth, currentLanguage, cloudUrl } = useWindow();
+ const { cloudUrl, bd_vid } = useWindow();
const closeBanner = () => {
setIsBannerVisible(false);
@@ -64,7 +64,10 @@ export default function Banner() {
{
- window.open(`${cloudUrl}/?openapp=system-costcenter?openRecharge=true`, '_blank');
+ window.open(
+ `${cloudUrl}/?bd_vid=${bd_vid}&openapp=system-costcenter?openRecharge=true`,
+ '_blank'
+ );
closeBanner();
}}
>
diff --git a/docs/website/src/pages/components/Capability/index.tsx b/docs/website/src/pages/components/Capability/index.tsx
index e496a1d218c..43456cee016 100644
--- a/docs/website/src/pages/components/Capability/index.tsx
+++ b/docs/website/src/pages/components/Capability/index.tsx
@@ -36,7 +36,7 @@ const i18nObj = {
const Capability = ({ isPc }: { isPc: boolean }) => {
const isBrowser = useIsBrowser();
- const { screenWidth, currentLanguage, cloudUrl } = useWindow();
+ const { screenWidth, currentLanguage, cloudUrl, bd_vid } = useWindow();
useLayoutEffect(() => {
// @ts-ignore nextline
@@ -66,7 +66,10 @@ const Capability = ({ isPc }: { isPc: boolean }) => {
{i18nObj.appMan}
{i18nObj.appManagement_introduce}
-
+
{i18nObj.Explore} {'>'}
@@ -84,7 +87,7 @@ const Capability = ({ isPc }: { isPc: boolean }) => {
{i18nObj.database}
{i18nObj.database_introduce}
-
+
{i18nObj.Explore} {'>'}
{
{i18nObj.appMan}
{i18nObj.appManagement_introduce}
-
+
{i18nObj.Explore} {'>'}
@@ -143,7 +146,7 @@ const Capability = ({ isPc }: { isPc: boolean }) => {
{i18nObj.database}
{i18nObj.database_introduce}
-
+
{i18nObj.Explore} {'>'}
{
const [stars, setStars] = useState(10000);
const isBrowser = useIsBrowser();
- const { cloudUrl } = useWindow();
- const { uploadConvertData, bd_vid } = useUploadData();
+ const { cloudUrl, bd_vid } = useWindow();
const i18nMap: { [key: string]: { label: string; link: string } } = {
en: { label: '中', link: '/zh-Hans/' },
@@ -166,22 +164,7 @@ const HomeHeader = ({ isPc }: { isPc: boolean }) => {
{navbar.map((item) => (
-
{
- if (item.key === 'contact') {
- console.log('uploadConvertData');
- uploadConvertData([
- {
- newType: 1
- }
- ])
- .then((response) => response && response.json())
- .then((data) => console.log(data, 'bd_res'));
- }
- }}
- >
+
{item.label}
))}
@@ -194,10 +177,15 @@ const HomeHeader = ({ isPc }: { isPc: boolean }) => {
{Math.floor(stars / 1000)}k
{isBrowser && (
-
-
- {i18nMap[currentLocale]?.label}
-
+
+ window.location.replace(
+ `${location.origin}${currentLocale === 'en' ? '/zh-Hans/' : '/'}`
+ )
+ }
+ >
+ {i18nMap[currentLocale]?.label}
)}
diff --git a/docs/website/src/pages/index.tsx b/docs/website/src/pages/index.tsx
index f0c129fb96b..dd416067ad8 100644
--- a/docs/website/src/pages/index.tsx
+++ b/docs/website/src/pages/index.tsx
@@ -14,7 +14,7 @@ import HomeUserBy from './components/UserBy';
import './index.scss';
const Home = () => {
- const { screenWidth, currentLanguage, cloudUrl } = useWindow();
+ const { screenWidth, cloudUrl } = useWindow();
const isPc = useMemo(() => screenWidth > PC_MIN_WIDTH, [screenWidth]);
useEffect(() => {
diff --git a/docs/website/src/pages/self-hosting/header/index.tsx b/docs/website/src/pages/self-hosting/header/index.tsx
index 67434125e90..c2d27eb8fef 100644
--- a/docs/website/src/pages/self-hosting/header/index.tsx
+++ b/docs/website/src/pages/self-hosting/header/index.tsx
@@ -40,7 +40,7 @@ const i18nObj = {
const HomeHeader = ({ isPc }: { isPc: boolean }) => {
const [stars, setStars] = useState(10000);
const isBrowser = useIsBrowser();
- const { screenWidth, currentLanguage, cloudUrl } = useWindow();
+ const { screenWidth, currentLanguage, cloudUrl, bd_vid } = useWindow();
const i18nMap: { [key: string]: { label: string; link: string } } = {
en: { label: '中', link: '/zh-Hans/' },
@@ -135,7 +135,7 @@ const HomeHeader = ({ isPc }: { isPc: boolean }) => {
)}
-
+
{i18nObj.startNow}
diff --git a/docs/website/src/pages/self-hosting/product/index.tsx b/docs/website/src/pages/self-hosting/product/index.tsx
index f4b9c884942..a6de5dde61b 100644
--- a/docs/website/src/pages/self-hosting/product/index.tsx
+++ b/docs/website/src/pages/self-hosting/product/index.tsx
@@ -1,8 +1,10 @@
+import useWindow from '@site/src/hooks/useWindow';
import CheckIcon from '@site/static/price/check.svg';
import StarIcon from '@site/static/price/star.svg';
import React from 'react';
export default function Product() {
+ const { bd_vid } = useWindow();
const standard = ['工单服务', '应用管理', '高可用数据库', '应用市场', '多租户', '计量/配额'];
const company = [
@@ -59,8 +61,7 @@ export default function Product() {
className="sealos_price_btn"
onClick={() =>
window.open(
- 'https://license.sealos.io/signin?external=true&clusterType=Standard',
- '_black'
+ `https://license.sealos.io/signin?external=true&clusterType=Standard&bd_vid=${bd_vid}`
)
}
>
@@ -97,8 +98,7 @@ export default function Product() {
}}
onClick={() =>
window.open(
- 'https://license.sealos.io/signin?external=true&clusterType=Enterprise',
- '_black'
+ `https://license.sealos.io/signin?external=true&clusterType=Enterprise&bd_vid=${bd_vid}`
)
}
>
@@ -130,8 +130,7 @@ export default function Product() {
style={{ marginTop: '46px' }}
onClick={() =>
window.open(
- 'https://fael3z0zfze.feishu.cn/share/base/form/shrcnesSfEK65JZaAf2W6Fwz6Ad',
- '_black'
+ 'https://fael3z0zfze.feishu.cn/share/base/form/shrcnesSfEK65JZaAf2W6Fwz6Ad'
)
}
>
diff --git a/docs/website/static/global.js b/docs/website/static/global.js
index be5e7bca225..8df8f09c6af 100644
--- a/docs/website/static/global.js
+++ b/docs/website/static/global.js
@@ -1,19 +1,18 @@
document.addEventListener("DOMContentLoaded", function () {
- console.log('addEventListener')
+ console.log('Handle a tag interception')
const parentElement = document.body
parentElement.addEventListener("click", function (event) {
if (event.target.tagName === "A") {
const href = event.target.getAttribute("href")
const currentHostname = window.location.hostname
- const bdId = sessionStorage.getItem("bd_vid")
- console.log(bdId, 'bd_vid')
+ const targetHostname = (currentHostname === "sealos.io") ? "sealos.io" : "sealos.top"
+
if (href.includes("sealos.io") || href.includes("sealos.top") || href.includes("sealos.run")) {
event.preventDefault()
- console.log("特殊处理链接: " + href)
- const targetHostname = (currentHostname === "sealos.io") ? "sealos.io" : "sealos.top"
- const modifiedHref = href.replace("sealos.io", targetHostname)
- console.log(modifiedHref, '修改后的链接')
+ console.log("Before:" + href)
+ const modifiedHref = href.replace(/(sealos\.io|sealos\.top|sealos\.run)/, targetHostname)
+ console.log("After:", modifiedHref)
event.target.href = modifiedHref
window.open(modifiedHref)
diff --git a/docs/website/yarn.lock b/docs/website/yarn.lock
index 0d5f203176f..7d3088d3bae 100644
--- a/docs/website/yarn.lock
+++ b/docs/website/yarn.lock
@@ -3661,11 +3661,6 @@ dot-prop@^5.2.0:
dependencies:
is-obj "^2.0.0"
-dotenv@^16.3.1:
- version "16.3.1"
- resolved "https://registry.npmmirror.com/dotenv/-/dotenv-16.3.1.tgz#369034de7d7e5b120972693352a3bf112172cc3e"
- integrity sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==
-
duplexer3@^0.1.4:
version "0.1.5"
resolved "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.5.tgz"
diff --git a/frontend/desktop/src/api/platform.ts b/frontend/desktop/src/api/platform.ts
new file mode 100644
index 00000000000..993137e94d6
--- /dev/null
+++ b/frontend/desktop/src/api/platform.ts
@@ -0,0 +1,17 @@
+import request from '@/services/request';
+
+// handle baidu
+export const uploadConvertData = (newType: number[], url?: string) => {
+ const defaultUrl =
+ window.location.hostname === 'cloud.sealos.io' ? 'https://sealos.io/' : 'https://sealos.run/';
+ const main_url = url || defaultUrl;
+ const bd_vid = sessionStorage.getItem('bd_vid');
+ if (!bd_vid) {
+ return Promise.reject('Parameter error');
+ }
+ return request.post('/api/platform/uploadData', {
+ newType,
+ bd_vid,
+ main_url
+ });
+};
diff --git a/frontend/desktop/src/components/account/index.tsx b/frontend/desktop/src/components/account/index.tsx
index 2895e479638..c2dcaf3af02 100644
--- a/frontend/desktop/src/components/account/index.tsx
+++ b/frontend/desktop/src/components/account/index.tsx
@@ -171,7 +171,7 @@ export default function Index({ disclosure }: { disclosure: UseDisclosureReturn
p="20px"
backdropFilter={'blur(150px)'}
>
-
+
{t('Log Out')}
diff --git a/frontend/desktop/src/components/signin/index.tsx b/frontend/desktop/src/components/signin/index.tsx
index 97335918b1e..66839e004c1 100644
--- a/frontend/desktop/src/components/signin/index.tsx
+++ b/frontend/desktop/src/components/signin/index.tsx
@@ -1,3 +1,4 @@
+import { uploadConvertData } from '@/api/platform';
import useAuthList from '@/components/signin/auth/useAuthList';
import useCustomError from '@/components/signin/auth/useCustomError';
import Language from '@/components/signin/auth/useLanguage';
@@ -92,6 +93,9 @@ export default function SigninComponent() {
if (isAgree && selectedConfig) {
const { login } = selectedConfig;
login();
+ uploadConvertData([3]).then((res) => {
+ console.log(res);
+ });
} else {
setIsInvalid(true);
showError(t('Read and agree'));
diff --git a/frontend/desktop/src/pages/_app.tsx b/frontend/desktop/src/pages/_app.tsx
index 3d0dc2a2e3d..f835e779a3c 100644
--- a/frontend/desktop/src/pages/_app.tsx
+++ b/frontend/desktop/src/pages/_app.tsx
@@ -30,7 +30,6 @@ const App = ({ Component, pageProps }: AppProps) => {
useEffect(() => {
const lang = getCookie('NEXT_LOCALE');
- console.log(lang);
i18n?.changeLanguage?.(lang);
}, [i18n]);
diff --git a/frontend/desktop/src/pages/api/desktop/getInstalledApps.ts b/frontend/desktop/src/pages/api/desktop/getInstalledApps.ts
index 53898a04277..be361eceae0 100644
--- a/frontend/desktop/src/pages/api/desktop/getInstalledApps.ts
+++ b/frontend/desktop/src/pages/api/desktop/getInstalledApps.ts
@@ -31,6 +31,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
jsonRes(res, { data: apps });
} catch (err) {
+ console.log(err);
jsonRes(res, { code: 500, data: err });
}
}
diff --git a/frontend/desktop/src/pages/api/platform/uploadData.ts b/frontend/desktop/src/pages/api/platform/uploadData.ts
new file mode 100644
index 00000000000..c6a0ae29c20
--- /dev/null
+++ b/frontend/desktop/src/pages/api/platform/uploadData.ts
@@ -0,0 +1,48 @@
+import type { NextApiRequest, NextApiResponse } from 'next';
+import { jsonRes } from '@/services/backend/response';
+
+export default async function handler(req: NextApiRequest, res: NextApiResponse) {
+ try {
+ const { newType, bd_vid, main_url } = req.body as {
+ newType: number[];
+ bd_vid: string;
+ main_url: string;
+ };
+
+ const BD_TOKEN = process.env.BD_TOKEN;
+
+ if (!BD_TOKEN || !bd_vid) {
+ return jsonRes(res, {
+ data: 'Parameter error',
+ code: 400
+ });
+ }
+
+ const url = 'https://ocpc.baidu.com/ocpcapi/api/uploadConvertData';
+
+ const logidUrl = `${main_url}?bd_vid=${bd_vid}`;
+
+ const data = {
+ token: BD_TOKEN,
+ conversionTypes: newType.map((item) => ({ logidUrl: logidUrl, newType: item }))
+ };
+
+ const result = await (
+ await fetch(url, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ body: JSON.stringify(data)
+ })
+ ).json();
+
+ console.log(data, result);
+
+ jsonRes(res, {
+ data: result
+ });
+ } catch (error) {
+ jsonRes(res, { code: 500, data: error });
+ }
+}
diff --git a/frontend/desktop/src/pages/callback.tsx b/frontend/desktop/src/pages/callback.tsx
index d4b4799a224..0f42b6c9cfa 100644
--- a/frontend/desktop/src/pages/callback.tsx
+++ b/frontend/desktop/src/pages/callback.tsx
@@ -5,6 +5,7 @@ import request from '@/services/request';
import useSessionStore from '@/stores/session';
import { Session } from '@/types';
import { Flex, Spinner } from '@chakra-ui/react';
+import { uploadConvertData } from '@/api/platform';
const Callback: NextPage = () => {
const router = useRouter();
const setSessionProp = useSessionStore((s) => s.setSessionProp);
@@ -30,7 +31,9 @@ const Callback: NextPage = () => {
setSessionProp('token', token);
setSessionProp('user', user);
setSessionProp('kubeconfig', kubeconfig);
-
+ uploadConvertData([3]).then((res) => {
+ console.log(res);
+ });
router.replace('/');
} else {
throw new Error();
diff --git a/frontend/desktop/src/pages/index.tsx b/frontend/desktop/src/pages/index.tsx
index 44c4b847aae..ca5c8cfa519 100644
--- a/frontend/desktop/src/pages/index.tsx
+++ b/frontend/desktop/src/pages/index.tsx
@@ -82,6 +82,14 @@ export default function Home({ sealos_cloud_domain }: { sealos_cloud_domain: str
}
}, [router, init, setAutoLaunch, sealos_cloud_domain]);
+ // handle baidui
+ useEffect(() => {
+ const { bd_vid } = router.query;
+ if (bd_vid) {
+ sessionStorage.setItem('bd_vid', bd_vid as string);
+ }
+ }, []);
+
return (
diff --git a/frontend/providers/dbprovider/src/pages/api/delDBByName.ts b/frontend/providers/dbprovider/src/pages/api/delDBByName.ts
index 98085e53c45..15087029d6e 100644
--- a/frontend/providers/dbprovider/src/pages/api/delDBByName.ts
+++ b/frontend/providers/dbprovider/src/pages/api/delDBByName.ts
@@ -28,7 +28,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
k8sAuth.deleteNamespacedRole(name, namespace),
k8sAuth.deleteNamespacedRoleBinding(name, namespace),
k8sCore.deleteNamespacedServiceAccount(name, namespace)
- ]);
+ ]).catch((err) => console.log(err, 'delete role err'));
// delete cluster
await k8sCustomObjects.deleteNamespacedCustomObject(
diff --git a/service/license/src/api/system.ts b/service/license/src/api/system.ts
index 34799395b8f..94f6d36d0d0 100644
--- a/service/license/src/api/system.ts
+++ b/service/license/src/api/system.ts
@@ -1,4 +1,4 @@
-import { GET } from '@/services/request';
+import { GET, POST } from '@/services/request';
import { SystemEnv } from '@/types';
export const getSystemEnv = (): Promise =>
@@ -11,3 +11,19 @@ export const getPriceBonus = () =>
steps: string;
ratios: string;
}>('/api/price/bonus');
+
+// handle baidu
+export const uploadConvertData = (newType: number[], url?: string) => {
+ const defaultUrl =
+ window.location.hostname === 'license.sealos.io' ? 'https://sealos.io/' : 'https://sealos.run/';
+ const main_url = url || defaultUrl;
+ const bd_vid = sessionStorage.getItem('bd_vid');
+ if (!bd_vid) {
+ return Promise.reject('Parameter error');
+ }
+ return POST('/api/platform/uploadData', {
+ newType,
+ bd_vid,
+ main_url
+ });
+};
diff --git a/service/license/src/components/Signin/index.tsx b/service/license/src/components/Signin/index.tsx
index 13e6040edff..03436873379 100644
--- a/service/license/src/components/Signin/index.tsx
+++ b/service/license/src/components/Signin/index.tsx
@@ -1,4 +1,4 @@
-import { getSystemEnv } from '@/api/system';
+import { getSystemEnv, uploadConvertData } from '@/api/system';
import useAuthList from '@/components/Signin/auth/useAuthList';
import useCustomError from '@/components/Signin/auth/useCustomError';
import Language from '@/components/Signin/auth/useLanguage';
@@ -93,6 +93,9 @@ export default function SigninComponent() {
if (isAgree && selectedConfig) {
const { login } = selectedConfig;
login();
+ uploadConvertData([3]).then((res) => {
+ console.log(res);
+ });
} else {
setIsInvalid(true);
showError(t('Read and agree'));
diff --git a/service/license/src/components/signin/index.tsx b/service/license/src/components/signin/index.tsx
index 13e6040edff..03436873379 100644
--- a/service/license/src/components/signin/index.tsx
+++ b/service/license/src/components/signin/index.tsx
@@ -1,4 +1,4 @@
-import { getSystemEnv } from '@/api/system';
+import { getSystemEnv, uploadConvertData } from '@/api/system';
import useAuthList from '@/components/Signin/auth/useAuthList';
import useCustomError from '@/components/Signin/auth/useCustomError';
import Language from '@/components/Signin/auth/useLanguage';
@@ -93,6 +93,9 @@ export default function SigninComponent() {
if (isAgree && selectedConfig) {
const { login } = selectedConfig;
login();
+ uploadConvertData([3]).then((res) => {
+ console.log(res);
+ });
} else {
setIsInvalid(true);
showError(t('Read and agree'));
diff --git a/service/license/src/pages/api/platform/uploadData.ts b/service/license/src/pages/api/platform/uploadData.ts
new file mode 100644
index 00000000000..c6a0ae29c20
--- /dev/null
+++ b/service/license/src/pages/api/platform/uploadData.ts
@@ -0,0 +1,48 @@
+import type { NextApiRequest, NextApiResponse } from 'next';
+import { jsonRes } from '@/services/backend/response';
+
+export default async function handler(req: NextApiRequest, res: NextApiResponse) {
+ try {
+ const { newType, bd_vid, main_url } = req.body as {
+ newType: number[];
+ bd_vid: string;
+ main_url: string;
+ };
+
+ const BD_TOKEN = process.env.BD_TOKEN;
+
+ if (!BD_TOKEN || !bd_vid) {
+ return jsonRes(res, {
+ data: 'Parameter error',
+ code: 400
+ });
+ }
+
+ const url = 'https://ocpc.baidu.com/ocpcapi/api/uploadConvertData';
+
+ const logidUrl = `${main_url}?bd_vid=${bd_vid}`;
+
+ const data = {
+ token: BD_TOKEN,
+ conversionTypes: newType.map((item) => ({ logidUrl: logidUrl, newType: item }))
+ };
+
+ const result = await (
+ await fetch(url, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ body: JSON.stringify(data)
+ })
+ ).json();
+
+ console.log(data, result);
+
+ jsonRes(res, {
+ data: result
+ });
+ } catch (error) {
+ jsonRes(res, { code: 500, data: error });
+ }
+}
diff --git a/service/license/src/pages/callback.tsx b/service/license/src/pages/callback.tsx
index e1b7d4545e7..58b102838bb 100644
--- a/service/license/src/pages/callback.tsx
+++ b/service/license/src/pages/callback.tsx
@@ -1,3 +1,4 @@
+import { uploadConvertData } from '@/api/system';
import { signInByProvider } from '@/api/user';
import useSessionStore from '@/stores/session';
import { Flex, Spinner } from '@chakra-ui/react';
@@ -26,6 +27,9 @@ const Callback: NextPage = () => {
const data = await signInByProvider(provider, code);
setSession(data);
+ uploadConvertData([3]).then((res) => {
+ console.log(res);
+ });
router.replace('/pricing');
} catch (error) {
router.replace('/signin');
diff --git a/service/license/src/pages/license/components/Recharge.tsx b/service/license/src/pages/license/components/Recharge.tsx
index 8b013922498..a173678b4ea 100644
--- a/service/license/src/pages/license/components/Recharge.tsx
+++ b/service/license/src/pages/license/components/Recharge.tsx
@@ -1,5 +1,5 @@
import { checkWechatPay, createPayment, handlePaymentResult } from '@/api/payment';
-import { getSystemEnv } from '@/api/system';
+import { getSystemEnv, uploadConvertData } from '@/api/system';
import { StripeIcon, WechatIcon } from '@/components/Icon';
import useBonusBox from '@/hooks/useBonusBox';
import { PaymentStatus, TPayMethod, WechatPaymentData } from '@/types';
@@ -145,6 +145,9 @@ export default function RechargeComponent() {
console.log(data, 'getPaymentResult');
if (data.status === PaymentStatus.PaymentSuccess) {
licenseMutation.mutate({ orderID: data.orderID });
+ uploadConvertData([90]).then((res) => {
+ console.log(res);
+ });
}
},
onError(err: any) {
diff --git a/service/license/src/pages/pricing/components/Product.tsx b/service/license/src/pages/pricing/components/Product.tsx
index b1826b05e0e..6690c3aa56c 100644
--- a/service/license/src/pages/pricing/components/Product.tsx
+++ b/service/license/src/pages/pricing/components/Product.tsx
@@ -1,6 +1,6 @@
import { createCluster, createClusterAndLicense } from '@/api/cluster';
import { checkWechatPay, createPayment, handlePaymentResult } from '@/api/payment';
-import { getSystemEnv } from '@/api/system';
+import { getSystemEnv, uploadConvertData } from '@/api/system';
import { StripeIcon, SuccessIcon } from '@/components/Icon';
import { company, contect, standard } from '@/constant/product';
import { ClusterType, PaymentStatus, TPayMethod, WechatPaymentData } from '@/types';
@@ -181,6 +181,9 @@ export default function Product() {
console.log(data, 'getPaymentResult');
if (data.status === PaymentStatus.PaymentSuccess) {
clusterAndLicenseMutation.mutate({ orderID: data.orderID, type: ClusterType.Enterprise });
+ uploadConvertData([90]).then((res) => {
+ console.log(res);
+ });
}
},
onError(err: any) {
diff --git a/service/license/src/pages/signin.tsx b/service/license/src/pages/signin.tsx
index e6634721a63..2d6c4dd51c4 100644
--- a/service/license/src/pages/signin.tsx
+++ b/service/license/src/pages/signin.tsx
@@ -24,6 +24,15 @@ export default function SigninPage() {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
+ // handle baidu id
+ useEffect(() => {
+ const { bd_vid } = router.query;
+ if (bd_vid) {
+ sessionStorage.setItem('bd_vid', bd_vid as string);
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
+
return ;
}