feat: 优化整体项目ui
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
import ky, { HTTPError, type Options, TimeoutError } from 'ky'
|
||||
import {
|
||||
ACCESS_TOKEN_REFRESH_SKEW_MS,
|
||||
API_ERROR_MESSAGES,
|
||||
AUTH_REFRESH_ATTEMPTED_CONTEXT_KEY,
|
||||
AUTH_REFRESH_ENDPOINT,
|
||||
AUTH_SKIP_REFRESH_CONTEXT_KEY,
|
||||
AUTH_TOKEN_CACHE_SKEW_MS,
|
||||
AUTH_TOKEN_ENDPOINT,
|
||||
DEFAULT_REQUEST_ACCEPT_HEADER,
|
||||
DEFAULT_REQUEST_TIMEOUT_MS,
|
||||
} from '@/constants'
|
||||
@@ -24,12 +30,6 @@ type JsonRequestOptions<TBody> = RequestOptions & {
|
||||
json?: TBody
|
||||
}
|
||||
|
||||
const AUTH_REFRESH_ATTEMPTED_CONTEXT_KEY = 'authRefreshAttempted'
|
||||
const AUTH_SKIP_REFRESH_CONTEXT_KEY = 'skipAuthRefresh'
|
||||
const AUTH_TOKEN_ENDPOINT = 'api/v1/authToken'
|
||||
const AUTH_REFRESH_ENDPOINT = 'api/user/refreshToken'
|
||||
const ACCESS_TOKEN_REFRESH_SKEW_MS = 60_000
|
||||
const AUTH_TOKEN_CACHE_SKEW_MS = 30_000
|
||||
const appEnv = import.meta.env.VITE_APP_ENV
|
||||
const authSecret = import.meta.env.VITE_AUTH_TOKEN_SECRET?.trim()
|
||||
const shouldLogRequests = import.meta.env.VITE_ENABLE_REQUEST_LOG === 'true'
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { create } from 'zustand'
|
||||
import {
|
||||
DEFAULT_ALERT_DURATION_MS,
|
||||
NOTIFICATION_EXIT_DURATION_MS,
|
||||
} from '@/constants'
|
||||
|
||||
type NotificationType = 'success' | 'error' | 'warning' | 'info' | 'loading'
|
||||
const DEFAULT_ALERT_DURATION_MS = 2600
|
||||
export const NOTIFICATION_EXIT_DURATION_MS = 220
|
||||
|
||||
export interface NotifyOptions {
|
||||
description?: string
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { type ClassValue, clsx } from 'clsx'
|
||||
import { twMerge } from 'tailwind-merge'
|
||||
import { FULLSCREEN_CHANGE_EVENTS } from '@/constants'
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs))
|
||||
@@ -20,13 +21,6 @@ type FullscreenCapableDocument = Document & {
|
||||
webkitFullscreenElement?: Element | null
|
||||
}
|
||||
|
||||
const FULLSCREEN_CHANGE_EVENTS = [
|
||||
'fullscreenchange',
|
||||
'webkitfullscreenchange',
|
||||
'mozfullscreenchange',
|
||||
'MSFullscreenChange',
|
||||
] as const
|
||||
|
||||
export function isDesktopFullscreen() {
|
||||
if (typeof document === 'undefined') {
|
||||
return false
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
import {
|
||||
LATENCY_PROBE_INTERVAL_MS,
|
||||
LATENCY_PROBE_TIMEOUT_MS,
|
||||
MAX_RECONNECT_DELAY_MS,
|
||||
} from '@/constants'
|
||||
|
||||
type GameSocketContext = {
|
||||
authToken: string
|
||||
deviceId: string
|
||||
@@ -47,10 +53,6 @@ type GameSocketClientOptions = {
|
||||
onStatusChange?: (status: GameSocketStatus, reconnectAttempt: number) => void
|
||||
}
|
||||
|
||||
const MAX_RECONNECT_DELAY_MS = 10_000
|
||||
const LATENCY_PROBE_INTERVAL_MS = 3_000
|
||||
const LATENCY_PROBE_TIMEOUT_MS = 10_000
|
||||
|
||||
function toQueryString(context: GameSocketContext) {
|
||||
const params = new URLSearchParams({
|
||||
token: context.token,
|
||||
|
||||
Reference in New Issue
Block a user