mirror of
https://github.com/XZB-1248/Spark
synced 2025-09-26 20:21:11 +08:00
update: overview column state persistence
This commit is contained in:
@@ -27,7 +27,6 @@ function overview(props) {
|
||||
const [terminal, setTerminal] = useState(false);
|
||||
const [screenBlob, setScreenBlob] = useState('');
|
||||
const [dataSource, setDataSource] = useState([]);
|
||||
const [columnsState, setColumnsState] = useState(getInitColumnsState());
|
||||
|
||||
const columns = [
|
||||
{
|
||||
@@ -179,26 +178,6 @@ function overview(props) {
|
||||
}
|
||||
}, [execute, desktop, procMgr, explorer, generate, terminal]);
|
||||
|
||||
function getInitColumnsState() {
|
||||
let data = localStorage.getItem(`columnsState`);
|
||||
if (data !== null) {
|
||||
let stateMap = {};
|
||||
try {
|
||||
stateMap = JSON.parse(data);
|
||||
} catch (e) {
|
||||
stateMap = {};
|
||||
}
|
||||
return stateMap
|
||||
} else {
|
||||
localStorage.setItem(`columnsState`, JSON.stringify({}));
|
||||
return {};
|
||||
}
|
||||
}
|
||||
function saveColumnsState(stateMap) {
|
||||
setColumnsState(stateMap);
|
||||
localStorage.setItem(`columnsState`, JSON.stringify(stateMap));
|
||||
}
|
||||
|
||||
function renderCPUStat(cpu) {
|
||||
let { model, usage, cores } = cpu;
|
||||
usage = Math.round(usage * 100) / 100;
|
||||
@@ -459,8 +438,8 @@ function overview(props) {
|
||||
options={options}
|
||||
columns={columns}
|
||||
columnsState={{
|
||||
value: columnsState,
|
||||
onChange: saveColumnsState
|
||||
persistenceKey: 'columnsState',
|
||||
persistenceType: 'localStorage'
|
||||
}}
|
||||
onLoadingChange={setLoading}
|
||||
loading={loading}
|
||||
|
Reference in New Issue
Block a user