Skip to content

Commit

Permalink
fix: protected pages behind selected endpoint, fixes MetaCubeX#647
Browse files Browse the repository at this point in the history
  • Loading branch information
kunish committed Mar 26, 2024
1 parent 495faf2 commit a387722
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 13 deletions.
Binary file modified bun.lockb
Binary file not shown.
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,35 @@
"@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",
"@types/byte-size": "^8.1.2",
"@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",
Expand All @@ -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"
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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} />
Expand Down
9 changes: 9 additions & 0 deletions src/pages/Config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { isSingBox } from '~/helpers'
import { locale, setLocale, useI18n } from '~/i18n'
import {
autoSwitchTheme,
endpoint,
favDayTheme,
favNightTheme,
setAutoSwitchTheme,
Expand Down Expand Up @@ -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('')
Expand Down
10 changes: 10 additions & 0 deletions src/pages/Connections.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { writeClipboard } from '@solid-primitives/clipboard'
import { makePersisted } from '@solid-primitives/storage'
import { useNavigate } from '@solidjs/router'
import {
IconInfoSmall,
IconPlayerPause,
Expand Down Expand Up @@ -51,6 +52,7 @@ import {
connectionsTableColumnOrder,
connectionsTableColumnVisibility,
connectionsTableSize,
endpoint,
formatTimeFromNow,
setConnectionsTableColumnOrder,
setConnectionsTableColumnVisibility,
Expand Down Expand Up @@ -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

Expand Down
16 changes: 15 additions & 1 deletion src/pages/Logs.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { makePersisted } from '@solid-primitives/storage'
import { useNavigate } from '@solidjs/router'
import {
IconSettings,
IconSortAscending,
Expand All @@ -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'

Expand All @@ -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()
Expand Down
9 changes: 9 additions & 0 deletions src/pages/Overview.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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 }[]>(
Expand Down
10 changes: 10 additions & 0 deletions src/pages/Proxies.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useNavigate } from '@solidjs/router'
import {
IconBrandSpeedtest,
IconReload,
Expand All @@ -19,6 +20,7 @@ import {
} from '~/helpers'
import { useI18n } from '~/i18n'
import {
endpoint,
formatTimeFromNow,
hideUnAvailableProxies,
proxiesOrderingType,
Expand All @@ -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()
Expand Down
11 changes: 10 additions & 1 deletion src/pages/Rules.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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 {
Expand All @@ -15,6 +16,14 @@ enum ActiveTab {
}

export default () => {
const navigate = useNavigate()

if (!endpoint()) {
navigate('/setup', { replace: true })

return null
}

const [t] = useI18n()
const {
rules,
Expand Down

0 comments on commit a387722

Please sign in to comment.