style: 格式化项目代码

- 根据prettier配置格式化整个项目的代码
This commit is contained in:
2025-09-17 15:50:29 +08:00
parent bb89721f1c
commit 359aaec8a9
43 changed files with 1900 additions and 1878 deletions

View File

@ -19,7 +19,6 @@
- 关于我们
- 公司基本信息
## 安装与设置
> [!NOTE]
@ -65,11 +64,13 @@ pnpm run dev
1. 构建生产版本
项目构建
```bash
pnpm run build
```
预览构建版本
```bash
pnpm run preview
```
@ -77,3 +78,4 @@ pnpm run preview
2. 部署
部署构建后的项目并推送到文件服务器中,具体步骤视服务器配置而定

View File

@ -9,7 +9,7 @@
</template>
<script setup lang="ts">
import { ElConfigProvider } from "element-plus";
import { ElConfigProvider } from 'element-plus';
const { login } = useStrapiAuth();
@ -22,15 +22,15 @@ onMounted(() => {
const user = useStrapiUser();
if (!user.value) {
// 如果未登录,重定向到登录页面
login({ identifier: "remilia", password: "huanshuo51" })
login({ identifier: 'remilia', password: 'huanshuo51' })
.then(() => {
console.log("Login successful");
console.log('Login successful');
})
.catch((error) => {
console.error("Login failed:", error);
console.error('Login failed:', error);
});
} else {
console.log("User is already logged in:", user.value);
console.log('User is already logged in:', user.value);
}
});
</script>

View File

