Convert all store files from JavaScript to TypeScript
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
import { defineStore } from "pinia";
|
||||
import apiClient from "@/api/client.js";
|
||||
import apiError from '@/module/apiError.js';
|
||||
|
||||
export const usePerformanceStore = defineStore('performanceStore', {
|
||||
state: () => ({
|
||||
allPerformanceData: null,
|
||||
freqChartData: null,
|
||||
freqChartOptions: null,
|
||||
freqChartXData: {
|
||||
minX: null,
|
||||
maxX: null,
|
||||
xData: null,
|
||||
content: null,
|
||||
}
|
||||
}),
|
||||
getters: {
|
||||
performanceData: state => {
|
||||
return state.allPerformanceData;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
/**
|
||||
* Get Performance
|
||||
* @param {string} type 'log' | 'filter',可傳入以上任一。
|
||||
* @param {*} id 檔案 ID
|
||||
*/
|
||||
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 apiClient.get(api);
|
||||
this.allPerformanceData = response.data;
|
||||
} catch(error) {
|
||||
apiError(error, 'Failed to load the Performance.');
|
||||
}
|
||||
},
|
||||
/**
|
||||
* In PrimeVue format
|
||||
* @param {object} freqChartData
|
||||
*/
|
||||
setFreqChartData(freqChartData){
|
||||
this.freqChartData = freqChartData;
|
||||
},
|
||||
/**
|
||||
* In PrimeVue format
|
||||
* @param {object} freqChartOptions
|
||||
*/
|
||||
setFreqChartOptions(freqChartOptions){
|
||||
this.freqChartOptions = freqChartOptions;
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @param {object} freqChartXData
|
||||
*/
|
||||
setFreqChartXData(freqChartXData) {
|
||||
this.freqChartXData = freqChartXData;
|
||||
}
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user