From 44d5a52499bb25dcb7ef7ffadef81bc68072ccb1 Mon Sep 17 00:00:00 2001 From: charlene tau express Date: Wed, 26 Feb 2025 17:55:44 +0800 Subject: [PATCH] table in progress --- src/assets/base.css | 2 +- src/components/InputFieldCard.vue | 116 ++++++++++++++++++++++++++---- src/components/TableComp.vue | 17 +++++ src/components/WelcomeItem.vue | 87 ---------------------- src/router/index.ts | 8 +++ src/stores/searchStore.ts | 8 +++ src/utils/api.js | 32 +++++++++ src/views/HomeView.vue | 3 +- src/views/ResponseView.vue | 9 +++ vite.config.ts | 9 +++ 10 files changed, 189 insertions(+), 102 deletions(-) create mode 100644 src/components/TableComp.vue delete mode 100644 src/components/WelcomeItem.vue create mode 100644 src/stores/searchStore.ts create mode 100644 src/utils/api.js create mode 100644 src/views/ResponseView.vue diff --git a/src/assets/base.css b/src/assets/base.css index f60f81d..dff995a 100644 --- a/src/assets/base.css +++ b/src/assets/base.css @@ -54,7 +54,7 @@ *::before, *::after { box-sizing: border-box; - margin: 0; + font-weight: normal; } diff --git a/src/components/InputFieldCard.vue b/src/components/InputFieldCard.vue index 82a58be..5ed3cfa 100644 --- a/src/components/InputFieldCard.vue +++ b/src/components/InputFieldCard.vue @@ -1,23 +1,115 @@ \ No newline at end of file diff --git a/src/components/TableComp.vue b/src/components/TableComp.vue new file mode 100644 index 0000000..ff2a377 --- /dev/null +++ b/src/components/TableComp.vue @@ -0,0 +1,17 @@ + + \ No newline at end of file diff --git a/src/components/WelcomeItem.vue b/src/components/WelcomeItem.vue deleted file mode 100644 index 6d7086a..0000000 --- a/src/components/WelcomeItem.vue +++ /dev/null @@ -1,87 +0,0 @@ - - - diff --git a/src/router/index.ts b/src/router/index.ts index 3e49915..8a541cf 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -17,6 +17,14 @@ const router = createRouter({ // which is lazy-loaded when the route is visited. component: () => import('../views/AboutView.vue'), }, + { + path: '/table', + name: 'table', + // route level code-splitting + // this generates a separate chunk (About.[hash].js) for this route + // which is lazy-loaded when the route is visited. + component: () => import('../views/ResponseView.vue'), + }, ], }) diff --git a/src/stores/searchStore.ts b/src/stores/searchStore.ts new file mode 100644 index 0000000..3c2a4b7 --- /dev/null +++ b/src/stores/searchStore.ts @@ -0,0 +1,8 @@ +import { ref, computed } from 'vue' +import { defineStore } from 'pinia' + +export const useSearchStore = defineStore('search', () => { + const searchParams = ref({}) + + return { searchParams } +}) diff --git a/src/utils/api.js b/src/utils/api.js new file mode 100644 index 0000000..6ec5adc --- /dev/null +++ b/src/utils/api.js @@ -0,0 +1,32 @@ +export const fetchData = async(endpoints="", requestType="GET", requestBody=null)=>{ + console.log("requestBody:", requestBody) + console.log("requestType:", requestType) + console.log("endpoints:", `https://192.168.99.121/${endpoints}`) + try{ + const options={ + method:requestType, + headers:{ + "Content-Type":"application/json", + "Authorization": "ApiKey NS00TXlKUUIweUhWaGFuUUpUVTk6bWNVWXI1VXRSN2VWcFRtaEZ6NmdCUQ==" + } + } + + if (requestType !=="GET" && requestBody){ + options.body = JSON.stringify(requestBody) + } + + const response = await fetch(`http://192.168.99.121/${endpoints}`, options) + console.log("response butrte: ", response) + if (!response.ok){ + throw new Error(`HTTP error! Status: ${response.status}`) + } + + return await response.json() + + } + catch(error){ + console.log("Fetch error:", error) + return null + } + +} \ No newline at end of file diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 5146004..2f6ad47 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -3,8 +3,7 @@ import InputFieldCard from '@/components/InputFieldCard.vue' diff --git a/src/views/ResponseView.vue b/src/views/ResponseView.vue new file mode 100644 index 0000000..c49fc40 --- /dev/null +++ b/src/views/ResponseView.vue @@ -0,0 +1,9 @@ + + \ No newline at end of file diff --git a/vite.config.ts b/vite.config.ts index 012597d..84c0749 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -6,6 +6,15 @@ import vueDevTools from 'vite-plugin-vue-devtools' import tailwindcss from '@tailwindcss/vite' // https://vite.dev/config/ export default defineConfig({ + server: { + proxy: { + "/search": { + target: "https://192.168.99.121", + changeOrigin: true, + secure: false, // Ignores SSL certificate issues + }, + }, + }, plugins: [ vue(), vueDevTools(),