debugPanel增加了download和upload的能力
This commit is contained in:
parent
09033ce0ca
commit
55a278989d
|
|
@ -56,5 +56,10 @@ exports.default = OakComponent({
|
||||||
dialogVisible: false,
|
dialogVisible: false,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
downloadEnv: function () {
|
||||||
|
var data = this.features.localStorage.loadAll();
|
||||||
|
},
|
||||||
|
uploadEnv: function () {
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -5,31 +5,64 @@ var jsx_runtime_1 = require("react/jsx-runtime");
|
||||||
var react_1 = tslib_1.__importDefault(require("react"));
|
var react_1 = tslib_1.__importDefault(require("react"));
|
||||||
var tdesign_react_1 = require("tdesign-react");
|
var tdesign_react_1 = require("tdesign-react");
|
||||||
var tdesign_icons_react_1 = require("tdesign-icons-react");
|
var tdesign_icons_react_1 = require("tdesign-icons-react");
|
||||||
|
// import { saveAs } from 'file-saver';
|
||||||
function render() {
|
function render() {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var _a = this.props, _b = _a.placement, placement = _b === void 0 ? 'bottom' : _b, _c = _a.style, style = _c === void 0 ? {} : _c;
|
var _a = this.props, _b = _a.placement, placement = _b === void 0 ? 'bottom' : _b, _c = _a.style, style = _c === void 0 ? {} : _c;
|
||||||
var visible = this.state.visible;
|
var visible = this.state.visible;
|
||||||
return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(tdesign_react_1.Button, { variant: "text", shape: "circle", theme: "primary", icon: (0, jsx_runtime_1.jsx)(tdesign_icons_react_1.ChevronUpIcon, {}), style: tslib_1.__assign({ position: 'fixed', bottom: 0, right: '45vw' }, style), onClick: function () {
|
return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(tdesign_react_1.Button, { variant: "text", shape: "circle", theme: "primary", icon: (0, jsx_runtime_1.jsx)(tdesign_icons_react_1.ChevronUpIcon, {}), style: tslib_1.__assign({ position: 'fixed', bottom: 0, right: '45vw' }, style), onClick: function () {
|
||||||
_this.setVisible(true);
|
_this.setVisible(true);
|
||||||
} }), (0, jsx_runtime_1.jsx)(tdesign_react_1.Drawer, tslib_1.__assign({ placement: placement, visible: visible, onClose: function () {
|
} }), (0, jsx_runtime_1.jsxs)(tdesign_react_1.Drawer, tslib_1.__assign({ placement: placement, visible: visible, onClose: function () {
|
||||||
_this.setVisible(false);
|
_this.setVisible(false);
|
||||||
}, header: "Debug\u63A7\u5236\u53F0", footer: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}) }, { children: (0, jsx_runtime_1.jsxs)(tdesign_react_1.Space, tslib_1.__assign({ breakLine: true, direction: "horizontal", size: "medium" }, { children: [(0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ theme: "primary", shape: "circle", onClick: function () { return _this.printRunningTree(); } }, { children: "R" })), (0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ theme: "primary", shape: "circle", onClick: function () { return _this.printDebugStore(); } }, { children: "S" })), (0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ theme: "primary", shape: "circle", onClick: function () { return _this.printCachedStore(); } }, { children: "C" })), (0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ theme: "warning", shape: "circle", onClick: function () {
|
}, header: "Debug\u63A7\u5236\u53F0", footer: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}) }, { children: [(0, jsx_runtime_1.jsx)("input", { type: "file", accept: 'application/json', hidden: true, id: "upload", onChange: function () {
|
||||||
var confirmDia = tdesign_react_1.DialogPlugin.confirm({
|
var that = _this;
|
||||||
header: '重置数据',
|
var file = document.getElementById('upload').files[0];
|
||||||
body: '重置后,原来的数据不可恢复',
|
if (typeof FileReader === undefined) {
|
||||||
confirmBtn: '确定',
|
alert('浏览器版本太老了');
|
||||||
cancelBtn: '取消',
|
}
|
||||||
onConfirm: function (_a) {
|
else {
|
||||||
var e = _a.e;
|
var reader = new FileReader();
|
||||||
_this.resetInitialData();
|
reader.readAsText(file);
|
||||||
confirmDia.hide();
|
reader.onload = function () {
|
||||||
|
try {
|
||||||
|
var data = JSON.parse(this.result);
|
||||||
|
that.features.localStorage.resetAll(data);
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
},
|
}
|
||||||
onClose: function (_a) {
|
catch (err) {
|
||||||
var e = _a.e, trigger = _a.trigger;
|
console.error(err);
|
||||||
confirmDia.hide();
|
}
|
||||||
},
|
};
|
||||||
});
|
}
|
||||||
} }, { children: "Reset" }))] })) }))] }));
|
} }), (0, jsx_runtime_1.jsxs)(tdesign_react_1.Space, tslib_1.__assign({ breakLine: true, direction: "horizontal", size: "medium" }, { children: [(0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ theme: "primary", shape: "circle", onClick: function () { return _this.printRunningTree(); } }, { children: "R" })), (0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ theme: "primary", shape: "circle", onClick: function () { return _this.printDebugStore(); } }, { children: "S" })), (0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ theme: "primary", shape: "circle", onClick: function () { return _this.printCachedStore(); } }, { children: "C" })), (0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ theme: "primary", shape: "circle", onClick: function () {
|
||||||
|
var data = _this.features.localStorage.loadAll();
|
||||||
|
var element = document.createElement('a');
|
||||||
|
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(data)));
|
||||||
|
element.setAttribute('download', 'data.json');
|
||||||
|
element.style.display = 'none';
|
||||||
|
document.body.appendChild(element);
|
||||||
|
element.click();
|
||||||
|
document.body.removeChild(element);
|
||||||
|
} }, { children: "D" })), (0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ theme: "primary", shape: "circle", onClick: function () {
|
||||||
|
var element = document.getElementById('upload');
|
||||||
|
element.click();
|
||||||
|
} }, { children: "U" })), (0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ theme: "warning", shape: "circle", onClick: function () {
|
||||||
|
var confirmDia = tdesign_react_1.DialogPlugin.confirm({
|
||||||
|
header: '重置数据',
|
||||||
|
body: '重置后,原来的数据不可恢复',
|
||||||
|
confirmBtn: '确定',
|
||||||
|
cancelBtn: '取消',
|
||||||
|
onConfirm: function (_a) {
|
||||||
|
var e = _a.e;
|
||||||
|
_this.resetInitialData();
|
||||||
|
confirmDia.hide();
|
||||||
|
window.location.reload();
|
||||||
|
},
|
||||||
|
onClose: function (_a) {
|
||||||
|
var e = _a.e, trigger = _a.trigger;
|
||||||
|
confirmDia.hide();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} }, { children: "Reset" }))] }))] }))] }));
|
||||||
}
|
}
|
||||||
exports.default = render;
|
exports.default = render;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
{
|
{
|
||||||
"waiting": "等待中",
|
"waiting": "等待中",
|
||||||
"success": "上传成功",
|
"success": "上传成功"
|
||||||
}
|
}
|
||||||
|
|
@ -58,5 +58,12 @@ export default OakComponent({
|
||||||
dialogVisible: false,
|
dialogVisible: false,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
downloadEnv() {
|
||||||
|
const data = this.features.localStorage.loadAll();
|
||||||
|
|
||||||
|
},
|
||||||
|
uploadEnv() {
|
||||||
|
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Button, Space, Drawer, DialogPlugin } from 'tdesign-react';
|
import { Button, Space, Drawer, DialogPlugin } from 'tdesign-react';
|
||||||
import { ChevronUpIcon } from 'tdesign-icons-react';
|
import { ChevronUpIcon } from 'tdesign-icons-react';
|
||||||
|
// import { saveAs } from 'file-saver';
|
||||||
|
|
||||||
export default function render(this: any) {
|
export default function render(this: any) {
|
||||||
const { placement = 'bottom', style = {} } = this.props;
|
const { placement = 'bottom', style = {} } = this.props;
|
||||||
|
|
@ -32,6 +33,33 @@ export default function render(this: any) {
|
||||||
header="Debug控制台"
|
header="Debug控制台"
|
||||||
footer={<></>}
|
footer={<></>}
|
||||||
>
|
>
|
||||||
|
<input
|
||||||
|
type="file"
|
||||||
|
accept='application/json'
|
||||||
|
hidden
|
||||||
|
id="upload"
|
||||||
|
onChange={()=>{
|
||||||
|
const that = this;
|
||||||
|
const file = (document.getElementById('upload') as any).files[0];
|
||||||
|
if (typeof FileReader === undefined) {
|
||||||
|
alert('浏览器版本太老了');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.readAsText(file);
|
||||||
|
reader.onload = function() {
|
||||||
|
try {
|
||||||
|
const data = JSON.parse(this.result as string);
|
||||||
|
that.features.localStorage.resetAll(data);
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
catch(err) {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<Space breakLine={true} direction="horizontal" size="medium">
|
<Space breakLine={true} direction="horizontal" size="medium">
|
||||||
<Button
|
<Button
|
||||||
theme="primary"
|
theme="primary"
|
||||||
|
|
@ -54,6 +82,36 @@ export default function render(this: any) {
|
||||||
>
|
>
|
||||||
C
|
C
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button
|
||||||
|
theme="primary"
|
||||||
|
shape="circle"
|
||||||
|
onClick={() => {
|
||||||
|
const data = this.features.localStorage.loadAll();
|
||||||
|
const element = document.createElement('a');
|
||||||
|
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(data)));
|
||||||
|
element.setAttribute('download', 'data.json');
|
||||||
|
|
||||||
|
element.style.display = 'none';
|
||||||
|
document.body.appendChild(element);
|
||||||
|
|
||||||
|
element.click();
|
||||||
|
|
||||||
|
document.body.removeChild(element);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
D
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
theme="primary"
|
||||||
|
shape="circle"
|
||||||
|
onClick={() => {
|
||||||
|
const element = document.getElementById('upload');
|
||||||
|
element!.click();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
U
|
||||||
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
theme="warning"
|
theme="warning"
|
||||||
shape="circle"
|
shape="circle"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue