mirror of
https://github.com/BlueSkyXN/WorkerJS_CloudFlare_ImageBed.git
synced 2024-11-16 11:42:33 +08:00
1.4.0 新增一个转换器
This commit is contained in:
parent
4fb8a3ea2a
commit
97e19e4fcc
23
cloudflare-page-build/scripts/Build_Tools-IMGProxy.js
Normal file
23
cloudflare-page-build/scripts/Build_Tools-IMGProxy.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
// 设置源文件和目标文件的路径
|
||||
const srcDir = path.join(__dirname, '..', '..', 'cloudflare-page'); // cloudflare-page 目录的路径
|
||||
const srcFilePath = path.join(srcDir, 'Tools-IMGProxy.html'); // 源文件路径
|
||||
const destDir = path.join(__dirname, '..', '..', 'dist'); // 目标 dist 目录的路径
|
||||
const destToolsDir = path.join(destDir, 'tools'); // 目标 tools 目录的路径
|
||||
const destFilePath = path.join(destToolsDir, 'imgproxy.html'); // 目标文件路径
|
||||
|
||||
// 确保目标目录存在
|
||||
if (!fs.existsSync(destToolsDir)) {
|
||||
fs.mkdirSync(destToolsDir, { recursive: true });
|
||||
}
|
||||
|
||||
// 检查源文件是否存在
|
||||
if (fs.existsSync(srcFilePath)) {
|
||||
// 复制并重命名文件
|
||||
fs.copyFileSync(srcFilePath, destFilePath);
|
||||
console.log(`文件 ${srcFilePath} 已成功复制并重命名到 ${destFilePath}`);
|
||||
} else {
|
||||
console.log(`源文件 ${srcFilePath} 不存在。`);
|
||||
}
|
|
@ -4,7 +4,6 @@
|
|||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>OneAPI File Uploader</title>
|
||||
<!-- INFO -->
|
||||
<!--
|
||||
本代码完全开源,仅供学习CloudFlare Page和Worker组件编程使用
|
||||
仓库地址 https://github.com/BlueSkyXN/WorkerJS_CloudFlare_ImageBed
|
||||
|
@ -13,7 +12,6 @@
|
|||
API接口均需要使用者自行解决,本人不提供任何API接口服务
|
||||
不得在中国大陆地区使用本代码
|
||||
-->
|
||||
<!-- 引入 Bootstrap CSS -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/css/bootstrap.min.css">
|
||||
<style>
|
||||
.container {
|
||||
|
@ -25,24 +23,24 @@
|
|||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
display: flex;
|
||||
flex-direction: column; /* 不同框之间纵向排列 */
|
||||
width: 100%; /* 设置结果框宽度为100% */
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
}
|
||||
.preview-container {
|
||||
max-width: calc(100% - 20px); /* 图片预览容器的最大宽度为外部框架宽度减去左右 padding */
|
||||
max-height: calc(8 * 50px); /* 最大高度不超过8个上传按钮的高度 */
|
||||
overflow: hidden; /* 超出部分隐藏 */
|
||||
margin-top: 10px; /* 添加顶部间距 */
|
||||
width: 100%; /* 设置预览容器宽度为100% */
|
||||
max-width: calc(100% - 20px);
|
||||
max-height: calc(8 * 50px);
|
||||
overflow: hidden;
|
||||
margin-top: 10px;
|
||||
width: 100%;
|
||||
}
|
||||
.preview-img {
|
||||
max-width: 100%; /* 图片预览的最大宽度为容器宽度 */
|
||||
height: auto; /* 自适应高度 */
|
||||
display: block; /* 防止图片下面产生空白 */
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
display: block;
|
||||
}
|
||||
.copy-button, .file-name, .file-url {
|
||||
display: inline-block; /* 按钮、文件名和URL在同一行 */
|
||||
margin-bottom: 5px; /* 添加底部间距 */
|
||||
display: inline-block;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.copy-button {
|
||||
width: auto;
|
||||
|
@ -79,6 +77,7 @@
|
|||
</label>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Upload</button>
|
||||
<button type="button" class="btn btn-info" onclick="window.location.href='/tools/imgproxy';">IMGProxy</button>
|
||||
<button type="button" id="convertButton" class="btn btn-success" style="display: none;">Transform</button>
|
||||
</form>
|
||||
<div id="result" class="mt-3">
|
||||
|
|
|
@ -4,6 +4,14 @@
|
|||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>文件上传</title>
|
||||
<!--
|
||||
本代码完全开源,仅供学习CloudFlare Page和Worker组件编程使用
|
||||
仓库地址 https://github.com/BlueSkyXN/WorkerJS_CloudFlare_ImageBed
|
||||
不提供任何免费的技术支持、指导、问题解答,请按GitHub标准用法进行issue等方式交互
|
||||
请勿滥用本代码,违规使用后果自负,任何操作和后果均与本人无关
|
||||
API接口均需要使用者自行解决,本人不提供任何API接口服务
|
||||
不得在中国大陆地区使用本代码
|
||||
-->
|
||||
<!-- 引入 Bootstrap CSS -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/css/bootstrap.min.css">
|
||||
<style>
|
||||
|
|
98
cloudflare-page/Tools-IMGProxy.html
Normal file
98
cloudflare-page/Tools-IMGProxy.html
Normal file
|
@ -0,0 +1,98 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>TGPH URL Transformer</title>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/css/bootstrap.min.css">
|
||||
<style>
|
||||
.container {
|
||||
margin-top: 50px;
|
||||
}
|
||||
.url-item {
|
||||
margin-top: 10px;
|
||||
border: 1px solid #ccc;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
background-color: #f9f9f9;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.copy-button {
|
||||
margin-right: 10px;
|
||||
background-color: #12ca49;
|
||||
border-color: #12ca49;
|
||||
}
|
||||
.copy-button:hover {
|
||||
background-color: #149e3e;
|
||||
border-color: #149e3e;
|
||||
}
|
||||
.input-group-prepend {
|
||||
margin-right: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h2>TGPH URL Transformer</h2>
|
||||
<div class="input-group mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<button class="btn btn-outline-secondary" type="button" id="pasteUrl">Paste URL</button>
|
||||
</div>
|
||||
<input type="text" class="form-control" id="inputUrl" placeholder="Input Raw URL">
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-primary" onclick="transformUrl()">Transform URL</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="urlList"></div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.getElementById('pasteUrl').addEventListener('click', function() {
|
||||
navigator.clipboard.readText().then(text => document.getElementById('inputUrl').value = text);
|
||||
});
|
||||
|
||||
function transformUrl() {
|
||||
const originalUrl = document.getElementById('inputUrl').value;
|
||||
const urlPart = originalUrl.split('://')[1]; // 提取https://之后的部分
|
||||
|
||||
const prefixes = [
|
||||
'https://cdn.cdnjson.com/pic.html?url=https://',
|
||||
'https://image.baidu.com/search/down?url=https://',
|
||||
'https://i3.wp.com/',
|
||||
'http://collect34.longsunhd.com/source/plugin/yzs1013_pldr/getimg.php?url=https://',
|
||||
'https://images.weserv.nl/?url=https://',
|
||||
'https://imageproxy.pimg.tw/resize?url=https://',
|
||||
'https://pic1.xuehuaimg.com/proxy/https://',
|
||||
'https://images.weserv.nl/?url=https://i3.wp.com/',
|
||||
'https://pic1.xuehuaimg.com/proxy/https://images.weserv.nl/?url=https://i3.wp.com/'
|
||||
];
|
||||
|
||||
let transformedUrls = prefixes.map(prefix => `${prefix}${urlPart}`);
|
||||
displayUrls(transformedUrls);
|
||||
}
|
||||
|
||||
function displayUrls(urls) {
|
||||
const urlList = document.getElementById('urlList');
|
||||
urlList.innerHTML = '';
|
||||
urls.forEach(url => {
|
||||
const urlItem = document.createElement('div');
|
||||
urlItem.className = 'url-item';
|
||||
|
||||
const copyBtn = document.createElement('button');
|
||||
copyBtn.className = 'btn btn-info copy-button';
|
||||
copyBtn.textContent = 'COPY URL';
|
||||
copyBtn.onclick = function() { navigator.clipboard.writeText(url); };
|
||||
|
||||
const urlText = document.createElement('span');
|
||||
urlText.textContent = url;
|
||||
|
||||
urlItem.appendChild(copyBtn);
|
||||
urlItem.appendChild(urlText);
|
||||
|
||||
urlList.appendChild(urlItem);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -6,7 +6,8 @@
|
|||
"scripts": {
|
||||
"build1": "node cloudflare-page-build/scripts/quick-build.js",
|
||||
"build2": "node cloudflare-page-build/scripts/Build_Tools-TGPH.js",
|
||||
"build": "npm run build1 && npm run build2"
|
||||
"build3": "node cloudflare-page-build/scripts/Build_Tools-IMGProxy.js",
|
||||
"build": "npm run build1 && npm run build2 && npm run build3"
|
||||
},
|
||||
"author": "BlueSkyXN",
|
||||
"license": "GPLv3",
|
||||
|
|
Loading…
Reference in New Issue
Block a user