update: 2026-03-28 20:59
This commit is contained in:
25
InfoGenie-frontend/scripts/inject-ig-embed.js
Normal file
25
InfoGenie-frontend/scripts/inject-ig-embed.js
Normal file
@@ -0,0 +1,25 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const root = path.join(__dirname, '../public/60sapi');
|
||||
const tag = '<script src="/60sapi/ig-embed.js"></script>';
|
||||
|
||||
function walk(dir) {
|
||||
for (const f of fs.readdirSync(dir)) {
|
||||
const p = path.join(dir, f);
|
||||
if (fs.statSync(p).isDirectory()) walk(p);
|
||||
else if (f.endsWith('.html')) {
|
||||
let c = fs.readFileSync(p, 'utf8');
|
||||
if (c.includes('ig-embed.js')) continue;
|
||||
if (!c.includes('</head>')) {
|
||||
console.warn('skip', p);
|
||||
continue;
|
||||
}
|
||||
c = c.replace('</head>', `${tag}\n</head>`);
|
||||
fs.writeFileSync(p, c, 'utf8');
|
||||
console.log('ok', p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
walk(root);
|
||||
34
InfoGenie-frontend/scripts/patch-60s-html-base.js
Normal file
34
InfoGenie-frontend/scripts/patch-60s-html-base.js
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 为 public/60sapi 下 HTML 注入 sixty-runtime.js,并将硬编码的 60s 域名改为 window.__SIXTY_API_BASE__
|
||||
*/
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const root = path.join(__dirname, '../public/60sapi');
|
||||
|
||||
function walk(dir) {
|
||||
for (const f of fs.readdirSync(dir)) {
|
||||
const p = path.join(dir, f);
|
||||
const st = fs.statSync(p);
|
||||
if (st.isDirectory()) walk(p);
|
||||
else if (f.endsWith('.html')) {
|
||||
let s = fs.readFileSync(p, 'utf8');
|
||||
if (!s.includes('sixty-runtime.js')) {
|
||||
if (s.includes('ig-embed.js')) {
|
||||
s = s.replace(
|
||||
'<script src="/60sapi/ig-embed.js"></script>',
|
||||
'<script src="/60sapi/ig-embed.js"></script>\n<script src="/60sapi/sixty-runtime.js"></script>'
|
||||
);
|
||||
} else {
|
||||
s = s.replace('</head>', '<script src="/60sapi/sixty-runtime.js"></script>\n</head>');
|
||||
}
|
||||
}
|
||||
s = s.replace(/fetch\('https:\/\/60s\.api\.shumengya\.top(\/[^']+)'/g, "fetch(window.__SIXTY_API_BASE__+'$1'");
|
||||
s = s.replace(/fetch\(`https:\/\/60s\.api\.shumengya\.top/g, 'fetch(`${window.__SIXTY_API_BASE__}');
|
||||
s = s.replace(/const API='https:\/\/60s\.api\.shumengya\.top([^']+)'/g, "const API=window.__SIXTY_API_BASE__+'$1'");
|
||||
s = s.replace(/const BASE='https:\/\/60s\.api\.shumengya\.top'/g, 'const BASE=window.__SIXTY_API_BASE__');
|
||||
fs.writeFileSync(p, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
walk(root);
|
||||
console.log('patched 60sapi html');
|
||||
141
InfoGenie-frontend/scripts/profile_template_renames.ps1
Normal file
141
InfoGenie-frontend/scripts/profile_template_renames.ps1
Normal file
@@ -0,0 +1,141 @@
|
||||
# 由 tidy_profile_templates.py 生成:关闭占用该目录的 IDE/资源管理器窗口后执行。
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$base = 'd:\SmyProjects\Frontend-Backend\InfoGenie\infogenie-frontend\public\toolbox\个人主页模板'
|
||||
|
||||
# 阶段 1:改为临时名
|
||||
Rename-Item -LiteralPath (Join-Path $base '-色 色致安简洁引导页') -NewName '__tmp_rename_87cc6d7f_0__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '-色地址发布页源码') -NewName '__tmp_rename_87cc6d7f_1__'
|
||||
Rename-Item -LiteralPath (Join-Path $base 'Bs缘空的个人主页') -NewName '__tmp_rename_87cc6d7f_2__'
|
||||
Rename-Item -LiteralPath (Join-Path $base 'Force Yc 第六引导公告网页源码') -NewName '__tmp_rename_87cc6d7f_3__'
|
||||
Rename-Item -LiteralPath (Join-Path $base 'HTML透明闪动方块导航网站源码') -NewName '__tmp_rename_87cc6d7f_4__'
|
||||
Rename-Item -LiteralPath (Join-Path $base 'Master 导航页') -NewName '__tmp_rename_87cc6d7f_5__'
|
||||
Rename-Item -LiteralPath (Join-Path $base 'zyyo个人主页 (1)') -NewName '__tmp_rename_87cc6d7f_6__'
|
||||
Rename-Item -LiteralPath (Join-Path $base 'zyyo主页') -NewName '__tmp_rename_87cc6d7f_7__'
|
||||
Rename-Item -LiteralPath (Join-Path $base 'zyyo主页2') -NewName '__tmp_rename_87cc6d7f_8__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '【原创】Scode源码站原创个人单页') -NewName '__tmp_rename_87cc6d7f_9__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '东方终焉组') -NewName '__tmp_rename_87cc6d7f_10__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '东方终焉组 (1)') -NewName '__tmp_rename_87cc6d7f_11__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '个人主页') -NewName '__tmp_rename_87cc6d7f_12__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '个人主页2') -NewName '__tmp_rename_87cc6d7f_13__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '个人主页2 (1)') -NewName '__tmp_rename_87cc6d7f_14__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '个人主页3') -NewName '__tmp_rename_87cc6d7f_15__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '个人主页源码') -NewName '__tmp_rename_87cc6d7f_16__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '个人介绍网页') -NewName '__tmp_rename_87cc6d7f_17__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '个人名片') -NewName '__tmp_rename_87cc6d7f_18__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '个人安全团队官方引导html单页') -NewName '__tmp_rename_87cc6d7f_19__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '个人安全团队官方引导html单页 (1)') -NewName '__tmp_rename_87cc6d7f_20__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '个简官网') -NewName '__tmp_rename_87cc6d7f_21__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '二次元自适应动态引导页') -NewName '__tmp_rename_87cc6d7f_22__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '介绍页') -NewName '__tmp_rename_87cc6d7f_23__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '全新自适应地址发布页HTML源码') -NewName '__tmp_rename_87cc6d7f_24__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '动态背景樱花飘落个人主页') -NewName '__tmp_rename_87cc6d7f_25__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '动态视频导航引导页源码') -NewName '__tmp_rename_87cc6d7f_26__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '动态雨滴玻璃主页') -NewName '__tmp_rename_87cc6d7f_27__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '单页') -NewName '__tmp_rename_87cc6d7f_28__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '卡网导航') -NewName '__tmp_rename_87cc6d7f_29__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '卡网导航炫酷') -NewName '__tmp_rename_87cc6d7f_30__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '叮当猫苹果QQ改机型PC官网') -NewName '__tmp_rename_87cc6d7f_31__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '天神云') -NewName '__tmp_rename_87cc6d7f_32__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '好看流光风格个人主页源码') -NewName '__tmp_rename_87cc6d7f_33__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '好看的个人仿QQ单页HTML') -NewName '__tmp_rename_87cc6d7f_34__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '家个人主页') -NewName '__tmp_rename_87cc6d7f_35__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '导航') -NewName '__tmp_rename_87cc6d7f_36__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '导航 1.01') -NewName '__tmp_rename_87cc6d7f_37__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '尘屿个人主页') -NewName '__tmp_rename_87cc6d7f_38__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '尽心小屋引导页') -NewName '__tmp_rename_87cc6d7f_39__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '引导页源码') -NewName '__tmp_rename_87cc6d7f_40__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '很漂亮个人主页自带音乐源码') -NewName '__tmp_rename_87cc6d7f_41__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '很漂亮个人主页自带音乐源码 (1)') -NewName '__tmp_rename_87cc6d7f_42__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '很漂亮的个人主页HTML源码') -NewName '__tmp_rename_87cc6d7f_43__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '很漂亮的个人主页源码') -NewName '__tmp_rename_87cc6d7f_44__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '很漂亮的个人主页源码 - 副本') -NewName '__tmp_rename_87cc6d7f_45__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '拟态个人主页(1)') -NewName '__tmp_rename_87cc6d7f_46__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '新拟态个人主页网站源码') -NewName '__tmp_rename_87cc6d7f_47__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '新拟态应用下载页HTML源码') -NewName '__tmp_rename_87cc6d7f_48__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '毛玻璃UI个人主页源码(开源版)') -NewName '__tmp_rename_87cc6d7f_49__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '毛玻璃个人引导页源码') -NewName '__tmp_rename_87cc6d7f_50__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '江东个人主页') -NewName '__tmp_rename_87cc6d7f_51__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '渐淡背景导航页源码') -NewName '__tmp_rename_87cc6d7f_52__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '漂亮的个人主页HTML源码') -NewName '__tmp_rename_87cc6d7f_53__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '炫酷个人引导页主页自适应HTML源码') -NewName '__tmp_rename_87cc6d7f_54__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '炫酷引导') -NewName '__tmp_rename_87cc6d7f_55__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '炫酷引导 (1)') -NewName '__tmp_rename_87cc6d7f_56__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '炫酷黑色系列源码') -NewName '__tmp_rename_87cc6d7f_57__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '琳琅De个人主页源码') -NewName '__tmp_rename_87cc6d7f_58__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '精址发布页') -NewName '__tmp_rename_87cc6d7f_59__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '素颜个人导航网.zip') -NewName '__tmp_rename_87cc6d7f_60__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '素颜引导页2.0') -NewName '__tmp_rename_87cc6d7f_61__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '自适应星空背景个人导航单页') -NewName '__tmp_rename_87cc6d7f_62__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '蓝色简洁引导页') -NewName '__tmp_rename_87cc6d7f_63__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '连心个人主页') -NewName '__tmp_rename_87cc6d7f_64__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '酷黑风个人引导页') -NewName '__tmp_rename_87cc6d7f_65__'
|
||||
Rename-Item -LiteralPath (Join-Path $base '黄色简洁好看的地址发布页源码') -NewName '__tmp_rename_87cc6d7f_66__'
|
||||
|
||||
# 阶段 2:改为最终名
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_0__') -NewName '葫芦侠-绿色简洁引导页'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_1__') -NewName '永久地址发布页,收藏我回家不迷路!'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_2__') -NewName 'Bs缘空的个人主页 空忆工作室 缘空科技'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_3__') -NewName '公告'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_4__') -NewName '旗下站点 - 琳琅天上 网址大全'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_5__') -NewName 'Website Guide'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_6__') -NewName 'ZYYO'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_7__') -NewName 'ZYYO引导页'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_8__') -NewName 'ZYYO 好好相遇,慢慢生活'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_9__') -NewName 'Scode源码站-网站源码站长资讯站长源码站长工具游戏源码SEO教程建站教程SCODE1.COM'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_10__') -NewName 'Touhou Project - 终焉项目组'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_11__') -NewName 'Touhou Project - 终焉项目组-2'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_12__') -NewName '南淮花酱MyIndex'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_13__') -NewName '求职简历'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_14__') -NewName '正在跳转葫芦侠'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_15__') -NewName 'ZYYO-2'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_16__') -NewName '个人主页'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_17__') -NewName '个人介绍'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_18__') -NewName '蝶痕-蝶影留痕'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_19__') -NewName '演示htpp'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_20__') -NewName '演示htpp-2'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_21__') -NewName '筱健的小窝-欢迎来到筱健的官网!'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_22__') -NewName '织音云'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_23__') -NewName '小凡联系方式'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_24__') -NewName '天环网络科技工作室'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_25__') -NewName '碎念个人引导页'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_26__') -NewName '动态视频App导航下载引导页 - 源码来自 ( )'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_27__') -NewName 'ZYYO-3'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_28__') -NewName '导航页'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_29__') -NewName '低价导航'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_30__') -NewName '518货源站'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_31__') -NewName '叮当猫苹果QQ改机型 - iPhone11在线'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_32__') -NewName '风也温柔 天神云'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_33__') -NewName '织音云zhiyinidc.com'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_34__') -NewName '欢迎来到1人个人主页'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_35__') -NewName '个人主页-2'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_36__') -NewName '曦婉丫丫'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_37__') -NewName '导航'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_38__') -NewName '尘屿小站'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_39__') -NewName '永久地址发布页,收藏我回家不迷路!-2'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_40__') -NewName '鲨鱼导航迎接页面'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_41__') -NewName 'Yun Shi 的 个人主页欢迎来到我的主场~'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_42__') -NewName 'Yun Shi 的 个人主页欢迎来到我的主场~-2'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_43__') -NewName '天神个人网页'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_44__') -NewName 'YUN SHI个人网页'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_45__') -NewName 'YUN SHI个人网页-2'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_46__') -NewName '个人主页-3'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_47__') -NewName '个人主页-4'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_48__') -NewName '应用名称 - 下载页'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_49__') -NewName '毛玻璃拟态UI - 个人主页(开源版)'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_50__') -NewName '个人简约引导页单页'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_51__') -NewName '江东cc个人主页'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_52__') -NewName '渐淡背景导航页'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_53__') -NewName '123'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_54__') -NewName '小白'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_55__') -NewName '炫酷引导页'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_56__') -NewName '炫酷引导页-2'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_57__') -NewName '演示 - 演示'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_58__') -NewName '琳琅De主页 - 突破自己,琳琅天上'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_59__') -NewName '最新地址发布页'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_60__') -NewName '素颜导航网官网永久发布页'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_61__') -NewName '天神引导页'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_62__') -NewName '织音云-2'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_63__') -NewName '蓝色简洁永久发布页'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_64__') -NewName 'Evan毕业于IT专业'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_65__') -NewName 'Anle 一款酷黑风个人引导页'
|
||||
Rename-Item -LiteralPath (Join-Path $base '__tmp_rename_87cc6d7f_66__') -NewName 'XXX永久地址发布页,收藏我回家不迷路!'
|
||||
234
InfoGenie-frontend/scripts/tidy_profile_templates.py
Normal file
234
InfoGenie-frontend/scripts/tidy_profile_templates.py
Normal file
@@ -0,0 +1,234 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""筛选个人主页模板:删除非静态项,并按网页 title 重命名顶层文件夹。"""
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
import shutil
|
||||
import sys
|
||||
import uuid
|
||||
from pathlib import Path
|
||||
|
||||
BASE = Path(
|
||||
r"d:\SmyProjects\Frontend-Backend\InfoGenie\infogenie-frontend\public\toolbox\个人主页模板"
|
||||
)
|
||||
|
||||
# 无 HTML 无法作为静态页;PHP 文件较多视为需服务端,非纯静态
|
||||
PHP_THRESHOLD = 5
|
||||
|
||||
|
||||
def count_html(root: Path) -> int:
|
||||
n = 0
|
||||
for p in root.rglob("*"):
|
||||
if p.is_file() and p.suffix.lower() in (".html", ".htm"):
|
||||
n += 1
|
||||
return n
|
||||
|
||||
|
||||
def count_php(root: Path) -> int:
|
||||
return sum(1 for p in root.rglob("*.php") if p.is_file())
|
||||
|
||||
|
||||
def extract_title_from_text(text: str) -> str | None:
|
||||
for pattern in (
|
||||
r"<title[^>]*>([^<]*)</title>",
|
||||
r"<h1[^>]*>([^<]*)</h1>",
|
||||
):
|
||||
m = re.search(pattern, text, re.I | re.DOTALL)
|
||||
if m:
|
||||
raw = m.group(1)
|
||||
raw = re.sub(r"<[^>]+>", "", raw)
|
||||
title = re.sub(r"\s+", " ", raw).strip()
|
||||
title = re.sub(r'[<>:"/\\|?*]', "", title)
|
||||
title = title.strip(" -_|")
|
||||
if title and len(title) < 100:
|
||||
return title
|
||||
return None
|
||||
|
||||
|
||||
def read_html(path: Path) -> str:
|
||||
for enc in ("utf-8", "utf-8-sig", "gbk", "gb2312"):
|
||||
try:
|
||||
return path.read_text(encoding=enc)
|
||||
except (UnicodeDecodeError, OSError):
|
||||
continue
|
||||
return path.read_text(encoding="utf-8", errors="ignore")
|
||||
|
||||
|
||||
def find_entry_html(folder: Path) -> Path | None:
|
||||
for name in ("index.html", "index.htm"):
|
||||
for p in folder.rglob(name):
|
||||
if p.is_file():
|
||||
return p
|
||||
for p in folder.rglob("*"):
|
||||
if p.is_file() and p.suffix.lower() in (".html", ".htm"):
|
||||
return p
|
||||
return None
|
||||
|
||||
|
||||
def sanitize_folder_name(name: str) -> str:
|
||||
for c in '<>:"/\\|?*':
|
||||
name = name.replace(c, "")
|
||||
name = name.strip(" .")
|
||||
if len(name) > 120:
|
||||
name = name[:120].rstrip()
|
||||
return name or "未命名模板"
|
||||
|
||||
|
||||
def ps_single_quote(s: str) -> str:
|
||||
return "'" + s.replace("'", "''") + "'"
|
||||
|
||||
|
||||
def write_rename_ps1(renames: list[tuple[str, str]], out_path: Path) -> None:
|
||||
"""两阶段重命名,避免 A→B 与 B→A 等占用冲突。"""
|
||||
pairs = [(o, n) for o, n in renames if o != n]
|
||||
tag = uuid.uuid4().hex[:8]
|
||||
lines = [
|
||||
"# 由 tidy_profile_templates.py 生成:关闭占用该目录的 IDE/资源管理器窗口后执行。",
|
||||
"$ErrorActionPreference = 'Stop'",
|
||||
f"$base = {ps_single_quote(str(BASE))}",
|
||||
"",
|
||||
"# 阶段 1:改为临时名",
|
||||
]
|
||||
mids: list[tuple[str, str, str]] = []
|
||||
for i, (old, new) in enumerate(pairs):
|
||||
mid = f"__tmp_rename_{tag}_{i}__"
|
||||
mids.append((old, mid, new))
|
||||
lines.append(
|
||||
f"Rename-Item -LiteralPath (Join-Path $base {ps_single_quote(old)}) "
|
||||
f"-NewName {ps_single_quote(mid)}"
|
||||
)
|
||||
lines.extend(["", "# 阶段 2:改为最终名"])
|
||||
for _old, mid, new in mids:
|
||||
lines.append(
|
||||
f"Rename-Item -LiteralPath (Join-Path $base {ps_single_quote(mid)}) "
|
||||
f"-NewName {ps_single_quote(new)}"
|
||||
)
|
||||
out_path.write_text("\n".join(lines) + "\n", encoding="utf-8-sig")
|
||||
|
||||
|
||||
def compute_renames(remaining: list[Path]) -> list[tuple[str, str]]:
|
||||
used: set[str] = {c.name for c in remaining}
|
||||
renames: list[tuple[str, str]] = []
|
||||
for folder in remaining:
|
||||
entry = find_entry_html(folder)
|
||||
if not entry:
|
||||
continue
|
||||
try:
|
||||
text = read_html(entry)
|
||||
except OSError:
|
||||
continue
|
||||
title = extract_title_from_text(text)
|
||||
if not title:
|
||||
continue
|
||||
new_name = sanitize_folder_name(title)
|
||||
if new_name == folder.name:
|
||||
continue
|
||||
final = new_name
|
||||
if final in used and final != folder.name:
|
||||
i = 2
|
||||
while f"{new_name}-{i}" in used:
|
||||
i += 1
|
||||
final = f"{new_name}-{i}"
|
||||
used.discard(folder.name)
|
||||
used.add(final)
|
||||
renames.append((folder.name, final))
|
||||
return renames
|
||||
|
||||
|
||||
def main() -> None:
|
||||
dry = "--apply" not in sys.argv
|
||||
write_script = "--write-rename-script" in sys.argv
|
||||
rename_only = "--rename-only" in sys.argv
|
||||
script_path = Path(__file__).resolve().parent / "profile_template_renames.ps1"
|
||||
|
||||
if not BASE.is_dir():
|
||||
print(f"Missing base: {BASE}")
|
||||
sys.exit(1)
|
||||
|
||||
if rename_only:
|
||||
remaining = sorted([c for c in BASE.iterdir() if c.is_dir()], key=lambda x: x.name)
|
||||
renames = compute_renames(remaining)
|
||||
write_rename_ps1(renames, script_path)
|
||||
print(f"已写入重命名脚本: {script_path}")
|
||||
print("请在关闭占用该文件夹的程序后,在 PowerShell 中执行:")
|
||||
print(f" powershell -ExecutionPolicy Bypass -File \"{script_path}\"")
|
||||
return
|
||||
|
||||
children = [c for c in BASE.iterdir() if c.is_dir()]
|
||||
to_delete: list[tuple[Path, str, int, int]] = []
|
||||
for child in children:
|
||||
h, p = count_html(child), count_php(child)
|
||||
if h == 0:
|
||||
to_delete.append((child, "no_html", h, p))
|
||||
elif p >= PHP_THRESHOLD:
|
||||
to_delete.append((child, "php_heavy", h, p))
|
||||
|
||||
print("=== 将删除(非静态或无可展示 HTML)===")
|
||||
for path, reason, h, p in sorted(to_delete, key=lambda x: x[0].name):
|
||||
print(f" [{reason}] html={h} php={p} {path.name}")
|
||||
|
||||
if dry:
|
||||
print("\n[DRY RUN] 加参数 --apply 执行删除与重命名\n")
|
||||
|
||||
delete_set = {p for p, _, _, _ in to_delete}
|
||||
|
||||
if not dry:
|
||||
for path, _, _, _ in to_delete:
|
||||
shutil.rmtree(path, ignore_errors=False)
|
||||
print(f"已删除: {path.name}")
|
||||
|
||||
# 重命名:dry-run 时排除即将删除的目录
|
||||
remaining = sorted(
|
||||
[c for c in BASE.iterdir() if c.is_dir() and (dry and c not in delete_set or not dry)],
|
||||
key=lambda x: x.name,
|
||||
)
|
||||
renames = compute_renames(remaining)
|
||||
|
||||
print("=== 计划重命名(按页面 title)===")
|
||||
for old, new in renames:
|
||||
if old != new:
|
||||
print(f" {old}\n -> {new}")
|
||||
|
||||
if dry:
|
||||
if write_script:
|
||||
write_rename_ps1(renames, script_path)
|
||||
print(f"\n已写入重命名脚本: {script_path}")
|
||||
return
|
||||
|
||||
write_rename_ps1(renames, script_path)
|
||||
print(f"\n已写入重命名脚本(若本机重命名失败可手动执行): {script_path}")
|
||||
|
||||
pairs = [(o, n) for o, n in renames if o != n]
|
||||
tag = uuid.uuid4().hex[:8]
|
||||
mids: list[tuple[str, str, str]] = []
|
||||
for i, (old_name, new_name) in enumerate(pairs):
|
||||
mid = f"__tmp_rename_{tag}_{i}__"
|
||||
mids.append((old_name, mid, new_name))
|
||||
|
||||
for old_name, mid, new_name in mids:
|
||||
src = BASE / old_name
|
||||
dst = BASE / mid
|
||||
if not src.is_dir():
|
||||
continue
|
||||
try:
|
||||
src.rename(dst)
|
||||
except OSError as e:
|
||||
print(f"阶段1 重命名失败(可稍后运行脚本): {old_name} -> {mid} {e}")
|
||||
|
||||
for old_name, mid, new_name in mids:
|
||||
src = BASE / mid
|
||||
dst = BASE / new_name
|
||||
if not src.is_dir():
|
||||
continue
|
||||
if dst.exists():
|
||||
print(f"跳过(目标已存在): {mid} -> {new_name}")
|
||||
continue
|
||||
try:
|
||||
src.rename(dst)
|
||||
print(f"重命名: {old_name} -> {new_name}")
|
||||
except OSError as e:
|
||||
print(f"阶段2 重命名失败(可稍后运行脚本): {mid} -> {new_name} {e}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
18
InfoGenie-frontend/scripts/verify-60sapi-paths.js
Normal file
18
InfoGenie-frontend/scripts/verify-60sapi-paths.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { API_ITEM_STATIC_HTML } = require('../src/config/Api60sConfig.js');
|
||||
|
||||
const pub = path.join(__dirname, '../public');
|
||||
const bad = [];
|
||||
for (const [id, p] of Object.entries(API_ITEM_STATIC_HTML)) {
|
||||
const rel = p.replace(/^\//, '');
|
||||
const full = path.join(pub, rel);
|
||||
if (!fs.existsSync(full)) bad.push({ id, p, full });
|
||||
}
|
||||
if (bad.length === 0) {
|
||||
console.log(`全部 ${Object.keys(API_ITEM_STATIC_HTML).length} 个静态路径对应文件均存在`);
|
||||
} else {
|
||||
console.log('缺失文件数:', bad.length);
|
||||
console.log(JSON.stringify(bad, null, 2));
|
||||
}
|
||||
process.exit(bad.length ? 1 : 0);
|
||||
Reference in New Issue
Block a user