From 802a5e51fd3bcade4b549af83394efdbbe3b4eff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Fri, 6 Mar 2026 08:57:36 +0800 Subject: [PATCH] Replace let with const where variable is never reassigned Co-Authored-By: Claude Opus 4.6 --- src/module/alertModal.js | 4 +-- src/module/timeLabel.js | 3 +- src/stores/allMapData.js | 50 ++++++++++++++++----------------- src/stores/conformance.js | 58 +++++++++++++++++++-------------------- src/stores/files.js | 10 +++---- 5 files changed, 62 insertions(+), 63 deletions(-) diff --git a/src/module/alertModal.js b/src/module/alertModal.js index fa84e6b..9618b4e 100644 --- a/src/module/alertModal.js +++ b/src/module/alertModal.js @@ -397,7 +397,7 @@ export async function uploadloader() { * @param { string } baseName 改名前的檔名 */ export async function renameModal(rename, type, id, baseName) { - let fileName = baseName; + const fileName = baseName; const { value, isConfirmed } = await Swal.fire({ title: 'RENAME', input: 'text', @@ -444,7 +444,7 @@ export async function deleteFileModal(files, type, id, name) { const filesStore = FilesStore(); const safeName = escapeHtml(name); - let htmlText = files.length === 0 ? `Do you really want to delete ${safeName}?` : `

Do you really want to delete ${safeName}?

The following dependent file(s) will also be deleted:

    ${files}
`; + const htmlText = files.length === 0 ? `Do you really want to delete ${safeName}?` : `

Do you really want to delete ${safeName}?

The following dependent file(s) will also be deleted:

    ${files}
`; const deleteCustomClass = { ...customClass }; deleteCustomClass.confirmButton = '!inline-block !rounded-full !text-sm !font-medium !text-center !align-middle !transition-colors !duration-300 !px-5 !py-2 !w-[100px] !h-[40px] !text-danger !bg-neutral-10 !border !border-danger'; diff --git a/src/module/timeLabel.js b/src/module/timeLabel.js index dc58e13..5cda455 100644 --- a/src/module/timeLabel.js +++ b/src/module/timeLabel.js @@ -9,9 +9,8 @@ const TOFIXED_DEICMAL = 1; */ export const getStepSizeOfYTicks = (maxTimeInSecond, numOfParts) => { const {unitToUse, timeValue} = getTimeUnitAndValueToUse(maxTimeInSecond); - let resultStepSize; const getLarger = 1 + (1 / (numOfParts - 1)); - resultStepSize = (timeValue * getLarger / numOfParts); + const resultStepSize = (timeValue * getLarger / numOfParts); return {resultStepSize, unitToUse}; } diff --git a/src/stores/allMapData.js b/src/stores/allMapData.js index 5192b2a..b7559f1 100644 --- a/src/stores/allMapData.js +++ b/src/stores/allMapData.js @@ -125,9 +125,9 @@ export default defineStore('allMapDataStore', { * fetch discover api, include '/process-map, /bpmn, /stats, /insights'. */ async getAllMapData() { - let logId = this.logId; - let tempFilterId = this.tempFilterId; - let createfilterId = this.createFilterId + const logId = this.logId; + const tempFilterId = this.tempFilterId; + const createfilterId = this.createFilterId let api = ''; // 先判斷暫存 再判斷 filter 最後 log @@ -149,11 +149,11 @@ export default defineStore('allMapDataStore', { * fetch trace api. */ async getAllTrace() { - let logId = this.logId; - let tempFilterId = this.tempFilterId; - let createfilterId = this.createFilterId; - let baseLogId = this.baseLogId; - let baseApi = `/api/logs/${baseLogId}/traces`; + const logId = this.logId; + const tempFilterId = this.tempFilterId; + const createfilterId = this.createFilterId; + const baseLogId = this.baseLogId; + const baseApi = `/api/logs/${baseLogId}/traces`; let api = ''; // 先判斷暫存 再判斷 filter 最後 log @@ -177,11 +177,11 @@ export default defineStore('allMapDataStore', { * fetch trace detail api. */ async getTraceDetail() { - let logId = this.logId; - let traceId = this.traceId; - let tempFilterId = this.tempFilterId; - let createfilterId = this.createFilterId; - let start = this.infiniteStart; + const logId = this.logId; + const traceId = this.traceId; + const tempFilterId = this.tempFilterId; + const createfilterId = this.createFilterId; + const start = this.infiniteStart; let api = ''; // 先判斷暫存 再判斷 filter 最後 log @@ -223,10 +223,10 @@ export default defineStore('allMapDataStore', { * fetch base log trace detail api. */ async getBaseTraceDetail() { - let logId = this.baseLogId; - let traceId = this.baseTraceId; - let start = this.baseInfiniteStart; - let api = `/api/logs/${logId}/traces/${traceId}?start=${start}&page_size=20`; + const logId = this.baseLogId; + const traceId = this.baseTraceId; + const start = this.baseInfiniteStart; + const api = `/api/logs/${logId}/traces/${traceId}?start=${start}&page_size=20`; try { const response = await this.$axios.get(api); @@ -262,7 +262,7 @@ export default defineStore('allMapDataStore', { * fetch Filter Parameters api. */ async getFilterParams() { - let logId = this.logId; + const logId = this.logId; const api = `/api/filters/params?log_id=${logId}`; try { @@ -274,8 +274,8 @@ export default defineStore('allMapDataStore', { this.allFilterTrace = response.data.trace; this.allFilterAttrs = response.data.attrs; - let min = this.allFilterTimeframe.x_axis.min; - let max = this.allFilterTimeframe.x_axis.max; + const min = this.allFilterTimeframe.x_axis.min; + const max = this.allFilterTimeframe.x_axis.max; // 給 Chart.js 原始資料,格式不同的畫會錯誤輸出 this.allFilterTimeframe.x_axis.min_base = min; this.allFilterTimeframe.x_axis.max_base = max; @@ -290,7 +290,7 @@ export default defineStore('allMapDataStore', { * Test if the Filter Rules Result in Any Data */ async checkHasResult() { - let logId = this.logId; + const logId = this.logId; const api = `/api/filters/has-result?log_id=${logId}`; try { @@ -304,7 +304,7 @@ export default defineStore('allMapDataStore', { * Add a New Temporary Filter */ async addTempFilterId() { - let logId = this.logId; + const logId = this.logId; const api = `/api/temp-filters?log_id=${logId}`; try { @@ -319,9 +319,9 @@ export default defineStore('allMapDataStore', { * @param {string} value file's name */ async addFilterId(value) { - let logId = this.logId; + const logId = this.logId; const api = `/api/filters?log_id=${logId}`; - let createFilterObj = { + const createFilterObj = { name: value, rules: this.postRuleData }; @@ -357,7 +357,7 @@ export default defineStore('allMapDataStore', { * Update an Existing Filter */ async updateFilter() { - let createFilterId = this.createFilterId + const createFilterId = this.createFilterId const api = `/api/filters/${createFilterId}`; const data = this.postRuleData; diff --git a/src/stores/conformance.js b/src/stores/conformance.js index 720c403..ddd6f96 100644 --- a/src/stores/conformance.js +++ b/src/stores/conformance.js @@ -189,8 +189,8 @@ export default defineStore('conformanceStore', { * fetch Log Conformance Parameters api for Rule Settings. */ async getConformanceParams() { - let logId = this.conformanceLogId; - let filterId = this.conformanceFilterId; + const logId = this.conformanceLogId; + const filterId = this.conformanceFilterId; let api = ''; // 先判斷 filter 檔,再判斷 log 檔。 @@ -217,8 +217,8 @@ export default defineStore('conformanceStore', { * @param {object} data 送給後端的 data */ async addConformanceCheckId(data) { - let logId = this.conformanceLogId; - let filterId = this.conformanceFilterId; + const logId = this.conformanceLogId; + const filterId = this.conformanceFilterId; let api = ''; // 先判斷 filter 檔,再判斷 log 檔。 @@ -246,10 +246,10 @@ export default defineStore('conformanceStore', { * @param {boolean} getRouteFile 是否為了取得 route file 而呼叫?使用在非 Conformance page */ async getConformanceReport(getRouteFile = false) { - let logTempCheckId = this.conformanceLogTempCheckId; - let filterTempCheckId = this.conformanceFilterTempCheckId; - let logCreateCheckId = this.conformanceLogCreateCheckId; - let filterCreateCheckId = this.conformanceFilterCreateCheckId; + const logTempCheckId = this.conformanceLogTempCheckId; + const filterTempCheckId = this.conformanceFilterTempCheckId; + const logCreateCheckId = this.conformanceLogCreateCheckId; + const filterCreateCheckId = this.conformanceFilterCreateCheckId; let api = ''; // 先判斷 Temp 再判斷原 ID;先判斷 filter 檔,再判斷 log 檔。 @@ -281,10 +281,10 @@ export default defineStore('conformanceStore', { * @param {number} issueNo Issues 編號 */ async getConformanceIssue(issueNo) { - let logTempCheckId = this.conformanceLogTempCheckId; - let filterTempCheckId = this.conformanceFilterTempCheckId; - let logCreateCheckId = this.conformanceLogCreateCheckId; - let filterCreateCheckId = this.conformanceFilterCreateCheckId; + const logTempCheckId = this.conformanceLogTempCheckId; + const filterTempCheckId = this.conformanceFilterTempCheckId; + const logCreateCheckId = this.conformanceLogCreateCheckId; + const filterCreateCheckId = this.conformanceFilterCreateCheckId; let api = ''; // 先判斷 filter 檔,再判斷 log 檔。 @@ -315,10 +315,10 @@ export default defineStore('conformanceStore', { * @param {number} start Trace 要從哪個編號開始載入 */ async getConformanceTraceDetail(issueNo, traceId, start) { - let logTempCheckId = this.conformanceLogTempCheckId; - let filterTempCheckId = this.conformanceFilterTempCheckId; - let logCreateCheckId = this.conformanceLogCreateCheckId; - let filterCreateCheckId = this.conformanceFilterCreateCheckId; + const logTempCheckId = this.conformanceLogTempCheckId; + const filterTempCheckId = this.conformanceFilterTempCheckId; + const logCreateCheckId = this.conformanceLogCreateCheckId; + const filterCreateCheckId = this.conformanceFilterCreateCheckId; let api = ''; // 先判斷 filter 檔,再判斷 log 檔。 @@ -353,10 +353,10 @@ export default defineStore('conformanceStore', { * @param {number} loopNo loop 編號 */ async getConformanceLoop(loopNo) { - let logTempCheckId = this.conformanceLogTempCheckId; - let filterTempCheckId = this.conformanceFilterTempCheckId; - let logCreateCheckId = this.conformanceLogCreateCheckId; - let filterCreateCheckId = this.conformanceFilterCreateCheckId; + const logTempCheckId = this.conformanceLogTempCheckId; + const filterTempCheckId = this.conformanceFilterTempCheckId; + const logCreateCheckId = this.conformanceLogCreateCheckId; + const filterCreateCheckId = this.conformanceFilterCreateCheckId; let api = ''; // 先判斷 filter 檔,再判斷 log 檔。 @@ -379,10 +379,10 @@ export default defineStore('conformanceStore', { * @param {number} start Trace 要從哪個編號開始載入 */ async getConformanceLoopsTraceDetail(loopNo, traceId, start) { - let logTempCheckId = this.conformanceLogTempCheckId; - let filterTempCheckId = this.conformanceFilterTempCheckId; - let logCreateCheckId = this.conformanceLogCreateCheckId; - let filterCreateCheckId = this.conformanceFilterCreateCheckId; + const logTempCheckId = this.conformanceLogTempCheckId; + const filterTempCheckId = this.conformanceFilterTempCheckId; + const logCreateCheckId = this.conformanceLogCreateCheckId; + const filterCreateCheckId = this.conformanceFilterCreateCheckId; let api = ''; // 先判斷 filter 檔,再判斷 log 檔。 @@ -409,10 +409,10 @@ export default defineStore('conformanceStore', { * @param {string} value file's name */ async addConformanceCreateCheckId(value) { - let logId = this.conformanceLogId; - let filterId = this.conformanceFilterId; + const logId = this.conformanceLogId; + const filterId = this.conformanceFilterId; let api = ''; - let data = { + const data = { name: value, rule: this.conformanceRuleData }; @@ -439,8 +439,8 @@ export default defineStore('conformanceStore', { * Update an Existing Conformance Check, log and filter */ async updateConformance() { - let logCreateCheckId = this.conformanceLogCreateCheckId; - let filterCreateCheckId = this.conformanceFilterCreateCheckId; + const logCreateCheckId = this.conformanceLogCreateCheckId; + const filterCreateCheckId = this.conformanceFilterCreateCheckId; let api = ''; const data = this.conformanceRuleData; diff --git a/src/stores/files.js b/src/stores/files.js index 09b8c02..8e1cf3a 100644 --- a/src/stores/files.js +++ b/src/stores/files.js @@ -35,8 +35,8 @@ export default defineStore('filesStore', { */ allFiles: state => { let result = state.allEventFiles; - let data = state.switchFilesTagData; - let filesTag = state.filesTag; + const data = state.switchFilesTagData; + const filesTag = state.filesTag; result = result.filter(file => data[filesTag].includes(file.fileType)); @@ -128,7 +128,7 @@ export default defineStore('filesStore', { if(error.response.status === 422) { // msg: 'not in UTF-8' | 'insufficient columns' | 'the csv file is empty' | 'the filename does not ends with .csv' // type: 'encoding' | 'insufficient_columns' | 'empty' | 'name_suffix' - let detail = error.response.data.detail; + const detail = error.response.data.detail; uploadFailedFirst(detail[0].type, detail[0].msg, detail[0].loc[2]); } else { @@ -170,7 +170,7 @@ export default defineStore('filesStore', { this.$router.push({name: 'Files'}); } catch(error) { if(error.response.status === 422) { - let detail = [...error.response.data.detail]; + const detail = [...error.response.data.detail]; uploadFailedSecond(detail); } else { @@ -194,7 +194,7 @@ export default defineStore('filesStore', { } let api; - let data = {"name": fileName}; + const data = {"name": fileName}; switch (type) { case 'log':