Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:docs & delete db role & baidu #4272

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions docs/website/docusaurus.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// @ts-check
const generateAlgoliKey = () => "ce5b8e1e4d0d35ff587caf75ac404df4"
require('dotenv').config()

/** @type {import('@docusaurus/types').Config} */
const config = {
Expand All @@ -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.
Expand Down
1 change: 0 additions & 1 deletion docs/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
44 changes: 0 additions & 44 deletions docs/website/src/hooks/useUploadData.ts

This file was deleted.

12 changes: 10 additions & 2 deletions docs/website/src/hooks/useWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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'
);
Expand All @@ -33,6 +40,7 @@ export default function () {
return {
screenWidth,
currentLanguage,
cloudUrl
cloudUrl,
bd_vid
};
}
7 changes: 5 additions & 2 deletions docs/website/src/pages/components/Banner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -64,7 +64,10 @@ export default function Banner() {
<div
className="btn"
onClick={() => {
window.open(`${cloudUrl}/?openapp=system-costcenter?openRecharge=true`, '_blank');
window.open(
`${cloudUrl}/?bd_vid=${bd_vid}&openapp=system-costcenter?openRecharge=true`,
'_blank'
);
closeBanner();
}}
>
Expand Down
13 changes: 8 additions & 5 deletions docs/website/src/pages/components/Capability/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -66,7 +66,10 @@ const Capability = ({ isPc }: { isPc: boolean }) => {
</div>
<h3> {i18nObj.appMan} </h3>
<h4>{i18nObj.appManagement_introduce}</h4>
<a href={`${cloudUrl}/?openapp=system-applaunchpad%3F`} target="_black">
<a
href={`${cloudUrl}/?bd_vid=${bd_vid}&openapp=system-applaunchpad%3F`}
target="_black"
>
{i18nObj.Explore} {'>'}
</a>
</div>
Expand All @@ -84,7 +87,7 @@ const Capability = ({ isPc }: { isPc: boolean }) => {
</div>
<div className="application-title">{i18nObj.database} </div>
<div className="application-text">{i18nObj.database_introduce}</div>
<a href={`${cloudUrl}/?openapp=system-dbprovider%3F`} target="_black">
<a href={`${cloudUrl}/?bd_vid=${bd_vid}&openapp=system-dbprovider%3F`} target="_black">
{i18nObj.Explore} {'>'}
</a>
<img
Expand Down Expand Up @@ -125,7 +128,7 @@ const Capability = ({ isPc }: { isPc: boolean }) => {
</div>
<h3> {i18nObj.appMan} </h3>
<h4>{i18nObj.appManagement_introduce}</h4>
<a href={`${cloudUrl}/?openapp=system-applaunchpad%3F`} target="_black">
<a href={`${cloudUrl}/?bd_vid=${bd_vid}&openapp=system-applaunchpad%3F`} target="_black">
{i18nObj.Explore} {'>'}
</a>
</div>
Expand All @@ -143,7 +146,7 @@ const Capability = ({ isPc }: { isPc: boolean }) => {
</div>
<div className="application-title">{i18nObj.database}</div>
<div className="application-text">{i18nObj.database_introduce}</div>
<a href={`${cloudUrl}/?openapp=system-dbprovider%3F`} target="_black">
<a href={`${cloudUrl}/?bd_vid=${bd_vid}&openapp=system-dbprovider%3F`} target="_black">
{i18nObj.Explore} {'>'}
</a>
<img
Expand Down
1 change: 1 addition & 0 deletions docs/website/src/pages/components/Header/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
margin-left: 16px;
font-weight: 500;
color: #fff;
cursor: pointer;
a {
font-size: 16px;
}
Expand Down
34 changes: 11 additions & 23 deletions docs/website/src/pages/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import LogoIcon from '@site/static/icons/sealos.svg';
import React, { useEffect, useState } from 'react';
import VideoPlayer from '../VideoPlayer';
import './index.scss';
import useUploadData from '@site/src/hooks/useUploadData';

const navbar = [
{
Expand Down Expand Up @@ -42,8 +41,7 @@ const i18nObj = {
const HomeHeader = ({ isPc }: { isPc: boolean }) => {
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/' },
Expand Down Expand Up @@ -166,22 +164,7 @@ const HomeHeader = ({ isPc }: { isPc: boolean }) => {
</div>
<div className="links">
{navbar.map((item) => (
<Link
key={item.key}
to={item.to}
onClick={() => {
if (item.key === 'contact') {
console.log('uploadConvertData');
uploadConvertData([
{
newType: 1
}
])
.then((response) => response && response.json())
.then((data) => console.log(data, 'bd_res'));
}
}}
>
<Link key={item.key} to={item.to}>
{item.label}
</Link>
))}
Expand All @@ -194,10 +177,15 @@ const HomeHeader = ({ isPc }: { isPc: boolean }) => {
<span className="git-stars">{Math.floor(stars / 1000)}k</span>
</Link>
{isBrowser && (
<div className="i18nIcon">
<Link to={`${location.origin}${i18nMap[currentLocale]?.link}`} target="_self">
{i18nMap[currentLocale]?.label}
</Link>
<div
className="i18nIcon"
onClick={() =>
window.location.replace(
`${location.origin}${currentLocale === 'en' ? '/zh-Hans/' : '/'}`
)
}
>
{i18nMap[currentLocale]?.label}
</div>
)}
<a className="start-now-button" href={`${cloudUrl}?bd_vid=${bd_vid}`} target="_blank">
Expand Down
2 changes: 1 addition & 1 deletion docs/website/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
4 changes: 2 additions & 2 deletions docs/website/src/pages/self-hosting/header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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/' },
Expand Down Expand Up @@ -135,7 +135,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
11 changes: 5 additions & 6 deletions docs/website/src/pages/self-hosting/product/index.tsx
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down Expand Up @@ -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}`
)
}
>
Expand Down Expand Up @@ -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}`
)
}
>
Expand Down Expand Up @@ -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'
)
}
>
Expand Down
13 changes: 6 additions & 7 deletions docs/website/static/global.js
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
5 changes: 0 additions & 5 deletions docs/website/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
17 changes: 17 additions & 0 deletions frontend/desktop/src/api/platform.ts
Original file line number Diff line number Diff line change
@@ -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
});
};
2 changes: 1 addition & 1 deletion frontend/desktop/src/components/account/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export default function Index({ disclosure }: { disclosure: UseDisclosureReturn
p="20px"
backdropFilter={'blur(150px)'}
>
<Flex justifyContent={'end'} alignItems={'center'} overflow={'hidden'}>
<Flex justifyContent={'end'} alignItems={'center'} overflow={'hidden'} cursor={'pointer'}>
<Iconfont iconName="icon-logout" width={14} height={14} color="#24282C"></Iconfont>
<Text ml="6px" color={'#24282C'} fontSize={'12px'} fontWeight={500} onClick={logout}>
{t('Log Out')}
Expand Down
4 changes: 4 additions & 0 deletions frontend/desktop/src/components/signin/index.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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'));
Expand Down
1 change: 0 additions & 1 deletion frontend/desktop/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const App = ({ Component, pageProps }: AppProps) => {

useEffect(() => {
const lang = getCookie('NEXT_LOCALE');
console.log(lang);
i18n?.changeLanguage?.(lang);
}, [i18n]);

Expand Down
Loading
Loading