Standardize store exports to named useXxxStore convention
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import apiClient from '@/api/client.js';
|
||||
import apiError from '@/module/apiError';
|
||||
import piniaLoginStore from '@/stores/login';
|
||||
import { useLoginStore } from '@/stores/login';
|
||||
import { JUST_CREATE_ACCOUNT_HOT_DURATION_MINS } from '@/constants/constants';
|
||||
|
||||
interface User {
|
||||
@@ -25,7 +25,7 @@ interface EditDetail {
|
||||
is_active: boolean;
|
||||
}
|
||||
|
||||
export default defineStore('acctMgmtStore', {
|
||||
export const useAcctMgmtStore = defineStore('acctMgmtStore', {
|
||||
persist: true,
|
||||
state: () => ({
|
||||
allUserAccoutList: [] as User[],
|
||||
@@ -99,7 +99,7 @@ export default defineStore('acctMgmtStore', {
|
||||
* Add some customization. For example, add isHovered field
|
||||
*/
|
||||
async customizeAllUserList(rawResponseData: User[]): Promise<User[]> {
|
||||
const loginStore = piniaLoginStore();
|
||||
const loginStore = useLoginStore();
|
||||
await loginStore.getUserData();
|
||||
const loginUserData:User = loginStore.userData;
|
||||
return rawResponseData.map(user => ({
|
||||
@@ -114,7 +114,7 @@ export default defineStore('acctMgmtStore', {
|
||||
* Current logged in user should be placed at the first row on list
|
||||
*/
|
||||
async moveCurrentLoginUserToFirstRow(fetchedUserList: User[]): Promise<User[]> {
|
||||
const loginStore = piniaLoginStore();
|
||||
const loginStore = useLoginStore();
|
||||
await loginStore.getUserData();
|
||||
const loginUserData:User = loginStore.userData;
|
||||
const foundLoginUserIndex = fetchedUserList.findIndex(user => user.username === loginUserData.username);
|
||||
|
||||
@@ -4,7 +4,7 @@ import apiClient from "@/api/client.js";
|
||||
import apiError from '@/module/apiError.js';
|
||||
import { Decimal } from 'decimal.js';
|
||||
|
||||
export default defineStore('allMapDataStore', {
|
||||
export const useAllMapDataStore = defineStore('allMapDataStore', {
|
||||
state: () => ({
|
||||
baseLogId: null,
|
||||
logId: null,
|
||||
|
||||
@@ -2,7 +2,7 @@ import { defineStore } from "pinia";
|
||||
import apiClient from "@/api/client.js";
|
||||
import apiError from '@/module/apiError.js';
|
||||
|
||||
export default defineStore('compareStore', {
|
||||
export const useCompareStore = defineStore('compareStore', {
|
||||
state: () => ({
|
||||
allCompareDashboardData: null,
|
||||
}),
|
||||
|
||||
@@ -5,7 +5,7 @@ import abbreviateNumber from '@/module/abbreviateNumber.js';
|
||||
import apiClient from "@/api/client.js";
|
||||
import apiError from '@/module/apiError.js';
|
||||
|
||||
export default defineStore('conformanceStore', {
|
||||
export const useConformanceStore = defineStore('conformanceStore', {
|
||||
state: () => ({
|
||||
conformanceLogId: null, // log 檔
|
||||
conformanceFilterId: null, // filter 檔
|
||||
|
||||
@@ -7,7 +7,7 @@ import moment from 'moment';
|
||||
* 而後者則側重在 API 的串接之所需
|
||||
*/
|
||||
|
||||
export default defineStore('conformanceInputStore', {
|
||||
export const useConformanceInputStore = defineStore('conformanceInputStore', {
|
||||
state: () => ({
|
||||
inputDataToSave: {
|
||||
inputStart: null, // 有待釐清,start 是活動的開始,還是時間的開始?
|
||||
|
||||
@@ -23,7 +23,7 @@ interface NodePositions {
|
||||
}
|
||||
|
||||
|
||||
export default defineStore('useCytoscapeStore', {
|
||||
export const useCytoscapeStore = defineStore('cytoscapeStore', {
|
||||
state: () => ({
|
||||
nodePositions: {} as NodePositions,
|
||||
currentGraphId: "",
|
||||
|
||||
@@ -4,9 +4,9 @@ import moment from 'moment';
|
||||
import apiError from '@/module/apiError.js';
|
||||
import Swal from 'sweetalert2';
|
||||
import { uploadFailedFirst, uploadFailedSecond, uploadloader, uploadSuccess, deleteSuccess } from '@/module/alertModal.js';
|
||||
import loadingStore from '@/stores/loading.js';
|
||||
import { useLoadingStore } from '@/stores/loading.js';
|
||||
|
||||
export default defineStore('filesStore', {
|
||||
export const useFilesStore = defineStore('filesStore', {
|
||||
state: () => ({
|
||||
allEventFiles: [
|
||||
{
|
||||
@@ -259,7 +259,7 @@ export default defineStore('filesStore', {
|
||||
console.error('Delete File API Error: invalid id');
|
||||
return;
|
||||
};
|
||||
const loading = loadingStore();
|
||||
const loading = useLoadingStore();
|
||||
loading.isLoading = true;
|
||||
switch (type) {
|
||||
case 'log':
|
||||
@@ -292,7 +292,7 @@ export default defineStore('filesStore', {
|
||||
async deletionRecord(id) {
|
||||
let api = '';
|
||||
|
||||
const loading = loadingStore();
|
||||
const loading = useLoadingStore();
|
||||
loading.isLoading = true;
|
||||
api = `/api/deletion/${id}`;
|
||||
try {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { defineStore } from "pinia";
|
||||
|
||||
export default defineStore('loadingStore', {
|
||||
export const useLoadingStore = defineStore('loadingStore', {
|
||||
state: () => ({
|
||||
isLoading: true,
|
||||
}),
|
||||
|
||||
@@ -4,7 +4,7 @@ import apiClient from '@/api/client.js';
|
||||
import apiError from '@/module/apiError.js';
|
||||
import { deleteCookie, setCookie, setCookieWithoutExpiration, getCookie } from "../utils/cookieUtil";
|
||||
|
||||
export default defineStore('loginStore', {
|
||||
export const useLoginStore = defineStore('loginStore', {
|
||||
// data, methods, computed
|
||||
// state, actions, getters
|
||||
state: () => ({
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import AllMapData from '@/stores/allMapData.js';
|
||||
import { useAllMapDataStore } from '@/stores/allMapData.js';
|
||||
import { INSIGHTS_FIELDS_AND_LABELS } from '@/constants/constants';
|
||||
import ImgCapsuleGlow1 from '@/assets/capsule1-glow.svg';
|
||||
import ImgCapsuleGlow2 from '@/assets/capsule2-glow.svg';
|
||||
@@ -13,7 +13,7 @@ import ImgCapsule4 from '@/assets/capsule4.svg';
|
||||
const ImgCapsulesGlow = [ImgCapsuleGlow1, ImgCapsuleGlow2, ImgCapsuleGlow3, ImgCapsuleGlow4];
|
||||
const ImgCapsules = [ImgCapsule1, ImgCapsule2, ImgCapsule3, ImgCapsule4];
|
||||
|
||||
export default defineStore('useMapCompareStore', {
|
||||
export const useMapCompareStore = defineStore('mapCompareStore', {
|
||||
state: () => ({
|
||||
routeParam: {
|
||||
primaryType: '',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import AllMapData from '@/stores/allMapData.js';
|
||||
import { useAllMapDataStore } from '@/stores/allMapData.js';
|
||||
import { INSIGHTS_FIELDS_AND_LABELS } from '@/constants/constants';
|
||||
import ImgCapsuleGlow1 from '@/assets/capsule1-glow.svg';
|
||||
import ImgCapsuleGlow2 from '@/assets/capsule2-glow.svg';
|
||||
@@ -13,7 +13,7 @@ import ImgCapsule4 from '@/assets/capsule4.svg';
|
||||
const ImgCapsulesGlow = [ImgCapsuleGlow1, ImgCapsuleGlow2, ImgCapsuleGlow3, ImgCapsuleGlow4];
|
||||
const ImgCapsules = [ImgCapsule1, ImgCapsule2, ImgCapsule3, ImgCapsule4];
|
||||
|
||||
export default defineStore('useMapPathStore', {
|
||||
export const useMapPathStore = defineStore('mapPathStore', {
|
||||
state: () => ({
|
||||
clickedPath: [],
|
||||
insights: {},
|
||||
@@ -65,7 +65,7 @@ export default defineStore('useMapPathStore', {
|
||||
}
|
||||
},
|
||||
async createInsightWithPath() {
|
||||
const { insights } = AllMapData();
|
||||
const { insights } = useAllMapDataStore();
|
||||
this.insights = { ...insights };
|
||||
this.startNode = this.cytoscape[this.processOrBPMN][this.curveType][this.directionType]?.nodes()
|
||||
.filter(function (elem) {
|
||||
@@ -118,7 +118,7 @@ export default defineStore('useMapPathStore', {
|
||||
});
|
||||
// Depth First Search from the starting node
|
||||
await this.depthFirstSearchCreatePath(this.startNode, [this.startNode], []);
|
||||
const { insights } = AllMapData();
|
||||
const { insights } = useAllMapDataStore();
|
||||
this.insights = { ...insights };
|
||||
await this.matchGraphPathWithInsightsPath();
|
||||
},
|
||||
|
||||
@@ -7,7 +7,7 @@ const printPageAdminLog = false;
|
||||
// Therefore, we need to handle page transitions caused by both of these methods.
|
||||
// 至少有兩種方式引起畫面的導向: 點選導覽按鈕與重新整理網頁
|
||||
// 因此至少要處理這兩種方式所引起的畫面切換
|
||||
export default defineStore('pageAdminStore', {
|
||||
export const usePageAdminStore = defineStore('pageAdminStore', {
|
||||
state: () => ({
|
||||
activePage: 'MAP',
|
||||
previousPage: 'MAP',
|
||||
|
||||
@@ -2,7 +2,7 @@ import { defineStore } from "pinia";
|
||||
import apiClient from "@/api/client.js";
|
||||
import apiError from '@/module/apiError.js';
|
||||
|
||||
export default defineStore('performanceStore', {
|
||||
export const usePerformanceStore = defineStore('performanceStore', {
|
||||
state: () => ({
|
||||
allPerformanceData: null,
|
||||
freqChartData: null,
|
||||
|
||||
Reference in New Issue
Block a user