-
Notifications
You must be signed in to change notification settings - Fork 0
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
Bara chain #134
Bara chain #134
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
VITE_SOCKET_BASE_URL="wss://dev-chat-xfans-api.buidlerdao.xyz" | ||
VITE_ROOM_BASE_URL="https://dev-chat-xfans-api.buidlerdao.xyz" | ||
VITE_CONTRACT_BASE_URL="https://test-mpc-xfans-api.buidlerdao.xyz" | ||
VITE_BASE_URL="https://test-api.xfans.tech" | ||
# arb | ||
VITE_ARB_SOCKET_BASE_URL="wss://dev-chat-xfans-api.buidlerdao.xyz" | ||
VITE_ARB_ROOM_BASE_URL="https://dev-chat-xfans-api.buidlerdao.xyz" | ||
VITE_ARB_CONTRACT_BASE_URL="http://localhost:3001" | ||
VITE_ARB_BASE_URL="https://test-api.xfans.tech" | ||
|
||
# bera | ||
VITE_BERA_SOCKET_BASE_URL="wss://dev-chat-xfans-api.buidlerdao.xyz" | ||
VITE_BERA_ROOM_BASE_URL="https://dev-chat-xfans-api.buidlerdao.xyz" | ||
VITE_BERA_CONTRACT_BASE_URL="http://localhost:3001" | ||
VITE_BERA_BASE_URL="https://test-bera-api.xfans.tech" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from 'react'; | ||
import { Select, MenuItem, SelectChangeEvent } from '@mui/material'; | ||
|
||
interface TSelectProps { | ||
handleChange: (value: string) => void; | ||
} | ||
|
||
const TSelect: React.FC<TSelectProps> = ({ handleChange }) => { | ||
const [selectedValue, setSelectedValue] = React.useState('arb'); | ||
|
||
const handleInternalChange = (event: SelectChangeEvent<string>) => { | ||
const value = event.target.value; | ||
setSelectedValue(value); | ||
handleChange(value); // 调用传入的 handleChange 函数 | ||
}; | ||
|
||
return ( | ||
<Select | ||
value={selectedValue} | ||
onChange={handleInternalChange} | ||
style={{ minWidth: '120px', height: '60px' }} | ||
> | ||
<MenuItem value="arb">arb</MenuItem> | ||
<MenuItem value="bera">bera</MenuItem> | ||
</Select> | ||
); | ||
}; | ||
|
||
export default TSelect; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
interface ChainConfigType { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 搞个 store 把,类似 global store,或者直接放进去也行 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. store试过了 放到json中会报错,只能放到function中 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 你这里又直接用 localStorage 了啊 |
||
vite_socket_base_url: string; | ||
vite_room_base_url: string; | ||
vite_contract_base_url: string; | ||
vite_base_url: string; | ||
} | ||
|
||
const _chainConfig: Record<string, ChainConfigType> = { | ||
arb: { | ||
vite_socket_base_url: import.meta.env.VITE_ARB_SOCKET_BASE_URL!, | ||
vite_room_base_url: import.meta.env.VITE_ARB_ROOM_BASE_URL!, | ||
vite_contract_base_url: import.meta.env.VITE_ARB_CONTRACT_BASE_URL!, | ||
vite_base_url: import.meta.env.VITE_ARB_BASE_URL!, | ||
}, | ||
bera: { | ||
vite_socket_base_url: import.meta.env.VITE_BERA_SOCKET_BASE_URL!, | ||
vite_room_base_url: import.meta.env.VITE_BERA_ROOM_BASE_URL!, | ||
vite_contract_base_url: import.meta.env.VITE_BERA_CONTRACT_BASE_URL!, | ||
vite_base_url: import.meta.env.VITE_BERA_BASE_URL!, | ||
}, | ||
}; | ||
|
||
console.log('_chainConfig', _chainConfig); | ||
const ChainConfig = () => { | ||
if (getCurrentChain() == '') console.error('chain info undefined!'); | ||
return _chainConfig[getCurrentChain()]; | ||
}; | ||
|
||
export const getCurrentChain = () => localStorage.getItem('current_chain') ?? 'arb'; | ||
export const setCurrentChain = (chain: string) => { | ||
localStorage.setItem('current_chain', chain); | ||
}; | ||
|
||
export default ChainConfig; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import React, { FC } from 'react'; | ||
|
||
import { NextButton } from '../../components/buttons/loginButton'; | ||
|
||
import TSelect from '../../components/Select/index'; | ||
import { setCurrentChain, getCurrentChain } from '../../config/chainConfig'; | ||
import '../../tailwind.css'; | ||
|
||
interface SignInWithXPageProps { | ||
|
@@ -53,6 +54,13 @@ const SignInWithXPage: FC<SignInWithXPageProps> = ({ handleButtonClick, showLoad | |
'Login With X' | ||
)} | ||
</NextButton> | ||
<TSelect | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个能不能判断下 dev 环境才展示 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 临时代码 |
||
handleChange={(x: string) => { | ||
console.log('select', x); | ||
setCurrentChain(x); | ||
console.log('getCurrentChain', getCurrentChain()); | ||
}} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果不打算做成通用,建议组件名字改下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
临时代码