Skip to content

Commit

Permalink
chore: Update readme
Browse files Browse the repository at this point in the history
Signed-off-by: ittuann <ittuann@outlook.com>
  • Loading branch information
ittuann committed Aug 18, 2024
1 parent 20104a7 commit d4742c4
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 25 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Route to CIDR Converter
# [Route to CIDR Converter](https://ittuann.github.io/Route2CIDR/)

## <https://ittuann.github.io/Route2CIDR/>
访问本工具:***<https://ittuann.github.io/Route2CIDR/>***

![Route2CIDR WebSite](docs/images/homepage.png)

本项目是一个在线工具,用于将路由表转换为 CIDR (无类域间路由,Classless Inter-Domain Routing),并支持转换为Clash、SSTap和Netch代理规则。

Expand Down
2 changes: 1 addition & 1 deletion dist/bundle.js

Large diffs are not rendered by default.

Binary file added docs/images/homepage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<link rel="icon" type="image/png" sizes="16x16" href="iconx/favicon-16x16.png">
<link rel="manifest" href="iconx/site.webmanifest">
<script async src="https://www.googletagmanager.com/gtag/js?id=G-YQ3R6RXKW7"></script>
<script>function gtag(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],gtag("js",new Date),gtag("config","G-YQ3R6RXKW7")</script>
<script>function gtag() { dataLayer.push(arguments) } window.dataLayer = window.dataLayer || [], gtag("js", new Date), gtag("config", "G-YQ3R6RXKW7")</script>
</head>

<body class="bg-gray-100 flex justify-center items-center min-h-screen">
Expand Down Expand Up @@ -75,6 +75,7 @@ <h2 class="text-xl font-semibold text-gray-700">转换结果:</h2>
class="bg-red-500 text-white px-4 py-2 rounded-lg hover:bg-green-600">下载</button>
</div>
</div>
<p class="text-sm text-gray-500 text-left mt-2">Note: 转换速度取决于输入路由表长度</p>

<div id="notification"
class="fixed bottom-4 right-4 bg-gray-800 text-white py-2 px-4 rounded-lg shadow-lg opacity-0 transition-opacity duration-300">
Expand Down
42 changes: 21 additions & 21 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ function routeToCIDR(routeRawStr) {
);
});

cidrAddressList.forEach((network) => {
console.log(`${network.networkAddress}/${network.subnetMaskLength}`);
});
// cidrAddressList.forEach((network) => {
// console.log(`${network.networkAddress}/${network.subnetMaskLength}`);
// });

return cidrAddressList; // 返回CIDR地址列表
return cidrAddressList; // 返回CIDR列表
}

function convertCIDRListToStr(cidrAddressList, formatFn, header = "") {
Expand Down Expand Up @@ -153,20 +153,6 @@ document.addEventListener("DOMContentLoaded", () => {
inputElement.placeholder = exampleRouteInput;
configContainer.style.display = "none";

// 定义转换按钮点击事件通用处理函数
function handleButtonClick(convertFunction, extraParam = null) {
const routeInput =
inputElement.value.trim() === ""
? exampleRouteInput
: inputElement.value;
const cidrAddressList = routeToCIDR(routeInput);
const result = extraParam
? convertFunction(cidrAddressList, extraParam)
: convertFunction(cidrAddressList);
outputElement.textContent = result;
showNotification("转换完成!");
}

// 切换显示/隐藏额外设置
function toggleConfigContainer(show) {
configContainer.style.display = show ? "block" : "none";
Expand All @@ -185,22 +171,36 @@ document.addEventListener("DOMContentLoaded", () => {
}, 3000);
}

// 定义转换按钮点击事件通用处理函数
function handleButtonClick(convertFunction, extraParam = null) {
showNotification("正在转换路由表至CIDR~ 转换速度取决于路由表长度");

const routeInput =
inputElement.value.trim() === ""
? exampleRouteInput
: inputElement.value;
const cidrAddressList = routeToCIDR(routeInput);
const result = extraParam
? convertFunction(cidrAddressList, extraParam)
: convertFunction(cidrAddressList);
outputElement.textContent = result;

showNotification("转换完成!");
}

// 添加事件监听器
buttonToClash.addEventListener("click", () => {
showNotification("正在转换路由至CIDR~ 转换速度取决于路由表长度");
handleButtonClick(convertCIDRListToClashStr);
toggleConfigContainer(false);
});
buttonToSSTap.addEventListener("click", () => {
showNotification("正在转换路由至CIDR~ 转换速度取决于路由表长度");
handleButtonClick(
convertCIDRListToSSTapStr,
sstapHeaderElement.value.trim(),
);
toggleConfigContainer(true);
});
buttonToNetch.addEventListener("click", () => {
showNotification("正在转换路由至CIDR~ 转换速度取决于路由表长度");
handleButtonClick(convertCIDRListToNetchStr);
toggleConfigContainer(false);
});
Expand Down

0 comments on commit d4742c4

Please sign in to comment.