mirror of
https://github.com/BlueSkyXN/WorkerJS_CloudFlare_ImageBed.git
synced 2024-11-16 03:32:26 +08:00
20240327-1447
This commit is contained in:
parent
9e118ec0e1
commit
5cccf19fc3
23
cloudflare-page-build/scripts/Build_Tools-TGPH.js
Normal file
23
cloudflare-page-build/scripts/Build_Tools-TGPH.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-TGPH.html'); // 源文件路径
|
||||||
|
const destDir = path.join(__dirname, '..', '..', 'dist'); // 目标 dist 目录的路径
|
||||||
|
const destToolsDir = path.join(destDir, 'tools'); // 目标 tools 目录的路径
|
||||||
|
const destFilePath = path.join(destToolsDir, 'tgph.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} 不存在。`);
|
||||||
|
}
|
|
@ -2,22 +2,32 @@ const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
// 设置源文件和目标文件的路径
|
// 设置源文件和目标文件的路径
|
||||||
const srcDir = path.join(__dirname, '..', '..', 'cloudflare-page'); // cloudflare-page 目录的路径
|
const srcPath = path.join(__dirname, '..', '..', 'cloudflare-page', 'OneAPI-imgbed-MIX.html');
|
||||||
const srcFilePath = path.join(srcDir, 'Tools-TGPH.html'); // 源文件路径
|
const destDir = path.join(__dirname, '..', '..', 'dist');
|
||||||
const destDir = path.join(__dirname, '..', '..', 'dist'); // 目标 dist 目录的路径
|
const destPath = path.join(destDir, 'index.html');
|
||||||
const destToolsDir = path.join(destDir, 'tools'); // 目标 tools 目录的路径
|
|
||||||
const destFilePath = path.join(destToolsDir, 'tgph.html'); // 目标文件路径
|
|
||||||
|
|
||||||
// 确保目标目录存在
|
// 确保目标目录存在
|
||||||
if (!fs.existsSync(destToolsDir)) {
|
if (!fs.existsSync(destDir)) {
|
||||||
fs.mkdirSync(destToolsDir, { recursive: true });
|
fs.mkdirSync(destDir, { recursive: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查源文件是否存在
|
// 复制并重命名文件
|
||||||
if (fs.existsSync(srcFilePath)) {
|
fs.copyFileSync(srcPath, destPath);
|
||||||
// 复制并重命名文件
|
console.log('文件已成功复制并重命名到:', destPath);
|
||||||
fs.copyFileSync(srcFilePath, destFilePath);
|
|
||||||
console.log(`文件 ${srcFilePath} 已成功复制并重命名到 ${destFilePath}`);
|
// 读取目标文件内容
|
||||||
} else {
|
fs.readFile(destPath, 'utf8', function (err, data) {
|
||||||
console.log(`源文件 ${srcFilePath} 不存在。`);
|
if (err) {
|
||||||
}
|
return console.log(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 替换{{API_ENDPOINT}}占位符为环境变量的值,如果环境变量未设置,则使用默认值
|
||||||
|
const apiEndpoint = process.env.API_ENDPOINT || 'https://github.com/BlueSkyXN/WorkerJS_CloudFlare_ImageBed';
|
||||||
|
const result = data.replace(/{{API_ENDPOINT}}/g, apiEndpoint);
|
||||||
|
|
||||||
|
// 将修改后的内容写回文件
|
||||||
|
fs.writeFile(destPath, result, 'utf8', function (err) {
|
||||||
|
if (err) return console.log(err);
|
||||||
|
console.log('API_ENDPOINT已替换,并保存到:', destPath);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
<form id="upload-form">
|
<form id="upload-form">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="apiUrl">API 域名:</label>
|
<label for="apiUrl">API 域名:</label>
|
||||||
<input type="text" class="form-control" id="apiUrl" placeholder="输入 API 域名" required>
|
<input type="text" class="form-control" id="apiUrl" placeholder="输入 API 域名" value="{{API_ENDPOINT}}" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="fileInput">选择文件</label>
|
<label for="fileInput">选择文件</label>
|
||||||
|
|
|
@ -21,12 +21,12 @@
|
||||||
}
|
}
|
||||||
.copy-button {
|
.copy-button {
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
background-color: #17a2b8; /* Bootstrap info color */
|
background-color: #12ca49; /* Bootstrap info color */
|
||||||
border-color: #17a2b8; /* Bootstrap info color */
|
border-color: #12ca49; /* Bootstrap info color */
|
||||||
}
|
}
|
||||||
.copy-button:hover {
|
.copy-button:hover {
|
||||||
background-color: #138496; /* Darker shade */
|
background-color: #149e3e; /* Darker shade */
|
||||||
border-color: #117a8b; /* Darker shade */
|
border-color: #149e3e; /* Darker shade */
|
||||||
}
|
}
|
||||||
.input-group-prepend {
|
.input-group-prepend {
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
"description": "workerjscloudflareimagebed",
|
"description": "workerjscloudflareimagebed",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "node cloudflare-page-build/scripts/quick-build.js"
|
"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"
|
||||||
},
|
},
|
||||||
"author": "BlueSkyXN",
|
"author": "BlueSkyXN",
|
||||||
"license": "GPLv3",
|
"license": "GPLv3",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user