user login WIP
This commit is contained in:
parent
8fc5a164a4
commit
90969cfe4c
78
www/package-lock.json
generated
78
www/package-lock.json
generated
@ -18,6 +18,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rollup/plugin-commonjs": "^17.0.0",
|
"@rollup/plugin-commonjs": "^17.0.0",
|
||||||
"@rollup/plugin-node-resolve": "^11.0.0",
|
"@rollup/plugin-node-resolve": "^11.0.0",
|
||||||
|
"@rollup/plugin-replace": "^5.0.0",
|
||||||
"@rollup/plugin-typescript": "^8.0.0",
|
"@rollup/plugin-typescript": "^8.0.0",
|
||||||
"@tsconfig/svelte": "^2.0.0",
|
"@tsconfig/svelte": "^2.0.0",
|
||||||
"@types/three": "^0.144.0",
|
"@types/three": "^0.144.0",
|
||||||
@ -209,6 +210,52 @@
|
|||||||
"rollup": "^1.20.0||^2.0.0"
|
"rollup": "^1.20.0||^2.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@rollup/plugin-replace": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@rollup/plugin-replace/-/plugin-replace-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-TiPmjMuBjQM+KLWK16O5TAM/eW4yXBYyQ17FbfeNzBC1t2kzX2aXoa8AlS9XTSmg6/2TNvkER1lMEEeN4Lhavw==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@rollup/pluginutils": "^4.2.1",
|
||||||
|
"magic-string": "^0.26.4"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"rollup": "^1.20.0||^2.0.0||^3.0.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"rollup": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@rollup/plugin-replace/node_modules/@rollup/pluginutils": {
|
||||||
|
"version": "4.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.2.1.tgz",
|
||||||
|
"integrity": "sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"estree-walker": "^2.0.1",
|
||||||
|
"picomatch": "^2.2.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 8.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@rollup/plugin-replace/node_modules/magic-string": {
|
||||||
|
"version": "0.26.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.26.7.tgz",
|
||||||
|
"integrity": "sha512-hX9XH3ziStPoPhJxLq1syWuZMxbDvGNbVchfrdCtanC7D13888bMFow61x8axrx+GfHLtVeAx2kxL7tTGRl+Ow==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"sourcemap-codec": "^1.4.8"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@rollup/plugin-typescript": {
|
"node_modules/@rollup/plugin-typescript": {
|
||||||
"version": "8.5.0",
|
"version": "8.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-8.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-8.5.0.tgz",
|
||||||
@ -1828,6 +1875,37 @@
|
|||||||
"resolve": "^1.19.0"
|
"resolve": "^1.19.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@rollup/plugin-replace": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@rollup/plugin-replace/-/plugin-replace-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-TiPmjMuBjQM+KLWK16O5TAM/eW4yXBYyQ17FbfeNzBC1t2kzX2aXoa8AlS9XTSmg6/2TNvkER1lMEEeN4Lhavw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@rollup/pluginutils": "^4.2.1",
|
||||||
|
"magic-string": "^0.26.4"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@rollup/pluginutils": {
|
||||||
|
"version": "4.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.2.1.tgz",
|
||||||
|
"integrity": "sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"estree-walker": "^2.0.1",
|
||||||
|
"picomatch": "^2.2.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"magic-string": {
|
||||||
|
"version": "0.26.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.26.7.tgz",
|
||||||
|
"integrity": "sha512-hX9XH3ziStPoPhJxLq1syWuZMxbDvGNbVchfrdCtanC7D13888bMFow61x8axrx+GfHLtVeAx2kxL7tTGRl+Ow==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"sourcemap-codec": "^1.4.8"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"@rollup/plugin-typescript": {
|
"@rollup/plugin-typescript": {
|
||||||
"version": "8.5.0",
|
"version": "8.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-8.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-8.5.0.tgz",
|
||||||
|
@ -7,13 +7,14 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rollup -c",
|
"build": "rollup -c",
|
||||||
"dev": "rollup -c -w ",
|
"dev": "rollup -c -w ",
|
||||||
"start": "sirv public --no-clear --host",
|
"start": "sirv public --no-clear --host --single",
|
||||||
"check": "svelte-check --tsconfig ./tsconfig.json",
|
"check": "svelte-check --tsconfig ./tsconfig.json",
|
||||||
"prettier": "prettier -w ./src"
|
"prettier": "prettier -w ./src"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rollup/plugin-commonjs": "^17.0.0",
|
"@rollup/plugin-commonjs": "^17.0.0",
|
||||||
"@rollup/plugin-node-resolve": "^11.0.0",
|
"@rollup/plugin-node-resolve": "^11.0.0",
|
||||||
|
"@rollup/plugin-replace": "^5.0.0",
|
||||||
"@rollup/plugin-typescript": "^8.0.0",
|
"@rollup/plugin-typescript": "^8.0.0",
|
||||||
"@tsconfig/svelte": "^2.0.0",
|
"@tsconfig/svelte": "^2.0.0",
|
||||||
"@types/three": "^0.144.0",
|
"@types/three": "^0.144.0",
|
||||||
|
@ -10,7 +10,7 @@ body {
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
/* padding: 0; */
|
/* padding: 0; */
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
/* font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; */
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
@ -34,8 +34,8 @@ input,
|
|||||||
button,
|
button,
|
||||||
select,
|
select,
|
||||||
textarea {
|
textarea {
|
||||||
font-family: inherit;
|
/* font-family: inherit; */
|
||||||
font-size: inherit;
|
/* font-size: inherit; */
|
||||||
-webkit-padding: 0.4em 0;
|
-webkit-padding: 0.4em 0;
|
||||||
padding: 0.4em;
|
padding: 0.4em;
|
||||||
margin: 0 0 0.5em 0;
|
margin: 0 0 0.5em 0;
|
||||||
|
@ -6,6 +6,7 @@ import { terser } from 'rollup-plugin-terser';
|
|||||||
import sveltePreprocess from 'svelte-preprocess';
|
import sveltePreprocess from 'svelte-preprocess';
|
||||||
import typescript from '@rollup/plugin-typescript';
|
import typescript from '@rollup/plugin-typescript';
|
||||||
import css from 'rollup-plugin-css-only';
|
import css from 'rollup-plugin-css-only';
|
||||||
|
import replace from '@rollup/plugin-replace';
|
||||||
|
|
||||||
const production = !process.env.ROLLUP_WATCH;
|
const production = !process.env.ROLLUP_WATCH;
|
||||||
|
|
||||||
@ -50,6 +51,12 @@ export default {
|
|||||||
dev: !production,
|
dev: !production,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
typescript({
|
||||||
|
sourceMap: !production,
|
||||||
|
inlineSources: !production,
|
||||||
|
importsNotUsedAsValues: 'remove',
|
||||||
|
}),
|
||||||
|
|
||||||
// we'll extract any component CSS out into
|
// we'll extract any component CSS out into
|
||||||
// a separate file - better for performance
|
// a separate file - better for performance
|
||||||
css({ output: 'bundle.css' }),
|
css({ output: 'bundle.css' }),
|
||||||
@ -65,9 +72,9 @@ export default {
|
|||||||
dedupe: ['svelte'],
|
dedupe: ['svelte'],
|
||||||
}),
|
}),
|
||||||
commonjs(),
|
commonjs(),
|
||||||
typescript({
|
replace({
|
||||||
sourceMap: !production,
|
'process.env.APIURL': production ? '"/api"' : '"http://localhost:8000"',
|
||||||
inlineSources: !production,
|
'process.env.CORS': production ? 'false' : 'true',
|
||||||
}),
|
}),
|
||||||
|
|
||||||
// In dev mode, call `npm run start` once
|
// In dev mode, call `npm run start` once
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<script>
|
<script>
|
||||||
import 'papercss/dist/paper.min.css';
|
import 'papercss/dist/paper.min.css';
|
||||||
|
|
||||||
import { Router, Route, Link } from 'svelte-navigator';
|
import { Router, Route, Link } from 'svelte-navigator';
|
||||||
import Test3D from './components/test3D.svelte';
|
|
||||||
|
import Test3D from './pages/test3D.svelte';
|
||||||
import Login from './pages/Login.svelte';
|
import Login from './pages/Login.svelte';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
37
www/src/functions/request.ts
Normal file
37
www/src/functions/request.ts
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
enum Methods {
|
||||||
|
'GET' = 'GET',
|
||||||
|
'POST' = 'POST',
|
||||||
|
'PUT' = 'PUT',
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function get<T>(route: string): Promise<T | null> {
|
||||||
|
return request<T>('GET', route);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function post<T>(route: string, data: unknown): Promise<T | null> {
|
||||||
|
return request<T>('POST', route, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function put<T>(route: string, data: unknown): Promise<T | null> {
|
||||||
|
return request<T>('PUT', route, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function request<T>(
|
||||||
|
method: keyof typeof Methods,
|
||||||
|
route: string,
|
||||||
|
data?: unknown,
|
||||||
|
): Promise<T | null> {
|
||||||
|
const response = await fetch(`${process.env.APIURL}${route}`, {
|
||||||
|
headers: {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
},
|
||||||
|
mode: process.env.CORS ? 'cors' : 'same-origin',
|
||||||
|
method: method,
|
||||||
|
body: data ? JSON.stringify(data) : null,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
return response.json() as T;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
7
www/src/functions/user.ts
Normal file
7
www/src/functions/user.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import type { LoginUserBody, UserInfo } from '@core';
|
||||||
|
import { post } from './request';
|
||||||
|
|
||||||
|
export async function login(raw: LoginUserBody) {
|
||||||
|
const user = await post<UserInfo>('/user/login', raw);
|
||||||
|
console.debug(user);
|
||||||
|
}
|
@ -1,14 +1,35 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import type { LoginUserBody } from '@core';
|
||||||
import { Form, Input, Button } from 'spaper';
|
import { Form, Input, Button } from 'spaper';
|
||||||
|
import { login } from '../functions/user';
|
||||||
|
|
||||||
|
const user: LoginUserBody = {
|
||||||
|
username: '',
|
||||||
|
password: '',
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
<div class="row" id="container">
|
<div class="row" id="container">
|
||||||
<Form class="">
|
<Form>
|
||||||
<Input placeholder="email" class="row" />
|
<Input
|
||||||
<Input placeholder="password" type="password" class="row" />
|
placeholder="username"
|
||||||
|
class="row col-8"
|
||||||
|
bind:value={user.username}
|
||||||
|
/>
|
||||||
|
<Input
|
||||||
|
placeholder="password"
|
||||||
|
type="password"
|
||||||
|
class="row col-8"
|
||||||
|
bind:value={user.password}
|
||||||
|
/>
|
||||||
|
|
||||||
<Button type="secondary" class="row" id="button">Sign in</Button>
|
<Button
|
||||||
|
type="secondary"
|
||||||
|
class="row sm-2 col-4"
|
||||||
|
block
|
||||||
|
on:click={() => login(user)}>Sign in</Button
|
||||||
|
>
|
||||||
</Form>
|
</Form>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
@ -17,9 +38,6 @@
|
|||||||
main {
|
main {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
#button {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
#container {
|
#container {
|
||||||
height: inherit;
|
height: inherit;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -10,18 +10,16 @@
|
|||||||
let maxInnerHeight: number = 0;
|
let maxInnerHeight: number = 0;
|
||||||
|
|
||||||
let portrait: boolean = true;
|
let portrait: boolean = true;
|
||||||
let focalLength: number = (540/Math.atan(70*Math.PI / 180));
|
let focalLength: number = 540 / Math.atan((70 * Math.PI) / 180);
|
||||||
let fov = 75;
|
let fov = 75;
|
||||||
//let baseHorizontalFOV: number = 2.0*Math.atan(baseAspectRation*Math.tan(baseVerticalFOV*0.5));
|
//let baseHorizontalFOV: number = 2.0*Math.atan(baseAspectRation*Math.tan(baseVerticalFOV*0.5));
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
|
||||||
//#region functions
|
//#region functions
|
||||||
function updateVerticalFOV() {
|
function updateVerticalFOV() {
|
||||||
fov = (180 / Math.PI) * Math.tan(innerHeight / (focalLength * 2));
|
fov = (180 / Math.PI) * Math.tan(innerHeight / (focalLength * 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function resetMaxDimensions() {
|
function resetMaxDimensions() {
|
||||||
maxInnerWidth = 0;
|
maxInnerWidth = 0;
|
||||||
maxInnerHeight = 0;
|
maxInnerHeight = 0;
|
||||||
@ -49,7 +47,6 @@
|
|||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
|
||||||
let scene: Three.Scene = new Three.Scene();
|
let scene: Three.Scene = new Three.Scene();
|
||||||
let camera: Three.PerspectiveCamera = new Three.PerspectiveCamera(
|
let camera: Three.PerspectiveCamera = new Three.PerspectiveCamera(
|
||||||
75,
|
75,
|
||||||
@ -97,7 +94,7 @@
|
|||||||
updateVerticalFOV();
|
updateVerticalFOV();
|
||||||
|
|
||||||
camera.aspect = innerWidth / innerHeight;
|
camera.aspect = innerWidth / innerHeight;
|
||||||
camera.fov = fov
|
camera.fov = fov;
|
||||||
camera.setViewOffset(
|
camera.setViewOffset(
|
||||||
window.innerWidth,
|
window.innerWidth,
|
||||||
window.innerHeight,
|
window.innerHeight,
|
||||||
@ -111,9 +108,7 @@
|
|||||||
//renderer.setClearColor(0x000000, (innerHeight/(maxInnerHeight))/2 + 0.5);
|
//renderer.setClearColor(0x000000, (innerHeight/(maxInnerHeight))/2 + 0.5);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterUpdate(() => {
|
afterUpdate(() => {});
|
||||||
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:window bind:innerWidth bind:innerHeight />
|
<svelte:window bind:innerWidth bind:innerHeight />
|
||||||
@ -130,6 +125,5 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
Loading…
x
Reference in New Issue
Block a user