create-nexgen 1.0.4
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/package.json +26 -0
- package/src/index.js +108 -0
- package/template/.dockerignore +14 -0
- package/template/.env +58 -0
- package/template/.env.example +59 -0
- package/template/.prettierignore +5 -0
- package/template/.prettierrc +8 -0
- package/template/README.md +447 -0
- package/template/drizzle.config.ts +29 -0
- package/template/eslint.config.js +52 -0
- package/template/gitignore-stub +24 -0
- package/template/package.json +96 -0
- package/template/public/assets/AuthLayout-CbswhpjJ.js +1 -0
- package/template/public/assets/Button-_7aQ7gHL.js +1 -0
- package/template/public/assets/Input-CLNJXmKc.css +1 -0
- package/template/public/assets/Input-z8GI8Aqo.js +1 -0
- package/template/public/assets/InputPasswordToggle-BxlzVGp3.js +1 -0
- package/template/public/assets/InputPasswordToggle-C77FI9Eg.css +1 -0
- package/template/public/assets/Layout-DotR1sQC.js +1 -0
- package/template/public/assets/Refresh-BdqsPPBC.js +1 -0
- package/template/public/assets/admin-ui-CU34rLdN.js +1 -0
- package/template/public/assets/bootstrap-icons-BeopsB42.woff +0 -0
- package/template/public/assets/bootstrap-icons-mSm7cUeB.woff2 +0 -0
- package/template/public/assets/dashboard-CwybEyLc.js +1 -0
- package/template/public/assets/dashboard-Dc4d-Pi7.css +1 -0
- package/template/public/assets/forgetPassword-CKEJaXsq.js +1 -0
- package/template/public/assets/index-Bleyx5dm.js +64 -0
- package/template/public/assets/index-DUw8E6Yg.css +1 -0
- package/template/public/assets/login-DC7PTlQF.js +1 -0
- package/template/public/assets/realtime-test-BPQdrFym.css +1 -0
- package/template/public/assets/realtime-test-tQZ0rBEJ.js +1 -0
- package/template/public/assets/register-3O7Qs28C.js +1 -0
- package/template/public/assets/resetPassword-A5AzMWKs.js +1 -0
- package/template/public/assets/verifyEmail-DDBEQHOv.js +1 -0
- package/template/public/index.html +17 -0
- package/template/src/database/migrations/mysql/0000_init.sql +73 -0
- package/template/src/database/migrations/mysql/meta/0000_snapshot.json +484 -0
- package/template/src/database/migrations/mysql/meta/_journal.json +13 -0
- package/template/src/database/schema.ts +4 -0
- package/template/src/env.ts +107 -0
- package/template/src/framework/cache/cache.ts +81 -0
- package/template/src/framework/database/connection.ts +168 -0
- package/template/src/framework/database/optional-db-drivers.d.ts +9 -0
- package/template/src/framework/database/paginate.ts +200 -0
- package/template/src/framework/database/schema.ts +26 -0
- package/template/src/framework/database/seed.ts +33 -0
- package/template/src/framework/events/dispatcher.ts +57 -0
- package/template/src/framework/facade.ts +27 -0
- package/template/src/framework/http/app.ts +61 -0
- package/template/src/framework/http/cors.ts +19 -0
- package/template/src/framework/http/logger.ts +85 -0
- package/template/src/framework/http/openapi.ts +34 -0
- package/template/src/framework/http/ratelimiter.ts +13 -0
- package/template/src/framework/http/router.ts +76 -0
- package/template/src/framework/http/static.ts +33 -0
- package/template/src/framework/http/validation.ts +24 -0
- package/template/src/framework/kernel.ts +40 -0
- package/template/src/framework/maker-cli/src/index.mjs +51 -0
- package/template/src/framework/maker-cli/src/levels/level-1/env-db.mjs +57 -0
- package/template/src/framework/maker-cli/src/levels/level-1/file-ops.mjs +30 -0
- package/template/src/framework/maker-cli/src/levels/level-1/flags.mjs +16 -0
- package/template/src/framework/maker-cli/src/levels/level-1/help.mjs +24 -0
- package/template/src/framework/maker-cli/src/levels/level-1/naming.mjs +13 -0
- package/template/src/framework/maker-cli/src/levels/level-1/process.mjs +47 -0
- package/template/src/framework/maker-cli/src/levels/level-2/db/core.mjs +299 -0
- package/template/src/framework/maker-cli/src/levels/level-2/db/index.mjs +177 -0
- package/template/src/framework/maker-cli/src/levels/level-2/deploy/core.mjs +635 -0
- package/template/src/framework/maker-cli/src/levels/level-2/deploy/index.mjs +145 -0
- package/template/src/framework/maker-cli/src/levels/level-2/module/core.mjs +707 -0
- package/template/src/framework/maker-cli/src/levels/level-2/module/index.mjs +116 -0
- package/template/src/framework/maker-cli/src/levels/level-2/runtime/build-frontend.mjs +16 -0
- package/template/src/framework/maker-cli/src/levels/level-2/runtime/core.mjs +311 -0
- package/template/src/framework/maker-cli/src/levels/level-2/runtime/index.mjs +71 -0
- package/template/src/framework/maker-cli/stubs/controller/openapi.ts.stub +55 -0
- package/template/src/framework/maker-cli/stubs/controller/openapi.with-model.ts.stub +56 -0
- package/template/src/framework/maker-cli/stubs/controller/plain.ts.stub +57 -0
- package/template/src/framework/maker-cli/stubs/controller/schema.plain.ts.stub +13 -0
- package/template/src/framework/maker-cli/stubs/controller/schema.ts.stub +32 -0
- package/template/src/framework/maker-cli/stubs/deploy/Dockerfile.bun.stub +49 -0
- package/template/src/framework/maker-cli/stubs/deploy/Dockerfile.pnpm.stub +53 -0
- package/template/src/framework/maker-cli/stubs/deploy/Dockerfile.stub +49 -0
- package/template/src/framework/maker-cli/stubs/deploy/Dockerfile.yarn.stub +53 -0
- package/template/src/framework/maker-cli/stubs/deploy/README.stub +55 -0
- package/template/src/framework/maker-cli/stubs/deploy/compose/mysql.server.stub +29 -0
- package/template/src/framework/maker-cli/stubs/deploy/compose/postgres.server.stub +29 -0
- package/template/src/framework/maker-cli/stubs/deploy/compose/sqlite.stub +29 -0
- package/template/src/framework/maker-cli/stubs/deploy/env/mysql.server.stub +73 -0
- package/template/src/framework/maker-cli/stubs/deploy/env/postgres.server.stub +73 -0
- package/template/src/framework/maker-cli/stubs/deploy/env/sqlite.stub +72 -0
- package/template/src/framework/maker-cli/stubs/deploy/scripts/auto-migrate.sh.stub +15 -0
- package/template/src/framework/maker-cli/stubs/deploy/server/README.stub +77 -0
- package/template/src/framework/maker-cli/stubs/deploy/server/compose/noredis.stub +118 -0
- package/template/src/framework/maker-cli/stubs/deploy/server/compose/redis.dev.stub +131 -0
- package/template/src/framework/maker-cli/stubs/deploy/server/compose/redis.stub +129 -0
- package/template/src/framework/maker-cli/stubs/deploy/server/env/local.example.stub +10 -0
- package/template/src/framework/maker-cli/stubs/deploy/server/env/noredis.stub +24 -0
- package/template/src/framework/maker-cli/stubs/deploy/server/env/redis.stub +24 -0
- package/template/src/framework/maker-cli/stubs/deploy/server/nginx-vhost/README.stub +15 -0
- package/template/src/framework/maker-cli/stubs/deploy/server/nginx-vhost/app.example.com.stub +12 -0
- package/template/src/framework/maker-cli/stubs/deploy/server/pgadmin/servers.stub +13 -0
- package/template/src/framework/maker-cli/stubs/deploy/server/redis/redis.conf.stub +6 -0
- package/template/src/framework/maker-cli/stubs/deploy/supervisor/noredis.stub +53 -0
- package/template/src/framework/maker-cli/stubs/deploy/supervisor/redis.stub +69 -0
- package/template/src/framework/maker-cli/stubs/deploy/workflow/local.json.stub +24 -0
- package/template/src/framework/maker-cli/stubs/deploy/workflow/remote.json.stub +20 -0
- package/template/src/framework/maker-cli/stubs/example/console.ts.stub +33 -0
- package/template/src/framework/maker-cli/stubs/example/controller.ts.stub +503 -0
- package/template/src/framework/maker-cli/stubs/example/job.ts.stub +74 -0
- package/template/src/framework/maker-cli/stubs/example/route.api.ts.stub +206 -0
- package/template/src/framework/maker-cli/stubs/example/schema.ts.stub +41 -0
- package/template/src/framework/maker-cli/stubs/job/name.ts.stub +24 -0
- package/template/src/framework/maker-cli/stubs/model/name.mysql.ts.stub +8 -0
- package/template/src/framework/maker-cli/stubs/model/name.postgresql.ts.stub +8 -0
- package/template/src/framework/maker-cli/stubs/model/name.sqlite.ts.stub +8 -0
- package/template/src/framework/maker-cli/stubs/notification/NotificationBell.vue.stub +218 -0
- package/template/src/framework/maker-cli/stubs/notification/controller.ts.stub +85 -0
- package/template/src/framework/maker-cli/stubs/notification/index.vue.stub +211 -0
- package/template/src/framework/maker-cli/stubs/notification/job.ts.stub +12 -0
- package/template/src/framework/maker-cli/stubs/notification/route.api.ts.stub +49 -0
- package/template/src/framework/maker-cli/stubs/notification/schema.ts.stub +25 -0
- package/template/src/framework/maker-cli/stubs/route/api.ts.stub +79 -0
- package/template/src/framework/maker-cli/stubs/route/plain.ts.stub +10 -0
- package/template/src/framework/maker-cli/stubs/schedule/name.ts.stub +35 -0
- package/template/src/framework/maker-cli/stubs/seeder/name.ts.stub +17 -0
- package/template/src/framework/modules/discover.ts +54 -0
- package/template/src/framework/modules/routes.ts +26 -0
- package/template/src/framework/notification/index.ts +109 -0
- package/template/src/framework/queue/clear.ts +20 -0
- package/template/src/framework/queue/queue.ts +213 -0
- package/template/src/framework/queue/ui.ts +104 -0
- package/template/src/framework/queue/worker.ts +33 -0
- package/template/src/framework/realtime/broadcast.ts +27 -0
- package/template/src/framework/realtime/index.ts +1 -0
- package/template/src/framework/realtime/socket-cookie.ts +65 -0
- package/template/src/framework/realtime/socket.ts +132 -0
- package/template/src/framework/realtime/types.ts +6 -0
- package/template/src/framework/realtime/ui.ts +16 -0
- package/template/src/framework/redis/client.ts +126 -0
- package/template/src/framework/scheduler/lock.ts +124 -0
- package/template/src/framework/scheduler/run.ts +26 -0
- package/template/src/framework/scheduler/scheduler.ts +82 -0
- package/template/src/framework/server.ts +147 -0
- package/template/src/framework/session/session.ts +116 -0
- package/template/src/framework/storage/storage.ts +743 -0
- package/template/src/framework/support/cookie.ts +78 -0
- package/template/src/framework/support/jwt.ts +45 -0
- package/template/src/framework/support/lifecycle.ts +35 -0
- package/template/src/framework/support/logger.ts +102 -0
- package/template/src/framework/support/mail.ts +43 -0
- package/template/src/framework/support/password.ts +23 -0
- package/template/src/framework/support/url.ts +25 -0
- package/template/src/middlewares/auth-middleware.ts +98 -0
- package/template/src/middlewares/role-middleware.ts +24 -0
- package/template/src/modules/auth/controllers/auth.controller.ts +445 -0
- package/template/src/modules/auth/controllers/auth.helpers.ts +110 -0
- package/template/src/modules/auth/controllers/auth.schema.ts +102 -0
- package/template/src/modules/auth/controllers/role.controller.ts +25 -0
- package/template/src/modules/auth/database/models/notifications.ts +22 -0
- package/template/src/modules/auth/database/models/role.ts +14 -0
- package/template/src/modules/auth/database/models/user.ts +46 -0
- package/template/src/modules/auth/database/seeders/role.ts +19 -0
- package/template/src/modules/auth/database/seeders/user.ts +33 -0
- package/template/src/modules/auth/jobs/forgetpass.ts +18 -0
- package/template/src/modules/auth/jobs/registeruser.ts +31 -0
- package/template/src/modules/auth/jobs/verifyemail.ts +18 -0
- package/template/src/modules/auth/routes/api.ts +151 -0
- package/template/src/modules/auth/routes/role.ts +39 -0
- package/template/src/modules/welcome/controllers/welcome.controller.ts +14 -0
- package/template/src/modules/welcome/controllers/welcome.schema.ts +6 -0
- package/template/src/modules/welcome/database/models/welcome.ts +6 -0
- package/template/src/modules/welcome/routes/api.ts +20 -0
- package/template/src/resources/index.html +16 -0
- package/template/src/resources/src/App.vue +5 -0
- package/template/src/resources/src/assets/css/styles.css +14934 -0
- package/template/src/resources/src/assets/css/styles.css.map +1 -0
- package/template/src/resources/src/assets/images/favicon/favicon.ico +0 -0
- package/template/src/resources/src/assets/images/favicon/favicon1.ico +0 -0
- package/template/src/resources/src/assets/images/logo-1.png +0 -0
- package/template/src/resources/src/assets/images/logo-dark-sm.png +0 -0
- package/template/src/resources/src/assets/images/logo-dark.png +0 -0
- package/template/src/resources/src/assets/images/logo-dark1.png +0 -0
- package/template/src/resources/src/assets/images/logo-sm.png +0 -0
- package/template/src/resources/src/assets/images/logo1.png +0 -0
- package/template/src/resources/src/assets/images/logo2.png +0 -0
- package/template/src/resources/src/assets/scss/custom.css +217 -0
- package/template/src/resources/src/assets/scss/custom.css.map +1 -0
- package/template/src/resources/src/assets/scss/custom.scss +1100 -0
- package/template/src/resources/src/components/Button.vue +35 -0
- package/template/src/resources/src/components/Checkbox.vue +29 -0
- package/template/src/resources/src/components/FloatButton.vue +36 -0
- package/template/src/resources/src/components/Href.vue +32 -0
- package/template/src/resources/src/components/Input.vue +227 -0
- package/template/src/resources/src/components/InputGroup.vue +153 -0
- package/template/src/resources/src/components/InputPasswordToggle.vue +226 -0
- package/template/src/resources/src/components/Modal.vue +102 -0
- package/template/src/resources/src/components/Pagebar.vue +28 -0
- package/template/src/resources/src/components/Refresh.vue +26 -0
- package/template/src/resources/src/components/Select.vue +390 -0
- package/template/src/resources/src/components/Spinner.vue +42 -0
- package/template/src/resources/src/components/Switch.vue +65 -0
- package/template/src/resources/src/components/TextArea.vue +121 -0
- package/template/src/resources/src/components/Toast.vue +56 -0
- package/template/src/resources/src/components/datatable/DataTableSkeleton.vue +99 -0
- package/template/src/resources/src/components/datatable/Pagination.vue +161 -0
- package/template/src/resources/src/components/datatable/SelectOpption.vue +54 -0
- package/template/src/resources/src/components/datatable/index.vue +237 -0
- package/template/src/resources/src/composables/useAuth.ts +52 -0
- package/template/src/resources/src/composables/useBrowserDetect.ts +5 -0
- package/template/src/resources/src/composables/useDialog.ts +5 -0
- package/template/src/resources/src/composables/useGum.ts +3 -0
- package/template/src/resources/src/composables/usePulse.ts +5 -0
- package/template/src/resources/src/env.d.ts +20 -0
- package/template/src/resources/src/helpers/nformatter.ts +10 -0
- package/template/src/resources/src/helpers/utils.ts +68 -0
- package/template/src/resources/src/layouts/AuthLayout.vue +20 -0
- package/template/src/resources/src/layouts/Layout/Footer.vue +23 -0
- package/template/src/resources/src/layouts/Layout/Header.vue +90 -0
- package/template/src/resources/src/layouts/Layout/Sidebar.vue +137 -0
- package/template/src/resources/src/layouts/Layout/index.vue +76 -0
- package/template/src/resources/src/main.ts +27 -0
- package/template/src/resources/src/pages/auth/forgetPassword.vue +76 -0
- package/template/src/resources/src/pages/auth/login.vue +93 -0
- package/template/src/resources/src/pages/auth/register.vue +130 -0
- package/template/src/resources/src/pages/auth/resetPassword.vue +119 -0
- package/template/src/resources/src/pages/auth/verifyEmail.vue +60 -0
- package/template/src/resources/src/pages/dashboard/index.vue +76 -0
- package/template/src/resources/src/plugins/axios.ts +33 -0
- package/template/src/resources/src/plugins/browserDetect.ts +55 -0
- package/template/src/resources/src/plugins/dialog.ts +167 -0
- package/template/src/resources/src/plugins/gum.ts +343 -0
- package/template/src/resources/src/plugins/pulse.ts +141 -0
- package/template/src/resources/src/plugins/routeProgress.ts +87 -0
- package/template/src/resources/src/router/index.ts +85 -0
- package/template/src/resources/src/stores/admin-ui.ts +148 -0
- package/template/src/resources/src/stores/auth.ts +151 -0
- package/template/src/resources/tsconfig.json +19 -0
- package/template/src/resources/vite.config.ts +43 -0
- package/template/src/storage/logs/app.log +20179 -0
- package/template/src/storage/logs/fatal.log +727 -0
- package/template/tsconfig.json +20 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { computed, ref } from "vue";
|
|
2
|
+
import { defineStore } from "pinia";
|
|
3
|
+
|
|
4
|
+
const THEME_KEY = "app-theme";
|
|
5
|
+
const SIDEBAR_COLLAPSE_KEY = "sidebar-open-collapses";
|
|
6
|
+
const SIDEBAR_SCROLL_KEY = "sidebar-scroll-top";
|
|
7
|
+
type ThemeMode = "light" | "dark" | "auto";
|
|
8
|
+
|
|
9
|
+
export const useAdminUiStore = defineStore("admin-ui", () => {
|
|
10
|
+
const sidebarOpen = ref(false);
|
|
11
|
+
const themeMode = ref<ThemeMode>("auto");
|
|
12
|
+
const sidebarOpenCollapseIds = ref<string[]>([]);
|
|
13
|
+
const sidebarScrollTop = ref(0);
|
|
14
|
+
let sidebarAccordionEl: HTMLElement | null = null;
|
|
15
|
+
let sidebarScrollListener: (() => void) | null = null;
|
|
16
|
+
|
|
17
|
+
const themeIcon = computed(() => {
|
|
18
|
+
if (themeMode.value === "light") return "bi-brightness-high-fill";
|
|
19
|
+
return "bi-moon-stars";
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const toggleSidebar = () => {
|
|
23
|
+
sidebarOpen.value = !sidebarOpen.value;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const closeSidebar = () => {
|
|
27
|
+
sidebarOpen.value = false;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const applyTheme = (mode: ThemeMode) => {
|
|
31
|
+
themeMode.value = mode;
|
|
32
|
+
document.body.classList.remove("theme-light", "theme-dark", "theme-auto");
|
|
33
|
+
document.body.classList.add(`theme-${mode}`);
|
|
34
|
+
localStorage.setItem(THEME_KEY, mode);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const cycleTheme = () => {
|
|
38
|
+
const order: ThemeMode[] = ["light", "dark"];
|
|
39
|
+
const index = order.indexOf(themeMode.value);
|
|
40
|
+
applyTheme(order[(index + 1) % order.length]);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const initTheme = () => {
|
|
44
|
+
const saved = localStorage.getItem(THEME_KEY);
|
|
45
|
+
if (saved === "light" || saved === "dark") {
|
|
46
|
+
applyTheme(saved);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
applyTheme("light");
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const cleanupTheme = () => { };
|
|
54
|
+
|
|
55
|
+
const loadSidebarCollapseIds = () => {
|
|
56
|
+
try {
|
|
57
|
+
const raw = localStorage.getItem(SIDEBAR_COLLAPSE_KEY);
|
|
58
|
+
sidebarOpenCollapseIds.value = raw ? (JSON.parse(raw) as string[]) : [];
|
|
59
|
+
} catch {
|
|
60
|
+
sidebarOpenCollapseIds.value = [];
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const persistSidebarCollapseIds = () => {
|
|
65
|
+
localStorage.setItem(SIDEBAR_COLLAPSE_KEY, JSON.stringify(sidebarOpenCollapseIds.value));
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const setSidebarCollapseOpen = (id: string, open: boolean) => {
|
|
69
|
+
const ids = new Set(sidebarOpenCollapseIds.value);
|
|
70
|
+
if (open) ids.add(id);
|
|
71
|
+
else ids.delete(id);
|
|
72
|
+
sidebarOpenCollapseIds.value = Array.from(ids);
|
|
73
|
+
persistSidebarCollapseIds();
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const restoreSidebarCollapseState = () => {
|
|
77
|
+
sidebarOpenCollapseIds.value.forEach((id) => {
|
|
78
|
+
const collapse = document.getElementById(id);
|
|
79
|
+
if (!collapse) return;
|
|
80
|
+
collapse.classList.add("show");
|
|
81
|
+
const trigger = document.querySelector(`[data-bs-target="#${id}"]`);
|
|
82
|
+
if (trigger instanceof HTMLElement) {
|
|
83
|
+
trigger.classList.remove("collapsed");
|
|
84
|
+
trigger.setAttribute("aria-expanded", "true");
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const onSidebarCollapseShown = (event: Event) => {
|
|
90
|
+
const target = event.target as HTMLElement | null;
|
|
91
|
+
if (!target?.id) return;
|
|
92
|
+
setSidebarCollapseOpen(target.id, true);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const onSidebarCollapseHidden = (event: Event) => {
|
|
96
|
+
const target = event.target as HTMLElement | null;
|
|
97
|
+
if (!target?.id) return;
|
|
98
|
+
setSidebarCollapseOpen(target.id, false);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const initSidebarCollapsePersistence = () => {
|
|
102
|
+
loadSidebarCollapseIds();
|
|
103
|
+
restoreSidebarCollapseState();
|
|
104
|
+
|
|
105
|
+
const sidebarAccordion = document.querySelector(".sidebar .accordion");
|
|
106
|
+
if (sidebarAccordion instanceof HTMLElement) {
|
|
107
|
+
const storedTop = Number(localStorage.getItem(SIDEBAR_SCROLL_KEY) || "0");
|
|
108
|
+
sidebarScrollTop.value = Number.isFinite(storedTop) ? storedTop : 0;
|
|
109
|
+
sidebarAccordion.scrollTop = sidebarScrollTop.value;
|
|
110
|
+
|
|
111
|
+
sidebarAccordionEl = sidebarAccordion;
|
|
112
|
+
sidebarScrollListener = () => {
|
|
113
|
+
sidebarScrollTop.value = sidebarAccordion.scrollTop;
|
|
114
|
+
localStorage.setItem(SIDEBAR_SCROLL_KEY, String(sidebarScrollTop.value));
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
sidebarAccordion.addEventListener("scroll", sidebarScrollListener, { passive: true });
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
document.addEventListener("shown.bs.collapse", onSidebarCollapseShown);
|
|
121
|
+
document.addEventListener("hidden.bs.collapse", onSidebarCollapseHidden);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const cleanupSidebarCollapsePersistence = () => {
|
|
125
|
+
if (sidebarAccordionEl && sidebarScrollListener) {
|
|
126
|
+
sidebarAccordionEl.removeEventListener("scroll", sidebarScrollListener);
|
|
127
|
+
}
|
|
128
|
+
sidebarAccordionEl = null;
|
|
129
|
+
sidebarScrollListener = null;
|
|
130
|
+
document.removeEventListener("shown.bs.collapse", onSidebarCollapseShown);
|
|
131
|
+
document.removeEventListener("hidden.bs.collapse", onSidebarCollapseHidden);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
return {
|
|
135
|
+
sidebarOpen,
|
|
136
|
+
themeMode,
|
|
137
|
+
themeIcon,
|
|
138
|
+
toggleSidebar,
|
|
139
|
+
closeSidebar,
|
|
140
|
+
applyTheme,
|
|
141
|
+
cycleTheme,
|
|
142
|
+
initTheme,
|
|
143
|
+
cleanupTheme,
|
|
144
|
+
sidebarOpenCollapseIds,
|
|
145
|
+
initSidebarCollapsePersistence,
|
|
146
|
+
cleanupSidebarCollapsePersistence
|
|
147
|
+
};
|
|
148
|
+
});
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { defineStore } from "pinia";
|
|
2
|
+
import { ref } from "vue";
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
import { clearUser, setUser, type AuthUser } from "@/composables/useAuth";
|
|
5
|
+
|
|
6
|
+
type LoginPayload = { email: string; password: string; remember?: boolean; };
|
|
7
|
+
type RegisterPayload = {
|
|
8
|
+
name: string;
|
|
9
|
+
email: string;
|
|
10
|
+
password: string;
|
|
11
|
+
password_confirmation: string;
|
|
12
|
+
};
|
|
13
|
+
type VerifyEmailPayload = { email: string; token: string; };
|
|
14
|
+
type ForgotPayload = { email: string; };
|
|
15
|
+
type ResetPayload = {
|
|
16
|
+
email: string;
|
|
17
|
+
token: string;
|
|
18
|
+
password: string;
|
|
19
|
+
password_confirmation: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
type ApiResponse<T> = { message: string; data?: T; };
|
|
23
|
+
type AuthData = { user: AuthUser; };
|
|
24
|
+
|
|
25
|
+
async function request<T>(method: "GET" | "POST", path: string, payload?: unknown): Promise<ApiResponse<T>> {
|
|
26
|
+
try {
|
|
27
|
+
const response = await axios.request<ApiResponse<T>>({
|
|
28
|
+
method,
|
|
29
|
+
url: `/api/auth${path}`,
|
|
30
|
+
data: payload
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
return response.data;
|
|
34
|
+
} catch (error: unknown) {
|
|
35
|
+
if (axios.isAxiosError(error)) {
|
|
36
|
+
throw new Error(String(error.response?.data?.message || error.message || "Request failed"));
|
|
37
|
+
}
|
|
38
|
+
throw new Error("Request failed");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const useAuthStore = defineStore("auth", () => {
|
|
43
|
+
const user = ref<AuthUser | null>(null);
|
|
44
|
+
const isAuthenticated = ref(false);
|
|
45
|
+
const processing = ref(false);
|
|
46
|
+
const initialized = ref(false);
|
|
47
|
+
|
|
48
|
+
const syncUser = (value: AuthUser | null) => {
|
|
49
|
+
user.value = value;
|
|
50
|
+
isAuthenticated.value = !!value;
|
|
51
|
+
if (value) setUser(value);
|
|
52
|
+
else clearUser();
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const bootstrap = async () => {
|
|
56
|
+
if (initialized.value) return;
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
const data = await request<AuthUser>("GET", "/me");
|
|
60
|
+
syncUser((data?.data || null) as AuthUser | null);
|
|
61
|
+
} catch {
|
|
62
|
+
syncUser(null);
|
|
63
|
+
} finally {
|
|
64
|
+
initialized.value = true;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const login = async (payload: LoginPayload) => {
|
|
69
|
+
processing.value = true;
|
|
70
|
+
try {
|
|
71
|
+
const data = await request<AuthData>("POST", "/login", payload);
|
|
72
|
+
syncUser((data?.data?.user || null) as AuthUser | null);
|
|
73
|
+
initialized.value = true;
|
|
74
|
+
return data.message || "Login successful";
|
|
75
|
+
} finally {
|
|
76
|
+
processing.value = false;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const register = async (payload: RegisterPayload) => {
|
|
81
|
+
processing.value = true;
|
|
82
|
+
try {
|
|
83
|
+
const data = await request<AuthData>("POST", "/register", payload);
|
|
84
|
+
const createdUser = (data?.data?.user || null) as AuthUser | null;
|
|
85
|
+
if (createdUser) {
|
|
86
|
+
syncUser(createdUser);
|
|
87
|
+
initialized.value = true;
|
|
88
|
+
} else {
|
|
89
|
+
syncUser(null);
|
|
90
|
+
}
|
|
91
|
+
return data.message || "Registration successful";
|
|
92
|
+
} finally {
|
|
93
|
+
processing.value = false;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const verifyEmail = async (payload: VerifyEmailPayload) => {
|
|
98
|
+
processing.value = true;
|
|
99
|
+
try {
|
|
100
|
+
const data = await request<unknown>("POST", "/verify-email", payload);
|
|
101
|
+
return data.message || "Email verified successfully";
|
|
102
|
+
} finally {
|
|
103
|
+
processing.value = false;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const forgotPassword = async (payload: ForgotPayload) => {
|
|
108
|
+
processing.value = true;
|
|
109
|
+
try {
|
|
110
|
+
const data = await request<unknown>("POST", "/forgot-password", payload);
|
|
111
|
+
return data.message || "If this email exists, a reset link has been sent";
|
|
112
|
+
} finally {
|
|
113
|
+
processing.value = false;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const resetPassword = async (payload: ResetPayload) => {
|
|
118
|
+
processing.value = true;
|
|
119
|
+
try {
|
|
120
|
+
const data = await request<unknown>("POST", "/reset-password", payload);
|
|
121
|
+
return data.message || "Password reset successfully";
|
|
122
|
+
} finally {
|
|
123
|
+
processing.value = false;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const logout = async () => {
|
|
128
|
+
processing.value = true;
|
|
129
|
+
try {
|
|
130
|
+
await request<unknown>("POST", "/logout");
|
|
131
|
+
} finally {
|
|
132
|
+
syncUser(null);
|
|
133
|
+
processing.value = false;
|
|
134
|
+
initialized.value = true;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
return {
|
|
139
|
+
user,
|
|
140
|
+
isAuthenticated,
|
|
141
|
+
processing,
|
|
142
|
+
initialized,
|
|
143
|
+
bootstrap,
|
|
144
|
+
register,
|
|
145
|
+
login,
|
|
146
|
+
forgotPassword,
|
|
147
|
+
resetPassword,
|
|
148
|
+
verifyEmail,
|
|
149
|
+
logout
|
|
150
|
+
};
|
|
151
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "Bundler",
|
|
6
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
7
|
+
"paths": {
|
|
8
|
+
"@/*": ["./src/*"]
|
|
9
|
+
},
|
|
10
|
+
"strict": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"esModuleInterop": true,
|
|
15
|
+
"noEmit": true,
|
|
16
|
+
"types": ["vite/client", "vue"]
|
|
17
|
+
},
|
|
18
|
+
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.vue"]
|
|
19
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { defineConfig } from "vite";
|
|
2
|
+
import vue from "@vitejs/plugin-vue";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { fileURLToPath, URL } from "node:url";
|
|
5
|
+
import { env } from "../env.ts";
|
|
6
|
+
|
|
7
|
+
const cacheBase = process.env.LOCALAPPDATA || process.env.TEMP || ".";
|
|
8
|
+
const apiUrl = env.APP_URL;
|
|
9
|
+
|
|
10
|
+
const proxy: Record<string, any> = {
|
|
11
|
+
"/api": { target: apiUrl, changeOrigin: true },
|
|
12
|
+
"/health": { target: apiUrl, changeOrigin: true },
|
|
13
|
+
"/storage": { target: apiUrl, changeOrigin: true }
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
proxy["/socket.io"] = { target: apiUrl, changeOrigin: true, ws: true };
|
|
17
|
+
|
|
18
|
+
export default defineConfig({
|
|
19
|
+
define: { __SOCKET_ENABLED__: env.SOCKET },
|
|
20
|
+
root: "src/resources",
|
|
21
|
+
cacheDir: path.join(cacheBase, "nexgen", "vite-cache", "resources"),
|
|
22
|
+
plugins: [vue()],
|
|
23
|
+
css: {
|
|
24
|
+
preprocessorOptions: {
|
|
25
|
+
scss: {
|
|
26
|
+
quietDeps: true
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
resolve: {
|
|
31
|
+
alias: {
|
|
32
|
+
"@": fileURLToPath(new URL("./src", import.meta.url))
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
build: {
|
|
36
|
+
outDir: "../../public",
|
|
37
|
+
emptyOutDir: true
|
|
38
|
+
},
|
|
39
|
+
server: {
|
|
40
|
+
port: 5173,
|
|
41
|
+
proxy
|
|
42
|
+
}
|
|
43
|
+
});
|