Skip to content

Commit

Permalink
feat: 实时测试正则表达式 (#1368)
Browse files Browse the repository at this point in the history
* refactor: i18n-related code

Update i18n.js

* feat: add tooltips component

* feat: add i18n-attr function

* chore: unify the HTML dataset naming style

* style: add some tooltips

Also for testing tooltips function

* feat: real-time testing of ipv6 regular expressions
  • Loading branch information
PairZhu authored Jan 14, 2025
1 parent 147b9c5 commit c68080b
Show file tree
Hide file tree
Showing 5 changed files with 592 additions and 187 deletions.
16 changes: 16 additions & 0 deletions static/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,19 @@ main {
text-decoration: none;
outline: none;
}

.tooltip[x-placement^="top"] .arrow, .tooltip[x-placement^="bottom"] .arrow {
left: 50%;
}

.tooltip[x-placement^="left"] .arrow, .tooltip[x-placement^="right"] .arrow {
top: 50%;
}

.tooltip[x-placement^="top"] .arrow::before, .tooltip[x-placement^="bottom"] .arrow::before {
transform: translateX(-50%);
}

.tooltip[x-placement^="left"] .arrow::before, .tooltip[x-placement^="right"] .arrow::before {
transform: translateY(-50%);
}
136 changes: 0 additions & 136 deletions static/constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,139 +166,3 @@ const SVG_CODE = {
warning: '<svg viewBox="64 64 896 896" focusable="false" data-icon="exclamation-circle" width="1em" height="1em" fill="#faad14" aria-hidden="true"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm-32 232c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V296zm32 440a48.01 48.01 0 010-96 48.01 48.01 0 010 96z"></path></svg>',
error: '<svg viewBox="64 64 896 896" focusable="false" data-icon="close-circle" width="1em" height="1em" fill="#ff4d4f" aria-hidden="true"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm165.4 618.2l-66-.3L512 563.4l-99.3 118.4-66.1.3c-4.4 0-8-3.5-8-8 0-1.9.7-3.7 1.9-5.2l130.1-155L340.5 359a8.32 8.32 0 01-1.9-5.2c0-4.4 3.6-8 8-8l66.1.3L512 464.6l99.3-118.4 66-.3c4.4 0 8 3.5 8 8 0 1.9-.7 3.7-1.9 5.2L553.5 514l130 155c1.2 1.5 1.9 3.3 1.9 5.2 0 4.4-3.6 8-8 8z"></path></svg>'
}


const I18N_MAP = {
'en': {
'Logs': 'Logs',
'Save': 'Save',
'Config:': 'Config:',
'Add': 'Add',
'Rename': 'Rename',
'RenameHelp': 'Enter a new name:',
'Delete': 'Delete',
'DNS Provider': 'DNS Provider',
'Create AccessKey': 'Create AccessKey',
'Auto': 'Auto',
'1s': '1s',
'5s': '5s',
'10s': '10s',
'1m': '1m',
'2m': '2m',
'10m': '10m',
'30m': '30m',
'1h': '1h',
'ttlHelp': 'You can modify it if the account supports a smaller TTL. The TTL will only be updated when the IP changes',
'Enabled': 'Enabled',
'Get IP method': 'Get IP method',
'By api': 'By api',
'By network card': 'By network card',
'By command': 'By command',
'domainsHelp': `
Enter one domain per line.
If the domain is unregistrable, manually separate it into a subdomain and a root domain by using a colon. e.g. <code>www:domain.example.com</code><br />
Support for <a target="blank" href="https://github.com/jeessy2/ddns-go/wiki/传递自定义参数">custom parameters</a> (Simplified Chinese)
`,
'Regular exp.': 'Regular exp.',
'regHelp': 'You can use @1 to specify the first IPv6 address, @2 to specify the second IPv6 address... You can also use regular expressions to match the specified IPv6 address, leave it blank to disable it',
'Others': 'Others',
'Deny from WAN': 'Deny from WAN',
'NotAllowWanAccessHelp': 'Enable to deny access from the public network',
'Username': 'Username',
'accountHelp': 'Username/Password is required',
'passwordHelp': 'If you need to change the password, please enter it here',
'Password': 'Password',
'WebhookURLHelp': `
<a
target="blank"
href="https://github.com/jeessy2/ddns-go/blob/master/README_EN.md#webhook"
>Click to get more info</a
><br />
Support variables #{ipv4Addr}, #{ipv4Result},
#{ipv4Domains}, #{ipv6Addr}, #{ipv6Result}, #{ipv6Domains}
`,
'WebhookRequestBodyHelp': 'If RequestBody is empty, it is a GET request, otherwise it is a POST request. Supported variables are the same as above',
'WebhookHeadersHelp': 'One header per line, such as: Authorization: Bearer API_KEY',
'Try it': 'Try it',
'Clear': 'Clear',
'OK': 'OK',
"Ipv4UrlHelp": "https://api.ipify.org, https://myip.ipip.net, https://ddns.oray.com/checkip, https://ip.3322.net, https://v4.yinghualuo.cn/bejson",
"Ipv6UrlHelp": "https://speed.neu6.edu.cn/getIP.php, https://v6.ident.me, https://6.ipw.cn, https://v6.yinghualuo.cn/bejson",
"Ipv4NetInterfaceHelp": "Get IPv4 address through network card",
"Ipv6NetInterfaceHelp": "If you do not specify a matching regular expression, the first IPv6 address will be used by default",
"Ipv4CmdHelp": "Get IPv4 through command, only use the first matching IPv4 address of standard output(stdout). Such as: ip -4 addr show eth1",
"Ipv6CmdHelp": "Get IPv6 through command, only use the first matching IPv6 address of standard output(stdout). Such as: ip -6 addr show eth1",
"NetInterfaceEmptyHelp": '<span style="color: red">No available network card found</span>',
"Login": 'Login',
"LoginInit": 'Login and configure as an administrator account',
"Logout": 'Logout',
},
'zh-cn': {
'Logs': '日志',
'Save': '保存',
'Config:': '配置切换:',
'Add': '添加',
'Rename': '重命名',
'RenameHelp': '输入新名称:',
'Delete': '删除',
'DNS Provider': 'DNS服务商',
'Create AccessKey': '创建 AccessKey',
'Auto': '自动',
'1s': '1秒',
'5s': '5秒',
'10s': '10秒',
'1m': '1分钟',
'2m': '2分钟',
'10m': '10分钟',
'30m': '30分钟',
'1h': '1小时',
'ttlHelp': '如账号支持更小的 TTL, 可修改。IP 有变化时才会更新TTL',
'Enabled': '是否启用',
'Get IP method': '获取 IP 方式',
'By api': '通过接口获取',
'By network card': '通过网卡获取',
'By command': '通过命令获取',
'domainsHelp': `
每行一个域名。
如果域名不可注册,请使用冒号手动将其分为子域名和根域名。如 <code>www:domain.example.com</code><br />
支持<a target="blank" href="https://github.com/jeessy2/ddns-go/wiki/传递自定义参数">自定义参数</a>
`,
'Regular exp.': '匹配正则表达式',
'regHelp': '可使用 @1 指定第一个IPv6地址, @2 指定第二个IPv6地址... 也可使用正则表达式匹配指定的IPv6地址, 留空则不启用',
'Others': '其他',
'Deny from WAN': '禁止公网访问',
'NotAllowWanAccessHelp': '启用后禁止从公网访问此页面',
'Username': '用户名',
'accountHelp': '必须输入用户名/密码',
'passwordHelp': '如需修改密码,请在此处输入新密码',
'Password': '密码',
'WebhookURLHelp': `
<a target="blank" href="https://github.com/jeessy2/ddns-go#webhook">点击参考官方 Webhook 说明</a>
<br />
支持的变量 #{ipv4Addr}, #{ipv4Result}, #{ipv4Domains}, #{ipv6Addr}, #{ipv6Result}, #{ipv6Domains}
`,
'WebhookRequestBodyHelp': '如果 RequestBody 为空, 则为 GET 请求, 否则为 POST 请求。支持的变量同上',
'WebhookHeadersHelp': '一行一个Header, 如: Authorization: Bearer API_KEY',
'Try it': '模拟测试Webhook',
'Clear': '清空',
'OK': '确定',
"Ipv4UrlHelp": "https://myip.ipip.net, https://ddns.oray.com/checkip, https://ip.3322.net, https://v4.yinghualuo.cn/bejson",
"Ipv6UrlHelp": "https://speed.neu6.edu.cn/getIP.php, https://v6.ident.me, https://6.ipw.cn, https://v6.yinghualuo.cn/bejson",
"Ipv4NetInterfaceHelp": "通过网卡获取IPv4",
"Ipv6NetInterfaceHelp": "如不指定匹配正则表达式,将默认使用第一个 IPv6 地址",
"Ipv4CmdHelp": `
通过命令获取IPv4, 仅使用标准输出(stdout)的第一个匹配的 IPv4 地址。如: ip -4 addr show eth1
<a target="blank" href="https://github.com/jeessy2/ddns-go/wiki/通过命令获取IP参考">点击参考更多</a>
`,
"Ipv6CmdHelp": `
通过命令获取IPv6, 仅使用标准输出(stdout)的第一个匹配的 IPv6 地址。如: ip -6 addr show eth1
<a target="blank" href="https://github.com/jeessy2/ddns-go/wiki/通过命令获取IP参考">点击参考更多</a>
`,
"NetInterfaceEmptyHelp": '<span style="color: red">没有找到可用的网卡</span>',
"Login": '登录',
"LoginInit": '登录并配置为管理员账号',
"Logout": '注销',
}
};
Loading

0 comments on commit c68080b

Please sign in to comment.