mirror of
https://github.com/whyour/qinglong.git
synced 2025-06-02 23:36:07 +08:00
环境变量增加导出功能
This commit is contained in:
parent
93c69826ad
commit
3a62cc37ff
16
src/pages/env/index.tsx
vendored
16
src/pages/env/index.tsx
vendored
|
@ -25,7 +25,7 @@ import EditNameModal from './editNameModal';
|
||||||
import { DndProvider, useDrag, useDrop } from 'react-dnd';
|
import { DndProvider, useDrag, useDrop } from 'react-dnd';
|
||||||
import { HTML5Backend } from 'react-dnd-html5-backend';
|
import { HTML5Backend } from 'react-dnd-html5-backend';
|
||||||
import './index.less';
|
import './index.less';
|
||||||
import { getTableScroll } from '@/utils/index';
|
import { exportJson, getTableScroll } from '@/utils/index';
|
||||||
|
|
||||||
const { Text, Paragraph } = Typography;
|
const { Text, Paragraph } = Typography;
|
||||||
const { Search } = Input;
|
const { Search } = Input;
|
||||||
|
@ -462,6 +462,13 @@ const Env = ({ headerStyle, isPhone, theme }: any) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const exportEnvs = () => {
|
||||||
|
const envs = value
|
||||||
|
.filter((x) => selectedRowIds.includes(x.id))
|
||||||
|
.map((x) => ({ value: x.value, name: x.name, remarks: x.remarks }));
|
||||||
|
exportJson('env.json', JSON.stringify(envs));
|
||||||
|
};
|
||||||
|
|
||||||
const modifyName = () => {
|
const modifyName = () => {
|
||||||
setIsEditNameModalVisible(true);
|
setIsEditNameModalVisible(true);
|
||||||
};
|
};
|
||||||
|
@ -516,6 +523,13 @@ const Env = ({ headerStyle, isPhone, theme }: any) => {
|
||||||
>
|
>
|
||||||
批量删除
|
批量删除
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
onClick={() => exportEnvs()}
|
||||||
|
style={{ marginLeft: 8, marginRight: 8 }}
|
||||||
|
>
|
||||||
|
批量导出
|
||||||
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
onClick={() => operateEnvs(0)}
|
onClick={() => operateEnvs(0)}
|
||||||
|
|
|
@ -205,3 +205,39 @@ export function getTableScroll({
|
||||||
let height = document.body.clientHeight - mainTop - extraHeight;
|
let height = document.body.clientHeight - mainTop - extraHeight;
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 自动触发点击事件
|
||||||
|
function automaticClick(elment: HTMLElement) {
|
||||||
|
const ev = document.createEvent('MouseEvents');
|
||||||
|
ev.initMouseEvent(
|
||||||
|
'click',
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
window,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
0,
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
elment.dispatchEvent(ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导出文件
|
||||||
|
export function exportJson(name: string, data: string) {
|
||||||
|
const urlObject = window.URL || window.webkitURL || window;
|
||||||
|
const export_blob = new Blob([data]);
|
||||||
|
const createA = document.createElementNS(
|
||||||
|
'http://www.w3.org/1999/xhtml',
|
||||||
|
'a',
|
||||||
|
) as any;
|
||||||
|
createA.href = urlObject.createObjectURL(export_blob);
|
||||||
|
createA.download = name;
|
||||||
|
automaticClick(createA);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user