debugpanel 调整
This commit is contained in:
parent
f6cb02cb58
commit
70ceda9903
|
|
@ -1,9 +1,5 @@
|
||||||
|
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
height: 100vh;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
|
||||||
justify-content: 'center';
|
|
||||||
align-items: 'center';
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Button, Space, Drawer, DialogPlugin } from 'tdesign-react';
|
import { Button, Space, Drawer, Modal, Tooltip } from 'antd';
|
||||||
import { ChevronUpIcon } from 'tdesign-icons-react';
|
import { UpOutlined } from '@ant-design/icons';
|
||||||
// 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;
|
||||||
|
|
@ -9,14 +8,14 @@ export default function render(this: any) {
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<Button
|
<Button
|
||||||
variant="text"
|
type="text"
|
||||||
shape="circle"
|
shape="circle"
|
||||||
theme="primary"
|
icon={<UpOutlined style={{ fontSize: 16 }} />}
|
||||||
icon={<ChevronUpIcon />}
|
|
||||||
style={{
|
style={{
|
||||||
position: 'fixed',
|
position: 'fixed',
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
right: '45vw',
|
right: '45vw',
|
||||||
|
zIndex: 999,
|
||||||
...style,
|
...style,
|
||||||
}}
|
}}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|
@ -30,110 +29,137 @@ export default function render(this: any) {
|
||||||
onClose={() => {
|
onClose={() => {
|
||||||
this.setVisible(false);
|
this.setVisible(false);
|
||||||
}}
|
}}
|
||||||
header="Debug控制台"
|
title="Debug控制台"
|
||||||
footer={<></>}
|
footer={<></>}
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
type="file"
|
type="file"
|
||||||
accept='application/json'
|
accept="application/json"
|
||||||
hidden
|
hidden
|
||||||
id="upload"
|
id="upload"
|
||||||
onChange={()=>{
|
onChange={() => {
|
||||||
const that = this;
|
const that = this;
|
||||||
const file = (document.getElementById('upload') as any).files[0];
|
const file = (document.getElementById('upload') as any)
|
||||||
|
.files[0];
|
||||||
if (typeof FileReader === undefined) {
|
if (typeof FileReader === undefined) {
|
||||||
alert('浏览器版本太老了');
|
alert('浏览器版本太老了');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.readAsText(file);
|
reader.readAsText(file);
|
||||||
reader.onload = function() {
|
reader.onload = function () {
|
||||||
try {
|
try {
|
||||||
const data = JSON.parse(this.result as string);
|
const data = JSON.parse(
|
||||||
|
this.result as string
|
||||||
|
);
|
||||||
that.features.localStorage.resetAll(data);
|
that.features.localStorage.resetAll(data);
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
} catch (err) {
|
||||||
catch(err) {
|
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Space breakLine={true} direction="horizontal" size="medium">
|
<Space wrap={true}>
|
||||||
<Button
|
<Tooltip title="页面结构">
|
||||||
theme="primary"
|
<Button
|
||||||
shape="circle"
|
size="large"
|
||||||
onClick={() => this.printRunningTree()}
|
type="primary"
|
||||||
>
|
shape="circle"
|
||||||
R
|
onClick={() => this.printRunningTree()}
|
||||||
</Button>
|
>
|
||||||
<Button
|
R
|
||||||
theme="primary"
|
</Button>
|
||||||
shape="circle"
|
</Tooltip>
|
||||||
onClick={() => this.printDebugStore()}
|
<Tooltip title="Store数据">
|
||||||
>
|
<Button
|
||||||
S
|
size="large"
|
||||||
</Button>
|
type="primary"
|
||||||
<Button
|
shape="circle"
|
||||||
theme="primary"
|
onClick={() => this.printDebugStore()}
|
||||||
shape="circle"
|
>
|
||||||
onClick={() => this.printCachedStore()}
|
S
|
||||||
>
|
</Button>
|
||||||
C
|
</Tooltip>
|
||||||
</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';
|
<Tooltip title="页面缓存">
|
||||||
document.body.appendChild(element);
|
<Button
|
||||||
|
size="large"
|
||||||
|
type="primary"
|
||||||
|
shape="circle"
|
||||||
|
onClick={() => this.printCachedStore()}
|
||||||
|
>
|
||||||
|
C
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
|
<Tooltip title="下载Store">
|
||||||
|
<Button
|
||||||
|
size="large"
|
||||||
|
type="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.click();
|
element.style.display = 'none';
|
||||||
|
document.body.appendChild(element);
|
||||||
|
|
||||||
document.body.removeChild(element);
|
element.click();
|
||||||
}}
|
|
||||||
>
|
|
||||||
D
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Button
|
document.body.removeChild(element);
|
||||||
theme="primary"
|
}}
|
||||||
shape="circle"
|
>
|
||||||
onClick={() => {
|
D
|
||||||
const element = document.getElementById('upload');
|
</Button>
|
||||||
element!.click();
|
</Tooltip>
|
||||||
}}
|
|
||||||
>
|
<Tooltip title="上传Store">
|
||||||
U
|
<Button
|
||||||
</Button>
|
size="large"
|
||||||
<Button
|
type="primary"
|
||||||
theme="warning"
|
shape="circle"
|
||||||
shape="circle"
|
onClick={() => {
|
||||||
onClick={() => {
|
const element =
|
||||||
const confirmDia = DialogPlugin.confirm!({
|
document.getElementById('upload');
|
||||||
header: '重置数据',
|
element!.click();
|
||||||
body: '重置后,原来的数据不可恢复',
|
}}
|
||||||
confirmBtn: '确定',
|
>
|
||||||
cancelBtn: '取消',
|
U
|
||||||
onConfirm: ({ e }) => {
|
</Button>
|
||||||
this.resetInitialData();
|
</Tooltip>
|
||||||
confirmDia.hide!();
|
<Tooltip title="重置Store">
|
||||||
window.location.reload();
|
<Button
|
||||||
},
|
size="large"
|
||||||
onClose: ({ e, trigger }) => {
|
type="primary"
|
||||||
confirmDia.hide!();
|
danger
|
||||||
},
|
shape="circle"
|
||||||
});
|
onClick={() => {
|
||||||
}}
|
const modal = Modal.confirm!({
|
||||||
>
|
title: '重置数据',
|
||||||
Reset
|
content: '重置后,原来的数据不可恢复',
|
||||||
</Button>
|
okText: '确定',
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk: (e) => {
|
||||||
|
this.resetInitialData();
|
||||||
|
modal.destroy!();
|
||||||
|
window.location.reload();
|
||||||
|
},
|
||||||
|
onCancel: (e) => {
|
||||||
|
modal.destroy!();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Reset
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
</Space>
|
</Space>
|
||||||
</Drawer>
|
</Drawer>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue