iTab标签页转换Halo工具箱
1. 使用iTab浏览器标签页
官网:iTab新标签页
导出本地数据
2. 环境准备
Idea,fastjson2
3. 执行代码,读取备份文件
package top.sp817.blogTools;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
/**
* iTab 标签页生成Halo工具箱
*
* @author 葡萄w by sp817.top
* @since 2025-03-28 09:18:34
*/
public class calcTools {
public static final String header = "<div class=\"author-content author-content-item essayPage single\"\n" +
" style=\"background:url(https://sp817.top/upload/tools_back.png) left 28% / cover no-repeat !important;\">\n" +
" <div class=\"card-content\">\n" +
" <div class=\"author-content-item-tips\">效率</div>\n" +
" <span class=\"author-content-item-title\">推荐网址</span>\n" +
" <div class=\"content-bottom\">\n" +
" <div class=\"tips\">跟 葡萄w 一起高效create code</div>\n" +
" </div>\n" +
" </div>\n" +
"</div>";
public static String getPrefix(String name) {
return "<hao-flink name=\""+ name +"\" style=\"default\"><div class=\"_tpl\">\n";
}
public static final String suffix = "\n</div></hao-flink>";
public static final String nl = "\n";
public static final String comma = ",";
public static void main(String[] args) {
String filePath = "./Analysis/files/iTab备份-2025-03-28 03_09.itabdata";
String tmp;
try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {
StringBuilder content = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
content.append(line).append("\n");
}
tmp = content.toString();
} catch (IOException e) {
e.printStackTrace();
return;
}
StringBuilder result = new StringBuilder();
result.append(header);
result.append(nl);
JSONArray value = JSON.parseObject(tmp).getJSONArray("navConfig");
for (int i = 0; i < value.size(); i++) {
JSONObject node = value.getJSONObject(i);
String name = node.getString("name");
if("系统内容".equals(name)) continue;
JSONArray children = node.getJSONArray("children");
result.append(getPrefix(name));
for (int j = 0; j < children.size(); j++) {
JSONObject child = children.getJSONObject(j);
String title = child.getString("name");
String type = child.getString("type");
String id = child.getString("id");
if("icon".equals(type)) {
String src = child.getString("src");
String url = child.getString("url");
result.append(nl)
.append("{")
.append(title)
.append(comma)
.append(url)
.append(comma)
.append(src)
.append(comma)
.append(id)
.append("}");
}
}
result.append(nl);
result.append(suffix);
result.append(nl);
result.append(nl);
result.append(nl);
}
System.out.println(result);
}
}
4. 保存到您的Halo
- 感谢你赐予我前进的力量
赞赏者名单
因为你们的支持让我意识到写文章的价值🙏
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 葡萄w
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果