@qlover/create-app 0.4.3 → 0.4.5

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 CHANGED
@@ -1,5 +1,54 @@
1
1
  # @qlover/create-app
2
2
 
3
+ ## 0.4.5
4
+
5
+ ### Patch Changes
6
+
7
+ #### ✨ Features
8
+
9
+ - **create-app:** implement logout functionality and enhance localization ([c49f956](https://github.com/qlover/fe-base/commit/c49f956aecbc11a6b96b28309d112f7219a7dcca)) ([#438](https://github.com/qlover/fe-base/pull/438))
10
+
11
+ - Added a new LogoutButton component to handle user logout with a confirmation dialog.
12
+ - Introduced localization keys for logout dialog titles and content in both English and Chinese.
13
+ - Updated BaseHeader to conditionally display the logout button based on the layout context.
14
+ - Refactored AppConfig to utilize the Vite environment mode directly.
15
+ - Adjusted LoginInterface to accept a more generic parameter type for login.
16
+
17
+ This update improves user experience by providing a clear logout process and enhances localization support for logout-related messages.
18
+
19
+ ## 0.4.4
20
+
21
+ ### Patch Changes
22
+
23
+ #### ✨ Features
24
+
25
+ - **create-app:** add error identifiers and localization support for new components ([0ec3780](https://github.com/qlover/fe-base/commit/0ec3780a7972acd855e1b4d2ae866575534dc094)) ([#434](https://github.com/qlover/fe-base/pull/434))
26
+
27
+ - Introduced new error identifiers in Error.ts for handling various application states, including IOC not implemented and token absence.
28
+ - Added extensive localization keys in I18n.ts for various pages and components, enhancing user experience across different languages.
29
+ - Improved error handling and messaging consistency throughout the application.
30
+
31
+ This update enhances the application's localization capabilities and error management, providing clearer feedback to users.
32
+
33
+ - **create-app:** enhance TypeScript configuration and linting ([f049395](https://github.com/qlover/fe-base/commit/f049395c90ee2c13a33d7358098a87251ef40913)) ([#434](https://github.com/qlover/fe-base/pull/434))
34
+
35
+ - Updated the TypeScript configuration by introducing a new `tsconfig.app.json` for better modularity and organization.
36
+ - Modified `tsconfig.json` to reference the new app configuration and streamline project structure.
37
+ - Enhanced `tsconfig.node.json` with improved compiler options for better compatibility and performance.
38
+ - Updated linting script in `package.json` to include TypeScript checks alongside ESLint, ensuring code quality and type safety.
39
+ - Refactored imports in `RequestLogger.ts` and `ThemeSwitcher.tsx` to use type imports for better clarity and performance.
40
+
41
+ This update improves the TypeScript setup and linting process, enhancing code quality and maintainability across the application.
42
+
43
+ #### ♻️ Refactors
44
+
45
+ - **create-app:** remove unused error identifiers and localization keys ([3b19f19](https://github.com/qlover/fe-base/commit/3b19f193b839c1e97fa727c1847a4bbd5ff84211)) ([#434](https://github.com/qlover/fe-base/pull/434))
46
+
47
+ - Deleted Error.ts and I18n.ts files as they contained unused error identifiers and localization keys.
48
+ - This cleanup improves the overall codebase by removing unnecessary files, enhancing maintainability and reducing clutter.
49
+
50
+ This update streamlines the application by eliminating redundant localization and error handling resources.
51
+
3
52
  ## 0.4.3
4
53
 
5
54
  ### Patch Changes
package/dist/index.js CHANGED
@@ -2378,7 +2378,7 @@ var Generator = class {
2378
2378
 
2379
2379
  // package.json
2380
2380
  var package_default = {
2381
- version: "0.4.3",
2381
+ version: "0.4.5",
2382
2382
  description: "Create a new app with a single command"};
2383
2383
  function programArgs() {
2384
2384
  const program = new Command();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qlover/create-app",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "Create a new app with a single command",
5
5
  "private": false,
6
6
  "type": "module",
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @description logout dialog title
3
+ * @localZh 登出
4
+ * @localEn Logout
5
+ */
6
+ export const AUTH_LOGOUT_DIALOG_TITLE = 'Logout';
7
+
8
+ /**
9
+ * @description logout dialog content
10
+ * @localZh 确定要登出吗?
11
+ * @localEn Are you sure you want to logout?
12
+ */
13
+ export const AUTH_LOGOUT_DIALOG_CONTENT = 'Are you sure you want to logout?';
@@ -47,7 +47,7 @@
47
47
  "dev:staging": "vite --mode staging",
48
48
  "dev:prod": "vite --mode production",
49
49
  "build": "vite build",
50
- "lint": "eslint ./src --fix",
50
+ "lint": "tsc -b --noEmit && eslint ./src --fix",
51
51
  "prettier": "prettier --write ./src",
52
52
  "preview": "vite preview",
53
53
  "test": "vitest run"
@@ -194,5 +194,7 @@
194
194
  "page.500.title": "500 - Server Error",
195
195
  "page.login.title": "Login",
196
196
  "page.register.title": "Register",
197
- "response.no.token": "Response not token value"
197
+ "response.no.token": "Response not token value",
198
+ "Logout": "Logout",
199
+ "Are you sure you want to logout?": "Are you sure you want to logout?"
198
200
  }
@@ -194,5 +194,7 @@
194
194
  "page.500.title": "500 - 服务器错误",
195
195
  "page.login.title": "登录",
196
196
  "page.register.title": "注册",
197
- "response.no.token": "响应内容没有 token 值"
197
+ "response.no.token": "响应内容没有 token 值",
198
+ "Logout": "登出",
199
+ "Are you sure you want to logout?": "确定要登出吗?"
198
200
  }
@@ -44,8 +44,10 @@ export class AppConfig implements EnvConfigInterface {
44
44
  * Current environment mode for Vite
45
45
  * @description Represents the running environment (development, production, etc.)
46
46
  * Automatically set based on the current .env file being used
47
+ *
48
+ * from vite.config `mode`
47
49
  */
48
- readonly env: string = '';
50
+ readonly env: string = import.meta.env.MODE;
49
51
 
50
52
  /**
51
53
  * Storage key for user authentication token
@@ -10,7 +10,8 @@ import {
10
10
  type ApiCatchPluginResponse
11
11
  } from '@qlover/corekit-bridge';
12
12
  import { injectable, inject } from 'inversify';
13
- import { LoggerInterface } from '@qlover/logger';
13
+ import type { LoggerInterface } from '@qlover/logger';
14
+
14
15
  @injectable()
15
16
  export class RequestLogger
16
17
  implements ExecutorPlugin<RequestAdapterFetchConfig>
@@ -6,7 +6,7 @@ export interface RegisterFormData {
6
6
  agreeToTerms: boolean;
7
7
  }
8
8
  export interface LoginInterface {
9
- login(params: { username: string; password: string }): Promise<unknown>;
9
+ login(params: unknown): Promise<unknown>;
10
10
  logout(): void;
11
11
  register(params: RegisterFormData): Promise<unknown>;
12
12
  }
@@ -16,7 +16,8 @@ export const dialogHandler = new DialogHandler();
16
16
  */
17
17
  export const logger = new Logger({
18
18
  handlers: new ConsoleHandler(new ColorFormatter(loggerStyles)),
19
- silent: isProduction
19
+ silent: isProduction,
20
+ level: 'debug'
20
21
  });
21
22
 
22
23
  /**
@@ -15,7 +15,7 @@ export default function Layout() {
15
15
 
16
16
  return (
17
17
  <>
18
- <BaseHeader />
18
+ <BaseHeader showLogoutButton={false} />
19
19
  <div className="flex-1">
20
20
  <Outlet />
21
21
  </div>
@@ -9,7 +9,7 @@ export default function Layout() {
9
9
  data-testid="basic-layout"
10
10
  className="text-base min-h-screen bg-primary"
11
11
  >
12
- <BaseHeader />
12
+ <BaseHeader showLogoutButton />
13
13
 
14
14
  <div className="text-text bg-primary">
15
15
  <Outlet />
@@ -3,8 +3,13 @@ import LocaleLink from '@/uikit/components/LocaleLink';
3
3
  import LanguageSwitcher from '@/uikit/components/LanguageSwitcher';
4
4
  import { PublicAssetsPath } from '@/base/cases/PublicAssetsPath';
5
5
  import { IOC } from '@/core/IOC';
6
+ import LogoutButton from './LogoutButton';
6
7
 
7
- export default function BaseHeader() {
8
+ export default function BaseHeader({
9
+ showLogoutButton
10
+ }: {
11
+ showLogoutButton?: boolean;
12
+ }) {
8
13
  return (
9
14
  <header className="h-14 bg-secondary border-b border-border sticky top-0 z-50">
10
15
  <div className="flex items-center justify-between h-full px-4 mx-auto max-w-7xl">
@@ -26,6 +31,8 @@ export default function BaseHeader() {
26
31
  <div className="flex items-center gap-4">
27
32
  <LanguageSwitcher />
28
33
  <ThemeSwitcher />
34
+
35
+ {showLogoutButton && <LogoutButton />}
29
36
  </div>
30
37
  </div>
31
38
  </header>
@@ -0,0 +1,32 @@
1
+ import { UserService } from '@/base/services/UserService';
2
+ import { IOC } from '@/core/IOC';
3
+ import {
4
+ AUTH_LOGOUT_DIALOG_CONTENT,
5
+ AUTH_LOGOUT_DIALOG_TITLE
6
+ } from '@config/Identifier/Auth';
7
+ import { Button } from 'antd';
8
+ import { useCallback } from 'react';
9
+ import { useTranslation } from 'react-i18next';
10
+
11
+ export default function LogoutButton() {
12
+ const { t } = useTranslation();
13
+
14
+ const tTitle = t(AUTH_LOGOUT_DIALOG_TITLE);
15
+ const tContent = t(AUTH_LOGOUT_DIALOG_CONTENT);
16
+
17
+ const onClick = useCallback(() => {
18
+ IOC('DialogHandler').confirm({
19
+ title: tTitle,
20
+ content: tContent,
21
+ onOk: () => {
22
+ IOC(UserService).logout();
23
+ }
24
+ });
25
+ }, [tTitle, tContent]);
26
+
27
+ return (
28
+ <Button danger onClick={onClick}>
29
+ {tTitle}
30
+ </Button>
31
+ );
32
+ }
@@ -1,5 +1,5 @@
1
1
  import { IOC } from '@/core/IOC';
2
- import { ThemeService } from '@qlover/corekit-bridge';
2
+ import { ThemeService, ThemeServiceState } from '@qlover/corekit-bridge';
3
3
  import { useStore } from '@/uikit/hooks/useStore';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { Select } from 'antd';
@@ -12,6 +12,7 @@ import {
12
12
  import clsx from 'clsx';
13
13
  import { useMemo } from 'react';
14
14
  import * as i18nKeys from '@config/Identifier/I18n';
15
+ import { StoreInterface } from '@/base/port/StoreInterface';
15
16
 
16
17
  const colorMap: Record<
17
18
  string,
@@ -36,7 +37,9 @@ const colorMap: Record<
36
37
 
37
38
  export default function ThemeSwitcher() {
38
39
  const themeService = IOC(ThemeService);
39
- const { theme } = useStore(themeService);
40
+ const { theme } = useStore(
41
+ themeService as unknown as StoreInterface<ThemeServiceState>
42
+ );
40
43
  const themes = themeService.getSupportedThemes();
41
44
  const { t } = useTranslation('common');
42
45
 
@@ -0,0 +1,35 @@
1
+ {
2
+ "compilerOptions": {
3
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
4
+ "target": "ES2020",
5
+ "useDefineForClassFields": true,
6
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
7
+ "module": "ESNext",
8
+ "skipLibCheck": true,
9
+
10
+ /* Bundler mode */
11
+ "moduleResolution": "bundler",
12
+ "allowImportingTsExtensions": true,
13
+ "isolatedModules": true,
14
+ "moduleDetection": "force",
15
+ "noEmit": true,
16
+ "jsx": "react-jsx",
17
+
18
+ /* Linting */
19
+ "strict": true,
20
+ "noUnusedLocals": true,
21
+ "noUnusedParameters": true,
22
+ "noFallthroughCasesInSwitch": true,
23
+ "noUncheckedSideEffectImports": true,
24
+ "experimentalDecorators": true,
25
+ "emitDecoratorMetadata": true,
26
+ "baseUrl": ".",
27
+ "types": ["vite/client"],
28
+ "paths": {
29
+ "@/*": ["./src/*"],
30
+ "@config/*": ["./config/*"],
31
+ "@lib/*": ["./lib/*"]
32
+ }
33
+ },
34
+ "include": ["src", "config"]
35
+ }
@@ -1,30 +1,10 @@
1
1
  {
2
+ "files": [],
3
+ "references": [
4
+ { "path": "./tsconfig.app.json" },
5
+ { "path": "./tsconfig.node.json" }
6
+ ],
2
7
  "compilerOptions": {
3
- "target": "ES2020",
4
- "useDefineForClassFields": true,
5
- "lib": ["ES2020", "DOM", "DOM.Iterable"],
6
- "module": "ESNext",
7
- "skipLibCheck": true,
8
- "moduleResolution": "bundler",
9
- "allowImportingTsExtensions": true,
10
- "resolveJsonModule": true,
11
- "isolatedModules": true,
12
- "noEmit": true,
13
- "jsx": "react-jsx",
14
- "strict": true,
15
- "noUnusedLocals": true,
16
- "noUnusedParameters": true,
17
- "noFallthroughCasesInSwitch": true,
18
- "esModuleInterop": true,
19
- "allowJs": true,
20
- "types": ["vite/client"],
21
- "paths": {
22
- "@/*": ["./src/*"],
23
- "@config/*": ["./config/*"],
24
- "@lib/*": ["./lib/*"]
25
- },
26
8
  "experimentalDecorators": true
27
- },
28
- "include": ["src", "lib/**/*.tsx"],
29
- "references": [{ "path": "./tsconfig.node.json" }]
9
+ }
30
10
  }
@@ -1,14 +1,24 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "composite": true,
4
- "skipLibCheck": true,
3
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
4
+ "target": "ES2022",
5
+ "lib": ["ES2023"],
5
6
  "module": "ESNext",
7
+ "skipLibCheck": true,
8
+
9
+ /* Bundler mode */
6
10
  "moduleResolution": "bundler",
7
- "allowSyntheticDefaultImports": true,
8
- "paths": {
9
- "@config/*": ["./config/*"]
10
- }
11
+ "allowImportingTsExtensions": true,
12
+ "isolatedModules": true,
13
+ "moduleDetection": "force",
14
+ "noEmit": true,
15
+
16
+ /* Linting */
17
+ "strict": true,
18
+ "noUnusedLocals": true,
19
+ "noUnusedParameters": true,
20
+ "noFallthroughCasesInSwitch": true,
21
+ "noUncheckedSideEffectImports": true
11
22
  },
12
- "include": ["vite.config.ts", "config", "lib"],
13
- "exclude": ["lib/**/*.tsx"]
23
+ "include": ["vite.config.ts"]
14
24
  }
@@ -118,7 +118,6 @@ export default defineConfig({
118
118
  server: {
119
119
  port: Number(process.env.VITE_SERVER_PORT || 3200)
120
120
  },
121
- mode: process.env.NODE_ENV,
122
121
  test: {
123
122
  environment: 'jsdom',
124
123
  globals: true,