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* npm-debug.log*
yarn-debug.log* yarn-debug.log*
yarn-error.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('') const [kefuUrl, setKefuUrl] = React.useState('')
React.useEffect(() => { React.useEffect(() => {
console.debug('should be once')
get_settings().then((res) => { get_settings().then((res) => {
const o = res.data.other const o = res.data.other

View File

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

View File

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

View File

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

View File

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

View File

@ -96,7 +96,7 @@ export const Farm = () => {
if (!app.address) { if (!app.address) {
toast({ toast({
title: 'Wallet not connected', 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', status: 'warning',
duration: 9000, duration: 9000,
isClosable: true, isClosable: true,
@ -235,8 +235,8 @@ export const Farm = () => {
{/* withdrawal box */} {/* withdrawal box */}
<ModalBox <ModalBox
title="Withdrawal" title="Withdrawal"
isOpening={isWithdrawalOpen} isOpen={isWithdrawalOpen}
onCloseModal={onWithdrawalClose} onClose={onWithdrawalClose}
onConfirm={onWithdrawalConfirmed} onConfirm={onWithdrawalConfirmed}
focusRef={withdrawalRef} focusRef={withdrawalRef}
> >
@ -248,8 +248,8 @@ export const Farm = () => {
{/* deposite box */} {/* deposite box */}
<ModalBox <ModalBox
title="Deposite" title="Deposite"
isOpening={isDepositeOpen} isOpen={isDepositeOpen}
onCloseModal={onDepositeClose} onClose={onDepositeClose}
onConfirm={onDepositeConfirmed} onConfirm={onDepositeConfirmed}
focusRef={depositeRef} focusRef={depositeRef}
> >