From 5bd27e9d7d93a691bf0961a245f4c95abee97737 Mon Sep 17 00:00:00 2001 From: yml2213 Date: Wed, 18 Nov 2026 18:21:14 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E5=A4=A7=E9=94=A4?= =?UTF-8?q?=E4=B8=8E=E8=A7=A3=E5=BF=A7=E9=81=A5=E5=8F=8C=E5=93=81=E7=89=8C?= =?UTF-8?q?=E5=89=8D=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 5 +++ .env.dachui | 5 +++ .env.example | 7 +++ .env.jieyouyao | 5 +++ .gitignore | 1 + Dockerfile | 4 +- README.md | 65 +++++++++++++++++++++++++++ deploy/Caddyfile.brands.example | 9 ++++ docker-compose.yml | 13 ++++++ index.html | 8 ++-- package.json | 9 ++-- public/favicon-dachui.svg | 11 +++++ public/favicon-jieyouyao.svg | 11 +++++ src/App.vue | 3 +- src/api/index.js | 11 ++--- src/components/Footer.vue | 19 ++++---- src/components/Header.vue | 13 +++--- src/components/ProductCard.vue | 4 +- src/config/brands.js | 80 +++++++++++++++++++++++++++++++++ src/main.js | 4 ++ src/router/index.js | 19 ++++---- src/styles/index.css | 11 ++--- src/views/Home.vue | 9 ++-- src/views/NewsList.vue | 3 +- src/views/Rental.vue | 3 +- tailwind.config.js | 8 ++-- 26 files changed, 284 insertions(+), 56 deletions(-) create mode 100644 .dockerignore create mode 100644 .env.dachui create mode 100644 .env.example create mode 100644 .env.jieyouyao create mode 100644 README.md create mode 100644 deploy/Caddyfile.brands.example create mode 100644 public/favicon-dachui.svg create mode 100644 public/favicon-jieyouyao.svg create mode 100644 src/config/brands.js diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..01b8e10 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +node_modules +dist +.git +.DS_Store +*.log diff --git a/.env.dachui b/.env.dachui new file mode 100644 index 0000000..b48f094 --- /dev/null +++ b/.env.dachui @@ -0,0 +1,5 @@ +VITE_BRAND=dachui +VITE_BRAND_NAME=大锤网络 +VITE_BRAND_DESCRIPTION=大锤网络数码商城,提供电脑、手机、平板及数码设备免押租赁服务。 +VITE_BRAND_THEME="#e93323" +VITE_BRAND_FAVICON=./favicon-dachui.svg diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..4f3d3a5 --- /dev/null +++ b/.env.example @@ -0,0 +1,7 @@ +VITE_BRAND=dachui +VITE_BRAND_NAME=大锤网络 +VITE_BRAND_DESCRIPTION=大锤网络数码商城,提供电脑、手机、平板及数码设备免押租赁服务。 +VITE_BRAND_THEME="#e93323" +VITE_BRAND_FAVICON=./favicon-dachui.svg +VITE_BASE=/ +VITE_API_URL=/api diff --git a/.env.jieyouyao b/.env.jieyouyao new file mode 100644 index 0000000..d732c91 --- /dev/null +++ b/.env.jieyouyao @@ -0,0 +1,5 @@ +VITE_BRAND=jieyouyao +VITE_BRAND_NAME=解忧遥网络 +VITE_BRAND_DESCRIPTION=解忧遥网络数码商城,提供电脑、手机、平板及数码设备免押租赁服务。 +VITE_BRAND_THEME="#0f766e" +VITE_BRAND_FAVICON=./favicon-jieyouyao.svg diff --git a/.gitignore b/.gitignore index 80c77a8..e6eaf5b 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ dist-ssr .vscode/* !.vscode/extensions.json .idea +.openidea *.suo *.ntvs* *.njsproj diff --git a/Dockerfile b/Dockerfile index 0a86d91..86a4ba5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,9 +7,11 @@ COPY package*.json ./ RUN npm install COPY . . +ARG VITE_BRAND=dachui +ENV VITE_BRAND=$VITE_BRAND ENV OUT_DIR=dist ENV VITE_BASE=/ -RUN npm run build +RUN ./node_modules/.bin/vite build --mode "$VITE_BRAND" --outDir dist # Production Stage FROM nginx:alpine diff --git a/README.md b/README.md new file mode 100644 index 0000000..6697235 --- /dev/null +++ b/README.md @@ -0,0 +1,65 @@ +# 多品牌数码商城前端 + +一套 Vue 3 + Vite 代码维护多个商城品牌,当前包含: + +- `dachui`:大锤网络 +- `jieyouyao`:解忧遥网络 + +页面、组件、状态管理和接口逻辑全部共享,品牌名称、Logo、文案和主题色通过构建环境切换。 + +## 本地开发 + +```bash +npm ci +npm run dev +``` + +开发解忧遥品牌: + +```bash +npm run dev:jieyouyao +``` + +默认开发地址为 `http://localhost:3000`。 + +## 分别构建 + +```bash +npm run build:dachui +npm run build:jieyouyao +``` + +产物分别位于: + +- `dist/dachui/` +- `dist/jieyouyao/` + +不指定品牌时,`npm run build` 默认构建大锤网络到 `dist/`。 + +## Docker + +```bash +docker compose up -d --build +``` + +两个站点使用同一份源代码和 Dockerfile,仅构建参数不同: + +- 大锤网络:宿主机 `8090` +- 解忧遥网络:宿主机 `8091` + +域名入口模板见 `deploy/Caddyfile.brands.example`。 + +## 品牌配置 + +品牌定义位于 `src/config/brands.js`。新增品牌时: + +1. 在 `brands.js` 增加品牌配置。 +2. 增加对应 `.env.`。 +3. 在 `package.json` 增加开发与构建脚本。 +4. 在 `docker-compose.yml` 增加独立前端服务端口。 + +## 发布前确认 + +- 解忧遥网络正式域名为 `mall.hao857.com`。 +- 如使用真实后端,需要配置 `VITE_API_URL` 和网关 `/api` 反向代理。 +- 当前订单、购物车和登录仍包含演示 mock 回退,正式交易前应关闭生产环境回退。 diff --git a/deploy/Caddyfile.brands.example b/deploy/Caddyfile.brands.example new file mode 100644 index 0000000..85b88c0 --- /dev/null +++ b/deploy/Caddyfile.brands.example @@ -0,0 +1,9 @@ +mail.khhao.com, mall.khhao.com { + encode gzip zstd + reverse_proxy 172.17.0.1:8090 +} + +mall.hao857.com { + encode gzip zstd + reverse_proxy 172.17.0.1:8091 +} diff --git a/docker-compose.yml b/docker-compose.yml index d232efe..0b12f78 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,20 @@ services: build: context: . dockerfile: Dockerfile + args: + VITE_BRAND: dachui container_name: dachui_pc_web restart: always ports: - "8090:80" + + jieyouyao-pc: + build: + context: . + dockerfile: Dockerfile + args: + VITE_BRAND: jieyouyao + container_name: jieyouyao_mall_web + restart: always + ports: + - "8091:80" diff --git a/index.html b/index.html index fd22082..b39e327 100644 --- a/index.html +++ b/index.html @@ -2,14 +2,16 @@ - + - 大锤网络 - 官方旗舰商城 & 数码设备免押租赁 + + + %VITE_BRAND_NAME% - 官方旗舰商城 & 数码设备免押租赁 - +
diff --git a/package.json b/package.json index 70d6b8b..04cc579 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,12 @@ "private": true, "type": "module", "scripts": { - "dev": "vite", - "build": "vite build", - "preview": "vite preview" + "dev": "vite --mode dachui", + "dev:jieyouyao": "vite --mode jieyouyao", + "build": "vite build --mode dachui", + "build:dachui": "vite build --mode dachui --outDir dist/dachui", + "build:jieyouyao": "vite build --mode jieyouyao --outDir dist/jieyouyao", + "preview": "vite preview --mode dachui" }, "dependencies": { "@element-plus/icons-vue": "^2.3.1", diff --git a/public/favicon-dachui.svg b/public/favicon-dachui.svg new file mode 100644 index 0000000..e5e841a --- /dev/null +++ b/public/favicon-dachui.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/public/favicon-jieyouyao.svg b/public/favicon-jieyouyao.svg new file mode 100644 index 0000000..00d786e --- /dev/null +++ b/public/favicon-jieyouyao.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/App.vue b/src/App.vue index 81aa755..d82ca22 100644 --- a/src/App.vue +++ b/src/App.vue @@ -45,7 +45,7 @@

官方在线客服

9:00 - 21:00 在线

- 客服工作台 + 客服工作台
@@ -73,6 +73,7 @@ import MobileBottomNav from '@/components/MobileBottomNav.vue' import AuthModal from '@/components/AuthModal.vue' import { useUserStore } from '@/store/user' import { useCartStore } from '@/store/cart' +import { brand } from '@/config/brands' const userStore = useUserStore() const cartStore = useCartStore() diff --git a/src/api/index.js b/src/api/index.js index 9d37021..994e636 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -1,4 +1,5 @@ import request from './request' +import { brand } from '@/config/brands' import { mockCategories, mockBanners, @@ -39,13 +40,13 @@ export const getRecommendList = (type) => })) export const getSiteConfig = () => - safeCall(() => request.get('/site_config'), { site_name: '大锤网络 官方旗舰商城', version: '6.0.0' }) + safeCall(() => request.get('/site_config'), { site_name: `${brand.name} 官方旗舰商城`, version: '6.0.0' }) export const getHotSearch = () => safeCall(() => request.get('/search/keyword'), ['租电脑', '租iPhone', '租iPad', 'MacBook Pro', '智能手表']) export const getCompanyInfo = () => - safeCall(() => request.get('/pc/get_company_info'), { company_name: '大锤网络 智能数码租赁与商城', tel: '400-888-9999' }) + safeCall(() => request.get('/pc/get_company_info'), { company_name: brand.companyDescription, tel: brand.customerServicePhone }) export const getWechatQrcode = () => safeCall(() => request.get('/pc/get_wechat_qrcode'), { code: '' }) @@ -251,18 +252,18 @@ export const getNewsCategory = () => export const getNewsList = (params) => safeCall(() => request.get('/pc/get_news_list', { params }), { list: [ - { id: 1, title: '关于 大锤网络 开启全国免押数码设备租赁业务的通知', synopsis: '支持芝麻信用免押金快速起租,包含苹果MacBook、旗舰手机及平板...', add_time: '2026-08-19' }, + { id: 1, title: `关于 ${brand.name} 开启全国免押数码设备租赁业务的通知`, synopsis: '支持芝麻信用免押金快速起租,包含苹果MacBook、旗舰手机及平板...', add_time: '2026-08-19' }, { id: 2, title: '数码设备长租与买断方案深度解读:怎样租最划算?', synopsis: '全品类数码设备租满 12 个月即可 0 元买断...', add_time: '2026-08-18' } ] }) export const getNewsDetail = (id) => safeCall(() => request.get(`/pc/get_news_detail/${id}`), { - title: '关于 大锤网络 开启全国免押数码设备租赁业务的通知', + title: `关于 ${brand.name} 开启全国免押数码设备租赁业务的通知`, add_time: '2026-08-19', visit: 1280, content: ` -

为满足广大企业客户与个人用户的短期体验、办公扩容及活动会展需求,大锤网络 商城即日起全面开启全品类数码设备信用免押租赁服务!

+

为满足广大企业客户与个人用户的短期体验、办公扩容及活动会展需求,${brand.name} 商城即日起全面开启全品类数码设备信用免押租赁服务!

业务核心亮点:

-
关于 大锤网络
+
关于 {{ brand.name }}
-
大锤客服热线
-

400-888-9999

+
{{ brand.customerServiceTitle }}
+

{{ brand.customerServicePhone }}

周一至周日 9:00 - 21:00

@@ -75,7 +75,7 @@ class="w-16 h-16 rounded-full mx-auto object-cover border-2 border-red-100 shadow-sm" />

- {{ userStore.token ? (userStore.userInfo?.nickname || userStore.userInfo?.account || '尊贵会员') : 'Hi,欢迎来到 大锤网络' }} + {{ userStore.token ? (userStore.userInfo?.nickname || userStore.userInfo?.account || '尊贵会员') : `Hi,欢迎来到 ${brand.name}` }}

正品大牌 · 全场包邮 · 售后无忧

@@ -140,7 +140,7 @@
-

{{ item.name || '大锤网络 · 爆款数码狂欢' }}

+

{{ item.name || `${brand.name} · 爆款数码狂欢` }}

@@ -353,6 +353,7 @@ import { useRouter } from 'vue-router' import { useUserStore } from '@/store/user' import { useCartStore } from '@/store/cart' import ProductCard from '@/components/ProductCard.vue' +import { brand } from '@/config/brands' import { getBanner, getCategory, @@ -424,7 +425,7 @@ const categoryFloors = ref([ { id: 2, cate_name: '📱 智能手机 / 旗舰数码', productList: mockProducts.slice(2, 6) } ]) const newsList = ref([ - { id: 1, title: '关于 大锤网络 开启全国免押数码设备租赁业务的通知' }, + { id: 1, title: `关于 ${brand.name} 开启全国免押数码设备租赁业务的通知` }, { id: 2, title: '数码设备长租与买断方案深度解读:怎样租最划算?' } ]) diff --git a/src/views/NewsList.vue b/src/views/NewsList.vue index 167330e..fdfd240 100644 --- a/src/views/NewsList.vue +++ b/src/views/NewsList.vue @@ -42,12 +42,13 @@ import { ref, onMounted } from 'vue' import { useRouter } from 'vue-router' import { getNewsList } from '@/api' +import { brand } from '@/config/brands' const router = useRouter() const list = ref([ { id: 1, - title: '关于 大锤网络 开启全国免押数码设备租赁业务的通知', + title: `关于 ${brand.name} 开启全国免押数码设备租赁业务的通知`, synopsis: '支持芝麻信用免押金快速起租,包含苹果MacBook、旗舰手机及平板...', add_time: '2026-08-19' }, diff --git a/src/views/Rental.vue b/src/views/Rental.vue index db3255f..8e3120b 100644 --- a/src/views/Rental.vue +++ b/src/views/Rental.vue @@ -253,6 +253,7 @@ import { ref, computed } from 'vue' import { useRouter } from 'vue-router' import { useUserStore } from '@/store/user' import { ElMessage } from 'element-plus' +import { brand } from '@/config/brands' const router = useRouter() const userStore = useUserStore() @@ -406,7 +407,7 @@ const openRentalModal = (item) => { } const openConsult = () => { - ElMessage.success('企业客服专线已接通:400-888-9999,请联系在线客服了解企业批量免押授信方案') + ElMessage.success(`企业客服专线已接通:${brand.customerServicePhone},请联系在线客服了解企业批量免押授信方案`) } const submitRental = () => { diff --git a/tailwind.config.js b/tailwind.config.js index 856a8b0..9812898 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -8,10 +8,10 @@ export default { extend: { colors: { primary: { - DEFAULT: '#e93323', - hover: '#d82819', - light: '#fdebe9', - dark: '#b71d10' + DEFAULT: 'rgb(var(--brand-primary-rgb) / )', + hover: 'rgb(var(--brand-primary-hover-rgb) / )', + light: 'rgb(var(--brand-primary-light-rgb) / )', + dark: 'rgb(var(--brand-primary-dark-rgb) / )' }, secondary: { DEFAULT: '#ff7700',