mirror of
https://github.com/laoxong/nofx.git
synced 2026-06-04 01:48:22 +08:00
fix: division by zero guard, logout redirect, onboarding close button
- auto_trader_risk: skip drawdown check when entryPrice <= 0 - AuthContext: redirect to / on logout - App.tsx: simplify data page navigation - BeginnerOnboardingPage: add close button to overlay
This commit is contained in:
@@ -49,6 +49,12 @@ func (at *AutoTrader) checkPositionDrawdown() {
|
||||
quantity = -quantity // Short position quantity is negative, convert to positive
|
||||
}
|
||||
|
||||
// Guard: skip if entry price is zero (prevents division by zero panic)
|
||||
if entryPrice <= 0 {
|
||||
logger.Warnf("⚠️ Drawdown monitoring: %s %s has zero entry price, skipping", symbol, side)
|
||||
continue
|
||||
}
|
||||
|
||||
// Calculate current P&L percentage
|
||||
leverage := 10 // Default value
|
||||
if lev, ok := pos["leverage"].(float64); ok {
|
||||
|
||||
+1
-13
@@ -451,19 +451,7 @@ function App() {
|
||||
// Data page - publicly accessible with embedded dashboard
|
||||
if (route === '/data') {
|
||||
const dataPageNavigate = (page: Page) => {
|
||||
const pathMap: Record<string, string> = {
|
||||
'data': '/data',
|
||||
'competition': '/competition',
|
||||
'strategy-market': '/strategy-market',
|
||||
'traders': '/traders',
|
||||
'trader': '/dashboard',
|
||||
'strategy': '/strategy',
|
||||
'faq': '/faq',
|
||||
}
|
||||
const path = pathMap[page]
|
||||
if (path) {
|
||||
window.location.href = path
|
||||
}
|
||||
navigateToPage(page)
|
||||
}
|
||||
return (
|
||||
<div
|
||||
|
||||
@@ -290,6 +290,8 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
setToken(null)
|
||||
localStorage.removeItem('auth_token')
|
||||
localStorage.removeItem('auth_user')
|
||||
window.history.pushState({}, '', '/')
|
||||
window.dispatchEvent(new PopStateEvent('popstate'))
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
RefreshCw,
|
||||
Shield,
|
||||
Wallet,
|
||||
X,
|
||||
} from 'lucide-react'
|
||||
import { QRCodeSVG } from 'qrcode.react'
|
||||
import { toast } from 'sonner'
|
||||
@@ -85,6 +86,14 @@ export function BeginnerOnboardingPage() {
|
||||
<div className="fixed inset-0 z-[80]">
|
||||
<div className="absolute inset-0 bg-black/58 backdrop-blur-[2px]" />
|
||||
<div className="relative flex min-h-screen items-center justify-center px-4 py-10 sm:px-6">
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleContinue}
|
||||
className="absolute right-6 top-6 z-10 inline-flex h-10 w-10 items-center justify-center rounded-full border border-white/10 bg-white/5 text-zinc-400 transition hover:border-white/20 hover:bg-white/10 hover:text-white"
|
||||
aria-label={isZh ? '跳过' : 'Skip'}
|
||||
>
|
||||
<X className="h-5 w-5" />
|
||||
</button>
|
||||
<div className="w-full max-w-[1120px]">
|
||||
<div className="mb-5 flex flex-col gap-4 lg:flex-row lg:items-end lg:justify-between">
|
||||
<div className="flex items-center gap-4">
|
||||
|
||||
Reference in New Issue
Block a user