Lots of refactoring #75

Merged
tonitch merged 1 commits from tonitch/front/refactoring/ApplicationsPaterned into master 2024-03-09 09:52:56 +01:00
10 changed files with 25 additions and 144 deletions

View File

@ -19,9 +19,3 @@ npm run dev
```sh ```sh
npm run build npm run build
``` ```
### Run Unit Tests with [Vitest](https://vitest.dev/)
```sh
npm run test:unit
```

View File

@ -1,11 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Clyde - Login</title>
</head>
<body>
<div id="app"></div>
<script type=module src="/src/login.js"></script>
</body>
</html>

View File

@ -1,18 +1,26 @@
<script setup> <script setup>
import 'https://kit.fontawesome.com/fb3bbd0a95.js'
import { toast } from 'vue3-toastify'; import { toast } from 'vue3-toastify';
import { ref } from 'vue' import { ref, computed } from 'vue'
import i18n, { setLang } from './i18n.js' import i18n, { setLang } from './i18n.js'
import Inscription from "./Inscription.vue"
const test = ref(); // Liste des apps
import LoginPage from './Apps/Login.vue'
import Inscription from "./Apps/Inscription.vue"
async function draw(e) { const apps = {
test.value = (await fetch("http://localhost:8080/ping")); '/login': LoginPage,
test.value = await test.value.json(); '/inscription': Inscription
toast(test.value['txt']);
} }
const currentPath = ref(window.location.hash)
window.addEventListener('hashchange', () => {
currentPath.value = window.location.hash
})
const currentView = computed(() => {
return apps[currentPath.value.slice(1) || '/']
})
const home=ref(i18n("app.home")) const home=ref(i18n("app.home"))
const notifications=ref(i18n("app.notifications")) const notifications=ref(i18n("app.notifications"))
@ -37,7 +45,7 @@
<div class=" fa-solid fa-house" style="margin-top: 7px; margin-bottom: 3px;"></div> <div class=" fa-solid fa-house" style="margin-top: 7px; margin-bottom: 3px;"></div>
</a></li> </a></li>
<li style="float: right;" title=login> <li style="float: right;" title=login>
<a href="/login"> <a href="#/login">
<div class="fa-solid fa-user" style="margin-top: 7px; margin-bottom: 3px;"></div> <div class="fa-solid fa-user" style="margin-top: 7px; margin-bottom: 3px;"></div>
</a></li> </a></li>
<li style="float: right;" title=notifications> <li style="float: right;" title=notifications>
@ -75,7 +83,7 @@
<li ><a href="#Forum"> <li ><a href="#Forum">
<div class="fa-solid fa-envelope" style="font-size: 40px;" ></div> <div class="fa-solid fa-envelope" style="font-size: 40px;" ></div>
<div class="text">{{i18n("app.forum")}}</div></a></li> <div class="text">{{i18n("app.forum")}}</div></a></li>
<li><a href="#Inscription"> <li><a href="#/inscription">
<div class="fa-solid fa-users" style="font-size: 40px;"></div> <div class="fa-solid fa-users" style="font-size: 40px;"></div>
<div class="text">{{i18n("app.inscription.requests")}}</div></a></li> <div class="text">{{i18n("app.inscription.requests")}}</div></a></li>
</ul> </ul>
@ -83,7 +91,7 @@
</div> </div>
<div class="page"> <div class="page">
<div style=" margin:50px;"> <div style=" margin:50px;">
<Inscription></Inscription> <component :is="currentView" />
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,7 +1,7 @@
<script setup> <script setup>
import { login , register} from './rest/Users.js' import { login , register} from '@/rest/Users.js'
import { ref } from 'vue' import { ref } from 'vue'
import i18n from './i18n.js' import i18n from '@/i18n.js'
const loginPage= ref(true) const loginPage= ref(true)
const page = ref(0) const page = ref(0)
@ -27,12 +27,6 @@
<template> <template>
<body>
<div class="Home">
<a href="/">
<img @click="draw" src="./assets/Clyde.png" style="width: 40px; height: auto; margin-top:4px">
</a>
</div>
<div class="logBoxCenterer"> <div class="logBoxCenterer">
<div class='loginBox'> <div class='loginBox'>
@ -128,7 +122,6 @@
</div> </div>
</div> </div>
</div> </div>
</body>
</template> </template>
<style scoped> <style scoped>
@ -150,7 +143,6 @@
} }
.logBoxCenterer { .logBoxCenterer {
position: absolute;
width: 100%; width: 100%;
height: 100%; height: 100%;
display: flex; display: flex;
@ -161,7 +153,6 @@
.loginBox { .loginBox {
background-color: rgb(24,24,24); background-color: rgb(24,24,24);
position : absolute;
width: 400px; width: 400px;
display:flex; display:flex;
justify-content: center; justify-content: center;

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import i18n from "./i18n.js" import i18n from "@/i18n.js"
const props = defineProps({ const props = defineProps({
id: Number, id: Number,
type: String, type: String,

View File

@ -1,86 +0,0 @@
/* color palette from <https://github.com/vuejs/theme> */
:root {
--vt-c-white: #ffffff;
--vt-c-white-soft: #f8f8f8;
--vt-c-white-mute: #f2f2f2;
--vt-c-black: #181818;
--vt-c-black-soft: #222222;
--vt-c-black-mute: #282828;
--vt-c-indigo: #2c3e50;
--vt-c-divider-light-1: rgba(60, 60, 60, 0.29);
--vt-c-divider-light-2: rgba(60, 60, 60, 0.12);
--vt-c-divider-dark-1: rgba(84, 84, 84, 0.65);
--vt-c-divider-dark-2: rgba(84, 84, 84, 0.48);
--vt-c-text-light-1: var(--vt-c-indigo);
--vt-c-text-light-2: rgba(60, 60, 60, 0.66);
--vt-c-text-dark-1: var(--vt-c-white);
--vt-c-text-dark-2: rgba(235, 235, 235, 0.64);
}
/* semantic color variables for this project */
:root {
--color-background: var(--vt-c-white);
--color-background-soft: var(--vt-c-white-soft);
--color-background-mute: var(--vt-c-white-mute);
--color-border: var(--vt-c-divider-light-2);
--color-border-hover: var(--vt-c-divider-light-1);
--color-heading: var(--vt-c-text-light-1);
--color-text: var(--vt-c-text-light-1);
--section-gap: 160px;
}
@media (prefers-color-scheme: dark) {
:root {
--color-background: var(--vt-c-black);
--color-background-soft: var(--vt-c-black-soft);
--color-background-mute: var(--vt-c-black-mute);
--color-border: var(--vt-c-divider-dark-2);
--color-border-hover: var(--vt-c-divider-dark-1);
--color-heading: var(--vt-c-text-dark-1);
--color-text: var(--vt-c-text-dark-2);
}
}
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
font-weight: normal;
}
body {
min-height: 100vh;
color: var(--color-text);
background: var(--color-background);
transition:
color 0.5s,
background-color 0.5s;
line-height: 1.6;
font-family:
Inter,
-apple-system,
BlinkMacSystemFont,
'Segoe UI',
Roboto,
Oxygen,
Ubuntu,
Cantarell,
'Fira Sans',
'Droid Sans',
'Helvetica Neue',
sans-serif;
font-size: 15px;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

View File

@ -1,7 +0,0 @@
import './assets/main.css'
import 'vue3-toastify/dist/index.css';
import { createApp } from 'vue'
import App from './Login.vue'
createApp(App).mount('#app')

View File

@ -1,5 +1,6 @@
import './assets/main.css' import './assets/main.css'
import 'vue3-toastify/dist/index.css'; import 'vue3-toastify/dist/index.css';
import 'https://kit.fontawesome.com/fb3bbd0a95.js'
import { createApp } from 'vue' import { createApp } from 'vue'
import App from './App.vue' import App from './App.vue'

View File

@ -10,15 +10,6 @@ export default defineConfig({
vue(), vue(),
topLevelAwait(), topLevelAwait(),
], ],
build: {
rollupOptions:{
input:{
main: './index.html',
login: './login/index.html'
}
}
},
resolve: { resolve: {
alias: { alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)) '@': fileURLToPath(new URL('./src', import.meta.url))