mirror of
https://github.com/jeessy2/ddns-go.git
synced 2025-12-20 01:00:12 +08:00
feat: add Team ID support for Vercel DNS configuration (#1586)
* feat: add Team ID support for Vercel DNS configuration This update introduces a new optional `TeamId` field in the DNS configuration, allowing users to specify their Vercel Team ID. The Team ID is included in API requests when applicable. Additionally, the UI has been updated to show the Team ID input field only when the Vercel DNS provider is selected, along with relevant help text for users. Changes include: - Added `TeamId` field to DNS struct in config.go. - Updated Vercel API request handling to include Team ID. - Modified frontend to conditionally display Team ID input based on selected DNS provider. - Added localization support for Team ID help text. * refactor: rename TeamId to ExtParam for Vercel DNS configuration This update renames the `TeamId` field to `ExtParam` in the DNS configuration to better reflect its purpose as an extension parameter for various DNS providers. The changes include updates to the API request handling, frontend input fields, and localization support to accommodate this new naming convention. Changes include: - Renamed `TeamId` to `ExtParam` in the DNS struct and related files. - Updated Vercel API request logic to use `ExtParam`. - Modified frontend to display the new `ExtParam` input field with appropriate labels and help text. - Adjusted localization keys for the updated parameter. --------- Co-authored-by: welkin <xwmbxx@gmail.com>
This commit is contained in:
@@ -55,6 +55,8 @@ type DNS struct {
|
||||
Name string
|
||||
ID string
|
||||
Secret string
|
||||
// ExtParam 扩展参数,用于某些DNS提供商的特殊需求(如Vercel的teamId)
|
||||
ExtParam string
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
|
||||
@@ -150,6 +150,15 @@ func (v *Vercel) request(method, api string, data, result interface{}) (err erro
|
||||
payload, _ = json.Marshal(data)
|
||||
}
|
||||
|
||||
// 如果设置了 ExtParam (TeamId),添加查询参数
|
||||
if v.DNS.ExtParam != "" {
|
||||
if strings.Contains(api, "?") {
|
||||
api = api + "&teamId=" + v.DNS.ExtParam
|
||||
} else {
|
||||
api = api + "?teamId=" + v.DNS.ExtParam
|
||||
}
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(
|
||||
method,
|
||||
api,
|
||||
|
||||
@@ -98,8 +98,8 @@ const DNS_PROVIDERS = {
|
||||
idLabel: "Key",
|
||||
secretLabel: "Secret",
|
||||
helpHtml: {
|
||||
"en": "<a target='_blank' href='https://developer.godaddy.com/keys'>Create API KEY</a>",
|
||||
"zh-cn": "<a target='_blank' href='https://developer.godaddy.com/keys'>创建 API KEY</a>",
|
||||
"en": "<a target='_blank' href='https://developer.godaddy.com/keys'>Create API KEY</a><br/><span style='color: #ff9800;'>⚠️ Note: GoDaddy API requires you to have 10 or more domains or a Pro plan</span>",
|
||||
"zh-cn": "<a target='_blank' href='https://developer.godaddy.com/keys'>创建 API KEY</a><br/><span style='color: #ff9800;'>⚠️ 温馨提示:GoDaddy 现在需要拥有 10 个及以上的域名或 Pro Plan 才可以使用 API</span>",
|
||||
}
|
||||
},
|
||||
namecheap: {
|
||||
@@ -133,6 +133,11 @@ const DNS_PROVIDERS = {
|
||||
helpHtml: {
|
||||
"en": "<a target='_blank' href='https://vercel.com/account/tokens'>Create Token</a>",
|
||||
"zh-cn": "<a target='_blank' href='https://vercel.com/account/tokens'>创建令牌</a>",
|
||||
},
|
||||
extParamLabel: "Team ID",
|
||||
extParamHelpHtml: {
|
||||
"en": "Optional. If you are using a Vercel Team account, please fill in the Team ID",
|
||||
"zh-cn": "可选项,如果您使用的是 Vercel 团队账户,请填写团队 ID"
|
||||
}
|
||||
},
|
||||
dynadot: {
|
||||
|
||||
@@ -234,6 +234,10 @@ const I18N_MAP = {
|
||||
'en': 'Switch between light and dark themes',
|
||||
'zh-cn': '切换明暗主题'
|
||||
},
|
||||
"extParamHelp": {
|
||||
'en': 'Optional. If you are using a Vercel Team account, please fill in the Team ID',
|
||||
'zh-cn': '可选项,如果您使用的是 Vercel 团队账户,请填写团队 ID'
|
||||
},
|
||||
};
|
||||
|
||||
const LANG = localStorage.getItem('lang') || (navigator.language || navigator.browserLanguage).replaceAll('_', '-').toLowerCase();
|
||||
|
||||
@@ -81,6 +81,7 @@ func checkAndSave(request *http.Request) string {
|
||||
dnsConf.DNS.Name = v.DnsName
|
||||
dnsConf.DNS.ID = strings.TrimSpace(v.DnsID)
|
||||
dnsConf.DNS.Secret = strings.TrimSpace(v.DnsSecret)
|
||||
dnsConf.DNS.ExtParam = strings.TrimSpace(v.DnsExtParam)
|
||||
|
||||
if v.Ipv4Domains == "" && v.Ipv6Domains == "" {
|
||||
util.Log("第 %s 个配置未填写域名", util.Ordinal(k+1, conf.Lang))
|
||||
|
||||
@@ -23,6 +23,7 @@ type dnsConf4JS struct {
|
||||
DnsName string
|
||||
DnsID string
|
||||
DnsSecret string
|
||||
DnsExtParam string
|
||||
TTL string
|
||||
Ipv4Enable bool
|
||||
Ipv4GetType string
|
||||
@@ -89,6 +90,7 @@ func getDnsConfStr(dnsConf []config.DnsConfig) string {
|
||||
DnsName: conf.DNS.Name,
|
||||
DnsID: idHide,
|
||||
DnsSecret: secretHide,
|
||||
DnsExtParam: conf.DNS.ExtParam,
|
||||
TTL: conf.TTL,
|
||||
Ipv4Enable: conf.Ipv4.Enable,
|
||||
Ipv4GetType: conf.Ipv4.GetType,
|
||||
|
||||
@@ -158,6 +158,28 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row" id="DnsExtParamRow" style="display: none;">
|
||||
<label
|
||||
for="DnsExtParam"
|
||||
id="dnsExtParamLabel"
|
||||
class="col-sm-2 col-form-label"
|
||||
>Team ID</label
|
||||
>
|
||||
<div class="col-sm-10">
|
||||
<input
|
||||
class="form-control form"
|
||||
name="DnsExtParam"
|
||||
id="DnsExtParam"
|
||||
placeholder="team_xxxxxx (可选)"
|
||||
/>
|
||||
<small class="form-text text-muted">
|
||||
<span id="dnsExtParamHelp" data-i18n-html="extParamHelp">
|
||||
可选项,如果您使用的是 Vercel 团队账户,请填写团队 ID
|
||||
</span>
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-2 col-form-label">TTL</label>
|
||||
<div class="col-sm-10">
|
||||
@@ -740,6 +762,7 @@
|
||||
DnsID: "",
|
||||
DnsName: "alidns",
|
||||
DnsSecret: "",
|
||||
DnsExtParam: "",
|
||||
Ipv4Cmd: "",
|
||||
Ipv4Domains: "",
|
||||
Ipv4Enable: true,
|
||||
@@ -789,12 +812,23 @@
|
||||
$input.addEventListener('click', e => {
|
||||
const dnsInfo = DNS_PROVIDERS[e.target.value];
|
||||
const $dnsID = document.getElementById("DnsID");
|
||||
const $dnsExtParamRow = document.getElementById("DnsExtParamRow");
|
||||
const $dnsExtParamLabel = document.getElementById("dnsExtParamLabel");
|
||||
const $dnsExtParamHelp = document.getElementById("dnsExtParamHelp");
|
||||
// idLabel 为空时隐藏 DnsID
|
||||
if (dnsInfo.idLabel) {
|
||||
$dnsID.style.display = "block";
|
||||
} else {
|
||||
$dnsID.style.display = "none";
|
||||
}
|
||||
// 根据DNS提供商显示扩展参数
|
||||
if (dnsInfo.extParamLabel) {
|
||||
$dnsExtParamRow.style.display = "";
|
||||
$dnsExtParamLabel.innerHTML = dnsInfo.extParamLabel;
|
||||
$dnsExtParamHelp.innerHTML = i18n(dnsInfo.extParamHelpHtml);
|
||||
} else {
|
||||
$dnsExtParamRow.style.display = "none";
|
||||
}
|
||||
document.getElementById("dnsIdLabel").innerHTML = dnsInfo.idLabel;
|
||||
document.getElementById("dnsSecretLabel").innerHTML = dnsInfo.secretLabel;
|
||||
document.getElementById("dnsHelp").innerHTML = i18n(dnsInfo.helpHtml);
|
||||
@@ -895,6 +929,18 @@
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 根据 DNS 提供商显示或隐藏扩展参数输入框
|
||||
const $dnsExtParamRow = document.getElementById("DnsExtParamRow");
|
||||
const $dnsExtParamLabel = document.getElementById("dnsExtParamLabel");
|
||||
const $dnsExtParamHelp = document.getElementById("dnsExtParamHelp");
|
||||
const dnsInfo = DNS_PROVIDERS[conf.DnsName];
|
||||
if (dnsInfo && dnsInfo.extParamLabel) {
|
||||
$dnsExtParamRow.style.display = "";
|
||||
$dnsExtParamLabel.innerHTML = dnsInfo.extParamLabel;
|
||||
$dnsExtParamHelp.innerHTML = i18n(dnsInfo.extParamHelpHtml);
|
||||
} else {
|
||||
$dnsExtParamRow.style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
// 从json中重新加载配置
|
||||
|
||||
Reference in New Issue
Block a user