fix: 合并冲突
This commit is contained in:
parent
6ff8743c72
commit
bc3d82e20e
@ -1012,22 +1012,6 @@ func (ctrl *AssetController) generateOSSPolicyToken(
|
||||
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,避免
|
||||
// 1) URL 字符串相同导致 webview/CDN 命中老图缓存
|
||||
// 2) 并发上传时两路相互覆盖
|
||||
@ -1057,8 +1041,22 @@ func (ctrl *AssetController) generateOSSPolicyTokenWithKey(
|
||||
ossConfig config.OSSConfig,
|
||||
uploadKey string,
|
||||
) (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 凭证提供器
|
||||
>>>>>>> 0284bd6951fafc8a3862644ede979dc44eb6efe8
|
||||
credConfig := new(credentials.Config).
|
||||
SetType("ram_role_arn").
|
||||
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))
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
|
||||
if !useSTS {
|
||||
accessKeyID = ossConfig.AccessKeyID
|
||||
accessKeySecret = ossConfig.AccessKeySecret
|
||||
=======
|
||||
}
|
||||
// 2. 获取临时凭证
|
||||
cred, err := provider.GetCredential()
|
||||
if err != nil {
|
||||
@ -1107,7 +1105,6 @@ func (ctrl *AssetController) generateOSSPolicyTokenWithKey(
|
||||
*cred.AccessKeyId, date, ossConfig.Region, "oss")},
|
||||
map[string]string{"x-oss-date": utcTime.Format("20060102T150405Z")},
|
||||
map[string]string{"x-oss-security-token": *cred.SecurityToken},
|
||||
>>>>>>> 0284bd6951fafc8a3862644ede979dc44eb6efe8
|
||||
}
|
||||
|
||||
policyMap := map[string]interface{}{
|
||||
|
||||
@ -9,15 +9,12 @@ const LASER_BASE = 'http://localhost:8081' // 镭射 AI 生成 + compositor 走
|
||||
const PROD_BASE = 'http://101.132.250.62:8080' // 生产环境
|
||||
const HEALTH_URL = DEV_BASE + '/health'
|
||||
|
||||
<<<<<<< HEAD
|
||||
// 默认生产;H5 本地开发先走 DEV,避免 health 探测完成前请求打到生产(生产暂无 /segment)
|
||||
=======
|
||||
// 是否使用模拟数据(开发调试时设为 true,后端API准备好后改为 false)
|
||||
const USE_MOCK_API = true
|
||||
|
||||
// 环境检测状态:0=检测中, 1=开发环境, 2=生产环境
|
||||
let envStatus = 0
|
||||
>>>>>>> 0284bd6951fafc8a3862644ede979dc44eb6efe8
|
||||
let baseURL = PROD_BASE
|
||||
// #ifdef H5
|
||||
if (import.meta.env.DEV) {
|
||||
@ -26,29 +23,6 @@ if (import.meta.env.DEV) {
|
||||
}
|
||||
// #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 等待检测完成
|
||||
const envReadyPromise = new Promise((resolve) => {
|
||||
uni.request({
|
||||
@ -72,7 +46,6 @@ const envReadyPromise = new Promise((resolve) => {
|
||||
resolve(envStatus)
|
||||
}
|
||||
})
|
||||
>>>>>>> 0284bd6951fafc8a3862644ede979dc44eb6efe8
|
||||
})
|
||||
|
||||
/** 等待环境检测完成(返回 'dev' | 'prod') */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user