feat: Performance API done.

This commit is contained in:
chiayin
2024-01-26 10:38:42 +08:00
parent 8ebfb151c7
commit 329e1035ad
4 changed files with 77 additions and 4 deletions

39
src/stores/performance.js Normal file
View File

@@ -0,0 +1,39 @@
import { defineStore } from "pinia";
// import moment from "moment";
// import { Decimal } from 'decimal.js';
// import abbreviateNumber from '@/module/abbreviateNumber.js';
import apiError from '@/module/apiError.js';
export default defineStore('performanceStore', {
state: () => ({
allPerformanceData: null,
}),
getters: {
performanceData: state => {
return state.allPerformanceData;
},
},
actions: {
/**
* Get Performance
*/
async getPerformance(type, id) {
let api = '';
switch (type) {
case 'log':
api = `/api/logs/${id}/performance`;
break;
case 'filter':
api = `/api/filters/${id}/performance`;
break;
}
try {
const response = await this.$axios.get(api);
this.allPerformanceData = response.data;
} catch(error) {
apiError(error, 'Failed to load the Performance.');
}
}
},
})