Skip to content

Commit afdccb6

Browse files
committed
feat: add altcha widget
1 parent b59a7ee commit afdccb6

4 files changed

Lines changed: 3137 additions & 1 deletion

File tree

astro.config.mjs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// @ts-check
22
import { defineConfig } from "astro/config";
3+
import { copyFileSync, mkdirSync, existsSync } from "fs";
4+
import { join } from "path";
35

46
// https://astro.build/config
57
export default defineConfig({
@@ -11,4 +13,31 @@ export default defineConfig({
1113
allowedHosts: ["dvdbr3o-laptop", "dvdbr3o-laptop.local", ".local"],
1214
},
1315
},
16+
integrations: [
17+
{
18+
name: "copy-altcha-to-lang-dirs",
19+
hooks: {
20+
"astro:build:done": ({ dir }) => {
21+
const srcFile = join(dir.pathname, "js", "altcha.js");
22+
const langDirs = ["en", "zh"];
23+
24+
for (const lang of langDirs) {
25+
const targetDir = join(dir.pathname, lang, "js");
26+
const targetFile = join(targetDir, "altcha.js");
27+
28+
// 确保目标目录存在
29+
if (!existsSync(targetDir)) {
30+
mkdirSync(targetDir, { recursive: true });
31+
}
32+
33+
// 复制文件
34+
if (existsSync(srcFile)) {
35+
copyFileSync(srcFile, targetFile);
36+
console.log(`Copied altcha.js to ${lang}/js/`);
37+
}
38+
}
39+
},
40+
},
41+
},
42+
],
1443
});

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"three": "^0.183.2"
2121
},
2222
"devDependencies": {
23+
"@types/node": "^25.5.0",
2324
"@types/three": "^0.183.1",
2425
"prettier": "^3.8.1",
2526
"prettier-plugin-astro": "^0.14.1"

0 commit comments

Comments
 (0)