当前位置: 首页 > 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.lqws.cn/news/496351.html

相关文章:

  • react gsap动画库使用详解之text文本动画
  • 山洪灾害智能监测站系统解决方案
  • 通过apache共享文件
  • 渗透测试指南(CSMSF):Windows 与 Linux 系统中的日志与文件痕迹清理
  • XSD是什么,与XML关系
  • D2554探鸽协议,sensor属性,回调
  • 关于 pdd:anti_content参数分析与逆向
  • 前端面试记录
  • Flask框架index.html里引用的本地的js和css或者图片
  • C#采集电脑硬件(CPU、GPU、硬盘、内存等)温度和使用状况
  • 深入理解PHP中的生成器(Generators)
  • 新高考需求之一
  • 【GNSS定位算法】Chapter.2 导航定位算法软件学习——Ginav(二)SPP算法 [2025年6月]
  • 系统规划与管理师(第2版)第9章思维导图发布
  • Java面试核心考点复习指南
  • 智能交通中的深度学习应用:从理论到实践
  • 深入解析 Windows 文件查找命令(dir、gci)
  • 在cursor中,配置jdk和maven环境,安装拓展插件
  • AngularJS
  • 【笔记】在Cygwin上使用mintty连接wsl
  • 【软考高级系统架构论文】论企业集成架构设计及应用
  • 海拔案例分享-门店业绩管理小程序
  • 【ARM 嵌入式 编译系列 7.4 -- GCC 链接脚本中 ASSERT 函数】
  • 如何利用Charles抓包工具提升API调试与性能优化
  • QT6(46)5.2 QStringListModel 和 QListView :列表的模型与视图的界面搭建与源代码实现
  • Netty内存池分层设计架构
  • 本地文件深度交互新玩法:Obsidian Copilot的深度开发
  • 【streamlit 组件样式定位与修改】
  • 数字孪生:为UI前端设计带来沉浸式交互新体验
  • 【2025CVPR】基于脉冲神经网络的能效目标检测模型:Multi-scale Spiking Detector(MSD)深度解析