adjust code

This commit is contained in:
john 2022-05-10 15:09:31 +07:00
parent 1dd9dc8bb1
commit fe358b6698
9 changed files with 80 additions and 19 deletions

1
.env.sample Normal file
View File

@ -0,0 +1 @@
DOMAIN='good'

4
.gitignore vendored
View File

@ -21,3 +21,7 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
*.tar.gz
.env
fabfile.py

55
fabfile.sample.py Normal file
View File

@ -0,0 +1,55 @@
"""
Deploy Tool
usage:
1. `fab deploy` 上传 DIRS 中指定的目录/文件
2. `fab deploy -p=xxx` 上传 xxx
3. `fab deploy -p='xxx yyy zzz' 上传 xxx, yyy, zzz
PS. 提前配置服务器地址密码
其他功能自行修改
"""
from os.path import exists, join
from fabric import task,Connection
FILE_TAR = 'coinwindf.tar.gz'
DIRS = ('build', )
UPLOAD_PATH = '~'
DEPLOY_PATH = '/www/coinwindf'
def run(c, cmd):
return c.run(cmd, hide=True)
@task
def tar(c):
c.run('rm -f {}'.format(FILE_TAR))
run(c, 'tar czf {} {}'.format(FILE_TAR, ' '.join(DIRS)))
# print(ret)
@task
def ptar(c, p):
# fallback
if not p:
return tar(c)
cmd = 'tar -czf {} {}'.format(FILE_TAR, p)
run(c, cmd)
@task
def deploy(c, p=''):
ptar(c, p)
with Connection(host='192.168.0.1', user='root', connect_kwargs={'password': '123456'}) as r:
with r.cd(UPLOAD_PATH):
r.put(FILE_TAR)
run(r, 'tar -xzf {} -C {}'.format(FILE_TAR, DEPLOY_PATH))
run(r, 'rm {}'.format(FILE_TAR))
run(r, 'chown -R nginx:nginx {}'.format(DEPLOY_PATH))

View File

@ -32,6 +32,7 @@ export const AppContextProvider = ({ children }) => {
const [kefuUrl, setKefuUrl] = React.useState('')
React.useEffect(() => {
console.debug('should be once')
get_settings().then((res) => {
const o = res.data.other

View File

@ -8,7 +8,7 @@ import { FiMenu, FiCircle } from 'react-icons/fi'
import { Logo } from './Logo'
import { config } from '../config'
import { useApp } from '../AppContext'
import { AlertWallet } from './alert/AlertWallet'
import { AlertBox } from './alert'
import { connectWallet, addEventListeners, fetchAccount } from '../lib'
import { get_register } from '../api'
import { useSearchParams } from 'react-router-dom'
@ -104,9 +104,9 @@ export const AppBar = ({ onOpenDrawer, ...rest }) => {
/>
</HStack>
<AlertWallet
<AlertBox
isOpen={isOpenConnectedWallet}
onCloseWnd={onCloseConnectedWallet}
onClose={onCloseConnectedWallet}
title="Wallet Address"
>
<VStack
@ -121,7 +121,7 @@ export const AppBar = ({ onOpenDrawer, ...rest }) => {
>{app.address}</Text>
</HStack>
</VStack>
</AlertWallet>
</AlertBox>
</Flex>
)
}

View File

@ -6,7 +6,7 @@ import {
AlertDialogBody, AlertDialogFooter
} from '@chakra-ui/react'
export const AlertWallet = ({ isOpen, onCloseWnd, title, children,
export const AlertBox = ({ isOpen, onClose, title, children,
showCancel = false, cancelText = 'Cancel', showOk = true, okText = 'OK' }) => {
const cancelRef = React.useRef()
@ -15,7 +15,7 @@ export const AlertWallet = ({ isOpen, onCloseWnd, title, children,
<AlertDialog
isOpen={isOpen}
leastDestructiveRef={cancelRef}
onClose={onCloseWnd}
onClose={onClose}
>
<AlertDialogOverlay>
@ -30,10 +30,10 @@ export const AlertWallet = ({ isOpen, onCloseWnd, title, children,
<AlertDialogFooter>
{
showCancel && <Button ref={cancelRef} onClick={onCloseWnd}>{cancelText}</Button>
showCancel && <Button ref={cancelRef} onClick={onClose}>{cancelText}</Button>
}
{
showOk && <Button colorScheme='blue' onClick={onCloseWnd} ml={3}>
showOk && <Button colorScheme='blue' onClick={onClose} ml={3}>
{okText}
</Button>
}

View File

@ -1,13 +1,13 @@
import React from 'react'
import { Button, Modal, ModalBody, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalOverlay } from '@chakra-ui/react'
export const ModalBox = ({ title, isOpening, onCloseModal, children, onConfirm = null, focusRef = null }) => {
export const ModalBox = ({ title, isOpen, onClose, children, onConfirm = null, focusRef = null }) => {
return (
<Modal
initialFocusRef={focusRef}
isOpen={isOpening}
onClose={onCloseModal}
isOpen={isOpen}
onClose={onClose}
>
<ModalOverlay />
<ModalContent>
@ -21,11 +21,11 @@ export const ModalBox = ({ title, isOpening, onCloseModal, children, onConfirm =
<ModalFooter>
<Button colorScheme="blue" onClick={() => {
onConfirm && onConfirm()
onCloseModal()
onClose()
}} mr={3}>
OK
</Button>
<Button onClick={onCloseModal}>Cancel</Button>
<Button onClick={onClose}>Cancel</Button>
</ModalFooter>
</ModalContent>
</Modal>

View File

@ -1,2 +1,2 @@
export * from './AlertWallet'
export * from './AlertBox'
export * from './ModalBox'

View File

@ -96,7 +96,7 @@ export const Farm = () => {
if (!app.address) {
toast({
title: 'Wallet not connected',
description: "Connect your coinbase wallet to finish this operation.",
description: "Please connect your wallet first to perform the operation",
status: 'warning',
duration: 9000,
isClosable: true,
@ -235,8 +235,8 @@ export const Farm = () => {
{/* withdrawal box */}
<ModalBox
title="Withdrawal"
isOpening={isWithdrawalOpen}
onCloseModal={onWithdrawalClose}
isOpen={isWithdrawalOpen}
onClose={onWithdrawalClose}
onConfirm={onWithdrawalConfirmed}
focusRef={withdrawalRef}
>
@ -248,8 +248,8 @@ export const Farm = () => {
{/* deposite box */}
<ModalBox
title="Deposite"
isOpening={isDepositeOpen}
onCloseModal={onDepositeClose}
isOpen={isDepositeOpen}
onClose={onDepositeClose}
onConfirm={onDepositeConfirmed}
focusRef={depositeRef}
>