当前位置: 首页 > news >正文

将RESP.app的备份数据转码成AnotherRedisDesktopManager的格式

将RESP.app的备份数据转码成AnotherRedisDesktopManager的格式

最近发现了AnotherRedisDesktopManager,这个软件可以直接展示proto数据。

将RESP.app导出的json文件,转码为AnotherRedisDesktopManager的ano文件(是一个list转了base64)
注意:AnotherRedisDesktopManager是没有分组的,这个工具只转了基础的功能,ip、端口、密码、颜色,复杂功能没有处理。

创建一个html文件,复制下面的代码贴进去,打开即可。
在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>redis数据转码</title>
</head>
<body>
<div><h2>redis数据转码</h2><p style="color: #a8a6a6"><a href="https://github.com/uglide/RedisDesktopManager" target="_blank">RESP.app</a>的数据转码成<a href="https://github.com/qishibo/AnotherRedisDesktopManager/" target="_blank">AnotherRedisDesktopManager</a>的格式</p><!--选择RESP.app的json文件--><input type="file" id="file"><br/><br/><button onclick="convert()">转换</button><br/><p id="result" style="color: green"></p><script>function convert() {// 获取文件(utf-8编码)let file = document.getElementById('file').files[0];// 读取文件let reader = new FileReader();reader.readAsText(file);reader.onload = function () {// 解析json(utf-8编码)if (reader.result.startsWith("\ufeff")) {reader.result = reader.result.substring(1);} else {if (reader.result.startsWith("\uFEFF")) {reader.result = reader.result.substring(1);}}let json = JSON.parse(reader.result);// 转换(转换后的格式为AnotherRedisDesktopManager的格式,一个大list)let result = [];for (let i = 0; i < json.length; i++) {//新版加了分组功能,需要判断若是有connections,则为分组,处理里面的连接,否则为连接if (json[i].connections) {for (let j = 0; j < json[i].connections.length; j++) {// 处理连接try {result.push(convertConnection(json[i].connections[j], result.length + 1));} catch (e) {console.log("解析失败", json[i].connections[j]);continue;}}} else {// 处理连接try {result.push(convertConnection(json[i], result.length + 1));} catch (e) {console.log("解析失败", json[i]);continue;}}}// console.log(result);if (result.length == 0) {alert("解析失败,请检查文件格式");return;}//将结果转为base64加密字符串let base64 = safeBtoa(JSON.stringify(result));//结果下载为 connections.ano 文件let link = document.createElement('a');link.href = "data:text/plain;charset=utf-8," + encodeURIComponent(base64);link.download = "connections.ano";link.click();//提示转换成功document.getElementById('result').innerHTML = "转换成功,请下载文件";}}/*** 处理连接,返回AnotherRedisDesktopManager的格式* @param connection*/function convertConnection(connection, order) {// 处理连接let result = {"host": connection.host,"port": connection.port,"auth": !connection.auth ? "" : connection.auth,"username": !connection.username ? "" : connection.username,"name": connection.name,"separator": connection.namespace_separator,"cluster": false,"connectionReadOnly": false,"key": generateKey(),"order": order};if (connection.icon_color) {result.color = connection.icon_color;}return result;}/*** 生成一个随机的key,时间戳_5位随机字符串*/function generateKey() {return Date.now() + "_" + Math.random().toString(36).substring(2, 7);}/*** 安全地将字符串编码为 Base64(支持 Unicode)* @param {string} str - 要编码的字符串* @returns {string} - Base64 编码后的字符串*/function safeBtoa(str) {// 先将Unicode字符转为UTF-8编码的二进制字符串const utf8Str = unescape(encodeURIComponent(str));// 再转为Base64return btoa(utf8Str);}</script>
</div></body>
</html>
http://www.lryc.cn/news/574311.html

相关文章:

  • 越南数学家吴宝珠恶搞式证明朗兰兹纲领
  • 基于SpringBoot + Vue 的网上拍卖系统
  • ESXi 8 相较于 ESXi 7 升级
  • 【C++】哈希表的实现(链地址法)
  • Linux切换中文输入法
  • SpringCloud系列(32)--使用Hystrix进行全局服务降级
  • STM32对接霍尔传感器
  • Vibe Coding - 使用cursor从PRD到TASK精准分解执行
  • 第十六届蓝桥杯C/C++程序设计研究生组国赛 国二
  • Vue按键事件
  • ​​根系杂种优势的分子解码:SPE基因互补与进化可塑性的协同效应​​
  • 电路图识图基础知识-塔式起重机控制电路识图与操作要点(三十五)
  • TestCafe 全解析:免费开源的 E2E 测试解决方案实战指南
  • libwebsockets编译
  • 优化提示词的常用技巧
  • 使用AI开发招聘网站(100天AI编程实验)
  • Matplotlib数据可视化入门:从基础图表到多图展示
  • 【AI 测试】测试用例设计:人工智能语言大模型性能测试用例设计
  • MySQL 慢查询日志与 Binlog 启用与故障排查实录
  • 全链接神经网络,CNN,RNN各自擅长解决什么问题
  • HarmonyOS应用开发——层叠布局
  • Deepoc大模型重构核工业智能基座:混合增强架构与安全增强决策技术​
  • MM-AttacKG:一种使用大型语言模型构建攻击图的多模态方法
  • pyhton基础【15】函数进阶一
  • Robyn高性能Web框架系列04:事件、中间件与错误处理
  • 前端跨域解决方案(7):Node中间件
  • 2025年CCF先进音频技术竞赛
  • Node鼠标键盘屏幕控制
  • 【LLaMA-Factory 实战系列】二、WebUI 篇 - Qwen2.5-VL 多模态模型 LoRA 微调保姆级教程
  • Perl语言基础