@ -1,7 +1,10 @@
@font-face {
font-family: "Source Han Sans CN";
src: url("/fonts/source-han-sans/SourceHanSansCN-Regular-Alphabetic.woff2") format("woff2"),
url("/fonts/source-han-sans/SourceHanSansCN-Regular-Alphabetic.woff") format("woff");
src:
url("/fonts/source-han-sans/SourceHanSansCN-Regular-Alphabetic.woff2")
format("woff2"),
url("/fonts/source-han-sans/SourceHanSansCN-Regular-Alphabetic.woff")
format("woff");
font-weight: 400;
font-style: normal;
font-display: swap;
@ -9,8 +12,12 @@
@font-face {
font-family: "Source Han Sans CN";
src: url("/fonts/source-han-sans/SourceHanSansCN-Bold-Alphabetic.woff2") format("woff2"),
url("/fonts/source-han-sans/SourceHanSansCN-Bold-Alphabetic.woff") format("woff");
src:
url("/fonts/source-han-sans/SourceHanSansCN-Bold-Alphabetic.woff2")
format("woff2"),
url("/fonts/source-han-sans/SourceHanSansCN-Bold-Alphabetic.woff")
format("woff");
font-weight: 700;
font-style: normal;
font-display: swap;
@ -18,8 +25,11 @@
@font-face {
font-family: "Source Han Sans CN";
src: url("/fonts/source-han-sans/SourceHanSansCN-Light-Alphabetic.woff2") format("woff2"),
url("/fonts/source-han-sans/SourceHanSansCN-Light-Alphabetic.woff") format("woff");
src:
url("/fonts/source-han-sans/SourceHanSansCN-Light-Alphabetic.woff2")
format("woff2"),
url("/fonts/source-han-sans/SourceHanSansCN-Light-Alphabetic.woff")
format("woff");
font-weight: 300;
font-style: normal;
font-display: swap;

View File

@ -1,6 +1,6 @@
@forward 'element-plus/theme-chalk/src/dark/var.scss' with (
@forward "element-plus/theme-chalk/src/dark/var.scss" with (
$bg-color: (
'page': #0a0a0a,
'overlay': #1d1e1f,
"page": #0a0a0a,
"overlay": #1d1e1f,
)
);

View File

@ -1,26 +1,26 @@
$-colors: (
'primary': (
'base': #177ee5,
"primary": (
"base": #177ee5,
),
'success': (
'base': green,
"success": (
"base": green,
),
'warning': (
'base': #f9a23c,
"warning": (
"base": #f9a23c,
),
'danger': (
'base': #ff3300,
"danger": (
"base": #ff3300,
),
'error': (
'base': #f56c6c,
"error": (
"base": #f56c6c,
),
'info': (
'base': #909399,
"info": (
"base": #909399,
),
);
@forward 'element-plus/theme-chalk/src/common/var.scss' with (
@forward "element-plus/theme-chalk/src/common/var.scss" with (
$colors: $-colors
);
@use './dark.scss';
@use "./dark.scss";

View File

@ -17,5 +17,6 @@ a {
}
:root {
--font-main: "Source Han Sans CN", "Noto Sans CJK SC", "Noto Sans CJK", sans-serif;
--font-main:
"Source Han Sans CN", "Noto Sans CJK SC", "Noto Sans CJK", sans-serif;
}

View File

@ -40,7 +40,7 @@ const handleDownload = async (fileName: string, fileUrl: string) => {
const blob = await response.blob();
const url = window.URL.createObjectURL(blob);
const link = document.createElement("a");
const link = document.createElement('a');
link.href = url;
link.download = fileName;
document.body.appendChild(link);

View File

@ -4,39 +4,39 @@
<!-- Logo 和公司信息 -->
<div class="footer-section">
<div class="footer-logo">
<img src="/jinshen-logo.png" alt="Jinshen Logo" class="logo-image">
<h3>{{ $t("company-name") }}</h3>
<img src="/jinshen-logo.png" alt="Jinshen Logo" class="logo-image" />
<h3>{{ $t('company-name') }}</h3>
</div>
<p class="company-description">
{{ $t("company-description") }}
{{ $t('company-description') }}
</p>
</div>
<!-- 快速链接 -->
<div class="footer-section">
<h4>{{ $t("quick-links") }}</h4>
<h4>{{ $t('quick-links') }}</h4>
<ul class="footer-links">
<li>
<NuxtLinkLocale to="/">{{ $t("navigation.home") }}</NuxtLinkLocale>
<NuxtLinkLocale to="/">{{ $t('navigation.home') }}</NuxtLinkLocale>
</li>
<li>
<NuxtLink :to="$localePath('/productions')">{{
$t("navigation.productions")
$t('navigation.productions')
}}</NuxtLink>
</li>
<li>
<NuxtLink :to="$localePath('/solutions')">{{
$t("navigation.solutions")
$t('navigation.solutions')
}}</NuxtLink>
</li>
<li>
<NuxtLink :to="$localePath('/support')">{{
$t("navigation.support")
$t('navigation.support')
}}</NuxtLink>
</li>
<li>
<NuxtLink :to="$localePath('/about')">{{
$t("navigation.about-us")
$t('navigation.about-us')
}}</NuxtLink>
</li>
</ul>
@ -44,24 +44,24 @@
<!-- 联系信息 -->
<div class="footer-section">
<h4>{{ $t("contact-info") }}</h4>
<h4>{{ $t('contact-info') }}</h4>
<div class="contact-item">
<el-icon><Phone /></el-icon>
<span>{{ $t("telephone") }}: 0573-88187988</span>
<span>{{ $t('telephone') }}: 0573-88187988</span>
</div>
<div class="contact-item">
<el-icon><Message /></el-icon>
<span>{{ $t("email") }}: jinshen@wzjinshen.com</span>
<span>{{ $t('email') }}: jinshen@wzjinshen.com</span>
</div>
<div class="contact-item">
<el-icon><Location /></el-icon>
<span>{{ $t("address") }}: {{ $t("company-address") }}</span>
<span>{{ $t('address') }}: {{ $t('company-address') }}</span>
</div>
</div>
<!-- 社交媒体 -->
<div class="footer-section">
<h4>{{ $t("follow-us") }}</h4>
<h4>{{ $t('follow-us') }}</h4>
<div class="social-links">
<a href="#" class="social-link" aria-label="WeChat">
<el-icon size="20"><ChatDotRound /></el-icon>
@ -84,21 +84,21 @@
<div class="footer-container">
<div class="copyright">
<p>
&copy; {{ currentYear }} {{ $t("company-name") }}.
{{ $t("all-rights-reserved") }}
&copy; {{ currentYear }} {{ $t('company-name') }}.
{{ $t('all-rights-reserved') }}
</p>
<p>备案号: 浙ICP备12003709号-5</p>
</div>
<div class="footer-links-bottom">
<NuxtLink :to="$localePath('/privacy')">{{
$t("privacy-policy")
$t('privacy-policy')
}}</NuxtLink>
<span class="separator">|</span>
<NuxtLink :to="$localePath('/terms')">{{
$t("terms-of-service")
$t('terms-of-service')
}}</NuxtLink>
<span class="separator">|</span>
<NuxtLink :to="$localePath('/sitemap')">{{ $t("sitemap") }}</NuxtLink>
<NuxtLink :to="$localePath('/sitemap')">{{ $t('sitemap') }}</NuxtLink>
</div>
</div>
</div>
@ -113,7 +113,7 @@ import {
ChatDotRound,
Star,
Link,
} from "@element-plus/icons-vue";
} from '@element-plus/icons-vue';
const currentYear = new Date().getFullYear();
</script>

View File

@ -22,16 +22,16 @@
router
>
<el-menu-item index="productions" :route="$localePath('/productions')">
<span class="title">{{ $t("navigation.productions") }}</span>
<span class="title">{{ $t('navigation.productions') }}</span>
</el-menu-item>
<el-menu-item index="solutions" :route="$localePath('/solutions')">
<span class="title">{{ $t("navigation.solutions") }}</span>
<span class="title">{{ $t('navigation.solutions') }}</span>
</el-menu-item>
<el-menu-item index="support" :route="$localePath('/support')">
<span class="title">{{ $t("navigation.support") }}</span>
<span class="title">{{ $t('navigation.support') }}</span>
</el-menu-item>
<el-menu-item index="about" :route="$localePath('/about')">
<span class="title">{{ $t("navigation.about-us") }}</span>
<span class="title">{{ $t('navigation.about-us') }}</span>
</el-menu-item>
</el-menu>
</div>
@ -62,14 +62,14 @@
</template>
<script setup lang="ts">
import { Search } from "@element-plus/icons-vue";
import { Search } from '@element-plus/icons-vue';
const router = useRouter();
const localePath = useLocalePath();
const { setLocale } = useI18n();
const searchQuery = ref("");
const searchQuery = ref('');
const activeName = ref<string | undefined>(undefined);
@ -77,24 +77,24 @@ const handleSearch = () => {
const trimmed = searchQuery.value.trim();
if (!trimmed) return;
navigateTo({
path: localePath("/search"),
path: localePath('/search'),
query: {
query: trimmed,
},
});
searchQuery.value = "";
searchQuery.value = '';
};
const refreshMenu = () => {
const path = router.currentRoute.value.path;
if (path.startsWith("/productions")) {
activeName.value = "productions";
} else if (path.startsWith("/solutions")) {
activeName.value = "solutions";
} else if (path.startsWith("/support")) {
activeName.value = "support";
} else if (path.startsWith("/about")) {
activeName.value = "about";
if (path.startsWith('/productions')) {
activeName.value = 'productions';
} else if (path.startsWith('/solutions')) {
activeName.value = 'solutions';
} else if (path.startsWith('/support')) {
activeName.value = 'support';
} else if (path.startsWith('/about')) {
activeName.value = 'about';
} else {
activeName.value = undefined; // 默认不激活任何菜单项
}

View File

@ -17,7 +17,7 @@ const contentWithAbsoluteUrls = convertMedia(props.content);
const safeHtml = computed(() => renderMarkdown(contentWithAbsoluteUrls));
// const safeHtml = computed(() => renderMarkdown(props.content))
console.log("Rendered HTML:", safeHtml.value);
console.log('Rendered HTML:', safeHtml.value);
</script>
<style>

View File

@ -15,16 +15,16 @@
const props = defineProps({
modelValue: {
type: String,
default: "",
default: '',
},
});
const activeTab = ref(props.modelValue || "");
const activeTab = ref(props.modelValue || '');
const options = [
{ label: "服务支持", value: "" },
{ label: "常见问题", value: "faq" },
{ label: "文档资料", value: "documents" },
{ label: "联系售后", value: "contact-us" },
{ label: '服务支持', value: '' },
{ label: '常见问题', value: 'faq' },
{ label: '文档资料', value: 'documents' },
{ label: '联系售后', value: 'contact-us' },
];
const handleSegmentedChange = (value: string) => {

View File

@ -1,12 +1,12 @@
import type { StrapiLocale } from "@nuxtjs/strapi";
import type { Language as ElementLanguage } from "element-plus/es/locale";
import zhCn from "element-plus/es/locale/lang/zh-cn";
import en from "element-plus/es/locale/lang/en";
import type { StrapiLocale } from '@nuxtjs/strapi';
import type { Language as ElementLanguage } from 'element-plus/es/locale';
import zhCn from 'element-plus/es/locale/lang/zh-cn';
import en from 'element-plus/es/locale/lang/en';
// Strapi本地化映射
export const strapiLocales: Record<string, StrapiLocale> = {
zh: "zh-CN",
en: "en",
zh: 'zh-CN',
en: 'en',
};
// Element Plus本地化映射
@ -21,14 +21,14 @@ export const useLocalizations = () => {
// 获取Strapi本地化代码
const getStrapiLocale = (nuxtLocale?: string): StrapiLocale => {
const currentLocale = nuxtLocale || locale.value;
return strapiLocales[currentLocale] || "zh-Hans";
return strapiLocales[currentLocale] || 'zh-Hans';
};
// 获取Element Plus本地化
const getElementPlusLocale = (nuxtLocale?: string) => {
const currentLocale = nuxtLocale || locale.value;
const elementPlusLocale =
elementPlusLocales[currentLocale] || elementPlusLocales["zh"];
elementPlusLocales[currentLocale] || elementPlusLocales['zh'];
return elementPlusLocale;
};

View File

@ -1,5 +1,5 @@
import { MeiliSearch } from "meilisearch";
import type { SearchParams, SearchResponse } from "meilisearch";
import { MeiliSearch } from 'meilisearch';
import type { SearchParams, SearchResponse } from 'meilisearch';
interface RawSearchSection {
indexUid: string;
@ -26,7 +26,7 @@ const parseIndexes = (indexes: string | string[] | undefined): string[] => {
return indexes.map((item) => item.trim()).filter(Boolean);
}
return indexes
.split(",")
.split(',')
.map((item) => item.trim())
.filter(Boolean);
};
@ -45,7 +45,7 @@ export const useMeilisearch = () => {
const host = runtimeConfig.public?.meili?.host;
if (!host) {
console.warn("Meilisearch host is not configured.");
console.warn('Meilisearch host is not configured.');
return null;
}
const apiKey = runtimeConfig.public?.meili?.searchKey;
@ -72,7 +72,7 @@ export const useMeilisearch = () => {
const activeIndexes = indexes.value;
if (!activeIndexes.length) {
console.warn("No Meilisearch indexes configured.");
console.warn('No Meilisearch indexes configured.');
return [];
}
@ -101,14 +101,14 @@ export const useMeilisearch = () => {
settled
.filter(
(result): result is PromiseRejectedResult =>
result.status === "rejected"
result.status === 'rejected'
)
.forEach((result) => {
console.error("Meilisearch query failed", result.reason);
console.error('Meilisearch query failed', result.reason);
});
return settled
.filter((result) => result.status === "fulfilled")
.filter((result) => result.status === 'fulfilled')
.map((result) => {
const fulfilled = result as PromiseFulfilledResult<RawSearchSection>;
return {

View File

@ -3,10 +3,10 @@
<div text4xl>
<div i-ep-warning inline-block />
</div>
<div>{{ $t("not-found") }}</div>
<div>{{ $t('not-found') }}</div>
<div>
<button text-sm btn m="3 t8" @click="router.back()">
{{ $t("back") }}
{{ $t('back') }}
</button>
</div>
</main>

View File

@ -4,12 +4,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('/about')">
{{ $t("navigation.about-us") }}
{{ $t('navigation.about-us') }}
</NuxtLink>
</el-breadcrumb-item>
</el-breadcrumb>
@ -25,7 +25,7 @@
<el-icon class="icon" size="80">
<ElIconService />
</el-icon>
<br>
<br />
联系信息
</el-card>
</NuxtLink>
@ -48,19 +48,19 @@ const content = ref<string | null>(null);
onMounted(async () => {
try {
const response = await findOne<StrapiCompanyProfile>(
"company-profile",
'company-profile',
undefined,
{
locale: strapiLocale,
}
);
if (response.data) {
content.value = response.data.content || "";
content.value = response.data.content || '';
} else {
console.warn("No company profile data found");
console.warn('No company profile data found');
}
} catch (error) {
console.error("Failed to fetch company profile:", error);
console.error('Failed to fetch company profile:', error);
}
});
</script>

View File

@ -141,22 +141,22 @@ const pending = ref(true);
onMounted(async () => {
try {
const response = await findOne<StrapiHomepage>("homepage", undefined, {
const response = await findOne<StrapiHomepage>('homepage', undefined, {
populate: {
carousel: {
populate: "*",
populate: '*',
},
recommend_productions: {
populate: {
cover: {
populate: "*",
populate: '*',
},
},
},
recommend_solutions: {
populate: {
cover: {
populate: "*",
populate: '*',
},
},
},
@ -167,11 +167,11 @@ onMounted(async () => {
carouselImages.value = response.data.carousel || [];
recommend_productions.value = response.data.recommend_productions || [];
recommend_solutions.value = response.data.recommend_solutions || [];
console.log("推荐产品:", recommend_productions.value);
console.log("推荐解决方案:", recommend_solutions.value);
console.log('推荐产品:', recommend_productions.value);
console.log('推荐解决方案:', recommend_solutions.value);
}
} catch (error) {
console.error("Error fetching homepage data:", error);
console.error('Error fetching homepage data:', error);
} finally {
pending.value = false;
}

View File

@ -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>
@ -119,7 +119,7 @@ const strapiLocale = getStrapiLocale();
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);
@ -127,24 +127,24 @@ const documentId = computed(() => route.params.slug as string);
onMounted(async () => {
try {
const response = await findOne<Production>(
"productions",
'productions',
documentId.value,
{
populate: {
production_specs: {
populate: "*",
populate: '*',
},
production_images: {
populate: "*",
populate: '*',
},
cover: {
populate: "*",
populate: '*',
},
questions: {
populate: "*",
populate: '*',
},
production_documents: {
populate: "document",
populate: 'document',
},
},
locale: strapiLocale,
@ -155,10 +155,10 @@ onMounted(async () => {
production.value = {
...item,
};
console.log("Fetched production:", production.value);
console.log('Fetched production:', production.value);
}
} catch (error) {
console.error("Failed to fetch production:", error);
console.error('Failed to fetch production:', error);
} finally {
pending.value = false;
}
@ -166,11 +166,11 @@ onMounted(async () => {
// SEO
useHead({
title: computed(() => production.value?.title || "Product Detail"),
title: computed(() => production.value?.title || 'Product Detail'),
meta: [
{
name: "description",
content: computed(() => production.value?.summary || ""),
name: 'description',
content: computed(() => production.value?.summary || ''),
},
],
});

View File

@ -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>
@ -56,15 +56,15 @@ const productions = ref<Production[]>([]);
const groupedProductions = computed(() => {
const groups: Record<string, Production[]> = {};
for (const prod of productions.value) {
let typeKey = "";
if (typeof prod.production_type === "string") {
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
typeof prod.production_type === 'object' &&
'type' in prod.production_type
) {
typeKey = prod.production_type.type || "";
typeKey = prod.production_type.type || '';
}
if (!groups[typeKey]) groups[typeKey] = [];
groups[typeKey]?.push(prod);
@ -74,13 +74,13 @@ const groupedProductions = computed(() => {
onMounted(async () => {
try {
const response = await find<Production>("productions", {
const response = await find<Production>('productions', {
populate: {
cover: {
populate: "*",
populate: '*',
},
production_type: {
populate: "*",
populate: '*',
},
},
filters: {
@ -97,9 +97,9 @@ onMounted(async () => {
}));
// 默认展开所有分组
activeNames.value = Object.keys(groupedProductions.value);
activeNames.value.push("no-category"); // 展开未分类
activeNames.value.push('no-category'); // 展开未分类
} catch (error) {
console.error("Failed to fetch productions:", error);
console.error('Failed to fetch productions:', error);
}
});
</script>

View File

@ -1,7 +1,7 @@
<template>
<div class="search-page">
<div class="search-header">
<h1 class="page-title">{{ $t("search.title") }}</h1>
<h1 class="page-title">{{ $t('search.title') }}</h1>
<div class="search-bar">
<el-input
v-model="keyword"
@ -14,11 +14,11 @@
@clear="handleClear"
/>
<el-button type="primary" @click="navigateToQuery(keyword)">
{{ $t("search.search-button") }}
{{ $t('search.search-button') }}
</el-button>
</div>
<p v-if="keyword && hasResults" class="search-meta">
{{ $t("search.results-for", { query: keyword }) }}
{{ $t('search.results-for', { query: keyword }) }}
</p>
</div>
@ -35,7 +35,7 @@
<h2 class="section-title">
{{ getIndexLabel(section.indexUid) }}
<span class="section-count">{{
$t("search.result-count", { count: section.estimatedTotalHits })
$t('search.result-count', { count: section.estimatedTotalHits })
}}</span>
</h2>
</header>
@ -73,8 +73,8 @@
</template>
<script setup lang="ts">
import { Search } from "@element-plus/icons-vue";
import type { SearchHit, SearchSection } from "~/composables/useMeilisearch";
import { Search } from '@element-plus/icons-vue';
import type { SearchHit, SearchSection } from '~/composables/useMeilisearch';
const { t } = useI18n();
const route = useRoute();
@ -87,7 +87,7 @@ const strapiLocale = getStrapiLocale();
const { search } = useMeilisearch();
const loading = ref(true);
const keyword = ref("");
const keyword = ref('');
const sections = ref<SearchSection[]>([]);
const localeSections = computed(() =>
sections.value.map((section) => ({
@ -105,10 +105,10 @@ const filteredSections = computed(() =>
const activeRequestId = ref(0);
const indexLabels = computed<Record<string, string>>(() => ({
production: t("search.sections.production"),
solution: t("search.sections.solution"),
support: t("search.sections.support"),
default: t("search.sections.default"),
production: t('search.sections.production'),
solution: t('search.sections.solution'),
support: t('search.sections.support'),
default: t('search.sections.default'),
}));
const getIndexLabel = (indexUid: string) =>
@ -121,16 +121,19 @@ const hasResults = computed(() =>
const getHitIdentifier = (hit: SearchHit, index: number) => {
const candidate = [hit.objectID, hit.documentId, hit.id, hit.slug].find(
(value) =>
["string", "number"].includes(typeof value) && String(value).length > 0
['string', 'number'].includes(typeof value) && String(value).length > 0
);
return candidate != null ? String(candidate) : String(index);
};
const getHitTitle = (hit: SearchHit) => {
const candidate = [hit.title, hit.name, hit.heading, hit.documentTitle].find(
(value) => typeof value === "string" && value.trim().length > 0
);
return candidate ? String(candidate) : t("search.untitled");
const candidate = [
hit.title,
hit.name,
hit.heading,
hit.documentTitle,
].find((value) => typeof value === 'string' && value.trim().length > 0);
return candidate ? String(candidate) : t('search.untitled');
};
const getHitSummary = (hit: SearchHit) => {
@ -140,18 +143,18 @@ const getHitSummary = (hit: SearchHit) => {
hit.snippet,
hit.content,
hit.text,
].find((value) => typeof value === "string" && value.trim().length > 0);
return candidate ? String(candidate) : "";
].find((value) => typeof value === 'string' && value.trim().length > 0);
return candidate ? String(candidate) : '';
};
const resolveHitLink = (hit: SearchHit) => {
if (typeof hit.route === "string" && hit.route.trim().length > 0) {
if (typeof hit.route === 'string' && hit.route.trim().length > 0) {
return localePath(hit.route);
}
const slugCandidate = [hit.slug, hit.documentId, hit.id, hit.objectID].find(
(value) =>
["string", "number"].includes(typeof value) && String(value).length > 0
['string', 'number'].includes(typeof value) && String(value).length > 0
);
if (!slugCandidate) {
@ -160,11 +163,11 @@ const resolveHitLink = (hit: SearchHit) => {
const slug = String(slugCandidate);
if (hit.indexUid === "production") {
if (hit.indexUid === 'production') {
return localePath({ path: `/productions/${slug}` });
}
if (hit.indexUid === "solution") {
if (hit.indexUid === 'solution') {
return localePath({ path: `/solutions/${slug}` });
}
@ -175,7 +178,7 @@ const navigateToQuery = (value: string) => {
const trimmed = value.trim();
if (!trimmed) return;
navigateTo({
path: localePath("/search"),
path: localePath('/search'),
query: { query: trimmed },
});
};
@ -201,7 +204,7 @@ const performSearch = async (value: string) => {
console.log(results);
console.log(localeSections.value);
} catch (error) {
console.error("Failed to perform search", error);
console.error('Failed to perform search', error);
if (requestId === activeRequestId.value) {
sections.value = [];
}
@ -233,13 +236,13 @@ const handleInput = debounce((value: string) => {
}, 300);
const handleClear = () => {
keyword.value = "";
keyword.value = '';
sections.value = [];
router.replace(localePath({ path: "/search" }));
router.replace(localePath({ path: '/search' }));
};
onMounted(() => {
if (typeof route.query.query === "string" && route.query.query.trim()) {
if (typeof route.query.query === 'string' && route.query.query.trim()) {
keyword.value = route.query.query;
performSearch(route.query.query);
} else {
@ -248,7 +251,7 @@ onMounted(() => {
});
useHead(() => ({
title: t("search.head-title"),
title: t('search.head-title'),
}));
</script>

View File

@ -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('/solutions')">{{
$t("navigation.solutions")
$t('navigation.solutions')
}}</NuxtLink>
</el-breadcrumb-item>
<el-breadcrumb-item class="text-md opacity-50">{{
@ -52,8 +52,8 @@ const documentId = computed(() => route.params.slug as string);
onMounted(async () => {
try {
const response = await findOne<Solution>("solutions", documentId.value, {
populate: "*",
const response = await findOne<Solution>('solutions', documentId.value, {
populate: '*',
locale: strapiLocale,
});
if (response.data) {
@ -63,9 +63,9 @@ onMounted(async () => {
solution_type: response.data.solution_type,
};
}
console.log("Fetched Solution:", solution.value);
console.log('Fetched Solution:', solution.value);
} catch (error) {
console.error("Failed to fetch solution:", error);
console.error('Failed to fetch solution:', error);
}
});
</script>

View File

@ -1,16 +1,16 @@
<template>
<div class="page-container">
<div class="page-header">
<h1 class="page-title">{{ $t("learn-our-solutions") }}</h1>
<h1 class="page-title">{{ $t('learn-our-solutions') }}</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('/solutions')">{{
$t("navigation.solutions")
$t('navigation.solutions')
}}</NuxtLink>
</el-breadcrumb-item>
</el-breadcrumb>
@ -57,7 +57,7 @@ const { getStrapiLocale } = useLocalizations();
const strapiLocale = getStrapiLocale();
const activeName = ref<string>("all");
const activeName = ref<string>('all');
const solutions = ref<Solution[]>([]);
@ -65,15 +65,15 @@ const solutions = ref<Solution[]>([]);
const groupedSolutions = computed(() => {
const gourps: Record<string, Solution[]> = {};
for (const sol of solutions.value) {
let typeKey = "";
if (typeof sol.solution_type === "string") {
let typeKey = '';
if (typeof sol.solution_type === 'string') {
typeKey = sol.solution_type;
} else if (
sol.solution_type &&
typeof sol.solution_type === "object" &&
"type" in sol.solution_type
typeof sol.solution_type === 'object' &&
'type' in sol.solution_type
) {
typeKey = sol.solution_type.type || "";
typeKey = sol.solution_type.type || '';
}
if (!gourps[typeKey]) gourps[typeKey] = [];
gourps[typeKey]?.push(sol);
@ -83,13 +83,13 @@ const groupedSolutions = computed(() => {
onMounted(async () => {
try {
const response = await find<Solution>("solutions", {
const response = await find<Solution>('solutions', {
populate: {
cover: {
populate: "*",
populate: '*',
},
solution_type: {
populate: "*",
populate: '*',
},
},
locale: strapiLocale,
@ -98,10 +98,10 @@ onMounted(async () => {
...item,
solution_type: item.solution_type,
}));
console.log("Fetched Solutions:", solutions.value);
console.log("Grouped Solutions:", groupedSolutions.value);
console.log('Fetched Solutions:', solutions.value);
console.log('Grouped Solutions:', groupedSolutions.value);
} catch (error) {
console.error("Failed to fetch solutions:", error);
console.error('Failed to fetch solutions:', error);
}
});
</script>

View File

@ -3,21 +3,21 @@
<div v-if="content">
<support-tabs model-value="contact-us" />
<div class="page-header">
<h1 class="page-title">{{ $t("navigation.contact-info") }}</h1>
<h1 class="page-title">{{ $t('navigation.contact-info') }}</h1>
<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('/support')">
{{ $t("navigation.support") }}
{{ $t('navigation.support') }}
</NuxtLink>
</el-breadcrumb-item>
<el-breadcrumb-item class="text-md opacity-50">
<NuxtLink :to="$localePath('/support/contact-us')">
{{ $t("navigation.contact-info") }}
{{ $t('navigation.contact-info') }}
</NuxtLink>
</el-breadcrumb-item>
</el-breadcrumb>
@ -39,25 +39,25 @@ const { getStrapiLocale } = useLocalizations();
const strapiLocale = getStrapiLocale();
const content = ref<string>("");
const content = ref<string>('');
onMounted(async () => {
try {
const response = await findOne<StrapiContactInfo>(
"contact-info",
'contact-info',
undefined,
{
populate: "*",
populate: '*',
locale: strapiLocale,
}
);
if (response.data) {
content.value = response.data.content || "";
content.value = response.data.content || '';
} else {
console.warn("No contact info data found");
console.warn('No contact info data found');
}
} catch (error) {
console.error("Failed to fetch contact info:", error);
console.error('Failed to fetch contact info:', error);
}
});
</script>

View File

@ -6,21 +6,21 @@
<div v-else>
<support-tabs model-value="documents" />
<div class="page-header">
<h1 class="page-title">{{ $t("navigation.documents") }}</h1>
<h1 class="page-title">{{ $t('navigation.documents') }}</h1>
<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('/support')">{{
$t("navigation.support")
$t('navigation.support')
}}</NuxtLink>
</el-breadcrumb-item>
<el-breadcrumb-item class="text-md opacity-50">
<NuxtLink :to="$localePath('/support/documents')">{{
$t("navigation.documents")
$t('navigation.documents')
}}</NuxtLink>
</el-breadcrumb-item>
</el-breadcrumb>
@ -43,9 +43,9 @@ const documents = ref<StrapiMedia[]>([]);
onMounted(async () => {
try {
const response = await find<ProductionDocument>("production-documents", {
const response = await find<ProductionDocument>('production-documents', {
locale: strapiLocale,
populate: "document",
populate: 'document',
});
if (response.data) {
documents.value =
@ -54,7 +54,7 @@ onMounted(async () => {
})) || [];
}
} catch (error) {
console.error("Error fetching documents:", error);
console.error('Error fetching documents:', error);
} finally {
pending.value = false;
}

View File

@ -6,21 +6,21 @@
<div v-else>
<support-tabs model-value="faq" />
<div class="page-header">
<h1 class="page-title">{{ $t("navigation.faq") }}</h1>
<h1 class="page-title">{{ $t('navigation.faq') }}</h1>
<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('/support')">{{
$t("navigation.support")
$t('navigation.support')
}}</NuxtLink>
</el-breadcrumb-item>
<el-breadcrumb-item class="text-md opacity-50">
<NuxtLink :to="$localePath('/support/faq')">{{
$t("navigation.faq")
$t('navigation.faq')
}}</NuxtLink>
</el-breadcrumb-item>
</el-breadcrumb>
@ -43,14 +43,14 @@ const pending = ref(true);
onMounted(async () => {
try {
const faqData = await find<Question>("questions", {
const faqData = await find<Question>('questions', {
locale: strapiLocale,
});
if (faqData) {
questions.value = faqData.data || [];
}
} catch (error) {
console.error("Failed to fetch FAQ data:", error);
console.error('Failed to fetch FAQ data:', error);
} finally {
pending.value = false;
}

View File

@ -3,16 +3,16 @@
<support-tabs />
<div class="page-content">
<div class="page-header">
<h1 class="page-title">{{ $t("navigation.support") }}</h1>
<h1 class="page-title">{{ $t('navigation.support') }}</h1>
<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('/support')">{{
$t("navigation.support")
$t('navigation.support')
}}</NuxtLink>
</el-breadcrumb-item>
</el-breadcrumb>
@ -32,7 +32,7 @@
</el-col>
<el-col :span="18">
<div class="card-title">
<span>{{ $t("navigation.faq") }}</span>
<span>{{ $t('navigation.faq') }}</span>
</div>
</el-col>
</el-row>
@ -58,7 +58,7 @@
</el-col>
<el-col :span="18">
<div class="card-title">
<span>{{ $t("navigation.documents") }}</span>
<span>{{ $t('navigation.documents') }}</span>
</div>
</el-col>
</el-row>
@ -84,7 +84,7 @@
</el-col>
<el-col :span="18">
<div class="card-title">
<span>{{ $t("navigation.contact-info") }}</span>
<span>{{ $t('navigation.contact-info') }}</span>
</div>
</el-col>
</el-row>

View File

@ -1,5 +1,5 @@
export * from "./common";
export * from "./production";
export * from "./singleTypes";
export * from "./solution";
export * from "./question";
export * from './common';
export * from './production';
export * from './singleTypes';
export * from './solution';
export * from './question';

View File

@ -3,7 +3,7 @@ import type {
StrapiImage,
StrapiMedia,
StrapiRelation,
} from "./common";
} from './common';
export interface ProductionType extends StrapiEntity {
type: string;
@ -29,13 +29,13 @@ export interface Production extends StrapiEntity {
production_specs: ProductionSpecGroup[];
production_documents: StrapiRelation<
ProductionDocument,
"related_productions"
'related_productions'
>[];
questions: StrapiRelation<Question, "related_productions">[];
questions: StrapiRelation<Question, 'related_productions'>[];
show_in_production_list: boolean;
}
export interface ProductionDocument extends StrapiEntity {
document: StrapiMedia;
related_productions: StrapiRelation<Production, "production_documents">[];
related_productions: StrapiRelation<Production, 'production_documents'>[];
}

View File

@ -1,5 +1,5 @@
export interface Question extends StrapiEntity {
title: string;
content: string;
related_productions: StrapiRelation<Production, "questions">[];
related_productions: StrapiRelation<Production, 'questions'>[];
}

View File

@ -1,4 +1,4 @@
import type { StrapiEntity, StrapiImage } from "./common";
import type { StrapiEntity, StrapiImage } from './common';
export interface SolutionType extends StrapiEntity {
type: string;

View File

@ -8,5 +8,5 @@ export function formatFileSize(sizeInKB: number): string {
}
export function formatFileExtension(ext: string): string {
return ext.startsWith(".") ? ext.slice(1).toUpperCase() : ext.toUpperCase();
return ext.startsWith('.') ? ext.slice(1).toUpperCase() : ext.toUpperCase();
}

View File

@ -1,4 +1,4 @@
import MarkdownIt from "markdown-it";
import MarkdownIt from 'markdown-it';
const md = new MarkdownIt({
html: true,
@ -10,8 +10,8 @@ const md = new MarkdownIt({
export function renderMarkdown(content: string): string {
const dirtyHtml = md.render(content);
if (typeof window !== "undefined") {
import("dompurify").then((DOMPurify) => {
if (typeof window !== 'undefined') {
import('dompurify').then((DOMPurify) => {
return DOMPurify.default.sanitize(dirtyHtml);
});
}
@ -23,7 +23,7 @@ export function convertMedia(content: string): string {
// 通过正则表达式替换Markdown中的图片链接
// ![alt text](image-url) -> ![alt text](strapiMedia(image-url))
if (!content) return "";
if (!content) return '';
const contentWithAbsoluteUrls = content.replace(
/!\[([^\]]*)\]\((\/uploads\/[^)]+)\)/g,

View File

@ -1,3 +1,3 @@
export default {
extends: ['@commitlint/config-conventional']
extends: ['@commitlint/config-conventional'],
};

View File

@ -1,15 +1,18 @@
// @ts-check
import withNuxt from './.nuxt/eslint.config.mjs'
import withNuxt from './.nuxt/eslint.config.mjs';
export default withNuxt(
// Your custom configs here
{
rules: {
"vue/html-self-closing": ["warn", {
"html": {
"void": "any",
'vue/html-self-closing': [
'warn',
{
html: {
void: 'any',
},
},
],
},
}
}]
}
}
)
);

View File

@ -2,5 +2,5 @@
export default defineI18nConfig(() => ({
legacy: false,
locale: 'zh',
fallbackLocale: 'zh'
}))
fallbackLocale: 'zh',
}));

View File

@ -2,4 +2,5 @@ export default defineI18nConfig(() => ({
legacy: false,
locale: 'zh',
fallbackLocale: 'zh',
}))
}));

View File

@ -1,33 +1,33 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
compatibilityDate: "2025-07-15",
compatibilityDate: '2025-07-15',
devtools: { enabled: true },
app: {
// head
head: {
title: "金申机械制造有限公司",
title: '金申机械制造有限公司',
meta: [
{ name: "viewport", content: "width=device-width, initial-scale=1" },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{
name: "description",
content: "Jinshen Website",
name: 'description',
content: 'Jinshen Website',
},
],
link: [{ rel: "icon", type: "image/x-icon", href: "/favicon.ico" }],
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
},
},
runtimeConfig: {
public: {
meili: {
host: process.env.MEILI_HOST || "http://localhost:7700",
searchKey: process.env.MEILI_SEARCH_KEY || "",
host: process.env.MEILI_HOST || 'http://localhost:7700',
searchKey: process.env.MEILI_SEARCH_KEY || '',
indexes: process.env.MEILI_SEARCH_INDEXES
? (typeof process.env.MEILI_SEARCH_INDEXES === "string"
? process.env.MEILI_SEARCH_INDEXES.split(",").map(i => i.trim())
: process.env.MEILI_SEARCH_INDEXES)
: ["production", "solution"],
? typeof process.env.MEILI_SEARCH_INDEXES === 'string'
? process.env.MEILI_SEARCH_INDEXES.split(',').map((i) => i.trim())
: process.env.MEILI_SEARCH_INDEXES
: ['production', 'solution'],
},
},
},
@ -38,22 +38,22 @@ export default defineNuxtConfig({
// css
css: [
"@unocss/reset/tailwind.css",
"~/assets/scss/index.scss",
"~/assets/css/fonts.css",
"@mdi/font/css/materialdesignicons.min.css",
'@unocss/reset/tailwind.css',
'~/assets/scss/index.scss',
'~/assets/css/fonts.css',
'@mdi/font/css/materialdesignicons.min.css',
],
nitro: {
esbuild: {
options: {
target: "esnext",
target: 'esnext',
},
},
prerender: {
crawlLinks: false,
routes: ["/"],
ignore: ["/hi"],
routes: ['/'],
ignore: ['/hi'],
},
},
@ -73,53 +73,52 @@ export default defineNuxtConfig({
},
elementPlus: {
icon: "ElIcon",
importStyle: "scss",
themes: ["dark"],
icon: 'ElIcon',
importStyle: 'scss',
themes: ['dark'],
},
i18n: {
detectBrowserLanguage: {
useCookie: true,
cookieKey: "i18n_redirected",
redirectOn: "root",
alwaysRedirect: true
cookieKey: 'i18n_redirected',
redirectOn: 'root',
alwaysRedirect: true,
},
locales: [
{ code: "en", language: "en-US", name: "English", file: "en.json" },
{ code: "zh", language: "zh-CN", name: "简体中文", file: "zh.json" },
{ code: 'en', language: 'en-US', name: 'English', file: 'en.json' },
{ code: 'zh', language: 'zh-CN', name: '简体中文', file: 'zh.json' },
],
defaultLocale: "zh",
strategy: "prefix_except_default",
langDir: "locales",
defaultLocale: 'zh',
strategy: 'prefix_except_default',
langDir: 'locales',
},
strapi: {
url: process.env.STRAPI_URL || "http://localhost:1337",
url: process.env.STRAPI_URL || 'http://localhost:1337',
token: process.env.STRAPI_TOKEN || undefined,
prefix: "/api",
admin: "/admin",
version: "v5",
prefix: '/api',
admin: '/admin',
version: 'v5',
cookie: {},
cookieName: "strapi_jwt",
cookieName: 'strapi_jwt',
},
imports: {
dirs: ['types/**']
dirs: ['types/**'],
},
modules: [
"@nuxt/eslint",
"@nuxt/fonts",
"@nuxt/icon",
"@nuxt/image",
"@nuxt/test-utils",
"@vueuse/nuxt",
"@pinia/nuxt",
"@unocss/nuxt",
"@element-plus/nuxt",
"@nuxtjs/i18n",
"@nuxtjs/strapi",
'@nuxt/eslint',
'@nuxt/fonts',
'@nuxt/icon',
'@nuxt/image',
'@nuxt/test-utils',
'@vueuse/nuxt',
'@pinia/nuxt',
'@unocss/nuxt',
'@element-plus/nuxt',
'@nuxtjs/i18n',
'@nuxtjs/strapi',
],
});

View File

@ -14,29 +14,29 @@ export default {
// 使用单引号
singleQuote: true,
// 尾随逗号
trailingComma: "es5",
trailingComma: 'es5',
// 对象大括号内的空格
bracketSpacing: true,
// 箭头函数参数括号
arrowParens: "always",
arrowParens: 'always',
// 括号行位置
bracketSameLine: false,
// 换行符使用 lf
endOfLine: "lf",
endOfLine: 'lf',
// HTML 空格敏感度
htmlWhitespaceSensitivity: "css",
htmlWhitespaceSensitivity: 'css',
// Vue 文件脚本和样式缩进
vueIndentScriptAndStyle: true,
overrides: [
{
// 对 CSS 文件使用双引号
files: "*.css",
files: '*.css',
options: { singleQuote: false },
},
{
// 对 SCSS 文件使用双引号
files: "*.scss",
files: '*.scss',
options: { singleQuote: false },
}
},
],
};

View File

@ -7,12 +7,18 @@ import {
// presetWebFonts,
transformerDirectives,
transformerVariantGroup,
} from 'unocss'
} from 'unocss';
export default defineConfig({
shortcuts: [
['btn', 'px-4 py-1 rounded inline-block bg-teal-600 text-white cursor-pointer hover:bg-teal-700 disabled:cursor-default disabled:bg-gray-600 disabled:opacity-50'],
['icon-btn', 'inline-block cursor-pointer select-none opacity-75 transition duration-200 ease-in-out hover:opacity-100 hover:text-teal-600'],
[
'btn',
'px-4 py-1 rounded inline-block bg-teal-600 text-white cursor-pointer hover:bg-teal-700 disabled:cursor-default disabled:bg-gray-600 disabled:opacity-50',
],
[
'icon-btn',
'inline-block cursor-pointer select-none opacity-75 transition duration-200 ease-in-out hover:opacity-100 hover:text-teal-600',
],
],
presets: [
presetUno(),
@ -30,8 +36,5 @@ export default defineConfig({
// },
// }),
],
transformers: [
transformerDirectives(),
transformerVariantGroup(),
],
})
transformers: [transformerDirectives(), transformerVariantGroup()],
});