@qlover/create-app 0.7.6 → 0.7.7
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/CHANGELOG.md +237 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/templates/next-app/.env.template +22 -0
- package/dist/templates/next-app/.prettierignore +58 -0
- package/dist/templates/next-app/README.md +36 -0
- package/dist/templates/next-app/build/generateLocales.ts +25 -0
- package/dist/templates/next-app/config/IOCIdentifier.ts +45 -0
- package/dist/templates/next-app/config/Identifier/common.error.ts +34 -0
- package/dist/templates/next-app/config/Identifier/common.ts +62 -0
- package/dist/templates/next-app/config/Identifier/index.ts +10 -0
- package/dist/templates/next-app/config/Identifier/page.about.ts +181 -0
- package/dist/templates/next-app/config/Identifier/page.executor.ts +272 -0
- package/dist/templates/next-app/config/Identifier/page.home.ts +63 -0
- package/dist/templates/next-app/config/Identifier/page.identifiter.ts +39 -0
- package/dist/templates/next-app/config/Identifier/page.jsonStorage.ts +72 -0
- package/dist/templates/next-app/config/Identifier/page.login.ts +165 -0
- package/dist/templates/next-app/config/Identifier/page.register.ts +147 -0
- package/dist/templates/next-app/config/Identifier/page.request.ts +182 -0
- package/dist/templates/next-app/config/common.ts +34 -0
- package/dist/templates/next-app/config/i18n/PageI18nInterface.ts +51 -0
- package/dist/templates/next-app/config/i18n/i18nConfig.ts +12 -0
- package/dist/templates/next-app/config/i18n/index.ts +3 -0
- package/dist/templates/next-app/config/i18n/loginI18n.ts +42 -0
- package/dist/templates/next-app/config/theme.ts +23 -0
- package/dist/templates/next-app/docs/env.md +94 -0
- package/dist/templates/next-app/eslint.config.mjs +181 -0
- package/dist/templates/next-app/next.config.ts +21 -0
- package/dist/templates/next-app/package.json +58 -0
- package/dist/templates/next-app/plugins/eslint-plugin-testid.mjs +94 -0
- package/dist/templates/next-app/plugins/generateLocalesPlugin.ts +33 -0
- package/dist/templates/next-app/postcss.config.mjs +5 -0
- package/dist/templates/next-app/public/file.svg +1 -0
- package/dist/templates/next-app/public/globe.svg +1 -0
- package/dist/templates/next-app/public/locales/en/common.json +183 -0
- package/dist/templates/next-app/public/locales/zh/common.json +183 -0
- package/dist/templates/next-app/public/next.svg +1 -0
- package/dist/templates/next-app/public/vercel.svg +1 -0
- package/dist/templates/next-app/public/window.svg +1 -0
- package/dist/templates/next-app/src/app/[locale]/favicon.ico +0 -0
- package/dist/templates/next-app/src/app/[locale]/layout.tsx +44 -0
- package/dist/templates/next-app/src/app/[locale]/login/FeatureItem.tsx +13 -0
- package/dist/templates/next-app/src/app/[locale]/login/LoginForm.tsx +115 -0
- package/dist/templates/next-app/src/app/[locale]/login/page.tsx +73 -0
- package/dist/templates/next-app/src/app/[locale]/not-found.tsx +24 -0
- package/dist/templates/next-app/src/app/[locale]/page.tsx +106 -0
- package/dist/templates/next-app/src/base/cases/AppConfig.ts +15 -0
- package/dist/templates/next-app/src/base/cases/InversifyContainer.ts +33 -0
- package/dist/templates/next-app/src/base/port/I18nServiceInterface.ts +25 -0
- package/dist/templates/next-app/src/base/port/UserServiceInterface.ts +11 -0
- package/dist/templates/next-app/src/base/services/I18nService.ts +115 -0
- package/dist/templates/next-app/src/base/services/UserService.ts +23 -0
- package/dist/templates/next-app/src/core/IOC.ts +58 -0
- package/dist/templates/next-app/src/core/IocRegisterImpl.ts +100 -0
- package/dist/templates/next-app/src/core/bootstraps/BootstrapClient.ts +98 -0
- package/dist/templates/next-app/src/core/bootstraps/BootstrapsRegistry.ts +47 -0
- package/dist/templates/next-app/src/core/bootstraps/IocIdentifierTest.ts +26 -0
- package/dist/templates/next-app/src/core/bootstraps/PrintBootstrap.ts +18 -0
- package/dist/templates/next-app/src/core/globals.ts +21 -0
- package/dist/templates/next-app/src/i18n/request.ts +22 -0
- package/dist/templates/next-app/src/i18n/routing.ts +30 -0
- package/dist/templates/next-app/src/middleware.ts +22 -0
- package/dist/templates/next-app/src/server/getServerI18n.ts +26 -0
- package/dist/templates/next-app/src/styles/css/antd-themes/_default.css +239 -0
- package/dist/templates/next-app/src/styles/css/antd-themes/dark.css +178 -0
- package/dist/templates/next-app/src/styles/css/antd-themes/index.css +3 -0
- package/dist/templates/next-app/src/styles/css/antd-themes/no-context.css +34 -0
- package/dist/templates/next-app/src/styles/css/antd-themes/pink.css +204 -0
- package/dist/templates/next-app/src/styles/css/index.css +6 -0
- package/dist/templates/next-app/src/styles/css/page.css +19 -0
- package/dist/templates/next-app/src/styles/css/tailwind.css +5 -0
- package/dist/templates/next-app/src/styles/css/themes/_default.css +29 -0
- package/dist/templates/next-app/src/styles/css/themes/dark.css +29 -0
- package/dist/templates/next-app/src/styles/css/themes/index.css +3 -0
- package/dist/templates/next-app/src/styles/css/themes/pink.css +29 -0
- package/dist/templates/next-app/src/styles/css/zIndex.css +9 -0
- package/dist/templates/next-app/src/uikit/components/BaseHeader.tsx +42 -0
- package/dist/templates/next-app/src/uikit/components/BootstrapsProvider.tsx +25 -0
- package/dist/templates/next-app/src/uikit/components/ComboProvider.tsx +45 -0
- package/dist/templates/next-app/src/uikit/components/LanguageSwitcher.tsx +52 -0
- package/dist/templates/next-app/src/uikit/components/LocaleLink.tsx +51 -0
- package/dist/templates/next-app/src/uikit/components/NextIntlProvider.tsx +21 -0
- package/dist/templates/next-app/src/uikit/components/ThemeSwitcher.tsx +86 -0
- package/dist/templates/next-app/src/uikit/context/IOCContext.ts +6 -0
- package/dist/templates/next-app/src/uikit/hook/useI18nInterface.ts +28 -0
- package/dist/templates/next-app/src/uikit/hook/useIOC.ts +37 -0
- package/dist/templates/next-app/src/uikit/hook/useMountedClient.ts +11 -0
- package/dist/templates/next-app/src/uikit/hook/useStore.ts +15 -0
- package/dist/templates/next-app/tailwind.config.ts +8 -0
- package/dist/templates/next-app/tsconfig.json +36 -0
- package/package.json +1 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useTranslations } from 'next-intl';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import type { PageI18nInterface } from '@config/i18n/PageI18nInterface';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Hook to get the i18n interface
|
|
7
|
+
*
|
|
8
|
+
* @param i18nInterface - The i18n interface to get
|
|
9
|
+
* @returns The i18n interface
|
|
10
|
+
*/
|
|
11
|
+
export function useI18nInterface<T extends PageI18nInterface>(
|
|
12
|
+
i18nInterface: T
|
|
13
|
+
): T {
|
|
14
|
+
const t = useTranslations();
|
|
15
|
+
|
|
16
|
+
const i18n = useMemo(() => {
|
|
17
|
+
return Object.fromEntries(
|
|
18
|
+
Object.entries(i18nInterface).map(([key, value]) => {
|
|
19
|
+
if (typeof value === 'string') {
|
|
20
|
+
return [key, t(value)];
|
|
21
|
+
}
|
|
22
|
+
return [key, value];
|
|
23
|
+
})
|
|
24
|
+
) as T;
|
|
25
|
+
}, [i18nInterface, t]);
|
|
26
|
+
|
|
27
|
+
return i18n;
|
|
28
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { IOCContext } from '../context/IOCContext';
|
|
3
|
+
import type { IOCIdentifierMap } from '@config/IOCIdentifier';
|
|
4
|
+
import type {
|
|
5
|
+
IOCContainerInterface,
|
|
6
|
+
IOCFunctionInterface
|
|
7
|
+
} from '@qlover/corekit-bridge';
|
|
8
|
+
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
type IOCIdentifier = keyof IOCIdentifierMap | (new (...args: any[]) => any);
|
|
11
|
+
|
|
12
|
+
export function useIOC(): IOCFunctionInterface<
|
|
13
|
+
IOCIdentifierMap,
|
|
14
|
+
IOCContainerInterface
|
|
15
|
+
>;
|
|
16
|
+
export function useIOC<T extends IOCIdentifier>(
|
|
17
|
+
identifier: T
|
|
18
|
+
): T extends keyof IOCIdentifierMap
|
|
19
|
+
? IOCIdentifierMap[T]
|
|
20
|
+
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
+
T extends new (...args: any[]) => any
|
|
22
|
+
? InstanceType<T>
|
|
23
|
+
: never;
|
|
24
|
+
|
|
25
|
+
export function useIOC<T extends IOCIdentifier>(identifier?: T) {
|
|
26
|
+
const IOC = useContext(IOCContext);
|
|
27
|
+
|
|
28
|
+
if (!IOC) {
|
|
29
|
+
throw new Error('IOC is not found');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (identifier === undefined) {
|
|
33
|
+
return IOC;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return IOC(identifier);
|
|
37
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useSliceStore, type SliceStore } from '@qlover/slice-store-react';
|
|
2
|
+
import type {
|
|
3
|
+
StoreInterface,
|
|
4
|
+
StoreStateInterface
|
|
5
|
+
} from '@qlover/corekit-bridge';
|
|
6
|
+
|
|
7
|
+
export function useStore<
|
|
8
|
+
C extends StoreInterface<StoreStateInterface>,
|
|
9
|
+
State = C['state']
|
|
10
|
+
>(store: C, selector?: (state: C['state']) => State): State {
|
|
11
|
+
return useSliceStore(
|
|
12
|
+
store as unknown as SliceStore<StoreStateInterface>,
|
|
13
|
+
selector
|
|
14
|
+
);
|
|
15
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2017",
|
|
4
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
5
|
+
"allowJs": true,
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"noEmit": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"module": "esnext",
|
|
11
|
+
"moduleResolution": "bundler",
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"jsx": "preserve",
|
|
15
|
+
"incremental": true,
|
|
16
|
+
"experimentalDecorators": true,
|
|
17
|
+
"emitDecoratorMetadata": true,
|
|
18
|
+
"plugins": [
|
|
19
|
+
{
|
|
20
|
+
"name": "next"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"paths": {
|
|
24
|
+
"@/*": ["./src/*"],
|
|
25
|
+
"@config/*": ["./config/*"]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"include": [
|
|
29
|
+
"next-env.d.ts",
|
|
30
|
+
"src/**/*.ts",
|
|
31
|
+
"src/**/*.tsx",
|
|
32
|
+
".next/types/**/*.ts",
|
|
33
|
+
"config/**/*.ts"
|
|
34
|
+
],
|
|
35
|
+
"exclude": ["node_modules"]
|
|
36
|
+
}
|