From dba2cdf3661588e6284ba7e4489e3e7f5a8e6119 Mon Sep 17 00:00:00 2001 From: R2m1liA <15258427350@163.com> Date: Tue, 16 Sep 2025 16:02:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 使用meilisearch进行搜索 - 增添搜索界面 --- app/components/JinshenHeader.vue | 25 +- app/composables/useMeilisearch.ts | 128 +++++++++++ app/pages/search.vue | 365 ++++++++++++++++++++++++++++++ i18n/locales/en.json | 16 ++ i18n/locales/zh.json | 16 ++ nuxt.config.ts | 14 ++ 6 files changed, 550 insertions(+), 14 deletions(-) create mode 100644 app/composables/useMeilisearch.ts create mode 100644 app/pages/search.vue diff --git a/app/components/JinshenHeader.vue b/app/components/JinshenHeader.vue index a5fdfe3..e7021ce 100644 --- a/app/components/JinshenHeader.vue +++ b/app/components/JinshenHeader.vue @@ -63,9 +63,9 @@ + + diff --git a/i18n/locales/en.json b/i18n/locales/en.json index 8a6730d..728272a 100644 --- a/i18n/locales/en.json +++ b/i18n/locales/en.json @@ -2,6 +2,22 @@ "back": "Back", "not-found": "Page Not Found", "search-placeholder": "Search...", + "search": { + "title": "Search", + "head-title": "Search", + "search-button": "Search", + "results-for": "Results for \"{query}\"", + "result-count": "{count} results", + "no-results": "No results found for \"{query}\".", + "no-query": "Enter a keyword to start searching.", + "untitled": "Untitled", + "sections": { + "production": "Products", + "solution": "Solutions", + "support": "Support", + "default": "Other" + } + }, "company-name": "Jinshen Machinary Manufacturing Co., Ltd.", "company-description": "We specialize in manufacturing a range of paper tube and can equipment, integrating design, manufacturing, sales, and service.", "learn-more": "Learn More", diff --git a/i18n/locales/zh.json b/i18n/locales/zh.json index 9690a74..21ae75f 100644 --- a/i18n/locales/zh.json +++ b/i18n/locales/zh.json @@ -2,6 +2,22 @@ "back": "返回", "not-found": "页面不存在", "search-placeholder": "搜索...", + "search": { + "title": "站内搜索", + "head-title": "搜索", + "search-button": "搜索", + "results-for": "“{query}” 的搜索结果", + "result-count": "共 {count} 条结果", + "no-results": "没有找到与 “{query}” 匹配的内容。", + "no-query": "请输入关键字开始搜索。", + "untitled": "未命名条目", + "sections": { + "production": "产品", + "solution": "解决方案", + "support": "服务支持", + "default": "其他内容" + } + }, "company-name": "金申机械制造有限公司", "company-description": "专业生产一系列纸管、纸罐设备,集设计、制造、销售、服务于一体。", "learn-more": "了解更多", diff --git a/nuxt.config.ts b/nuxt.config.ts index d737468..5b14344 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -18,6 +18,20 @@ export default defineNuxtConfig({ }, }, + runtimeConfig: { + public: { + meili: { + 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"], + }, + }, + }, + fonts: { provider: 'local', },