Skip to content

Commit

Permalink
[optimization] add table refresh logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiram committed Jul 21, 2024
1 parent 107292e commit 836cad9
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 6 deletions.
34 changes: 33 additions & 1 deletion src/renderer/src/pages/setting/analyze/AnalyzeSetting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
import _ from 'lodash';
import { AddIcon, CheckIcon, DiscountIcon, PoweroffIcon, RemoveIcon, SearchIcon } from 'tdesign-icons-vue-next';
import { MessagePlugin } from 'tdesign-vue-next';
import { onMounted, ref, reactive, watch } from 'vue';
import { onActivated, onMounted, ref, reactive, watch } from 'vue';
import { t } from '@/locales';
import { fetchAnalyzePage, updateAnalyzeItem, updateAnalyzeStatus, delAnalyzeItem } from '@/api/analyze';
Expand Down Expand Up @@ -141,6 +141,38 @@ onMounted(() => {
getData();
});
onActivated(() => {
const isListenedRefreshTableData = emitter.all.get('refreshAnalyzeTable');
if (!isListenedRefreshTableData) emitter.on('refreshAnalyzeTable', refreshTable);
});
const defaultSet = () => {
pagination.defaultPageSize = 20;
pagination.total = 0;
pagination.defaultCurrent = 1;
pagination.pageSize = 20;
pagination.current = 1;
analyzeTableConfig.value = {
data: [],
rawData: [],
sort: {},
filter: {
type: [],
},
select: [],
default: '',
group: [],
flag: []
};
};
const refreshTable = () => {
console.log('[analyzeSetting][bus][refresh]');
defaultSet();
getData();
};
const refreshEvent = (page = false) => {
getData();
if (page) pagination.current = 1;
Expand Down
8 changes: 8 additions & 0 deletions src/renderer/src/pages/setting/base/components/DialogData.vue
Original file line number Diff line number Diff line change
Expand Up @@ -273,18 +273,22 @@ const refreshEmitter = (arryList: string[]) => {
const actions = {
site: () => {
emitter.emit('refreshFilmConfig');
emitter.emit('refreshSiteTable');
},
iptv: () => {
emitter.emit('refreshIptvConfig');
emitter.emit('refreshIptvTable');
},
channel: () => {
emitter.emit('refreshIptvConfig');
},
analyze: () => {
emitter.emit('refreshAnalyzeConfig');
emitter.emit('refreshAnalyzeTable');
},
drive: () => {
emitter.emit('refreshDriveConfig');
emitter.emit('refreshDriveTable');
},
history: () => {
emitter.emit('refreshHistory');
Expand Down Expand Up @@ -712,10 +716,12 @@ const clearData = async () => {
'site': async () => {
await setDefault('defaultSite', null);
emitter.emit('refreshFilmConfig');
emitter.emit('refreshSiteTable');
},
'iptv': async () => {
await setDefault('defaultIptv', null);
emitter.emit('refreshIptvConfig');
emitter.emit('refreshIptvTable');
},
'channel': async () => {
await setDefault('defaultIptv', null);
Expand All @@ -724,10 +730,12 @@ const clearData = async () => {
'analyze': async () => {
await setDefault('defaultAnalyze', null);
emitter.emit('refreshAnalyzeConfig');
emitter.emit('refreshAnalyzeTable');
},
'drive': async () => {
await setDefault('defaultDrive', null);
emitter.emit('refreshDriveConfig');
emitter.emit('refreshDriveTable');
},
'history': () => {
emitter.emit('refreshHistory');
Expand Down
32 changes: 31 additions & 1 deletion src/renderer/src/pages/setting/drive/DriveSetting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
import _ from 'lodash';
import { AddIcon, CheckIcon, PoweroffIcon, RemoveIcon, SearchIcon } from 'tdesign-icons-vue-next';
import { MessagePlugin } from 'tdesign-vue-next';
import { onMounted, ref, reactive, watch } from 'vue';
import { onActivated, onMounted, ref, reactive, watch } from 'vue';
import { t } from '@/locales';
import { fetchDrivePage, updateDriveItem, updateDriveStatus, delDriveItem } from '@/api/drive';
Expand Down Expand Up @@ -159,6 +159,36 @@ onMounted(() => {
getData();
});
onActivated(() => {
const isListenedRefreshTableData = emitter.all.get('refreshDriveTable');
if (!isListenedRefreshTableData) emitter.on('refreshDriveTable', refreshTable);
});
const defaultSet = () => {
pagination.defaultPageSize = 20;
pagination.total = 0;
pagination.defaultCurrent = 1;
pagination.pageSize = 20;
pagination.current = 1;
driveTableConfig.value = {
data: [],
rawData: [],
sort: {},
filter: {
type: [],
},
select: [],
default: ''
};
};
const refreshTable = () => {
console.log('[driveSetting][bus][refresh]');
defaultSet();
getData();
};
const refreshEvent = (page = false) => {
getData();
if (page) pagination.current = 1;
Expand Down
33 changes: 31 additions & 2 deletions src/renderer/src/pages/setting/iptv/IptvSetting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
import _ from 'lodash';
import { AddIcon, CheckIcon, PoweroffIcon, RemoveIcon, SearchIcon } from 'tdesign-icons-vue-next';
import { MessagePlugin } from 'tdesign-vue-next';
import { onMounted, ref, reactive, watch } from 'vue';
import { onActivated, onMounted, ref, reactive, watch } from 'vue';
import { t } from '@/locales';
import { fetchIptvPage, updateIptvItem, updateIptvStatus, delIptvItem, addChannel, clearChannel } from '@/api/iptv';
Expand Down Expand Up @@ -139,7 +139,6 @@ const rehandleSortChange = (sortVal, options) => {
iptvTableConfig.value.data = options.currentDataSource;
};
const request = (filters) => {
const timer = setTimeout(() => {
clearTimeout(timer);
Expand Down Expand Up @@ -188,6 +187,36 @@ onMounted(() => {
getData();
});
onActivated(() => {
const isListenedRefreshTableData = emitter.all.get('refreshIptvTable');
if (!isListenedRefreshTableData) emitter.on('refreshIptvTable', refreshTable);
});
const defaultSet = () => {
pagination.defaultPageSize = 20;
pagination.total = 0;
pagination.defaultCurrent = 1;
pagination.pageSize = 20;
pagination.current = 1;
iptvTableConfig.value = {
data: [],
rawData: [],
sort: {},
filter: {
type: [],
},
select: [],
default: ''
};
};
const refreshTable = () => {
console.log('[iptvSetting][bus][refresh]');
defaultSet();
getData();
};
const refreshEvent = (page = false) => {
getData();
if (page) pagination.current = 1;
Expand Down
36 changes: 34 additions & 2 deletions src/renderer/src/pages/setting/site/SiteSetting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ import _ from 'lodash';
import PQueue from 'p-queue';
import { AddIcon, CheckIcon, PoweroffIcon, RefreshIcon, RemoveIcon, SearchIcon } from 'tdesign-icons-vue-next';
import { MessagePlugin } from 'tdesign-vue-next';
import { onMounted, ref, reactive, watch } from 'vue';
import { onActivated, onMounted, ref, reactive, watch } from 'vue';
import { t } from '@/locales';
import { setDefault } from '@/api/setting';
Expand Down Expand Up @@ -146,7 +146,7 @@ watch(
() => siteTableConfig.value.rawData,
(_, oldValue) => {
if (oldValue.length > 0) {
emitter.emit('refreshFilmConfig',111);
emitter.emit('refreshFilmConfig', 111);
}
}, {
deep: true
Expand Down Expand Up @@ -188,6 +188,38 @@ onMounted(() => {
getGroup();
});
onActivated(() => {
const isListenedRefreshTableData = emitter.all.get('refreshSiteTable');
if (!isListenedRefreshTableData) emitter.on('refreshSiteTable', refreshTable);
});
const defaultSet = () => {
pagination.defaultPageSize = 20;
pagination.total = 0;
pagination.defaultCurrent = 1;
pagination.pageSize = 20;
pagination.current = 1;
siteTableConfig.value = {
data: [],
rawData: [],
sort: {},
filter: {
type: [],
},
select: [],
default: '',
group: []
};
};
const refreshTable = () => {
console.log('[siteSetting][bus][refresh]');
defaultSet();
getData();
getGroup();
};
const refreshEvent = (page = false) => {
getData();
getGroup();
Expand Down

0 comments on commit 836cad9

Please sign in to comment.