Browse Source

fix: 更新环境配置和修复案例展示问题

- 更新生产环境和开发环境的API基础路径
- 修复案例详情页的数据获取逻辑,优先使用API返回数据
- 为联系信息添加条件渲染防止空值显示
- 调整vite代理配置的目标端口
- 注释掉首页的客户评价组件
master
主管理员 3 weeks ago
parent
commit
8c3e7c4f56
8 changed files with 60 additions and 24 deletions
  1. +2
    -2
      .env.development
  2. +1
    -1
      .env.production
  3. +3
    -3
      src/App.vue
  4. +3
    -1
      src/components/home/CaseSection.vue
  5. +4
    -1
      src/stores/cases.js
  6. +45
    -14
      src/views/pages/CaseDetail.vue
  7. +1
    -1
      src/views/pages/Home.vue
  8. +1
    -1
      vite.config.js

+ 2
- 2
.env.development View File

@ -2,5 +2,5 @@
# 开发环境
# VITE_APP_BASE_API = '/dev-api'
VITE_APP_BASE_API = 'http://42.194.239.145:8005/official'
VITE_APP_BASE_API = '/dev-api'
# VITE_APP_BASE_API = 'http://42.194.239.145:8005/official'

+ 1
- 1
.env.production View File

@ -1,3 +1,3 @@
# 生产环境
VITE_APP_BASE_API = 'http://42.194.239.145:8005/official'
VITE_APP_BASE_API = 'https://official-admin.hhlm1688.com/official'

+ 3
- 3
src/App.vue View File

@ -115,9 +115,9 @@ onMounted(() => {
<div class="link-group">
<h4>联系我们</h4>
<ul>
<li>{{ configParams.address }}</li>
<li>{{ configParams.email }}</li>
<li>{{ configParams.phone }}</li>
<li v-if="configParams.address">{{ configParams.address }}</li>
<li v-if="configParams.email">{{ configParams.email }}</li>
<li v-if="configParams.phone">{{ configParams.phone }}</li>
</ul>
</div>
</div>


+ 3
- 1
src/components/home/CaseSection.vue View File

@ -2,9 +2,11 @@
//
import CaseItem from '../cases/CaseItem.vue';
import { useRouter } from 'vue-router';
import { storeToRefs } from 'pinia';
import { useCasesStore } from '@/stores/cases'
const { selectedCase } = useCasesStore()
const casesStore = useCasesStore()
const { selectedCase } = storeToRefs(casesStore)
//
const router = useRouter();


+ 4
- 1
src/stores/cases.js View File

@ -104,13 +104,16 @@ export const useCasesStore = defineStore('cases', () => {
}
];
const selectedCase = ref(mockSelectedCases);
const selectedCase = ref([]);
const getSelectedCase = async () => {
try {
const res = await api.getSelectedCase();
if (res.data && res.data.length > 0) {
selectedCase.value = res.data;
} else {
// 如果API返回空数据,使用mock数据
selectedCase.value = mockSelectedCases;
}
} catch (error) {
console.error('获取精选案例失败:', error);


+ 45
- 14
src/views/pages/CaseDetail.vue View File

@ -3,13 +3,14 @@ import { ref, onMounted, computed, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import PageHeader from '../../components/PageHeader.vue';
import { useCasesStore } from '@/stores/cases';
import api from '@/api'
const route = useRoute();
const router = useRouter();
const { selectedCase } = useCasesStore();
// ID
const caseId = computed(() => Number(route.params.id));
const caseId = computed(() => route.params.id);
//
const currentCase = ref(null);
@ -45,23 +46,29 @@ const defaultCaseData = {
const getCaseDetail = async () => {
console.log('当前案例ID:', caseId.value);
console.log('所有案例:', selectedCase.value);
// API
currentCase.value = await api.getCaseDetail(caseId.value);
if (currentCase.value.data) {
currentCase.value = currentCase.value.data;
}
// selectedCase
if (selectedCase.value && selectedCase.value.length > 0) {
const currentCaseData = selectedCase.value[0];
console.log('使用的案例数据:', currentCaseData);
// if (selectedCase.value && selectedCase.value.length > 0) {
// const currentCaseData = selectedCase.value[0];
// console.log('使:', currentCaseData);
//
if (currentCaseData.imageUrl && typeof currentCaseData.imageUrl === 'string') {
currentCaseData.image = currentCaseData.imageUrl.split(',')[0];
}
// //
// if (currentCaseData.imageUrl && typeof currentCaseData.imageUrl === 'string') {
// currentCaseData.image = currentCaseData.imageUrl.split(',')[0];
// </span><span class="err"> pan> }
currentCase.value = currentCaseData;
} else {
// 使
console.log('使用默认的静态数据');
currentCase.value = defaultCaseData;
}
// currentCase.value = currentCaseData;
// } else {
// // 使
// console.log('使');
// currentCase.value = defaultCaseData;
// }
};
//
@ -154,6 +161,12 @@ onMounted(() => {
</div>
</div>
</section>
<!-- 详情 -->
<section class="case-gallery" v-if="currentCase.content">
<div class="container" v-html="currentCase.content">
</div>
</section>
</div>
</template>
@ -218,6 +231,24 @@ onMounted(() => {
background-color: #0056b3;
}
.btn-outline {
display: inline-block;
padding: 10px 20px;
background: transparent;
color: #007bff;
border: 2px solid #007bff;
border-radius: 6px;
text-decoration: none;
font-weight: 500;
transition: all 0.3s ease;
}
.btn-outline:hover {
background: #007bff;
color: white;
transform: translateY(-2px);
}
.qrcode-image {
max-width: 200px;
margin: 0 auto;


+ 1
- 1
src/views/pages/Home.vue View File

@ -138,7 +138,7 @@ onMounted(() => {
</section>
<!-- 客户评价 -->
<CustomerReviews />
<!-- <CustomerReviews /> -->
<!-- 合作流程视差滚动 -->
<section class="process-section" data-aos="fade-up">


+ 1
- 1
vite.config.js View File

@ -18,7 +18,7 @@ export default defineConfig(({ command, mode }) => {
open: true,
proxy: {
[env.VITE_APP_BASE_API]: {
target: 'http://localhost:8080',
target: 'http://localhost:8000',
changeOrigin: true,
ws: true,
rewrite: (path) => path.replace(new RegExp('^' + env.VITE_APP_BASE_API), '')


Loading…
Cancel
Save