From 5374afb22603df7f16e18767a819308cd4b24c3e Mon Sep 17 00:00:00 2001
From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com>
Date: Fri, 11 Oct 2024 14:41:05 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=8D=8E=E4=B8=BA?=
 =?UTF-8?q?=E4=BA=91=E7=94=B3=E8=AF=B7=E8=AF=81=E4=B9=A6=20(#6687)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Refs https://github.com/1Panel-dev/1Panel/issues/6047
---
 frontend/src/global/mimetype.ts               |  4 +++
 frontend/src/lang/modules/en.ts               |  1 +
 frontend/src/lang/modules/tw.ts               |  1 +
 frontend/src/lang/modules/zh.ts               |  1 +
 .../website/ssl/dns-account/create/index.vue  | 26 +++++++++++++++----
 5 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/frontend/src/global/mimetype.ts b/frontend/src/global/mimetype.ts
index 11a9615f1..ed342e4df 100644
--- a/frontend/src/global/mimetype.ts
+++ b/frontend/src/global/mimetype.ts
@@ -164,6 +164,10 @@ export const DNSTypes = [
         label: i18n.global.t('website.tencentCloud'),
         value: 'TencentCloud',
     },
+    {
+        label: i18n.global.t('website.huaweicloud'),
+        value: 'HuaweiCloud',
+    },
     {
         label: 'DNSPod (' + i18n.global.t('ssl.deprecated') + ')',
         value: 'DnsPod',
diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts
index f29884fa8..c49578dd8 100644
--- a/frontend/src/lang/modules/en.ts
+++ b/frontend/src/lang/modules/en.ts
@@ -2138,6 +2138,7 @@ const message = {
         sni: 'Origin SNI',
         sniHelper:
             "When the reverse proxy backend is HTTPS, you might need to set the origin SNI. Please refer to the CDN service provider's documentation for details.",
+        huaweicloud: 'Huawei Cloud',
     },
     php: {
         short_open_tag: 'Short tag support',
diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts
index 87823a4b5..61849797c 100644
--- a/frontend/src/lang/modules/tw.ts
+++ b/frontend/src/lang/modules/tw.ts
@@ -1987,6 +1987,7 @@ const message = {
         website404Helper: '網站 404 錯誤頁僅支援 PHP 運行環境網站和靜態網站',
         sni: '回源 SNI',
         sniHelper: '反代後端為 https 的時候可能需要設置回源 SNI,具體需要看 CDN 服務商文檔',
+        huaweicloud: '華為雲',
     },
     php: {
         short_open_tag: '短標簽支持',
diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts
index 1e6463db3..aa40b9b54 100644
--- a/frontend/src/lang/modules/zh.ts
+++ b/frontend/src/lang/modules/zh.ts
@@ -1989,6 +1989,7 @@ const message = {
         website404Helper: '网站 404 错误页仅支持 PHP 运行环境网站和静态网站',
         sni: '回源 SNI',
         sniHelper: '反代后端为 https 的时候可能需要设置回源 SNI,具体需要看 CDN 服务商文档',
+        huaweicloud: '华为云',
     },
     php: {
         short_open_tag: '短标签支持',
diff --git a/frontend/src/views/website/ssl/dns-account/create/index.vue b/frontend/src/views/website/ssl/dns-account/create/index.vue
index a64b9be3b..9511cd295 100644
--- a/frontend/src/views/website/ssl/dns-account/create/index.vue
+++ b/frontend/src/views/website/ssl/dns-account/create/index.vue
@@ -14,7 +14,11 @@
                         <el-input v-model.trim="account.name"></el-input>
                     </el-form-item>
                     <el-form-item :label="$t('commons.table.type')" prop="type">
-                        <el-select v-model="account.type" :disabled="accountData.mode === 'edit'">
+                        <el-select
+                            v-model="account.type"
+                            :disabled="accountData.mode === 'edit'"
+                            @change="changeType(account.type)"
+                        >
                             <el-option
                                 v-for="(type, index) in DNSTypes"
                                 :key="index"
@@ -25,8 +29,11 @@
                         <span class="input-help text-red-500" v-if="account.type === 'DnsPod'">
                             {{ $t('ssl.deprecatedHelper') }}
                         </span>
+                        <span class="input-help text-red-500" v-if="account.type === 'CloudFlare'">
+                            {{ $t('ssl.cfHelper') }}
+                        </span>
                     </el-form-item>
-                    <div v-if="account.type === 'AliYun'">
+                    <div v-if="account.type === 'AliYun' || account.type === 'HuaweiCloud'">
                         <el-form-item label="Access Key" prop="authorization.accessKey">
                             <el-input v-model.trim="account.authorization['accessKey']"></el-input>
                         </el-form-item>
@@ -34,6 +41,9 @@
                             <el-input v-model.trim="account.authorization['secretKey']"></el-input>
                         </el-form-item>
                     </div>
+                    <el-form-item label="Region" prop="authorization.region" v-if="account.type === 'HuaweiCloud'">
+                        <el-input v-model.trim="account.authorization['region']" :placeholder="'cn-north-1'"></el-input>
+                    </el-form-item>
                     <div v-if="account.type === 'TencentCloud'">
                         <el-form-item label="Secret ID" prop="authorization.secretID">
                             <el-input v-model.trim="account.authorization['secretID']"></el-input>
@@ -57,9 +67,6 @@
                         </el-form-item>
                         <el-form-item label="API Token" prop="authorization.apiKey">
                             <el-input v-model.trim="account.authorization['apiKey']"></el-input>
-                            <span class="input-help text-red-500">
-                                {{ $t('ssl.cfHelper') }}
-                            </span>
                         </el-form-item>
                     </div>
                     <el-form-item
@@ -130,6 +137,7 @@ const rules = ref<any>({
         apiKey: [Rules.requiredInput],
         apiUser: [Rules.requiredInput],
         secretID: [Rules.requiredInput],
+        region: [Rules.requiredInput],
     },
 });
 const account = ref({
@@ -156,6 +164,14 @@ const resetForm = () => {
     accountForm.value?.resetFields();
 };
 
+const changeType = (type: string) => {
+    account.value.type = type;
+    account.value.authorization = {};
+    if (account.value.type == 'HuaweiCloud') {
+        account.value.authorization['region'] = 'cn-north-1';
+    }
+};
+
 const acceptParams = async (props: AccountProps) => {
     accountData.value.mode = props.mode;
     if (props.mode === 'edit') {