瀏覽代碼

新增物品信息页
更新二维码生成和下载

wuyi 1 月之前
父節點
當前提交
36928f021b
共有 6 個文件被更改,包括 470 次插入639 次删除
  1. 1 1
      .env
  2. 106 1
      src/App.vue
  3. 5 3
      src/router/index.js
  4. 6 75
      src/services/api.js
  5. 351 559
      src/views/ScanView.vue
  6. 1 0
      vite.config.js

+ 1 - 1
.env

@@ -1 +1 @@
-VITE_API_URL=http://localhost:3010/api
+VITE_API_URL=http://192.168.6.125:3010/api

+ 106 - 1
src/App.vue

@@ -6,6 +6,111 @@ import ConfirmDialog from 'primevue/confirmdialog'
 
 <template>
   <RouterView />
-  <Toast />
+  <Toast position="top-center" />
   <ConfirmDialog />
 </template>
+
+<style>
+/* Toast 提示框样式优化 */
+.p-toast {
+  opacity: 1 !important;
+  width: auto !important;
+  max-width: min(90vw, 400px) !important;
+  top: 1rem !important;
+  left: 50% !important;
+  transform: translateX(-50%) !important;
+}
+
+.p-toast .p-toast-message {
+  margin: 0 !important;
+  border-radius: 0.75rem !important;
+  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1) !important;
+  backdrop-filter: blur(8px);
+}
+
+.p-toast .p-toast-message-content {
+  padding: 0.875rem 1rem !important;
+  gap: 0.75rem !important;
+}
+
+.p-toast .p-toast-message-icon {
+  font-size: 1.25rem !important;
+}
+
+.p-toast .p-toast-summary {
+  font-size: 0.875rem !important;
+  font-weight: 600 !important;
+}
+
+.p-toast .p-toast-detail {
+  font-size: 0.8125rem !important;
+  margin-top: 0.125rem !important;
+}
+
+.p-toast .p-toast-icon-close {
+  width: 1.5rem !important;
+  height: 1.5rem !important;
+  border-radius: 0.375rem !important;
+}
+
+/* 移动端优化 */
+@media (max-width: 640px) {
+  .p-toast {
+    max-width: calc(100vw - 2rem) !important;
+    top: 0.75rem !important;
+  }
+  
+  .p-toast .p-toast-message-content {
+    padding: 0.75rem 0.875rem !important;
+  }
+  
+  .p-toast .p-toast-summary {
+    font-size: 0.8125rem !important;
+  }
+  
+  .p-toast .p-toast-detail {
+    font-size: 0.75rem !important;
+  }
+}
+
+/* 不同类型的提示样式 */
+.p-toast .p-toast-message-success {
+  background-color: rgba(16, 185, 129, 0.95) !important;
+  border: 1px solid rgba(16, 185, 129, 0.2) !important;
+  color: white !important;
+}
+
+.p-toast .p-toast-message-info {
+  background-color: rgba(59, 130, 246, 0.95) !important;
+  border: 1px solid rgba(59, 130, 246, 0.2) !important;
+  color: white !important;
+}
+
+.p-toast .p-toast-message-warn {
+  background-color: rgba(245, 158, 11, 0.95) !important;
+  border: 1px solid rgba(245, 158, 11, 0.2) !important;
+  color: white !important;
+}
+
+.p-toast .p-toast-message-error {
+  background-color: rgba(239, 68, 68, 0.95) !important;
+  border: 1px solid rgba(239, 68, 68, 0.2) !important;
+  color: white !important;
+}
+
+/* 动画优化 */
+.p-toast .p-toast-message {
+  animation: toast-slide-in 0.3s ease-out;
+}
+
+@keyframes toast-slide-in {
+  from {
+    opacity: 0;
+    transform: translateY(-1rem);
+  }
+  to {
+    opacity: 1;
+    transform: translateY(0);
+  }
+}
+</style>

+ 5 - 3
src/router/index.js

@@ -6,12 +6,14 @@ const router = createRouter({
   routes: [
     {
       path: '/',
-      name: 'scan',
+      name: 'home',
       component: ScanView
     },
     {
-      path: '/:pathMatch(.*)*',
-      redirect: '/'
+      path: '/:qrCode',
+      name: 'scan',
+      component: ScanView,
+      props: true
     }
   ],
   scrollBehavior() {

+ 6 - 75
src/services/api.js

@@ -18,84 +18,11 @@ api.interceptors.response.use(
   (error) => Promise.reject(error.response?.data || error)
 )
 
-export const login = async (name, password) => {
-  const response = await api.post('/users/login', {
-    name,
-    password
-  })
-  return response.data
-}
-
-export const profile = async () => {
-  const response = await api.get('/users/profile')
-  return response.data
-}
-
-export const resetPasswordApi = async (password) => {
-  const response = await api.post('/users/reset-password', {
-    password
-  })
-  return response.data
-}
-
-export const listUsersApi = async (page, size) => {
-  const response = await api.get('/users', {
-    params: {
-      page,
-      size
-    }
-  })
-  return response.data
-}
-
-export const allUsersApi = async () => {
-  const response = await api.get('/users/all')
-  return response.data
-}
-
-export const createUserApi = async (userData) => {
-  const response = await api.post('/users/create', userData)
-  return response.data
-}
-
-export const updateUserApi = async (userData) => {
-  const response = await api.post('/users/update', userData)
-  return response.data
-}
-
-export const listSysConfig = async (page = 0, size = 20, type) => {
-  const params = { page, size }
-  if (type) params.type = type
-
-  const response = await api.get('/sys-config', { params })
-  return response.data
-}
-
-export const createSysConfig = async (configData) => {
-  const response = await api.post('/sys-config', configData)
-  return response.data
-}
-
-export const updateSysConfig = async (name, configData) => {
-  const response = await api.post(`/sys-config/update/${name}`, configData)
-  return response.data
-}
-
-export const deleteSysConfig = async (name) => {
-  const response = await api.post(`/sys-config/delete/${name}`)
-  return response.data
-}
-
-export const getSysConfigByName = async (name) => {
-  const response = await api.get(`/sys-config/${name}`)
-  return response.data
-}
-
 export const uploadFile = async (file) => {
   const formData = new FormData()
   formData.append('file', file)
 
-  const response = await api.post('/files/upload', formData, {
+  const response = await api.post('/files/upload/image', formData, {
     headers: {
       'Content-Type': 'multipart/form-data'
     }
@@ -136,6 +63,11 @@ export const updatePetProfileApi = async (profilePayload) => {
   return response.data
 }
 
+export const updateGoodsInfoApi = async (goodsPayload) => {
+  const response = await api.put('/goods/update', goodsPayload)
+  return response.data
+}
+
 export const createScanRecordApi = async (recordPayload) => {
   const response = await api.post('/scan/create', recordPayload)
   return response.data
@@ -147,4 +79,3 @@ export const fetchRecentScanRecordsApi = async (qrCode, limit = 10) => {
   })
   return response.data
 }
-

文件差異過大導致無法顯示
+ 351 - 559
src/views/ScanView.vue


+ 1 - 0
vite.config.js

@@ -11,6 +11,7 @@ export default defineConfig({
   plugins: [vue(), vueJsx(), vueDevTools(), tailwindcss()],
   base: '/',
   server: {
+    host: '0.0.0.0',
     port: 5180
   },
   resolve: {

部分文件因文件數量過多而無法顯示