From e5d782fefe03e681c7bf32d94eb82695edf72f45 Mon Sep 17 00:00:00 2001 From: imeepos Date: Sun, 28 Sep 2025 14:40:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dassets=E6=80=81=20?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 2 ++ config/dev.ts | 2 +- config/index.ts | 11 ++++++++--- config/prod.ts | 1 + package.json | 18 +++++++----------- src/app.tsx | 12 ------------ src/platforms/h5/payment.ts | 4 ++-- 7 files changed, 21 insertions(+), 29 deletions(-) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 0000000..fd09ad4 --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +cr_66a953f41a9953ef83565ccc7e5014a864ba407f9a4aaa5702206c09c24fa49a +http://cc.openllm.chat/api \ No newline at end of file diff --git a/config/dev.ts b/config/dev.ts index 1bacad5..ecfee3a 100644 --- a/config/dev.ts +++ b/config/dev.ts @@ -17,7 +17,7 @@ export default { proxy.on('error', (err, _req, _res) => { console.log('proxy error', err); }); - proxy.on('proxyReq', (proxyReq, req, _res) => { + proxy.on('proxyReq', (_proxyReq, req, _res) => { console.log('Sending Request to the Target:', req.method, req.url); }); proxy.on('proxyRes', (proxyRes, req, _res) => { diff --git a/config/index.ts b/config/index.ts index cdbbc53..cdf9416 100644 --- a/config/index.ts +++ b/config/index.ts @@ -99,8 +99,10 @@ export default defineConfig<'vite'>(async merge => { }, h5: { publicPath: '/', - staticDirectory: 'static', - + staticDirectory: 'assets', + router: { + mode: 'browser' + }, miniCssExtractPluginOption: { ignoreOrder: true, filename: 'css/[name].[hash].css', @@ -130,7 +132,10 @@ export default defineConfig<'vite'>(async merge => { }, }; - process.env.BROWSERSLIST_ENV = process.env.NODE_ENV; + // Set browserslist environment for legacy plugin + if (process.env.TARO_ENV === 'h5') { + process.env.BROWSERSLIST_ENV = process.env.NODE_ENV === 'production' ? 'production' : 'default'; + } if (process.env.NODE_ENV === 'development') { // 本地开发构建配置(不混淆压缩) diff --git a/config/prod.ts b/config/prod.ts index 1b8e569..f0c3766 100644 --- a/config/prod.ts +++ b/config/prod.ts @@ -3,6 +3,7 @@ import type { UserConfigExport } from '@tarojs/cli'; export default { mini: {}, h5: { + staticDirectory: 'assets', // 确保产物为 es5 legacy: true, }, diff --git a/package.json b/package.json index b06c5e8..53b9400 100644 --- a/package.json +++ b/package.json @@ -38,17 +38,13 @@ "dev:jd": "npm run build:jd -- --watch", "dev:harmony-hybrid": "npm run build:harmony-hybrid -- --watch" }, - "browserslist": { - "development": [ - "defaults and fully supports es6-module", - "maintained node versions" - ], - "production": [ - "last 3 versions", - "Android >= 4.1", - "ios >= 8" - ] - }, + "browserslist": [ + "last 3 versions", + "Android >= 4.1", + "ios >= 8", + "> 1%", + "not dead" + ], "author": "", "dependencies": { "@babel/runtime": "^7.24.4", diff --git a/src/app.tsx b/src/app.tsx index 9859727..7079f3f 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -21,7 +21,6 @@ function App({ children }: PropsWithChildren) { } const authorize = createPlatformFactory().createAuthorize() - const payment = createPlatformFactory().createPayment() try { // 检查登录状态,包括OAuth 2.0回调处理 const isLoggedIn = await authorize.checkLogin() @@ -30,17 +29,6 @@ function App({ children }: PropsWithChildren) { await authorize.login() return; } - // 检查是否是支付跳转页面 - const paymentResult = await payment.checkPaymentResult() - if (paymentResult && paymentResult.paymentId && paymentResult.templateCode) { - console.log({ paymentResult }) - Taro.navigateTo({ - url: `/pages/result/index?payment_id=${paymentResult.paymentId}`, - }); - } else { - const result = await payment.pay(`character_figurine_v1`, `http://gips2.baidu.com/it/u=1674525583,3037683813&fm=3028&app=3028&f=JPEG&fmt=auto?w=1024&h=1024`) - console.log({ result }) - } } catch (error) { console.error('登录检查失败:', error) } diff --git a/src/platforms/h5/payment.ts b/src/platforms/h5/payment.ts index 48294e6..d72e77f 100644 --- a/src/platforms/h5/payment.ts +++ b/src/platforms/h5/payment.ts @@ -3,12 +3,12 @@ import { Payment } from "../types/payment"; export class H5Payment extends Payment { async pay(templateCode: string, imageUrl: string) { const sdk = useServerSdk() - const { hostname, protocol, port, hash } = window.location; + const { hostname, protocol, port } = window.location; let baseUrl = `${protocol}//${hostname}` if (hostname === 'localhost') { baseUrl = `${protocol}//${hostname}:${port}` } - const response = await sdk.payTemplateCode(templateCode, imageUrl, `${baseUrl}#/${hash}`) + const response = await sdk.payTemplateCode(templateCode, imageUrl, `${baseUrl}/pages/result/index`) if (response.url) { window.location.href = response.url; return;