From cb4848234fe27c924fda5d3cad28d77e6bd55fc2 Mon Sep 17 00:00:00 2001
From: "L.star" <363033744@qq.com>
Date: Wed, 23 Jul 2025 18:34:05 +0800
Subject: [PATCH] =?UTF-8?q?refactor(views):=20=E6=A0=B8=E5=BF=83=E4=BD=93?=
=?UTF-8?q?=E9=AA=8C=E9=A1=B5=E9=9D=A2=E7=BB=93=E6=9E=84=E9=87=8D=E6=9E=84?=
=?UTF-8?q?=E4=B8=8EUI=E8=BF=AD=E4=BB=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
将所有核心用户体验相关的视图组件(HomeView, ScanView, SearchView 等)迁移至新的 'src/views/核心体验页/' 目录,以优化项目结构。
更新 router/index.ts 中的路由配置,以匹配新的文件路径。
对 HomeView-首页-2.0.vue 进行了密集的UI迭代,包括将扫码与分析卡片合并,并进行了大量的CSS微调。
新增了多个原型页面(ScanView, SearchView)和备份文件,记录开发过程。
---
shihuashishuo-ui/src/router/index.ts | 10 +-
.../HomeView-首页-2.0.backup-最简.vue} | 0
.../HomeView-首页-2.1.backup-合并前.vue} | 77 ++-
.../核心体验页/HomeView-首页-2.2.backup.vue | 610 ++++++++++++++++++
.../views/核心体验页/HomeView-首页-2.2.vue | 610 ++++++++++++++++++
.../{ => 核心体验页}/ResultView-结果页.vue | 0
.../{ => 核心体验页}/ScanView-扫码页.vue | 25 +-
.../SearchResultView-搜索结果页.vue | 0
.../{ => 核心体验页}/SearchView-搜索页.vue | 64 +-
9 files changed, 1358 insertions(+), 38 deletions(-)
rename shihuashishuo-ui/src/views/{HomeView-首页-2.0.backup.vue => 核心体验页/HomeView-首页-2.0.backup-最简.vue} (100%)
rename shihuashishuo-ui/src/views/{HomeView-首页-2.0.vue => 核心体验页/HomeView-首页-2.1.backup-合并前.vue} (85%)
create mode 100644 shihuashishuo-ui/src/views/核心体验页/HomeView-首页-2.2.backup.vue
create mode 100644 shihuashishuo-ui/src/views/核心体验页/HomeView-首页-2.2.vue
rename shihuashishuo-ui/src/views/{ => 核心体验页}/ResultView-结果页.vue (100%)
rename shihuashishuo-ui/src/views/{ => 核心体验页}/ScanView-扫码页.vue (75%)
rename shihuashishuo-ui/src/views/{ => 核心体验页}/SearchResultView-搜索结果页.vue (100%)
rename shihuashishuo-ui/src/views/{ => 核心体验页}/SearchView-搜索页.vue (57%)
diff --git a/shihuashishuo-ui/src/router/index.ts b/shihuashishuo-ui/src/router/index.ts
index 8c28b24..9b28ab3 100644
--- a/shihuashishuo-ui/src/router/index.ts
+++ b/shihuashishuo-ui/src/router/index.ts
@@ -56,7 +56,7 @@ const router = createRouter({
{
path: 'home',
name: 'home',
- component: () => import('../views/HomeView-首页-2.0.vue'),
+ component: () => import('../views/核心体验页/HomeView-首页-2.0.vue'),
},
{
path: 'discover',
@@ -84,22 +84,22 @@ const router = createRouter({
{
path: '/scan',
name: 'scan',
- component: () => import('../views/ScanView-扫码页.vue'),
+ component: () => import('../views/核心体验页/ScanView-扫码页.vue'),
},
{
path: '/search',
name: 'search',
- component: () => import('../views/SearchView-搜索页.vue'),
+ component: () => import('../views/核心体验页/SearchView-搜索页.vue'),
},
{
path: '/search-result',
name: 'search-result',
- component: () => import('../views/SearchResultView-搜索结果页.vue'),
+ component: () => import('../views/核心体验页/SearchResultView-搜索结果页.vue'),
},
{
path: '/result/:id',
name: 'result',
- component: () => import('../views/ResultView-结果页.vue'),
+ component: () => import('../views/核心体验页/ResultView-结果页.vue'),
},
{
path: '/messages',
diff --git a/shihuashishuo-ui/src/views/HomeView-首页-2.0.backup.vue b/shihuashishuo-ui/src/views/核心体验页/HomeView-首页-2.0.backup-最简.vue
similarity index 100%
rename from shihuashishuo-ui/src/views/HomeView-首页-2.0.backup.vue
rename to shihuashishuo-ui/src/views/核心体验页/HomeView-首页-2.0.backup-最简.vue
diff --git a/shihuashishuo-ui/src/views/HomeView-首页-2.0.vue b/shihuashishuo-ui/src/views/核心体验页/HomeView-首页-2.1.backup-合并前.vue
similarity index 85%
rename from shihuashishuo-ui/src/views/HomeView-首页-2.0.vue
rename to shihuashishuo-ui/src/views/核心体验页/HomeView-首页-2.1.backup-合并前.vue
index 3fec45e..ade3269 100644
--- a/shihuashishuo-ui/src/views/HomeView-首页-2.0.vue
+++ b/shihuashishuo-ui/src/views/核心体验页/HomeView-首页-2.1.backup-合并前.vue
@@ -65,11 +65,45 @@
蛋白质
-
{{ healthDashboardData.nutrition.protein }} / {{ healthDashboardData.nutrition.proteinGoal }}g
+
+ {{ healthDashboardData.nutrition.protein }}
+ / {{ healthDashboardData.nutrition.proteinGoal }}g
+
脂肪
-
{{ healthDashboardData.nutrition.fat }} / {{ healthDashboardData.nutrition.fatGoal }}g
+
+ {{ healthDashboardData.nutrition.fat }}
+ / {{ healthDashboardData.nutrition.fatGoal }}g
+
+
+
+
碳水化合物
+
+ {{ healthDashboardData.nutrition.carbs }}
+ / {{ healthDashboardData.nutrition.carbsGoal }}g
+
+
+
+
钙
+
+ {{ healthDashboardData.nutrition.calcium }}
+ / {{ healthDashboardData.nutrition.calciumGoal }}mg
+
+
+
+
维生素C
+
+ {{ healthDashboardData.nutrition.vitaminC }}
+ / {{ healthDashboardData.nutrition.vitaminCGoal }}mg
+
+
+
+
维生素D
+
+ {{ healthDashboardData.nutrition.vitaminD }}
+ / {{ healthDashboardData.nutrition.vitaminDGoal }}µg
+
@@ -139,7 +173,14 @@ let intervalId: number;
const hotSearches = ref(['无糖酸奶', '酱油', '儿童零食', '高钙牛奶']);
const healthDashboardData = ref({
- nutrition: { protein: 30, proteinGoal: 60, fat: 20, fatGoal: 50 },
+ nutrition: {
+ protein: 30, proteinGoal: 60,
+ fat: 20, fatGoal: 50,
+ carbs: 150, carbsGoal: 300,
+ calcium: 500, calciumGoal: 1000,
+ vitaminC: 40, vitaminCGoal: 90,
+ vitaminD: 5, vitaminDGoal: 15
+ },
calories: { current: 800, goal: 1800 },
water: { current: 1000, goal: 2000 },
});
@@ -224,6 +265,9 @@ const goTo = (link: object) => {
justify-content: space-between;
align-items: center;
flex-shrink: 0;
+ padding-bottom: 10px;
+ border-bottom: 1px solid #f0f0f0;
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}
.search-section {
@@ -268,10 +312,13 @@ const goTo = (link: object) => {
.hot-searches-section {
display: flex;
- justify-content: center;
+ justify-content: flex-start;
gap: 10px;
margin-top: 10px;
flex-wrap: wrap;
+ max-width: 90%;
+ margin-left: auto;
+ margin-right: auto;
}
.hot-search-tag {
@@ -279,7 +326,7 @@ const goTo = (link: object) => {
color: #555;
padding: 5px 12px;
border-radius: 15px;
- font-size: 12px;
+ font-size: 10px;
cursor: pointer;
}
@@ -422,8 +469,9 @@ const goTo = (link: object) => {
}
.nutrition-details {
- display: flex;
- justify-content: space-around;
+ display: grid;
+ grid-template-columns: repeat(3, 1fr);
+ gap: 15px;
text-align: center;
}
@@ -432,9 +480,18 @@ const goTo = (link: object) => {
font-size: 12px;
color: #666;
}
-.nutrition-details strong {
- font-size: 16px;
- color: #333;
+.nutrition-value {
+ line-height: 1;
+}
+.nutrition-value strong {
+ font-size: 18px;
+ font-weight: 600;
+ color: #111827;
+}
+.nutrition-value span {
+ font-size: 12px;
+ color: #6b7280;
+ margin-left: 2px;
}
.progress-card {
diff --git a/shihuashishuo-ui/src/views/核心体验页/HomeView-首页-2.2.backup.vue b/shihuashishuo-ui/src/views/核心体验页/HomeView-首页-2.2.backup.vue
new file mode 100644
index 0000000..9b3bf0c
--- /dev/null
+++ b/shihuashishuo-ui/src/views/核心体验页/HomeView-首页-2.2.backup.vue
@@ -0,0 +1,610 @@
+
+
+
+
+ 晚上好, 王女士
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
本周您已分析 8 种食品,
+
成功为家人避开 4 个高风险成分!
+
+
+
+
+
+
+
+
每日营养
+
+
+
蛋白质
+
+ {{ healthDashboardData.nutrition.protein }}
+ / {{ healthDashboardData.nutrition.proteinGoal }}g
+
+
+
+
脂肪
+
+ {{ healthDashboardData.nutrition.fat }}
+ / {{ healthDashboardData.nutrition.fatGoal }}g
+
+
+
+
碳水化合物
+
+ {{ healthDashboardData.nutrition.carbs }}
+ / {{ healthDashboardData.nutrition.carbsGoal }}g
+
+
+
+
钙
+
+ {{ healthDashboardData.nutrition.calcium }}
+ / {{ healthDashboardData.nutrition.calciumGoal }}mg
+
+
+
+
维生素C
+
+ {{ healthDashboardData.nutrition.vitaminC }}
+ / {{ healthDashboardData.nutrition.vitaminCGoal }}mg
+
+
+
+
维生素D
+
+ {{ healthDashboardData.nutrition.vitaminD }}
+ / {{ healthDashboardData.nutrition.vitaminDGoal }}µg
+
+
+
+
+
+
+
+
+
+
+
+
+
热量摄入
+
{{ healthDashboardData.calories.current }}
+
/ {{ healthDashboardData.calories.goal }} kcal
+
+
+
+
+
+
+
+
+
+
饮水
+
{{ healthDashboardData.water.current / 1000 }}
+
/ {{ healthDashboardData.water.goal / 1000 }} L
+
+
+
+
+
+
+
+
+
+
+
发现
+
{{ item.title }}
+
{{ item.summary }}
+
+
+
+
+
+
+ 为你推荐的菜谱
+
{{ item.title }}
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/shihuashishuo-ui/src/views/核心体验页/HomeView-首页-2.2.vue b/shihuashishuo-ui/src/views/核心体验页/HomeView-首页-2.2.vue
new file mode 100644
index 0000000..9b3bf0c
--- /dev/null
+++ b/shihuashishuo-ui/src/views/核心体验页/HomeView-首页-2.2.vue
@@ -0,0 +1,610 @@
+
+
+
+
+ 晚上好, 王女士
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
本周您已分析 8 种食品,
+
成功为家人避开 4 个高风险成分!
+
+
+
+
+
+
+
+
每日营养
+
+
+
蛋白质
+
+ {{ healthDashboardData.nutrition.protein }}
+ / {{ healthDashboardData.nutrition.proteinGoal }}g
+
+
+
+
脂肪
+
+ {{ healthDashboardData.nutrition.fat }}
+ / {{ healthDashboardData.nutrition.fatGoal }}g
+
+
+
+
碳水化合物
+
+ {{ healthDashboardData.nutrition.carbs }}
+ / {{ healthDashboardData.nutrition.carbsGoal }}g
+
+
+
+
钙
+
+ {{ healthDashboardData.nutrition.calcium }}
+ / {{ healthDashboardData.nutrition.calciumGoal }}mg
+
+
+
+
维生素C
+
+ {{ healthDashboardData.nutrition.vitaminC }}
+ / {{ healthDashboardData.nutrition.vitaminCGoal }}mg
+
+
+
+
维生素D
+
+ {{ healthDashboardData.nutrition.vitaminD }}
+ / {{ healthDashboardData.nutrition.vitaminDGoal }}µg
+
+
+
+
+
+
+
+
+
+
+
+
+
热量摄入
+
{{ healthDashboardData.calories.current }}
+
/ {{ healthDashboardData.calories.goal }} kcal
+
+
+
+
+
+
+
+
+
+
饮水
+
{{ healthDashboardData.water.current / 1000 }}
+
/ {{ healthDashboardData.water.goal / 1000 }} L
+
+
+
+
+
+
+
+
+
+
+
发现
+
{{ item.title }}
+
{{ item.summary }}
+
+
+
+
+
+
+ 为你推荐的菜谱
+
{{ item.title }}
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/shihuashishuo-ui/src/views/ResultView-结果页.vue b/shihuashishuo-ui/src/views/核心体验页/ResultView-结果页.vue
similarity index 100%
rename from shihuashishuo-ui/src/views/ResultView-结果页.vue
rename to shihuashishuo-ui/src/views/核心体验页/ResultView-结果页.vue
diff --git a/shihuashishuo-ui/src/views/ScanView-扫码页.vue b/shihuashishuo-ui/src/views/核心体验页/ScanView-扫码页.vue
similarity index 75%
rename from shihuashishuo-ui/src/views/ScanView-扫码页.vue
rename to shihuashishuo-ui/src/views/核心体验页/ScanView-扫码页.vue
index 5bb8c4c..1cfa2ff 100644
--- a/shihuashishuo-ui/src/views/ScanView-扫码页.vue
+++ b/shihuashishuo-ui/src/views/核心体验页/ScanView-扫码页.vue
@@ -3,7 +3,7 @@
@@ -14,12 +14,12 @@
-
+
💡
手电筒
-
-
+
+
⌨️
手动输入
@@ -36,10 +36,19 @@ const goBack = () => {
router.back();
};
-const scan = () => {
- // Simulate scanning and navigating to result page
- console.log('Simulating scan...');
- router.push({ name: 'result', params: { id: 'sample123' } });
+const simulateScan = () => {
+ console.log('Prototype: Simulating scan...');
+ // Show a loading indicator or a message
+ alert('正在识别,请稍候...');
+
+ setTimeout(() => {
+ // Navigate to the result page with a sample ID
+ router.push({ name: 'result', params: { id: 'prototype123' } });
+ }, 1500); // Simulate a 1.5-second network delay
+};
+
+const showPlaceholderAlert = (featureName: string) => {
+ alert(`${featureName} 功能正在开发中,敬请期待!`);
};
diff --git a/shihuashishuo-ui/src/views/SearchResultView-搜索结果页.vue b/shihuashishuo-ui/src/views/核心体验页/SearchResultView-搜索结果页.vue
similarity index 100%
rename from shihuashishuo-ui/src/views/SearchResultView-搜索结果页.vue
rename to shihuashishuo-ui/src/views/核心体验页/SearchResultView-搜索结果页.vue
diff --git a/shihuashishuo-ui/src/views/SearchView-搜索页.vue b/shihuashishuo-ui/src/views/核心体验页/SearchView-搜索页.vue
similarity index 57%
rename from shihuashishuo-ui/src/views/SearchView-搜索页.vue
rename to shihuashishuo-ui/src/views/核心体验页/SearchView-搜索页.vue
index e44a37f..93a15e2 100644
--- a/shihuashishuo-ui/src/views/SearchView-搜索页.vue
+++ b/shihuashishuo-ui/src/views/核心体验页/SearchView-搜索页.vue
@@ -13,18 +13,18 @@
历史记录
- 牛奶
- 酱油
- 益生菌
+
+ {{ tag }}
+
热门搜索
- 酸奶评测
- 无麸质
- 宝宝辅食
+
+ {{ tag }}
+
@@ -38,20 +38,38 @@ import { useRouter } from 'vue-router';
const router = useRouter();
const searchQuery = ref('');
+const historyTags = ref(['牛奶', '酱油', '益生菌', '宝宝零食']);
+const hotSearchTags = ref(['酸奶评测', '无麸质', '宝宝辅食', '添加剂查询', '预制菜']);
+
const goBack = () => {
router.back();
};
const performSearch = () => {
- if (searchQuery.value.trim()) {
- router.push({ name: 'search-result', query: { q: searchQuery.value } });
+ const query = searchQuery.value.trim();
+ if (query) {
+ console.log(`Prototype: Simulating search for "${query}"...`);
+ alert(`正在搜索 "${query}", 请稍候...`);
+
+ setTimeout(() => {
+ router.push({ name: 'search-result', query: { q: query } });
+ }, 1000); // Simulate a 1-second network delay
+ } else {
+ alert('请输入搜索内容!');
}
};
+
+const searchWithTag = (tag: string) => {
+ searchQuery.value = tag;
+ performSearch();
+};
\ No newline at end of file