Skip to content

feat: 添加url查询仓库功能 #146

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

Closed
wants to merge 9 commits into from
Closed
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
22 changes: 20 additions & 2 deletions site/components/quickIssue/QuickIssue.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// 场景案例模版
import React, { useState, useMemo, useEffect } from 'react';
import { Layout as AntLayout, Button, Form, Input, Select, Space } from 'antd';
import Article from '@antv/dumi-theme-antv/dist/slots/Article';
@@ -29,6 +28,7 @@ const formItemLayout = {
export default () => {
const [url, setUrl] = useState<url>(undefined)
const [windowSize, setWindowSize] = useState(getWindowSize());
const [form] = Form.useForm();
const locale = useLocale()
const lang = locale.id.includes('zh') ? 'zh' : 'en';

@@ -102,14 +102,32 @@ export default () => {
</div>
}, [lang])

const getQueryVariable = (variable: string) => {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) { return pair[1]; }
}
return (false);
}

useEffect(() => {
if (getQueryVariable('repo')) {
const data = GITHUB_URL.find((item) => item.label === getQueryVariable('repo'))
form.setFieldsValue({ gitHub: data?.gitUrl })
setUrl(data)
}
}, [])

return (
<>
<AntLayout hasSider>
<Article className={style.markdown}>
<div style={{ height: '100%', width: '100%', display: 'flex', justifyContent: 'center' }}>
<div className={style.content}>
{text}
<Form onFinish={onFinish} {...windowSize.innerWidth < 960 ? {} : formItemLayout} >
<Form form={form} onFinish={onFinish} {...windowSize.innerWidth < 960 ? {} : formItemLayout} >
<div className={style.flex}>
<Form.Item
label={lang === 'zh' ? '仓库' : 'Repositorie'}
2 changes: 1 addition & 1 deletion site/components/quickIssue/data.ts
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ export const GITHUB_URL = [
{
label: 'G6',
gitUrl: 'https://github.com/antvis/G6',
api: 'https://g6.antv.antgroup.com/api/overview',
api: 'https://g6.antv.antgroup.com/api/Graph',
chartDemo: 'https://g6.antv.antgroup.com/examples',
assignee:'Yanyan-Wang',
},