diff --git a/api/core/types/oss.go b/api/core/types/oss.go index 9bc93b41..434d0ddd 100644 --- a/api/core/types/oss.go +++ b/api/core/types/oss.go @@ -8,41 +8,41 @@ package types // * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ type OSSConfig struct { - Active string - Local LocalStorageConfig - Minio MiniOssConfig - QiNiu QiNiuOssConfig - AliYun AliYunOssConfig + Active string `json:"active"` + Local LocalStorageConfig `json:"local"` + Minio MiniOssConfig `json:"minio"` + QiNiu QiNiuOssConfig `json:"qiniu"` + AliYun AliYunOssConfig `json:"aliyun"` } + type MiniOssConfig struct { - Endpoint string - AccessKey string - AccessSecret string - Bucket string - SubDir string - UseSSL bool - Domain string + Endpoint string `json:"endpoint"` + AccessKey string `json:"access_key"` + AccessSecret string `json:"access_secret"` + Bucket string `json:"bucket"` + SubDir string `json:"sub_dir"` + UseSSL bool `json:"use_ssl"` + Domain string `json:"domain"` } type QiNiuOssConfig struct { - Zone string - AccessKey string - AccessSecret string - Bucket string - SubDir string - Domain string + Zone string `json:"zone"` + AccessKey string `json:"access_key"` + AccessSecret string `json:"access_secret"` + Bucket string `json:"bucket"` + SubDir string `json:"sub_dir"` + Domain string `json:"domain"` } type AliYunOssConfig struct { - Endpoint string - AccessKey string - AccessSecret string - Bucket string - SubDir string - Domain string + Endpoint string `json:"endpoint"` + AccessKey string `json:"access_key"` + AccessSecret string `json:"access_secret"` + Bucket string `json:"bucket"` + Domain string `json:"domain"` } type LocalStorageConfig struct { - BasePath string - BaseURL string + BasePath string `json:"base_path"` + BaseURL string `json:"base_url"` } diff --git a/api/core/types/sms.go b/api/core/types/sms.go index 3db10668..4d9c6504 100644 --- a/api/core/types/sms.go +++ b/api/core/types/sms.go @@ -15,16 +15,16 @@ type SMSConfig struct { // SmsConfigAli 阿里云短信平台配置 type SmsConfigAli struct { - AccessKey string - AccessSecret string - Sign string // 短信签名 - CodeTempId string // 验证码短信模板 ID + AccessKey string `json:"access_key"` + AccessSecret string `json:"access_secret"` + Sign string `json:"sign"` // 短信签名 + CodeTempId string `json:"code_temp_id"` // 验证码短信模板 ID } // SmsConfigBao 短信宝平台配置 type SmsConfigBao struct { - Username string //短信宝平台注册的用户名 - Password string //短信宝平台注册的密码 - Sign string // 短信签名 - CodeTemplate string // 验证码短信模板 匹配 + Username string `json:"username"` //短信宝平台注册的用户名 + Password string `json:"password"` //短信宝平台注册的密码 + Sign string `json:"sign"` // 短信签名 + CodeTemplate string `json:"code_template"` // 验证码短信模板 匹配 } diff --git a/api/service/oss/aliyun_oss.go b/api/service/oss/aliyun_oss.go index 827c85d3..20ff31b8 100644 --- a/api/service/oss/aliyun_oss.go +++ b/api/service/oss/aliyun_oss.go @@ -70,7 +70,7 @@ func (s AliYunOss) PutFile(ctx *gin.Context, name string) (File, error) { defer src.Close() fileExt := filepath.Ext(file.Filename) - objectKey := fmt.Sprintf("%s/%d%s", s.config.SubDir, time.Now().UnixMicro(), fileExt) + objectKey := fmt.Sprintf("%d%s", time.Now().UnixMicro(), fileExt) // 上传文件 err = s.bucket.PutObject(objectKey, src) if err != nil { @@ -104,7 +104,7 @@ func (s AliYunOss) PutUrlFile(fileURL string, ext string, useProxy bool) (string if ext == "" { ext = filepath.Ext(parse.Path) } - objectKey := fmt.Sprintf("%s/%d%s", s.config.SubDir, time.Now().UnixMicro(), ext) + objectKey := fmt.Sprintf("%d%s", time.Now().UnixMicro(), ext) // 上传文件字节数据 err = s.bucket.PutObject(objectKey, bytes.NewReader(fileData)) if err != nil { @@ -118,7 +118,7 @@ func (s AliYunOss) PutBase64(base64Img string) (string, error) { if err != nil { return "", fmt.Errorf("error decoding base64:%v", err) } - objectKey := fmt.Sprintf("%s/%d.png", s.config.SubDir, time.Now().UnixMicro()) + objectKey := fmt.Sprintf("%d.png", time.Now().UnixMicro()) // 上传文件字节数据 err = s.bucket.PutObject(objectKey, bytes.NewReader(imageData)) if err != nil { @@ -130,8 +130,7 @@ func (s AliYunOss) PutBase64(base64Img string) (string, error) { func (s AliYunOss) Delete(fileURL string) error { var objectKey string if strings.HasPrefix(fileURL, "http") { - filename := filepath.Base(fileURL) - objectKey = fmt.Sprintf("%s/%s", s.config.SubDir, filename) + objectKey = filepath.Base(fileURL) } else { objectKey = fileURL } diff --git a/web/src/views/admin/settings/BasicConfig.vue b/web/src/views/admin/settings/BasicConfig.vue index 14191239..5ebaf6c0 100644 --- a/web/src/views/admin/settings/BasicConfig.vue +++ b/web/src/views/admin/settings/BasicConfig.vue @@ -323,13 +323,24 @@ const uploadImg = (file) => { } - diff --git a/web/src/views/admin/settings/PaymentConfig.vue b/web/src/views/admin/settings/PaymentConfig.vue index ab69ec12..660576c7 100644 --- a/web/src/views/admin/settings/PaymentConfig.vue +++ b/web/src/views/admin/settings/PaymentConfig.vue @@ -1,5 +1,5 @@ - + @@ -17,7 +17,7 @@ >。 - + - + 支付回调域名 @@ -43,65 +41,75 @@ - - 保存 - 测试 - - - - + + + + 微信支付 + + + + + 如果你不知道怎么获取这些配置信息,请参考文档: + 微信支付配置。 + + + + - - + - 保存 - 测试 + + 回调域名 + + + + + + - - + + + + 易支付 + + + + 如果你不知道怎么获取这些配置信息,请参考文档: + 易支付配置。 + + + - + - - 保存 - 测试 - - - - - - - - - - - - - 保存 - 测试 - + + + 提交保存 + @@ -159,23 +167,26 @@ onMounted(() => { }) const save = () => { + loading.value = true const payload = { alipay: alipay.value, wxpay: wxpay.value, epay: epay.value } httpPost('/api/admin/config/update/payment', payload) .then(() => ElMessage.success('保存成功')) .catch((e) => ElMessage.error(e.message)) + .finally(() => (loading.value = false)) } - diff --git a/web/src/views/admin/settings/StorageConfig.vue b/web/src/views/admin/settings/StorageConfig.vue index ecd31e13..e3ccffa4 100644 --- a/web/src/views/admin/settings/StorageConfig.vue +++ b/web/src/views/admin/settings/StorageConfig.vue @@ -1,65 +1,102 @@ - - - - - - - - - - - - - - - + + + + + + 文件存储根目录 + + + 可以是绝对路径,如:/data/static/upload也可以是相对路径,如:./static/upload + + + + + + + + 文件访问根 URL + + + 可以是绝对路径,如:https://oss.geekai.me/static/upload + 也可以是相对路径,如:/static/upload + + + + + + - + - - - - + + + 如果你不知道怎么获取这些配置信息,请参考文档: + Minio 配置。 + + + + - - - + + + - + - - - - + + + + - - + + - + - - - - + + + + - - - + + - + + - - 保存 - 连接测试 - - + + 存储引擎 + + 本地存储 + 阿里云 + 七牛云 + Minio + + + + + 提交保存 + 连接测试 + @@ -69,44 +106,45 @@ import { ElMessage } from 'element-plus' import { onMounted, ref } from 'vue' const loading = ref(true) +const activeTab = ref('local') const active = ref('local') -const local = ref({ BasePath: '', BaseURL: '' }) +const local = ref({ base_path: '', base_url: '' }) const minio = ref({ - Endpoint: '', - AccessKey: '', - AccessSecret: '', - Bucket: '', - SubDir: '', - UseSSL: false, - Domain: '', + endpoint: '', + access_key: '', + access_secret: '', + bucket: '', + use_ssl: false, + domain: '', }) const qiniu = ref({ - Zone: 'z2', - AccessKey: '', - AccessSecret: '', - Bucket: '', - SubDir: '', - Domain: '', + zone: 'z2', + access_key: '', + access_secret: '', + bucket: '', + domain: '', }) const aliyun = ref({ - Endpoint: '', - AccessKey: '', - AccessSecret: '', - Bucket: '', - SubDir: '', - Domain: '', + endpoint: '', + access_key: '', + access_secret: '', + bucket: '', + domain: '', }) onMounted(() => { httpGet('/api/admin/config/get?key=oss') .then((res) => { const data = res.data || {} - const Active = data.Active || data.active || 'local' - active.value = String(Active).toLowerCase() - local.value = data.Local || data.local || local.value - minio.value = data.Minio || data.minio || minio.value - qiniu.value = data.QiNiu || data.qiniu || qiniu.value - aliyun.value = data.AliYun || data.aliyun || aliyun.value + active.value = data.active.toLowerCase() || active.value + local.value = data.local || local.value + minio.value = data.minio || minio.value + qiniu.value = data.qiniu || qiniu.value + aliyun.value = data.aliyun || aliyun.value + + minio.value.bucket = minio.value.bucket || 'geekai' + qiniu.value.bucket = qiniu.value.bucket || 'geekai' + aliyun.value.bucket = aliyun.value.bucket || 'geekai' }) .catch(() => {}) .finally(() => (loading.value = false)) @@ -129,8 +167,10 @@ const test = () => { } -