fix: protected pages behind selected endpoint, fixes #647

This commit is contained in:
kunish 2024-03-26 23:36:44 +08:00
parent 495faf2088
commit a3877229b8
No known key found for this signature in database
GPG Key ID: 67D3ACD788F3A7CD
9 changed files with 74 additions and 13 deletions

BIN
bun.lockb

Binary file not shown.

View File

@ -25,13 +25,13 @@
"@solid-primitives/keyed": "^1.2.2",
"@solid-primitives/media": "^2.2.8",
"@solid-primitives/resize-observer": "^2.0.25",
"@solid-primitives/storage": "^2.1.4",
"@solid-primitives/storage": "^3.0.0",
"@solid-primitives/timer": "^1.3.9",
"@solid-primitives/websocket": "^1.2.2",
"@solidjs/router": "^0.13.1",
"@tabler/icons-solidjs": "^2.47.0",
"@tanstack/match-sorter-utils": "^8.11.8",
"@tanstack/solid-table": "^8.14.0",
"@tanstack/solid-table": "^8.15.0",
"@tanstack/solid-virtual": "3.0.2",
"@tanstack/virtual-core": "3.0.2",
"@thisbeyond/solid-dnd": "^0.7.5",
@ -39,21 +39,21 @@
"@types/lodash": "^4.17.0",
"@types/node": "^20.11.30",
"@types/uuid": "^9.0.8",
"@typescript-eslint/eslint-plugin": "^7.3.1",
"@typescript-eslint/parser": "^7.3.1",
"@typescript-eslint/eslint-plugin": "^7.4.0",
"@typescript-eslint/parser": "^7.4.0",
"@vite-pwa/assets-generator": "^0.2.4",
"apexcharts": "^3.48.0",
"autoprefixer": "^10.4.18",
"autoprefixer": "^10.4.19",
"byte-size": "^8.1.1",
"commitlint": "^19.2.1",
"daisyui": "^4.7.3",
"daisyui": "^4.9.0",
"dayjs": "^1.11.10",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"husky": "^9.0.11",
"is-ip": "^5.0.1",
"ky": "^1.2.2",
"ky": "^1.2.3",
"lint-staged": "^15.2.2",
"lodash": "^4.17.21",
"match-sorter": "^6.3.4",
@ -66,10 +66,10 @@
"sort-package-json": "^2.8.0",
"tailwind-merge": "^2.2.2",
"tailwindcss": "^3.4.1",
"typescript": "^5.4.2",
"typescript": "^5.4.3",
"uuid": "^9.0.1",
"vite": "^5.1.6",
"vite-plugin-pwa": "^0.19.5",
"vite": "^5.2.6",
"vite-plugin-pwa": "^0.19.7",
"vite-plugin-solid": "^2.10.2",
"zod": "^3.22.4"
}

View File

