fix: 修复assets态 目录误

This commit is contained in:
imeepos 2025-09-28 14:40:54 +08:00
parent a468dc7dd3
commit e5d782fefe
7 changed files with 21 additions and 29 deletions

2
.env Normal file
View File

@ -0,0 +1,2 @@
cr_66a953f41a9953ef83565ccc7e5014a864ba407f9a4aaa5702206c09c24fa49a
http://cc.openllm.chat/api

View File

@ -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) => {

View File

@ -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') {
// 本地开发构建配置(不混淆压缩)

View File

@ -3,6 +3,7 @@ import type { UserConfigExport } from '@tarojs/cli';
export default {
mini: {},
h5: {
staticDirectory: 'assets',
// 确保产物为 es5
legacy: true,
},

View File

@ -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",

View File

@ -21,7 +21,6 @@ function App({ children }: PropsWithChildren<any>) {
}
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<any>) {
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)
}

View File

@ -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;