fix: 合并冲突

This commit is contained in:
zheng020 2026-06-03 23:44:33 +08:00
parent 6ff8743c72
commit bc3d82e20e
2 changed files with 17 additions and 47 deletions

View File

@ -1012,22 +1012,6 @@ func (ctrl *AssetController) generateOSSPolicyToken(
uploadDir = fmt.Sprintf("%s%d/%d/", baseDir, userID, starID) uploadDir = fmt.Sprintf("%s%d/%d/", baseDir, userID, starID)
} }
<<<<<<< HEAD
utcTime := time.Now().UTC()
date := utcTime.Format("20060102")
expiration := utcTime.Add(time.Duration(ossConfig.TokenExpireTime) * time.Second)
baseDir := ossConfig.GetUploadDir(uploadType)
uploadDir := baseDir
if userID != nil && starID != nil {
uploadDir = fmt.Sprintf("%s%d/%d/", baseDir, userID, starID)
}
var accessKeyID, accessKeySecret, securityToken string
useSTS := false
// 尝试 STS AssumeRole失败则降级到永久 AccessKey 直连
=======
// 头像上传:后端生成唯一 key避免 // 头像上传:后端生成唯一 key避免
// 1) URL 字符串相同导致 webview/CDN 命中老图缓存 // 1) URL 字符串相同导致 webview/CDN 命中老图缓存
// 2) 并发上传时两路相互覆盖 // 2) 并发上传时两路相互覆盖
@ -1057,8 +1041,22 @@ func (ctrl *AssetController) generateOSSPolicyTokenWithKey(
ossConfig config.OSSConfig, ossConfig config.OSSConfig,
uploadKey string, uploadKey string,
) (map[string]interface{}, error) { ) (map[string]interface{}, error) {
utcTime := time.Now().UTC()
date := utcTime.Format("20060102")
expiration := utcTime.Add(time.Duration(ossConfig.TokenExpireTime) * time.Second)
baseDir := ossConfig.GetUploadDir(uploadType)
uploadDir := baseDir
if userID != nil && starID != nil {
uploadDir = fmt.Sprintf("%s%d/%d/", baseDir, userID, starID)
}
var accessKeyID, accessKeySecret, securityToken string
useSTS := false
// 尝试 STS AssumeRole失败则降级到永久 AccessKey 直连
// 1. 创建 STS 凭证提供器 // 1. 创建 STS 凭证提供器
>>>>>>> 0284bd6951fafc8a3862644ede979dc44eb6efe8
credConfig := new(credentials.Config). credConfig := new(credentials.Config).
SetType("ram_role_arn"). SetType("ram_role_arn").
SetAccessKeyId(ossConfig.AccessKeyID). SetAccessKeyId(ossConfig.AccessKeyID).
@ -1081,11 +1079,11 @@ func (ctrl *AssetController) generateOSSPolicyTokenWithKey(
logger.Logger.Warn("STS credential provider failed, falling back to direct AK/SK", zap.Error(err)) logger.Logger.Warn("STS credential provider failed, falling back to direct AK/SK", zap.Error(err))
} }
<<<<<<< HEAD
if !useSTS { if !useSTS {
accessKeyID = ossConfig.AccessKeyID accessKeyID = ossConfig.AccessKeyID
accessKeySecret = ossConfig.AccessKeySecret accessKeySecret = ossConfig.AccessKeySecret
======= }
// 2. 获取临时凭证 // 2. 获取临时凭证
cred, err := provider.GetCredential() cred, err := provider.GetCredential()
if err != nil { if err != nil {
@ -1107,7 +1105,6 @@ func (ctrl *AssetController) generateOSSPolicyTokenWithKey(
*cred.AccessKeyId, date, ossConfig.Region, "oss")}, *cred.AccessKeyId, date, ossConfig.Region, "oss")},
map[string]string{"x-oss-date": utcTime.Format("20060102T150405Z")}, map[string]string{"x-oss-date": utcTime.Format("20060102T150405Z")},
map[string]string{"x-oss-security-token": *cred.SecurityToken}, map[string]string{"x-oss-security-token": *cred.SecurityToken},
>>>>>>> 0284bd6951fafc8a3862644ede979dc44eb6efe8
} }
policyMap := map[string]interface{}{ policyMap := map[string]interface{}{

View File

@ -9,15 +9,12 @@ const LASER_BASE = 'http://localhost:8081' // 镭射 AI 生成 + compositor 走
const PROD_BASE = 'http://101.132.250.62:8080' // 生产环境 const PROD_BASE = 'http://101.132.250.62:8080' // 生产环境
const HEALTH_URL = DEV_BASE + '/health' const HEALTH_URL = DEV_BASE + '/health'
<<<<<<< HEAD
// 默认生产H5 本地开发先走 DEV避免 health 探测完成前请求打到生产(生产暂无 /segment // 默认生产H5 本地开发先走 DEV避免 health 探测完成前请求打到生产(生产暂无 /segment
=======
// 是否使用模拟数据(开发调试时设为 true后端API准备好后改为 false // 是否使用模拟数据(开发调试时设为 true后端API准备好后改为 false
const USE_MOCK_API = true const USE_MOCK_API = true
// 环境检测状态0=检测中, 1=开发环境, 2=生产环境 // 环境检测状态0=检测中, 1=开发环境, 2=生产环境
let envStatus = 0 let envStatus = 0
>>>>>>> 0284bd6951fafc8a3862644ede979dc44eb6efe8
let baseURL = PROD_BASE let baseURL = PROD_BASE
// #ifdef H5 // #ifdef H5
if (import.meta.env.DEV) { if (import.meta.env.DEV) {
@ -26,29 +23,6 @@ if (import.meta.env.DEV) {
} }
// #endif // #endif
<<<<<<< HEAD
// 启动时探测开发环境是否可用(异步,不阻塞后续逻辑)
uni.request({
url: HEALTH_URL,
method: 'GET',
timeout: 2000,
success: (res) => {
if (res.statusCode === 200) {
baseURL = DEV_BASE
console.log('[API] 使用开发环境地址:', DEV_BASE)
}
},
fail: () => {
// #ifdef H5
if (import.meta.env.DEV) {
console.warn('[API] 开发 Gateway 不可达:', DEV_BASE, '— 请确认团队开发机在线,或改 DEV_BASE 为本机 8081')
return
}
// #endif
baseURL = PROD_BASE
console.log('[API] 开发环境不可用,使用生产环境地址:', PROD_BASE)
}
=======
// 环境检测 Promise确保 getApiBaseUrl / getWebSocketBaseUrl 等待检测完成 // 环境检测 Promise确保 getApiBaseUrl / getWebSocketBaseUrl 等待检测完成
const envReadyPromise = new Promise((resolve) => { const envReadyPromise = new Promise((resolve) => {
uni.request({ uni.request({
@ -72,7 +46,6 @@ const envReadyPromise = new Promise((resolve) => {
resolve(envStatus) resolve(envStatus)
} }
}) })
>>>>>>> 0284bd6951fafc8a3862644ede979dc44eb6efe8
}) })
/** 等待环境检测完成(返回 'dev' | 'prod' */ /** 等待环境检测完成(返回 'dev' | 'prod' */