fix: 🧑‍💻 use watch mode

This commit is contained in:
Michel Roux 2024-11-03 19:14:47 +01:00
parent 19782c0a10
commit 786524bd8a
4 changed files with 13 additions and 21 deletions

View File

@ -12,7 +12,7 @@
</div> </div>
<div class="navbar-menu"> <div class="navbar-menu">
<div class="navbar-start"> <div class="navbar-start">
<a class="navbar-item" :href="`${$api}/docs`"> <a class="navbar-item" href="/docs">
<span class="icon-text"> <span class="icon-text">
<span class="icon"> <span class="icon">
<i class="fa fa-book"></i> <i class="fa fa-book"></i>

View File

@ -4,15 +4,6 @@ import App from './App.vue'
import { createApp } from 'vue' import { createApp } from 'vue'
import router from './router' import router from './router'
declare module 'vue' {
interface ComponentCustomProperties {
$api: string
}
}
const app = createApp(App) const app = createApp(App)
app.config.globalProperties.$api = import.meta.env.PROD
? `${import.meta.env.BASE_URL}api`
: `http://localhost:${import.meta.env.API_PORT ?? 8000}/api`
app.use(router) app.use(router)
app.mount('#app') app.mount('#app')

View File

@ -1,18 +1,18 @@
<template> <template>
<Loading class="container" :loading="loading"> <Loading class="container" :loading="loading">
<Message v-if="error" type="danger">Error loading containers</Message> <Message v-if="error" type="danger">{{ error }}</Message>
<ul v-if="!loading && !error"> <ul v-if="!loading && !error">
<li v-for="container in containers" :key="container.name"> <li v-for="container in containers" :key="container">
{{ container.name }} {{ container }}
</li> </li>
</ul> </ul>
</Loading> </Loading>
</template> </template>
<script lang="ts"> <script lang="ts">
import axios, { AxiosError } from 'axios'
import Loading from '@/components/Loading.vue' import Loading from '@/components/Loading.vue'
import Message from '@/components/Message.vue' import Message from '@/components/Message.vue'
import axios from 'axios'
export default { export default {
name: 'Containers', name: 'Containers',
@ -22,17 +22,19 @@ export default {
}, },
data() { data() {
return { return {
containers: [], containers: [] as string[],
error: false, error: '',
loading: true, loading: true,
} }
}, },
async mounted() { async mounted() {
try { try {
this.containers = await axios.get(`${this.$api}/api/containers`) const response = await axios.get<string[]>('/api/containers')
this.containers = response.data
} catch (error) { } catch (error) {
console.error(error) console.error(error)
this.error = true this.error =
error instanceof AxiosError ? error.message : 'Error loading containers'
} finally { } finally {
this.loading = false this.loading = false
} }

View File

@ -4,9 +4,8 @@
"private": true, "private": true,
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "build": "vite build",
"preview": "vite preview", "watch": "vite build --watch",
"build-only": "vite build",
"type-check": "vue-tsc --build --force", "type-check": "vue-tsc --build --force",
"lint": "eslint . --fix" "lint": "eslint . --fix"
}, },