mirror of
https://github.com/He4eT/elseifplayer.git
synced 2026-05-05 01:17:22 +00:00
Home view
This commit is contained in:
parent
19e051045d
commit
c48d6ec305
3 changed files with 15 additions and 7 deletions
|
|
@ -3,7 +3,7 @@ import { Link, Route, Router, Switch } from 'wouter-preact'
|
||||||
|
|
||||||
import { useHashLocation } from '~/src/utils/utils.routing'
|
import { useHashLocation } from '~/src/utils/utils.routing'
|
||||||
|
|
||||||
import Index from '~/src/views/Index'
|
import Home from '~/src/views/Home'
|
||||||
import Player from '~/src/views/Player'
|
import Player from '~/src/views/Player'
|
||||||
|
|
||||||
function App () {
|
function App () {
|
||||||
|
|
@ -12,15 +12,13 @@ function App () {
|
||||||
<div className='App'>
|
<div className='App'>
|
||||||
<nav>
|
<nav>
|
||||||
<Link href='/'>Root</Link>
|
<Link href='/'>Root</Link>
|
||||||
<Link href='/#/about'>About</Link>
|
|
||||||
<Link href='/#/404'>404</Link>
|
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route
|
<Route
|
||||||
path='/'
|
path='/'
|
||||||
component={Index} />
|
component={Home} />
|
||||||
<Route
|
<Route
|
||||||
path='/play/:theme/:encodedUrl'
|
path='/play/:theme/:encodedUrl'
|
||||||
component={Player} />
|
component={Player} />
|
||||||
|
|
|
||||||
|
|
@ -19,3 +19,6 @@ export const useHashLocation = () => {
|
||||||
(window.location.hash = to.replace('#/', '')), [])
|
(window.location.hash = to.replace('#/', '')), [])
|
||||||
return [loc, navigate]
|
return [loc, navigate]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const buildPlayLinkHref = (url, theme = 'default') =>
|
||||||
|
`/#/play/${theme}/${encodeURIComponent(url)}`
|
||||||
|
|
|
||||||
|
|
@ -6,25 +6,32 @@ import { Link } from 'wouter-preact'
|
||||||
import FileSelector from '~/src/components/FileSelector'
|
import FileSelector from '~/src/components/FileSelector'
|
||||||
import URLSelector from '~/src/components/URLSelector'
|
import URLSelector from '~/src/components/URLSelector'
|
||||||
|
|
||||||
|
import { buildPlayLinkHref } from '~/src/utils/utils.routing'
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
const [targetName, setTargetName] = useState(null)
|
const [targetName, setTargetName] = useState(null)
|
||||||
const [targetURL, setTargetURL] = useState(null)
|
const [targetURL, setTargetURL] = useState(null)
|
||||||
|
|
||||||
const playButton = (
|
const playButton = (
|
||||||
<Link href={`/#/play/default/${encodeURIComponent(targetURL)}`}>
|
<Link href={buildPlayLinkHref(targetURL)}>
|
||||||
Play "{targetName}"
|
Play "{targetName}"
|
||||||
</Link>)
|
</Link>)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main>
|
<main>
|
||||||
|
<p>
|
||||||
|
You can browse some <Link href='/top100'>
|
||||||
|
games from IFDB
|
||||||
|
</Link> or play a game from a file.
|
||||||
|
</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<URLSelector
|
<FileSelector
|
||||||
emitName={setTargetName}
|
emitName={setTargetName}
|
||||||
emitURL={setTargetURL} />
|
emitURL={setTargetURL} />
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<FileSelector
|
<URLSelector
|
||||||
emitName={setTargetName}
|
emitName={setTargetName}
|
||||||
emitURL={setTargetURL} />
|
emitURL={setTargetURL} />
|
||||||
</li>
|
</li>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue