style: 格式化项目代码
- 根据prettier配置格式化整个项目的代码
This commit is contained in:
@ -5,12 +5,12 @@
|
||||
<el-breadcrumb class="breadcrumb" separator="/">
|
||||
<el-breadcrumb-item class="text-md opacity-50">
|
||||
<NuxtLink :to="$localePath('/')">{{
|
||||
$t("navigation.home")
|
||||
$t('navigation.home')
|
||||
}}</NuxtLink>
|
||||
</el-breadcrumb-item>
|
||||
<el-breadcrumb-item class="text-md opacity-50">
|
||||
<NuxtLink :to="$localePath('/productions')">{{
|
||||
$t("navigation.productions")
|
||||
$t('navigation.productions')
|
||||
}}</NuxtLink>
|
||||
</el-breadcrumb-item>
|
||||
<el-breadcrumb-item class="text-md opactiy-50">{{
|
||||
@ -102,7 +102,7 @@
|
||||
>
|
||||
<template #extra>
|
||||
<el-button type="primary" @click="$router.push('/productions')">
|
||||
{{ $t("back-to-productions") }}
|
||||
{{ $t('back-to-productions') }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-result>
|
||||
@ -111,166 +111,166 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const route = useRoute();
|
||||
const { findOne } = useStrapi();
|
||||
const { getStrapiLocale } = useLocalizations();
|
||||
const strapiLocale = getStrapiLocale();
|
||||
const route = useRoute();
|
||||
const { findOne } = useStrapi();
|
||||
const { getStrapiLocale } = useLocalizations();
|
||||
const strapiLocale = getStrapiLocale();
|
||||
|
||||
const production = ref<Production | null>(null);
|
||||
const pending = ref(true);
|
||||
const production = ref<Production | null>(null);
|
||||
const pending = ref(true);
|
||||
|
||||
const activeName = ref("details"); // 默认选中概览标签
|
||||
const activeName = ref('details'); // 默认选中概览标签
|
||||
|
||||
// 获取路由参数(slug 或 id)
|
||||
const documentId = computed(() => route.params.slug as string);
|
||||
// 获取路由参数(slug 或 id)
|
||||
const documentId = computed(() => route.params.slug as string);
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const response = await findOne<Production>(
|
||||
"productions",
|
||||
documentId.value,
|
||||
{
|
||||
populate: {
|
||||
production_specs: {
|
||||
populate: "*",
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const response = await findOne<Production>(
|
||||
'productions',
|
||||
documentId.value,
|
||||
{
|
||||
populate: {
|
||||
production_specs: {
|
||||
populate: '*',
|
||||
},
|
||||
production_images: {
|
||||
populate: '*',
|
||||
},
|
||||
cover: {
|
||||
populate: '*',
|
||||
},
|
||||
questions: {
|
||||
populate: '*',
|
||||
},
|
||||
production_documents: {
|
||||
populate: 'document',
|
||||
},
|
||||
},
|
||||
production_images: {
|
||||
populate: "*",
|
||||
},
|
||||
cover: {
|
||||
populate: "*",
|
||||
},
|
||||
questions: {
|
||||
populate: "*",
|
||||
},
|
||||
production_documents: {
|
||||
populate: "document",
|
||||
},
|
||||
},
|
||||
locale: strapiLocale,
|
||||
locale: strapiLocale,
|
||||
}
|
||||
);
|
||||
if (response.data) {
|
||||
const item = response.data;
|
||||
production.value = {
|
||||
...item,
|
||||
};
|
||||
console.log('Fetched production:', production.value);
|
||||
}
|
||||
);
|
||||
if (response.data) {
|
||||
const item = response.data;
|
||||
production.value = {
|
||||
...item,
|
||||
};
|
||||
console.log("Fetched production:", production.value);
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch production:', error);
|
||||
} finally {
|
||||
pending.value = false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch production:", error);
|
||||
} finally {
|
||||
pending.value = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// SEO
|
||||
useHead({
|
||||
title: computed(() => production.value?.title || "Product Detail"),
|
||||
meta: [
|
||||
{
|
||||
name: "description",
|
||||
content: computed(() => production.value?.summary || ""),
|
||||
},
|
||||
],
|
||||
});
|
||||
// SEO
|
||||
useHead({
|
||||
title: computed(() => production.value?.title || 'Product Detail'),
|
||||
meta: [
|
||||
{
|
||||
name: 'description',
|
||||
content: computed(() => production.value?.summary || ''),
|
||||
},
|
||||
],
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page-container {
|
||||
min-height: 80vh;
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.page-container {
|
||||
min-height: 80vh;
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.breadcrumb {
|
||||
padding: 2rem;
|
||||
}
|
||||
.breadcrumb {
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
.production-header {
|
||||
display: grid;
|
||||
grid-template-columns: 2fr 1fr;
|
||||
gap: 3rem;
|
||||
}
|
||||
|
||||
.production-image .el-image {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 500px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.production-image-caption {
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
/* left: 10%; */
|
||||
background-color: rgba(0, 0, 0, 0.2);
|
||||
border-radius: 5px;
|
||||
padding: 5px 10px;
|
||||
text-align: center;
|
||||
color: white;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.production-carousel :deep(.el-carousel__button) {
|
||||
/* 指示器按钮样式 */
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background-color: #475669;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.production-info h1 {
|
||||
margin-top: 2rem;
|
||||
margin-bottom: 1rem;
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
.summary {
|
||||
color: var(--el-color-info);
|
||||
font-size: 1rem;
|
||||
line-height: 1.6;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.production-tabs ::v-deep(.el-tabs__nav) {
|
||||
min-width: 30%;
|
||||
float: right;
|
||||
}
|
||||
|
||||
.production-tabs ::v-deep(.el-tabs__content) {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.production-content h2 {
|
||||
color: var(--el-text-color-primary);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.loading {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.not-found {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 400px;
|
||||
}
|
||||
|
||||
/* 响应式设计 */
|
||||
@media (max-width: 768px) {
|
||||
.production-header {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 2rem;
|
||||
display: grid;
|
||||
grid-template-columns: 2fr 1fr;
|
||||
gap: 3rem;
|
||||
}
|
||||
|
||||
.production-image .el-image {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 500px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.production-image-caption {
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
/* left: 10%; */
|
||||
background-color: rgba(0, 0, 0, 0.2);
|
||||
border-radius: 5px;
|
||||
padding: 5px 10px;
|
||||
text-align: center;
|
||||
color: white;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.production-carousel :deep(.el-carousel__button) {
|
||||
/* 指示器按钮样式 */
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background-color: #475669;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.production-info h1 {
|
||||
margin-top: 2rem;
|
||||
margin-bottom: 1rem;
|
||||
font-size: 2rem;
|
||||
}
|
||||
}
|
||||
|
||||
.summary {
|
||||
color: var(--el-color-info);
|
||||
font-size: 1rem;
|
||||
line-height: 1.6;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.production-tabs ::v-deep(.el-tabs__nav) {
|
||||
min-width: 30%;
|
||||
float: right;
|
||||
}
|
||||
|
||||
.production-tabs ::v-deep(.el-tabs__content) {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.production-content h2 {
|
||||
color: var(--el-text-color-primary);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.loading {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.not-found {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 400px;
|
||||
}
|
||||
|
||||
/* 响应式设计 */
|
||||
@media (max-width: 768px) {
|
||||
.production-header {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 2rem;
|
||||
}
|
||||
|
||||
.production-info h1 {
|
||||
font-size: 2rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div class="page-header">
|
||||
<h1 class="page-title">{{ $t("our-productions") }}</h1>
|
||||
<h1 class="page-title">{{ $t('our-productions') }}</h1>
|
||||
<el-breadcrumb class="breadcrumb">
|
||||
<el-breadcrumb-item class="text-md opacity-50">
|
||||
<NuxtLink :to="$localePath('/')">{{
|
||||
$t("navigation.home")
|
||||
$t('navigation.home')
|
||||
}}</NuxtLink>
|
||||
</el-breadcrumb-item>
|
||||
<el-breadcrumb-item class="text-md opacity-50">
|
||||
<NuxtLink :to="$localePath('/productions')">{{
|
||||
$t("navigation.productions")
|
||||
$t('navigation.productions')
|
||||
}}</NuxtLink>
|
||||
</el-breadcrumb-item>
|
||||
</el-breadcrumb>
|
||||
@ -42,117 +42,117 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const { find } = useStrapi();
|
||||
const { getStrapiLocale } = useLocalizations();
|
||||
const { find } = useStrapi();
|
||||
const { getStrapiLocale } = useLocalizations();
|
||||
|
||||
const strapiLocale = getStrapiLocale();
|
||||
const strapiLocale = getStrapiLocale();
|
||||
|
||||
const activeNames = ref<string[]>([]);
|
||||
const activeNames = ref<string[]>([]);
|
||||
|
||||
const productions = ref<Production[]>([]);
|
||||
const productions = ref<Production[]>([]);
|
||||
|
||||
// 按类型分组
|
||||
// 兼容 production_type 既可能为对象也可能为字符串
|
||||
const groupedProductions = computed(() => {
|
||||
const groups: Record<string, Production[]> = {};
|
||||
for (const prod of productions.value) {
|
||||
let typeKey = "";
|
||||
if (typeof prod.production_type === "string") {
|
||||
typeKey = prod.production_type;
|
||||
} else if (
|
||||
prod.production_type &&
|
||||
typeof prod.production_type === "object" &&
|
||||
"type" in prod.production_type
|
||||
) {
|
||||
typeKey = prod.production_type.type || "";
|
||||
// 按类型分组
|
||||
// 兼容 production_type 既可能为对象也可能为字符串
|
||||
const groupedProductions = computed(() => {
|
||||
const groups: Record<string, Production[]> = {};
|
||||
for (const prod of productions.value) {
|
||||
let typeKey = '';
|
||||
if (typeof prod.production_type === 'string') {
|
||||
typeKey = prod.production_type;
|
||||
} else if (
|
||||
prod.production_type &&
|
||||
typeof prod.production_type === 'object' &&
|
||||
'type' in prod.production_type
|
||||
) {
|
||||
typeKey = prod.production_type.type || '';
|
||||
}
|
||||
if (!groups[typeKey]) groups[typeKey] = [];
|
||||
groups[typeKey]?.push(prod);
|
||||
}
|
||||
if (!groups[typeKey]) groups[typeKey] = [];
|
||||
groups[typeKey]?.push(prod);
|
||||
}
|
||||
return groups;
|
||||
});
|
||||
return groups;
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const response = await find<Production>("productions", {
|
||||
populate: {
|
||||
cover: {
|
||||
populate: "*",
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const response = await find<Production>('productions', {
|
||||
populate: {
|
||||
cover: {
|
||||
populate: '*',
|
||||
},
|
||||
production_type: {
|
||||
populate: '*',
|
||||
},
|
||||
},
|
||||
production_type: {
|
||||
populate: "*",
|
||||
filters: {
|
||||
show_in_production_list: {
|
||||
$eq: true, // 只获取在产品列表中显示的产品
|
||||
},
|
||||
},
|
||||
},
|
||||
filters: {
|
||||
show_in_production_list: {
|
||||
$eq: true, // 只获取在产品列表中显示的产品
|
||||
},
|
||||
},
|
||||
locale: strapiLocale,
|
||||
});
|
||||
productions.value = response.data.map((item: Production) => ({
|
||||
...item,
|
||||
// 保持 production_type 原始类型,兼容对象或字符串
|
||||
production_type: item.production_type,
|
||||
}));
|
||||
// 默认展开所有分组
|
||||
activeNames.value = Object.keys(groupedProductions.value);
|
||||
activeNames.value.push("no-category"); // 展开未分类
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch productions:", error);
|
||||
}
|
||||
});
|
||||
locale: strapiLocale,
|
||||
});
|
||||
productions.value = response.data.map((item: Production) => ({
|
||||
...item,
|
||||
// 保持 production_type 原始类型,兼容对象或字符串
|
||||
production_type: item.production_type,
|
||||
}));
|
||||
// 默认展开所有分组
|
||||
activeNames.value = Object.keys(groupedProductions.value);
|
||||
activeNames.value.push('no-category'); // 展开未分类
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch productions:', error);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page-container {
|
||||
padding: 2rem;
|
||||
margin: 0 auto;
|
||||
max-width: 1200px;
|
||||
}
|
||||
.page-container {
|
||||
padding: 2rem;
|
||||
margin: 0 auto;
|
||||
max-width: 1200px;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
display: flex;
|
||||
}
|
||||
.page-header {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
font-size: 2rem;
|
||||
font-weight: bold;
|
||||
color: var(--el-color-primary);
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
.page-title {
|
||||
font-size: 2rem;
|
||||
font-weight: bold;
|
||||
color: var(--el-color-primary);
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.breadcrumb {
|
||||
margin-left: auto;
|
||||
}
|
||||
.breadcrumb {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.productions-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 40px;
|
||||
}
|
||||
.productions-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 40px;
|
||||
}
|
||||
|
||||
.production-group {
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
.production-group {
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
.group-title {
|
||||
font-size: 1.5rem;
|
||||
font-weight: bold;
|
||||
margin-bottom: 16px;
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
.group-title {
|
||||
font-size: 1.5rem;
|
||||
font-weight: bold;
|
||||
margin-bottom: 16px;
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
|
||||
.group-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
padding-top: 1rem;
|
||||
gap: 20px;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
.group-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
padding-top: 1rem;
|
||||
gap: 20px;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
:deep(.el-collapse-item__header) {
|
||||
padding: 30px auto;
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
:deep(.el-collapse-item__header) {
|
||||
padding: 30px auto;
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user