@simitgroup/simpleapp-generator 2.0.3-g-alpha → 2.0.3-h-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ReleaseNote.md +3 -0
- package/package.json +1 -1
- package/templates/nuxt/plugins/09.app-init.ts.eta +13 -0
- package/templates/nuxt/plugins/10.axios.ts.eta +86 -0
- package/templates/nuxt/plugins/11.event-bus.ts.eta +20 -0
- package/templates/nuxt/plugins/12.primevue-services.ts.eta +18 -0
- package/templates/nuxt/plugins/10.simpleapp-event.ts.eta +0 -126
package/ReleaseNote.md
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
+
* last change 2026-05-13
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { defineNuxtPlugin } from "#app";
|
|
8
|
+
|
|
9
|
+
export default defineNuxtPlugin(() => {
|
|
10
|
+
onNuxtReady(() => {
|
|
11
|
+
window.__NUXT__ = undefined;
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
+
* last change 2026-05-13
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { defineNuxtPlugin } from "#app";
|
|
8
|
+
import axios, { type AxiosError } from "axios";
|
|
9
|
+
|
|
10
|
+
function extractErrorPayload(error: AxiosError): {
|
|
11
|
+
statusCode: number;
|
|
12
|
+
statusMessage: string;
|
|
13
|
+
message: string;
|
|
14
|
+
} {
|
|
15
|
+
const data = error.response?.data as Record<string, any> | undefined;
|
|
16
|
+
if (data?.data?.message) {
|
|
17
|
+
return {
|
|
18
|
+
statusCode: data.data.status,
|
|
19
|
+
statusMessage: data.data.name,
|
|
20
|
+
message: data.data.message,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (data) {
|
|
24
|
+
return {
|
|
25
|
+
statusCode: data.statusCode,
|
|
26
|
+
statusMessage: data.message,
|
|
27
|
+
message: data.statusMessage,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
statusCode: error.status ?? 0,
|
|
32
|
+
statusMessage: error.name,
|
|
33
|
+
message: error.message,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default defineNuxtPlugin(() => {
|
|
38
|
+
const axiosInstance = axios.create({ timeout: 10000 });
|
|
39
|
+
|
|
40
|
+
axiosInstance.interceptors.response.use(
|
|
41
|
+
(response) => response,
|
|
42
|
+
(error: AxiosError) => {
|
|
43
|
+
const status = error.response?.status;
|
|
44
|
+
|
|
45
|
+
// 401: unauthenticated / session expired
|
|
46
|
+
// 302: backend redirecting to /login instead of returning 401 (legacy server behaviour)
|
|
47
|
+
// Both cases: let the caller handle the login flow
|
|
48
|
+
if (status === 401 || status === 302) {
|
|
49
|
+
return Promise.reject(error);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// 403: forbidden — user lacks permission, hard-redirect to home
|
|
53
|
+
if (status === 403) {
|
|
54
|
+
navigateTo("/", { external: true });
|
|
55
|
+
return Promise.reject(error);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// 402: subscription/plan expired — show a fatal system-expired screen
|
|
59
|
+
if (status === 402) {
|
|
60
|
+
throw createError({
|
|
61
|
+
statusCode: 402,
|
|
62
|
+
statusMessage: "System Expired",
|
|
63
|
+
message: error.response?.statusText ?? "",
|
|
64
|
+
fatal: true,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (error.response) {
|
|
69
|
+
const payload = extractErrorPayload(error);
|
|
70
|
+
throw createError({ ...payload, fatal: true });
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (error.code) {
|
|
74
|
+
throw createError({
|
|
75
|
+
statusCode: 500,
|
|
76
|
+
statusMessage: error.message,
|
|
77
|
+
fatal: true,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
throw createError({ statusCode: 500, statusMessage: "Internal server error", fatal: true });
|
|
82
|
+
},
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
return { provide: { axios: axiosInstance } };
|
|
86
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
+
* last change 2026-05-13
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { defineNuxtPlugin } from "#app";
|
|
8
|
+
import { EventType } from "~/types";
|
|
9
|
+
import mitt from "mitt";
|
|
10
|
+
|
|
11
|
+
const emitter = mitt<EventType>();
|
|
12
|
+
|
|
13
|
+
export default defineNuxtPlugin(() => {
|
|
14
|
+
return {
|
|
15
|
+
provide: {
|
|
16
|
+
event: emitter.emit,
|
|
17
|
+
listen: emitter.on,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
+
* last change 2026-05-13
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { defineNuxtPlugin } from "#app";
|
|
8
|
+
import { useConfirm } from "primevue/useconfirm";
|
|
9
|
+
import { useDialog } from "primevue/usedialog";
|
|
10
|
+
|
|
11
|
+
export default defineNuxtPlugin(() => {
|
|
12
|
+
return {
|
|
13
|
+
provide: {
|
|
14
|
+
confirm: useConfirm(),
|
|
15
|
+
dialog: useDialog,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
});
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
-
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
-
* last change 2025-10-25
|
|
5
|
-
* Author: Ks Tan
|
|
6
|
-
*/
|
|
7
|
-
import { defineNuxtPlugin } from "#app";
|
|
8
|
-
import axios from "axios";
|
|
9
|
-
import { EventType } from "~/types";
|
|
10
|
-
// import PrimeVue from "primevue/config";
|
|
11
|
-
import mitt from "mitt";
|
|
12
|
-
import { useConfirm } from "primevue/useconfirm";
|
|
13
|
-
import { useDialog } from "primevue/usedialog";
|
|
14
|
-
|
|
15
|
-
// import ToastService from 'primevue/toastservice';
|
|
16
|
-
// import ConfirmationService from 'primevue/confirmationservice';
|
|
17
|
-
// import Tooltip from 'primevue/tooltip';
|
|
18
|
-
const emitter = mitt<EventType>();
|
|
19
|
-
export default defineNuxtPlugin(async (nuxtApp) => {
|
|
20
|
-
//hide __NUXT__ at client side.
|
|
21
|
-
onNuxtReady(() => {
|
|
22
|
-
window.__NUXT__ = undefined;
|
|
23
|
-
});
|
|
24
|
-
// useNuxtApp().vueApp.use(DialogService)
|
|
25
|
-
//const { csrf } = useCsrf()
|
|
26
|
-
//axios.defaults.headers.common = {"CSRF-TOKEN": csrf};
|
|
27
|
-
const myaxios = axios.create({ timeout: 10000 });
|
|
28
|
-
myaxios.interceptors.response.use(
|
|
29
|
-
(response) => {
|
|
30
|
-
return response;
|
|
31
|
-
},
|
|
32
|
-
(error) => {
|
|
33
|
-
// console.log("error catch",error)
|
|
34
|
-
|
|
35
|
-
if (error?.code && error.code == "ERR_BAD_REQUEST") {
|
|
36
|
-
if (error.response && (error.response.status == 401 || error.response.status == 302)) {
|
|
37
|
-
return Promise.reject(error);
|
|
38
|
-
} else if (error.response && error.response.status == 403) {
|
|
39
|
-
console.warn("error status 403, redirect to external link /");
|
|
40
|
-
navigateTo("/", { external: true });
|
|
41
|
-
} else if (error.response && error.response.status === 402) {
|
|
42
|
-
const route = useRoute();
|
|
43
|
-
// if (route.fullPath.endsWith("/billing")) {
|
|
44
|
-
// return Promise.resolve({});
|
|
45
|
-
// } else {
|
|
46
|
-
throw createError({
|
|
47
|
-
statusCode: error.response.status,
|
|
48
|
-
statusMessage: "System Expired",
|
|
49
|
-
message: error.response.statusText,
|
|
50
|
-
});
|
|
51
|
-
// }
|
|
52
|
-
console.log(route);
|
|
53
|
-
} else {
|
|
54
|
-
console.error("axios ERR_BAD_REQUEST", error);
|
|
55
|
-
let errorMsg = "";
|
|
56
|
-
let errorCode = 0;
|
|
57
|
-
let moreMsg = "";
|
|
58
|
-
if (error.response?.data?.data?.message) {
|
|
59
|
-
errorCode = error.response.data.data.status;
|
|
60
|
-
moreMsg = error.response.data.data.message;
|
|
61
|
-
errorMsg = error.response.data.data.name;
|
|
62
|
-
} else if (error.response?.data) {
|
|
63
|
-
errorCode = error.response.data.statusCode;
|
|
64
|
-
moreMsg = error.response.data.statusMessage;
|
|
65
|
-
errorMsg = error.response.data.message;
|
|
66
|
-
} else {
|
|
67
|
-
errorCode = error.status;
|
|
68
|
-
moreMsg = error.message;
|
|
69
|
-
errorMsg = error.name;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const errorData = {
|
|
73
|
-
statusCode: errorCode,
|
|
74
|
-
statusMessage: errorMsg,
|
|
75
|
-
message: moreMsg,
|
|
76
|
-
fatal: true,
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
// console.log(error.response)
|
|
80
|
-
throw createError(errorData);
|
|
81
|
-
}
|
|
82
|
-
} else if (error.code) {
|
|
83
|
-
throw createError({
|
|
84
|
-
statusCode: error.code,
|
|
85
|
-
statusMessage: error.message,
|
|
86
|
-
fatal: true,
|
|
87
|
-
});
|
|
88
|
-
} else if (error.response && (error.response.status == 302 || error.response.status == 401)) {
|
|
89
|
-
console.error("axios 302 session expired, start login flow");
|
|
90
|
-
} else if (error.response && error.response.status) {
|
|
91
|
-
let errmsg = error.response.message;
|
|
92
|
-
let errorcode = error.response.status;
|
|
93
|
-
if (error.response?.data && error.response?.data?.message) {
|
|
94
|
-
errmsg = error.response.data.message;
|
|
95
|
-
errorcode = error.response.data.statusCode;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
throw createError({
|
|
99
|
-
statusCode: errorcode,
|
|
100
|
-
statusMessage: errmsg,
|
|
101
|
-
fatal: true,
|
|
102
|
-
});
|
|
103
|
-
// return Promise.reject(error)
|
|
104
|
-
} else {
|
|
105
|
-
console.error("unknown error");
|
|
106
|
-
throw createError({ statusCode: 500, statusMessage: "Internal server error" });
|
|
107
|
-
}
|
|
108
|
-
// if (error.response) {
|
|
109
|
-
// console.error("Backend error response:", error.response.data);
|
|
110
|
-
// } else {
|
|
111
|
-
// console.error("Network error:", error);
|
|
112
|
-
// }
|
|
113
|
-
return Promise.reject(error);
|
|
114
|
-
},
|
|
115
|
-
);
|
|
116
|
-
return {
|
|
117
|
-
provide: {
|
|
118
|
-
event: emitter.emit, // Will emit an event
|
|
119
|
-
listen: emitter.on, // Will register a listener for an event
|
|
120
|
-
axios: myaxios,
|
|
121
|
-
confirm: useConfirm(),
|
|
122
|
-
dialog: useDialog,
|
|
123
|
-
},
|
|
124
|
-
};
|
|
125
|
-
//other components that you need
|
|
126
|
-
});
|