Compare commits

...

2 Commits

Author SHA1 Message Date
kk 6534723050 修改授权回调配置
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 1m25s
2026-07-02 19:04:08 +08:00
kk f031501286 显示处理public目录下的静态文件
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 44s
2026-07-02 18:36:30 +08:00
4 changed files with 32 additions and 8 deletions
+2 -2
View File
@@ -8,8 +8,8 @@ const dev = {
// 网关地址(vms-gateway,端口 4001)— 用户授权、短信等接口走网关 // 网关地址(vms-gateway,端口 4001)— 用户授权、短信等接口走网关
apiGatewayUrl: 'https://gateway.arklinksmart.cn', apiGatewayUrl: 'https://gateway.arklinksmart.cn',
// 授权回调地址(支付宝/微信 OAuth redirect_uri // 授权回调地址(微信 OAuth redirect_uri,必须 HTTPS,指向前端页面
authRedirectUri: 'https://gateway.arklinksmart.cn/api/v1/user/auth/callback', authRedirectUri: 'https://m.arklinksmart.cn/pages/auth/loading',
// 开发阶段硬编码 Token(生产环境应从登录流程获取) // 开发阶段硬编码 Token(生产环境应从登录流程获取)
bearerToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImRlZXB2ZW5kaW5nIiwic3ViIjoiMTY0MDI0MTEyNiIsImZyb20iOiJwb3MiLCJyb2xlIjoicG9zIiwibWFpbmJvYXJkX2lkIjoiVDEwMDIiLCJwb3Nfc24iOiIxNjQwMjQxMTI2IiwiaWF0IjoxNzc4NDkxOTA3LCJleHAiOjE3NzkwOTY3MDd9.DjscZtrTCr30XOngToUifxoel4q2EGES_uqGQernkvg', bearerToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImRlZXB2ZW5kaW5nIiwic3ViIjoiMTY0MDI0MTEyNiIsImZyb20iOiJwb3MiLCJyb2xlIjoicG9zIiwibWFpbmJvYXJkX2lkIjoiVDEwMDIiLCJwb3Nfc24iOiIxNjQwMjQxMTI2IiwiaWF0IjoxNzc4NDkxOTA3LCJleHAiOjE3NzkwOTY3MDd9.DjscZtrTCr30XOngToUifxoel4q2EGES_uqGQernkvg',
+2 -2
View File
@@ -8,8 +8,8 @@ const prod = {
// 网关地址(vms-gateway)— 用户授权、短信等接口走网关 // 网关地址(vms-gateway)— 用户授权、短信等接口走网关
apiGatewayUrl: 'https://gateway.arklinksmart.cn', apiGatewayUrl: 'https://gateway.arklinksmart.cn',
// 授权回调地址(支付宝/微信 OAuth redirect_uri // 授权回调地址(微信 OAuth redirect_uri,必须 HTTPS,指向前端页面
authRedirectUri: 'https://gateway.arklinksmart.cn/api/v1/user/auth/callback', authRedirectUri: 'https://m.arklinksmart.cn/pages/auth/loading',
// 生产环境 Token 从登录流程获取,此处为空 // 生产环境 Token 从登录流程获取,此处为空
bearerToken: '', bearerToken: '',
+3 -3
View File
@@ -56,9 +56,9 @@ export default {
try { try {
this.statusText = '正在获取授权...'; this.statusText = '正在获取授权...';
// 构建回调地址(当前页面地址 // 回调地址必须是 HTTPS,使用配置文件中的地址
const redirectUri = encodeURIComponent( const redirectUri = config.authRedirectUri || (
window.location.origin + window.location.pathname window.location.origin.replace(/^http:/, 'https:') + window.location.pathname
); );
const res = await gatewayGet('/api/v1/user/auth/url', { const res = await gatewayGet('/api/v1/user/auth/url', {
+25 -1
View File
@@ -1,8 +1,31 @@
import { defineConfig } from 'vite' import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni' import uni from '@dcloudio/vite-plugin-uni'
import { existsSync, readFileSync } from 'fs'
import { resolve } from 'path'
// 开发服务器:显式处理 public 目录下的静态文件,避免被 SPA history 路由拦截
function servePublicFiles() {
return {
name: 'serve-public-files',
configureServer(server) {
server.middlewares.use((req, res, next) => {
if (req.url) {
const filePath = resolve(__dirname, 'public', req.url.slice(1))
if (existsSync(filePath) && filePath.endsWith('.txt')) {
const content = readFileSync(filePath, 'utf-8')
res.setHeader('Content-Type', 'text/plain; charset=utf-8')
res.end(content)
return
}
}
next()
})
},
}
}
export default defineConfig({ export default defineConfig({
plugins: [uni()], plugins: [servePublicFiles(), uni()],
css: { css: {
preprocessorOptions: { preprocessorOptions: {
scss: { scss: {
@@ -10,4 +33,5 @@ export default defineConfig({
}, },
}, },
}, },
publicDir: 'public',
}) })