@ -27,7 +27,7 @@ render(
<I18nProvider locale={locale()}>
<HashRouter root={App}>
<Route path={ROUTES.Setup} component={Setup} />
<Route path="/" component={Overview} />
<Route path="*" component={Overview} />
<Route path={ROUTES.Overview} component={Overview} />
<Route path={ROUTES.Proxies} component={Proxies} />
<Route path={ROUTES.Rules} component={Rules} />

View File

@ -35,6 +35,7 @@ import { isSingBox } from '~/helpers'
import { locale, setLocale, useI18n } from '~/i18n'
import {
autoSwitchTheme,
endpoint,
favDayTheme,
favNightTheme,
setAutoSwitchTheme,
@ -514,6 +515,14 @@ const Versions: Component<{ backendVersion: Accessor<string> }> = ({
}
export default () => {
const navigate = useNavigate()
if (!endpoint()) {
navigate('/setup', { replace: true })
return null
}
const [t] = useI18n()
const [backendVersion, setBackendVersion] = createSignal('')

View File

@ -1,5 +1,6 @@
import { writeClipboard } from '@solid-primitives/clipboard'
import { makePersisted } from '@solid-primitives/storage'
import { useNavigate } from '@solidjs/router'
import {
IconInfoSmall,
IconPlayerPause,
@ -51,6 +52,7 @@ import {
connectionsTableColumnOrder,
connectionsTableColumnVisibility,
connectionsTableSize,
endpoint,
formatTimeFromNow,
setConnectionsTableColumnOrder,
setConnectionsTableColumnVisibility,
@ -78,6 +80,14 @@ const fuzzyFilter: FilterFn<Connection> = (row, columnId, value, addMeta) => {
}
export default () => {
const navigate = useNavigate()
if (!endpoint()) {
navigate('/setup', { replace: true })
return null
}
let connectionsSettingsModalRef: HTMLDialogElement | undefined
let connectionsDetailsModalRef: HTMLDialogElement | undefined

View File

@ -1,4 +1,5 @@
import { makePersisted } from '@solid-primitives/storage'
import { useNavigate } from '@solidjs/router'
import {
IconSettings,
IconSortAscending,
@ -20,7 +21,12 @@ import { twMerge } from 'tailwind-merge'
import { Button, LogsSettingsModal } from '~/components'
import { LOG_LEVEL } from '~/constants'
import { useI18n } from '~/i18n'
import { logsTableSize, tableSizeClassName, useWsRequest } from '~/signals'
import {
endpoint,
logsTableSize,
tableSizeClassName,
useWsRequest,
} from '~/signals'
import { logLevel, logMaxRows } from '~/signals/config'
import { Log } from '~/types'
@ -40,6 +46,14 @@ const fuzzyFilter: FilterFn<LogWithSeq> = (row, columnId, value, addMeta) => {
}
export default () => {
const navigate = useNavigate()
if (!endpoint()) {
navigate('/setup', { replace: true })
return null
}
let logsSettingsModalRef: HTMLDialogElement | undefined
const [t] = useI18n()

View File

@ -1,4 +1,5 @@
import { makeTimer } from '@solid-primitives/timer'
import { useNavigate } from '@solidjs/router'
import type { ApexOptions } from 'apexcharts'
import byteSize from 'byte-size'
import { merge } from 'lodash'
@ -26,6 +27,14 @@ const TrafficWidget: ParentComponent<{ label: JSX.Element }> = (props) => (
)
export default () => {
const navigate = useNavigate()
if (!endpoint()) {
navigate('/setup', { replace: true })
return null
}
const [t] = useI18n()
const [traffics, setTraffics] = createSignal<{ down: number; up: number }[]>(

View File

@ -1,3 +1,4 @@
import { useNavigate } from '@solidjs/router'
import {
IconBrandSpeedtest,
IconReload,
@ -19,6 +20,7 @@ import {
} from '~/helpers'
import { useI18n } from '~/i18n'
import {
endpoint,
formatTimeFromNow,
hideUnAvailableProxies,
proxiesOrderingType,
@ -32,6 +34,14 @@ enum ActiveTab {
}
export default () => {
const navigate = useNavigate()
if (!endpoint()) {
navigate('/setup', { replace: true })
return null
}
let proxiesSettingsModalRef: HTMLDialogElement | undefined
const [t] = useI18n()

View File

@ -1,3 +1,4 @@
import { useNavigate } from '@solidjs/router'
import { IconReload } from '@tabler/icons-solidjs'
import { createVirtualizer } from '@tanstack/solid-virtual'
import { matchSorter } from 'match-sorter'
@ -6,7 +7,7 @@ import { twMerge } from 'tailwind-merge'
import { Button } from '~/components'
import { useStringBooleanMap } from '~/helpers'
import { useI18n } from '~/i18n'
import { formatTimeFromNow, useRules } from '~/signals'
import { endpoint, formatTimeFromNow, useRules } from '~/signals'
import { Rule, RuleProvider } from '~/types'
enum ActiveTab {
@ -15,6 +16,14 @@ enum ActiveTab {
}
export default () => {
const navigate = useNavigate()
if (!endpoint()) {
navigate('/setup', { replace: true })
return null
}
const [t] = useI18n()
const {
rules,