mirror of
https://github.com/qishibo/AnotherRedisDesktopManager.git
synced 2026-01-18 16:12:43 +00:00
81 lines
1.8 KiB
HTML
81 lines
1.8 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>NodeRedis</title>
|
|
</head>
|
|
<body>
|
|
|
|
<select id="operation">
|
|
<option value="get">get</option>
|
|
<option value="set">set</option>
|
|
<option value="del">del</option>
|
|
</select><br>
|
|
|
|
<input id="key" placeholder='key' value="name">
|
|
<input id="value" placeholder='value' value="value">
|
|
|
|
<textarea id="result"></textarea>
|
|
|
|
<button id="sub-btn">submit</button>
|
|
</body>
|
|
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
|
|
<script type="text/javascript">
|
|
|
|
|
|
|
|
var qii404 = {
|
|
|
|
redis: null,
|
|
|
|
init: function() {
|
|
this.redis = this.getRedis('10.20.1.133', 6379);
|
|
this.bindAction();
|
|
},
|
|
|
|
exec: function(operation, key, params, callback) {
|
|
// getAsync('name').then(function(res) {
|
|
// alert(res); // => 'bar'
|
|
// });
|
|
// return;
|
|
|
|
|
|
this.redis[operation + 'Async'](key).then(callback);
|
|
},
|
|
|
|
getRedis: function(host, port, auth) {
|
|
const redis = require('redis');
|
|
const bluebird = require('bluebird');
|
|
|
|
bluebird.promisifyAll(redis);
|
|
var client = redis.createClient(port, host);
|
|
|
|
client.on("error", function (err) {
|
|
alert(err);
|
|
return false;
|
|
});
|
|
|
|
return client;
|
|
},
|
|
|
|
bindAction: function() {
|
|
var that = this;
|
|
|
|
$('#sub-btn').click(function () {
|
|
var key = $('#key').val();
|
|
var operation = $('#operation').val();
|
|
|
|
that.exec(operation, key, '', (reply) => {
|
|
$('#result').val(reply);
|
|
});
|
|
});
|
|
}
|
|
};
|
|
|
|
qii404.init();
|
|
|
|
|
|
|
|
</script>
|
|
</html>
|