From 5efeb4cb896bd471b8ff2df2890d0708138a2b86 Mon Sep 17 00:00:00 2001 From: tangxinyue <524779910@qq.com> Date: Wed, 29 Jul 2026 16:15:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E6=96=87=E7=AB=A0=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 + package-lock.json | 12 + package.json | 3 +- service/core/router/index.cjs | 43 +- src/api/authService.js | 7 + src/api/wechat.js | 48 ++ src/components/ToolCard.vue | 6 +- src/components/common/AppHeader.vue | 27 +- src/components/simulator/SimulatorLayout.vue | 6 +- src/proxy.cjs | 4 +- src/public/article/empty.png | Bin 0 -> 2461 bytes src/views/Profile.vue | 8 + src/views/article/detail.vue | 326 ++++++------- src/views/article/list.vue | 456 ++++++++++++++++--- src/views/index/index.vue | 121 ++++- src/views/other/gongzidan.vue | 9 +- src/views/wxPage/BalanceEdit.vue | 15 +- src/views/wxPage/ChatEdit.vue | 23 +- vite.config.js | 59 ++- 19 files changed, 904 insertions(+), 271 deletions(-) create mode 100644 src/api/wechat.js create mode 100644 src/public/article/empty.png diff --git a/index.html b/index.html index fe1675f..5abb4a1 100644 --- a/index.html +++ b/index.html @@ -5,6 +5,8 @@ 装样大师 + + diff --git a/package-lock.json b/package-lock.json index e65b54c..334766c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "express": "^5.2.1", "html2canvas": "^1.4.1", "http-proxy": "^1.18.1", + "marked": "^18.0.7", "mime": "^4.1.0", "nprogress": "^0.2.0", "pinia": "^2.1.7", @@ -2621,6 +2622,17 @@ "@jridgewell/sourcemap-codec": "^1.5.5" } }, + "node_modules/marked": { + "version": "18.0.7", + "resolved": "https://registry.npmjs.org/marked/-/marked-18.0.7.tgz", + "integrity": "sha512-iDVQ5ldaiKXn6b2JroX5kgRfmwgqolW7NpaEzTl1k/2Zh1njIEN9yniyLV/mOvWwtsE8OGgkjsCYvijuPk1dtA==", + "bin": { + "marked": "bin/marked.js" + }, + "engines": { + "node": ">= 20" + } + }, "node_modules/math-intrinsics": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", diff --git a/package.json b/package.json index e92b2f9..fd66848 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "start": "node --stack-size=12800 --stack-trace-limit=20 ./service/main.cjs" }, "dependencies": { - "@batiao/batiao-sdk-vue-vite": "^1.0.357", + "@batiao/batiao-sdk-vue-vite": "^1.0.386", "@element-plus/icons-vue": "^2.3.1", "axios": "^1.6.8", "body-parser": "^2.3.0", @@ -20,6 +20,7 @@ "express": "^5.2.1", "html2canvas": "^1.4.1", "http-proxy": "^1.18.1", + "marked": "^18.0.7", "mime": "^4.1.0", "nprogress": "^0.2.0", "pinia": "^2.1.7", diff --git a/service/core/router/index.cjs b/service/core/router/index.cjs index 12a614a..b453faa 100644 --- a/service/core/router/index.cjs +++ b/service/core/router/index.cjs @@ -3,6 +3,8 @@ const routes = require('./routes.cjs') const httpProxy = require('http-proxy') const proxy = httpProxy.createProxyServer({}) const fs = require('fs') +const url = require('url') +const axios = require('axios') const dist = 'dist' let mime import('mime').then((res) => { @@ -105,11 +107,46 @@ const matchFile = async (request, response) => { } const endIndex = async (request, response) => { - console.log(dist + '/index.html') - fs.readFile(dist + '/index.html', (err, html) => { + fs.readFile(dist + '/index.html', 'utf-8', async (err, html) => { if (!err) { + let finalHtml = html + try { + const parsedUrl = url.parse(request.url, true) + if (parsedUrl.pathname === '/article-detail' && parsedUrl.query.id) { + const id = parsedUrl.query.id + const res = await axios.get(`http://wechat.wenyitu.com/api/articles/${id}`) + const article = res.data + if (article) { + if (article.title) { + finalHtml = finalHtml.replace(/.*?<\/title>/, `<title>${article.title} - 装样大师`) + } + if (article.seo_keywords) { + finalHtml = finalHtml.replace(/ 0 && data.items[0].category) { + const category = data.items[0].category + if (category.seo_keywords) { + finalHtml = finalHtml.replace(/ { + // 微信接口如果需要特定的 token,可以在这里统一携带 + // 例如:config.headers['X-Token'] = '...' + return config +}) + +// 响应拦截器 +wechatHttp.interceptors.response.use( + res => { + // 假设 Apifox 显示返回直接是数据数组,不包装在 data 字段内, + // 则 axios 会自动将其放在 res.data 下。 + // 如果实际外层还有 code, msg 字段,请在这里根据实际情况判断拦截。 + return res.data + }, + err => { + if (!err.config?._silent) { + const msg = err.response?.data?.message || err.message || '微信接口请求失败' + ElMessage.error(msg) + } + return Promise.reject(err) + } +) + +// 导出具体的接口调用方法 +export const wechatApi = { + // 获取首页 banner 图 + getBanners: () => wechatHttp.get('/api/public/banners'), + // 获取文章分类 + getArticlesCategories: () => wechatHttp.get('/api/articles/categories'), + // 获取文章列表 + getArticlesList: (params) => wechatHttp.get('/api/articles', { params }), + // 获取文章详情 + getArticleDetail: (id) => wechatHttp.get(`/api/articles/${id}`), + // 获取相关推荐文章 + getRelatedArticles: (id) => wechatHttp.get(`/api/articles/${id}/related`), +} + +export default wechatApi diff --git a/src/components/ToolCard.vue b/src/components/ToolCard.vue index e670b0e..2032e75 100644 --- a/src/components/ToolCard.vue +++ b/src/components/ToolCard.vue @@ -1,5 +1,5 @@