create-saasicat-admin 0.4.0 → 0.6.0
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 +1 -1
- package/templates/index.html.tpl +1 -0
- package/templates/src/main.ts.tpl +19 -4
- package/templates/src/services/http.ts.tpl +5 -0
- package/templates/src/services/platform-loaders.ts.tpl +15 -0
- package/templates/src/stores/manifest.ts.tpl +10 -0
- package/templates/vite.config.ts.tpl +9 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-saasicat-admin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Scaffolding CLI for SuperAdmin frontend projects (Vue 3 + Quasar + Vite). Generates a minimal working admin app built on @saasicat/ui-vue. Usage: `pnpm create saasicat-admin <dir>`.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/templates/index.html.tpl
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>__BRAND_NAME__ SuperAdmin</title>
|
|
7
|
+
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Crect width='16' height='16' rx='3' fill='%23f5a623'/%3E%3Cpath d='M5 4h6v1H5zM5 7h6v1H5zM5 10h4v1H5z' fill='%230f172a'/%3E%3C/svg%3E" />
|
|
7
8
|
</head>
|
|
8
9
|
<body>
|
|
9
10
|
<div id="app"></div>
|
|
@@ -1,17 +1,22 @@
|
|
|
1
|
-
// Bootstrap. createSuperAdminApp
|
|
1
|
+
// Bootstrap. createSuperAdminApp wires up Quasar + Pinia + Router + guards.
|
|
2
2
|
|
|
3
3
|
import 'quasar/src/css/index.sass';
|
|
4
4
|
import '@quasar/extras/material-icons/material-icons.css';
|
|
5
|
+
// Platform page styles (sa-* classes + CSS variables). Without it the
|
|
6
|
+
// standard pages render unstyled.
|
|
7
|
+
import '@saasicat/ui-vue/sa-theme.css';
|
|
5
8
|
|
|
6
|
-
import { createSuperAdminApp } from '@saasicat/ui-vue';
|
|
9
|
+
import { createSuperAdminApp } from '@saasicat/ui-vue/quasar';
|
|
7
10
|
import App from './App.vue';
|
|
8
11
|
import { appRoutes } from './router/routes';
|
|
9
|
-
import { adminLogin, isAuthenticated } from './services/http';
|
|
12
|
+
import { platformHttp, adminLogin, isAuthenticated } from './services/http';
|
|
13
|
+
import { ADMIN_ENDPOINTS } from './services/platform-loaders';
|
|
14
|
+
import { useManifestStore } from './stores/manifest';
|
|
10
15
|
|
|
11
16
|
const handle = createSuperAdminApp({
|
|
12
17
|
rootComponent: App,
|
|
13
18
|
brand: { logoText: '__LOGO_TEXT__', name: '__BRAND_NAME__' },
|
|
14
|
-
endpoints:
|
|
19
|
+
endpoints: ADMIN_ENDPOINTS,
|
|
15
20
|
appRoutes,
|
|
16
21
|
loginAdapter: { login: adminLogin },
|
|
17
22
|
authGuard: {
|
|
@@ -19,10 +24,20 @@ const handle = createSuperAdminApp({
|
|
|
19
24
|
onUnauthenticated: () => '/login',
|
|
20
25
|
},
|
|
21
26
|
manifestGuard: {
|
|
27
|
+
// Lazy store access: the Pinia instance exists once
|
|
28
|
+
// createSuperAdminApp() has run; the guard only fires afterwards.
|
|
29
|
+
ensureLoaded: () => useManifestStore().ensureLoaded(),
|
|
30
|
+
getManifest: () => useManifestStore().manifest,
|
|
22
31
|
errorRoute: '/admin-error',
|
|
23
32
|
},
|
|
33
|
+
// Platform pages issue their own requests (KPI cards, tenant tables) —
|
|
34
|
+
// without this they would fall back to a bare fetch() and lose the app's auth.
|
|
35
|
+
http: platformHttp,
|
|
24
36
|
actions: {},
|
|
25
37
|
extensions: {},
|
|
38
|
+
// UI language: 'de' (default) or 'en'. Pass a Ref to switch at runtime,
|
|
39
|
+
// `overrides` to replace individual strings (handbook §8.6).
|
|
40
|
+
i18n: { locale: 'de' },
|
|
26
41
|
});
|
|
27
42
|
|
|
28
43
|
handle.mount('#app');
|
|
@@ -57,3 +57,8 @@ export async function adminLogin(email: string, password: string) {
|
|
|
57
57
|
export function isAuthenticated(): boolean {
|
|
58
58
|
return !!localStorage.getItem(TOKEN_KEY);
|
|
59
59
|
}
|
|
60
|
+
|
|
61
|
+
/** Auth-token provider for the platform loaders (`Authorization: Bearer …`). */
|
|
62
|
+
export function getAuthToken(): string | null {
|
|
63
|
+
return localStorage.getItem(TOKEN_KEY);
|
|
64
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// BootLoader + ManifestLoader built from the same endpoint constant that
|
|
2
|
+
// `main.ts` passes to `createSuperAdminApp()` — endpoints live in exactly
|
|
3
|
+
// one place (handbook §8.1).
|
|
4
|
+
|
|
5
|
+
import { createPlatformLoaders, type SuperAdminEndpoints } from '@saasicat/ui-vue';
|
|
6
|
+
import { getAuthToken, platformHttp } from './http';
|
|
7
|
+
|
|
8
|
+
export const ADMIN_ENDPOINTS: SuperAdminEndpoints = { apiBase: '__API_BASE__' };
|
|
9
|
+
|
|
10
|
+
export const loaders = createPlatformLoaders({
|
|
11
|
+
endpoints: ADMIN_ENDPOINTS,
|
|
12
|
+
http: platformHttp,
|
|
13
|
+
storageKeyPrefix: '__PROJECT_KEY__:',
|
|
14
|
+
getAuthToken,
|
|
15
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Manifest Pinia store — the router guard in `main.ts` awaits
|
|
2
|
+
// `ensureLoaded()` before rendering admin routes (handbook §8.2).
|
|
3
|
+
|
|
4
|
+
import { createManifestStore } from '@saasicat/ui-vue';
|
|
5
|
+
import { loaders } from '../services/platform-loaders';
|
|
6
|
+
|
|
7
|
+
export const useManifestStore = createManifestStore({
|
|
8
|
+
loader: loaders.manifestLoader,
|
|
9
|
+
id: 'admin-manifest',
|
|
10
|
+
});
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
1
2
|
import { defineConfig } from 'vite';
|
|
2
3
|
import vue from '@vitejs/plugin-vue';
|
|
3
4
|
import { quasar } from '@quasar/vite-plugin';
|
|
4
5
|
|
|
5
6
|
export default defineConfig({
|
|
6
7
|
base: '/admin/',
|
|
7
|
-
plugins: [
|
|
8
|
+
plugins: [
|
|
9
|
+
vue(),
|
|
10
|
+
quasar({
|
|
11
|
+
// Absolute path — sass resolves plain relative paths against the
|
|
12
|
+
// importing file inside node_modules/quasar, not the project root.
|
|
13
|
+
sassVariables: fileURLToPath(new URL('./src/styles/theme.scss', import.meta.url)),
|
|
14
|
+
}),
|
|
15
|
+
],
|
|
8
16
|
server: {
|
|
9
17
|
port: __DEV_PORT__,
|
|
10
18
|
proxy: {
|