@4399ywkf/cli 1.0.7 → 1.0.9
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/dist/templates/AntdStaticMethods/index.tsx +20 -0
- package/dist/templates/AppTheme.tsx +136 -0
- package/dist/templates/DIRECTORY_STRUCTURE.md +141 -0
- package/dist/templates/GlobalProvider/AppTheme.tsx +136 -0
- package/dist/templates/GlobalProvider/Locale.tsx +84 -0
- package/dist/templates/GlobalProvider/Query.tsx +12 -0
- package/dist/templates/GlobalProvider/StyleRegistry.tsx +9 -0
- package/dist/templates/GlobalProvider/index.tsx +23 -0
- package/dist/templates/HarmonyOS_Sans_Bold.woff2 +0 -0
- package/dist/templates/HarmonyOS_Sans_Medium.woff2 +0 -0
- package/dist/templates/HarmonyOS_Sans_Regular.woff2 +0 -0
- package/dist/templates/Locale.tsx +49 -54
- package/dist/templates/MainContentWrap.tsx +11 -15
- package/dist/templates/Query.tsx +12 -0
- package/dist/templates/StyleRegistry.tsx +9 -0
- package/dist/templates/ThemeContext.tsx +27 -24
- package/dist/templates/analyzeUnusedKeys.ts +506 -0
- package/dist/templates/app/.i18nrc.js +57 -0
- package/dist/templates/app/config/env/.env.public.tpl +2 -19
- package/dist/templates/app/config/jwt/index.ts +4 -4
- package/dist/templates/app/config/request/error-handler.ts +67 -0
- package/dist/templates/app/config/request/index.ts +127 -129
- package/dist/templates/app/config/request/interceptors.ts +118 -0
- package/dist/templates/app/config/request/token-manager.ts +23 -0
- package/dist/templates/app/config/request/types.ts +63 -0
- package/dist/templates/app/config/rspack/rspack.config.mjs +62 -61
- package/dist/templates/app/config/rspack/rspack.prod.mjs +41 -62
- package/dist/templates/app/docs/DIRECTORY_STRUCTURE.md +141 -0
- package/dist/templates/app/docs/glossary.md +11 -0
- package/dist/templates/app/locales/zh-CN/common.json +3 -0
- package/dist/templates/app/package.json.tpl +8 -25
- package/dist/templates/app/public/fonts/HarmonyOS_Sans_Bold.woff2 +0 -0
- package/dist/templates/app/public/fonts/HarmonyOS_Sans_Medium.woff2 +0 -0
- package/dist/templates/app/public/fonts/HarmonyOS_Sans_Regular.woff2 +0 -0
- package/dist/templates/app/react-app-env.d.ts +13 -8
- package/dist/templates/app/scripts/i18nWorkflow/analyzeUnusedKeys.ts +506 -0
- package/dist/templates/app/scripts/i18nWorkflow/cleanUnusedKeys.ts +344 -0
- package/dist/templates/app/scripts/i18nWorkflow/const.ts +18 -0
- package/dist/templates/app/scripts/i18nWorkflow/flattenLocaleKeys.ts +139 -0
- package/dist/templates/app/scripts/i18nWorkflow/genDefaultLocale.ts +19 -0
- package/dist/templates/app/scripts/i18nWorkflow/genDiff.ts +49 -0
- package/dist/templates/app/scripts/i18nWorkflow/i18nConfig.ts +7 -0
- package/dist/templates/app/scripts/i18nWorkflow/index.ts +11 -0
- package/dist/templates/app/scripts/i18nWorkflow/protectedPatterns.ts +91 -0
- package/dist/templates/app/scripts/i18nWorkflow/utils.ts +76 -0
- package/dist/templates/app/src/bootstrap/index.ts +34 -0
- package/dist/templates/app/src/components/AntdStaticMethods/index.tsx +20 -0
- package/dist/templates/app/src/config/env.ts +84 -0
- package/dist/templates/app/src/index.tsx +13 -51
- package/dist/templates/app/src/layout/GlobalProvider/AppTheme.tsx +136 -0
- package/dist/templates/app/src/layout/GlobalProvider/Locale.tsx +84 -0
- package/dist/templates/app/src/layout/GlobalProvider/Query.tsx +12 -0
- package/dist/templates/app/src/layout/GlobalProvider/StyleRegistry.tsx +9 -0
- package/dist/templates/app/src/layout/GlobalProvider/index.tsx +23 -0
- package/dist/templates/app/src/layout/Locale.tsx +14 -18
- package/dist/templates/app/src/layout/MainContentWrap.tsx +11 -15
- package/dist/templates/app/src/layout/ThemeContext.tsx +27 -24
- package/dist/templates/app/src/locales/default/common.ts +3 -1
- package/dist/templates/app/src/locales/utils.ts +23 -0
- package/dist/templates/app/src/micro/garfish.ts +53 -0
- package/dist/templates/app/src/pages/base/index.tsx +280 -25
- package/dist/templates/app/src/routes.tsx +21 -12
- package/dist/templates/app/src/types/global.d.ts +19 -0
- package/dist/templates/app/src/utils/index.ts +3 -1
- package/dist/templates/app/store/middleware/createDevtools.ts +7 -7
- package/dist/templates/app/tsconfig.json +19 -3
- package/dist/templates/base/index.tsx +280 -25
- package/dist/templates/bootstrap/index.ts +34 -0
- package/dist/templates/cleanUnusedKeys.ts +344 -0
- package/dist/templates/common.json +3 -0
- package/dist/templates/common.ts +3 -1
- package/dist/templates/components/AntdStaticMethods/index.tsx +20 -0
- package/dist/templates/config/env/.env.public.tpl +2 -19
- package/dist/templates/config/env.ts +84 -0
- package/dist/templates/config/jwt/index.ts +4 -4
- package/dist/templates/config/request/error-handler.ts +67 -0
- package/dist/templates/config/request/index.ts +127 -129
- package/dist/templates/config/request/interceptors.ts +118 -0
- package/dist/templates/config/request/token-manager.ts +23 -0
- package/dist/templates/config/request/types.ts +63 -0
- package/dist/templates/config/rspack/rspack.config.mjs +62 -61
- package/dist/templates/config/rspack/rspack.prod.mjs +41 -62
- package/dist/templates/const.ts +18 -0
- package/dist/templates/createDevtools.ts +7 -7
- package/dist/templates/default/common.ts +3 -1
- package/dist/templates/docs/DIRECTORY_STRUCTURE.md +141 -0
- package/dist/templates/docs/glossary.md +11 -0
- package/dist/templates/env/.env.public.tpl +2 -19
- package/dist/templates/env.ts +83 -2
- package/dist/templates/error-handler.ts +67 -0
- package/dist/templates/flattenLocaleKeys.ts +139 -0
- package/dist/templates/fonts/HarmonyOS_Sans_Bold.woff2 +0 -0
- package/dist/templates/fonts/HarmonyOS_Sans_Medium.woff2 +0 -0
- package/dist/templates/fonts/HarmonyOS_Sans_Regular.woff2 +0 -0
- package/dist/templates/garfish.ts +53 -0
- package/dist/templates/genDefaultLocale.ts +19 -0
- package/dist/templates/genDiff.ts +49 -0
- package/dist/templates/global.d.ts +19 -0
- package/dist/templates/glossary.md +11 -0
- package/dist/templates/i18nConfig.ts +7 -0
- package/dist/templates/i18nWorkflow/analyzeUnusedKeys.ts +506 -0
- package/dist/templates/i18nWorkflow/cleanUnusedKeys.ts +344 -0
- package/dist/templates/i18nWorkflow/const.ts +18 -0
- package/dist/templates/i18nWorkflow/flattenLocaleKeys.ts +139 -0
- package/dist/templates/i18nWorkflow/genDefaultLocale.ts +19 -0
- package/dist/templates/i18nWorkflow/genDiff.ts +49 -0
- package/dist/templates/i18nWorkflow/i18nConfig.ts +7 -0
- package/dist/templates/i18nWorkflow/index.ts +11 -0
- package/dist/templates/i18nWorkflow/protectedPatterns.ts +91 -0
- package/dist/templates/i18nWorkflow/utils.ts +76 -0
- package/dist/templates/index.tsx +280 -25
- package/dist/templates/interceptors.ts +118 -0
- package/dist/templates/jwt/index.ts +4 -4
- package/dist/templates/layout/GlobalProvider/AppTheme.tsx +136 -0
- package/dist/templates/layout/GlobalProvider/Locale.tsx +84 -0
- package/dist/templates/layout/GlobalProvider/Query.tsx +12 -0
- package/dist/templates/layout/GlobalProvider/StyleRegistry.tsx +9 -0
- package/dist/templates/layout/GlobalProvider/index.tsx +23 -0
- package/dist/templates/layout/Locale.tsx +14 -18
- package/dist/templates/layout/MainContentWrap.tsx +11 -15
- package/dist/templates/layout/ThemeContext.tsx +27 -24
- package/dist/templates/locales/default/common.ts +3 -1
- package/dist/templates/locales/utils.ts +23 -0
- package/dist/templates/locales/zh-CN/common.json +3 -0
- package/dist/templates/micro/garfish.ts +53 -0
- package/dist/templates/middleware/createDevtools.ts +7 -7
- package/dist/templates/package.json.tpl +8 -25
- package/dist/templates/page.tsx +21 -19
- package/dist/templates/pages/base/index.tsx +280 -25
- package/dist/templates/protectedPatterns.ts +91 -0
- package/dist/templates/public/fonts/HarmonyOS_Sans_Bold.woff2 +0 -0
- package/dist/templates/public/fonts/HarmonyOS_Sans_Medium.woff2 +0 -0
- package/dist/templates/public/fonts/HarmonyOS_Sans_Regular.woff2 +0 -0
- package/dist/templates/react-app-env.d.ts +13 -8
- package/dist/templates/request/error-handler.ts +67 -0
- package/dist/templates/request/index.ts +127 -129
- package/dist/templates/request/interceptors.ts +118 -0
- package/dist/templates/request/token-manager.ts +23 -0
- package/dist/templates/request/types.ts +63 -0
- package/dist/templates/routes.tsx +21 -12
- package/dist/templates/rspack/rspack.config.mjs +62 -61
- package/dist/templates/rspack/rspack.prod.mjs +41 -62
- package/dist/templates/rspack.config.mjs +62 -61
- package/dist/templates/rspack.prod.mjs +41 -62
- package/dist/templates/scripts/i18nWorkflow/analyzeUnusedKeys.ts +506 -0
- package/dist/templates/scripts/i18nWorkflow/cleanUnusedKeys.ts +344 -0
- package/dist/templates/scripts/i18nWorkflow/const.ts +18 -0
- package/dist/templates/scripts/i18nWorkflow/flattenLocaleKeys.ts +139 -0
- package/dist/templates/scripts/i18nWorkflow/genDefaultLocale.ts +19 -0
- package/dist/templates/scripts/i18nWorkflow/genDiff.ts +49 -0
- package/dist/templates/scripts/i18nWorkflow/i18nConfig.ts +7 -0
- package/dist/templates/scripts/i18nWorkflow/index.ts +11 -0
- package/dist/templates/scripts/i18nWorkflow/protectedPatterns.ts +91 -0
- package/dist/templates/scripts/i18nWorkflow/utils.ts +76 -0
- package/dist/templates/src/bootstrap/index.ts +34 -0
- package/dist/templates/src/components/AntdStaticMethods/index.tsx +20 -0
- package/dist/templates/src/config/env.ts +84 -0
- package/dist/templates/src/index.tsx +13 -51
- package/dist/templates/src/layout/GlobalProvider/AppTheme.tsx +136 -0
- package/dist/templates/src/layout/GlobalProvider/Locale.tsx +84 -0
- package/dist/templates/src/layout/GlobalProvider/Query.tsx +12 -0
- package/dist/templates/src/layout/GlobalProvider/StyleRegistry.tsx +9 -0
- package/dist/templates/src/layout/GlobalProvider/index.tsx +23 -0
- package/dist/templates/src/layout/Locale.tsx +14 -18
- package/dist/templates/src/layout/MainContentWrap.tsx +11 -15
- package/dist/templates/src/layout/ThemeContext.tsx +27 -24
- package/dist/templates/src/locales/default/common.ts +3 -1
- package/dist/templates/src/locales/utils.ts +23 -0
- package/dist/templates/src/micro/garfish.ts +53 -0
- package/dist/templates/src/pages/base/index.tsx +280 -25
- package/dist/templates/src/routes.tsx +21 -12
- package/dist/templates/src/types/global.d.ts +19 -0
- package/dist/templates/src/utils/index.ts +3 -1
- package/dist/templates/store/middleware/createDevtools.ts +7 -7
- package/dist/templates/token-manager.ts +23 -0
- package/dist/templates/tsconfig.json +19 -3
- package/dist/templates/type.ts +23 -24
- package/dist/templates/types/global.d.ts +19 -0
- package/dist/templates/utils/index.ts +3 -1
- package/dist/templates/utils.ts +23 -0
- package/dist/templates/zh-CN/common.json +3 -0
- package/package.json +19 -21
- package/dist/templates/app/config/sentry/sentry.config.ts +0 -188
- package/dist/templates/app/src/hooks/useRouteTitle.tsx +0 -36
- package/dist/templates/app/src/hooks/useSentry.ts +0 -92
- package/dist/templates/app/src/pages/base/layout.tsx +0 -6
- package/dist/templates/app/src/pages/base/page.tsx +0 -25
- package/dist/templates/app/src/utils/env.ts +0 -3
- package/dist/templates/app/src/utils/format.ts +0 -21
- package/dist/templates/app/src/utils/getMicroApp.ts +0 -39
- package/dist/templates/app/src/utils/sentry.ts +0 -187
- package/dist/templates/app/src/utils/sentryDecorators.ts +0 -34
- package/dist/templates/app/src/utils/updateVersion.ts +0 -186
- package/dist/templates/base/layout.tsx +0 -6
- package/dist/templates/base/page.tsx +0 -25
- package/dist/templates/config/public/404.png +0 -0
- package/dist/templates/config/public/favicon.ico +0 -0
- package/dist/templates/config/public/images/banner_market_modal.webp +0 -0
- package/dist/templates/config/public/images/chatmode_chat_dark.webp +0 -0
- package/dist/templates/config/public/images/chatmode_chat_light.webp +0 -0
- package/dist/templates/config/public/images/chatmode_docs_dark.webp +0 -0
- package/dist/templates/config/public/images/chatmode_docs_light.webp +0 -0
- package/dist/templates/config/public/images/empty_topic_dark.webp +0 -0
- package/dist/templates/config/public/images/empty_topic_light.webp +0 -0
- package/dist/templates/config/public/images/screenshot_background.webp +0 -0
- package/dist/templates/config/public/images/theme_auto.webp +0 -0
- package/dist/templates/config/public/images/theme_dark.webp +0 -0
- package/dist/templates/config/public/images/theme_light.webp +0 -0
- package/dist/templates/config/public/index.html +0 -29
- package/dist/templates/config/sentry/sentry.config.ts +0 -188
- package/dist/templates/format.ts +0 -21
- package/dist/templates/getMicroApp.ts +0 -39
- package/dist/templates/hooks/useRouteTitle.tsx +0 -36
- package/dist/templates/hooks/useSentry.ts +0 -92
- package/dist/templates/layout.tsx +0 -6
- package/dist/templates/pages/base/layout.tsx +0 -6
- package/dist/templates/pages/base/page.tsx +0 -25
- package/dist/templates/sentry/sentry.config.ts +0 -188
- package/dist/templates/sentry.config.ts +0 -188
- package/dist/templates/sentry.ts +0 -187
- package/dist/templates/sentryDecorators.ts +0 -34
- package/dist/templates/src/hooks/useRouteTitle.tsx +0 -36
- package/dist/templates/src/hooks/useSentry.ts +0 -92
- package/dist/templates/src/pages/base/layout.tsx +0 -6
- package/dist/templates/src/pages/base/page.tsx +0 -25
- package/dist/templates/src/utils/env.ts +0 -3
- package/dist/templates/src/utils/format.ts +0 -21
- package/dist/templates/src/utils/getMicroApp.ts +0 -39
- package/dist/templates/src/utils/sentry.ts +0 -187
- package/dist/templates/src/utils/sentryDecorators.ts +0 -34
- package/dist/templates/src/utils/updateVersion.ts +0 -186
- package/dist/templates/updateVersion.ts +0 -186
- package/dist/templates/useRouteTitle.tsx +0 -36
- package/dist/templates/useSentry.ts +0 -92
- package/dist/templates/utils/env.ts +0 -3
- package/dist/templates/utils/format.ts +0 -21
- package/dist/templates/utils/getMicroApp.ts +0 -39
- package/dist/templates/utils/sentry.ts +0 -187
- package/dist/templates/utils/sentryDecorators.ts +0 -34
- package/dist/templates/utils/updateVersion.ts +0 -186
- /package/dist/templates/app/{config/public → public}/404.png +0 -0
- /package/dist/templates/app/{config/public → public}/favicon.ico +0 -0
- /package/dist/templates/app/{config/public → public}/images/banner_market_modal.webp +0 -0
- /package/dist/templates/app/{config/public → public}/images/chatmode_chat_dark.webp +0 -0
- /package/dist/templates/app/{config/public → public}/images/chatmode_chat_light.webp +0 -0
- /package/dist/templates/app/{config/public → public}/images/chatmode_docs_dark.webp +0 -0
- /package/dist/templates/app/{config/public → public}/images/chatmode_docs_light.webp +0 -0
- /package/dist/templates/app/{config/public → public}/images/empty_topic_dark.webp +0 -0
- /package/dist/templates/app/{config/public → public}/images/empty_topic_light.webp +0 -0
- /package/dist/templates/app/{config/public → public}/images/screenshot_background.webp +0 -0
- /package/dist/templates/app/{config/public → public}/images/theme_auto.webp +0 -0
- /package/dist/templates/app/{config/public → public}/images/theme_dark.webp +0 -0
- /package/dist/templates/app/{config/public → public}/images/theme_light.webp +0 -0
- /package/dist/templates/app/{config/public → public}/index.html +0 -0
package/dist/templates/type.ts
CHANGED
|
@@ -1,28 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
ThemeProviderProps as AntdThemeProviderProps,
|
|
3
|
-
CustomStylishParams,
|
|
4
|
-
CustomTokenParams,
|
|
5
|
-
} from 'antd-style';
|
|
6
|
-
import type { CSSProperties } from 'react';
|
|
1
|
+
export type StorageSelector = string | Record<string, string>;
|
|
7
2
|
|
|
8
|
-
|
|
3
|
+
export interface LocalStorageOptions {
|
|
4
|
+
dbName?: string;
|
|
5
|
+
/**
|
|
6
|
+
* @default 'localStorage'
|
|
7
|
+
*/
|
|
8
|
+
mode?: 'indexedDB' | 'localStorage';
|
|
9
|
+
selectors: StorageSelector[];
|
|
10
|
+
}
|
|
9
11
|
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
export type HyperStorageOptionsObj = {
|
|
13
|
+
localStorage?: LocalStorageOptions | false;
|
|
14
|
+
url?: {
|
|
15
|
+
/**
|
|
16
|
+
* @default 'hash'
|
|
17
|
+
*/
|
|
18
|
+
mode?: 'hash' | 'search';
|
|
19
|
+
selectors: StorageSelector[];
|
|
17
20
|
};
|
|
18
|
-
|
|
19
|
-
enableCustomFonts?: boolean;
|
|
20
|
-
enableGlobalStyle?: boolean;
|
|
21
|
-
style?: CSSProperties;
|
|
22
|
-
}
|
|
21
|
+
};
|
|
23
22
|
|
|
24
|
-
export
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
export type HyperStorageOptionsFn = () => HyperStorageOptionsObj;
|
|
24
|
+
|
|
25
|
+
export type HyperStorageOptions =
|
|
26
|
+
| HyperStorageOptionsObj
|
|
27
|
+
| HyperStorageOptionsFn;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Env } from "@/config/env";
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
interface Window {
|
|
5
|
+
__GARFISH__?: boolean;
|
|
6
|
+
Garfish?: {
|
|
7
|
+
channel: {
|
|
8
|
+
emit: (event: string, data: any) => void;
|
|
9
|
+
on: (event: string, handler: (data: any) => void) => void;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
namespace NodeJS {
|
|
15
|
+
interface ProcessEnv extends Env {}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const SAFE_KEY = /^[^.[\]]+$/;
|
|
2
|
+
|
|
3
|
+
export const toLodashPath = (segments: Array<number | string>) => {
|
|
4
|
+
let path = '';
|
|
5
|
+
|
|
6
|
+
for (const segment of segments) {
|
|
7
|
+
if (typeof segment === 'number') {
|
|
8
|
+
path += `[${segment}]`;
|
|
9
|
+
continue;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const key = segment;
|
|
13
|
+
const safe = SAFE_KEY.test(key);
|
|
14
|
+
if (safe) {
|
|
15
|
+
path += path ? `.${key}` : key;
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
path += `[${JSON.stringify(key)}]`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return path;
|
|
23
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@4399ywkf/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "运维开发部脚手架",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -9,24 +9,6 @@
|
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
|
-
"scripts": {
|
|
13
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
14
|
-
"dev": "node bin/cli.js",
|
|
15
|
-
"debug": "node --inspect-brk bin/cli.js",
|
|
16
|
-
"debug:create": "node --inspect-brk bin/cli.js create test-project",
|
|
17
|
-
"debug:create-with-template": "node --inspect-brk bin/cli.js create test-project -t webpack-mainApplicate_demo",
|
|
18
|
-
"debug:create-with-template-rspack": "node --inspect-brk bin/cli.js create test-project -t rspack-subApplicate_demo",
|
|
19
|
-
"debug:help": "node --inspect-brk bin/cli.js --help",
|
|
20
|
-
"build": "rollup -c && node scripts/postbuild.js",
|
|
21
|
-
"build:watch": "rollup -c -w",
|
|
22
|
-
"prepublishOnly": "npm run build",
|
|
23
|
-
"link": "npm link",
|
|
24
|
-
"unlink": "npm unlink -g",
|
|
25
|
-
"changeset": "changeset",
|
|
26
|
-
"changeset:version": "changeset version",
|
|
27
|
-
"changeset:publish": "changeset publish",
|
|
28
|
-
"postpublish": "pnpm build && git push && git push --tags"
|
|
29
|
-
},
|
|
30
12
|
"repository": {
|
|
31
13
|
"type": "git"
|
|
32
14
|
},
|
|
@@ -64,5 +46,21 @@
|
|
|
64
46
|
],
|
|
65
47
|
"authors": [
|
|
66
48
|
"ywjszx@4399.com"
|
|
67
|
-
]
|
|
68
|
-
|
|
49
|
+
],
|
|
50
|
+
"scripts": {
|
|
51
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
52
|
+
"dev": "node bin/cli.js",
|
|
53
|
+
"debug": "node --inspect-brk bin/cli.js",
|
|
54
|
+
"debug:create": "node --inspect-brk bin/cli.js create test-project",
|
|
55
|
+
"debug:create-with-template": "node --inspect-brk bin/cli.js create test-project -t webpack-mainApplicate_demo",
|
|
56
|
+
"debug:create-with-template-rspack": "node --inspect-brk bin/cli.js create test-project -t rspack-subApplicate_demo",
|
|
57
|
+
"debug:help": "node --inspect-brk bin/cli.js --help",
|
|
58
|
+
"build": "rollup -c && node scripts/postbuild.js",
|
|
59
|
+
"build:watch": "rollup -c -w",
|
|
60
|
+
"link": "npm link",
|
|
61
|
+
"unlink": "npm unlink -g",
|
|
62
|
+
"changeset": "changeset",
|
|
63
|
+
"changeset:version": "changeset version",
|
|
64
|
+
"changeset:publish": "changeset publish"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import * as Sentry from '@sentry/react';
|
|
2
|
-
|
|
3
|
-
// Sentry 配置接口
|
|
4
|
-
export interface SentryConfig {
|
|
5
|
-
dsn: string;
|
|
6
|
-
environment: string;
|
|
7
|
-
release?: string;
|
|
8
|
-
sampleRate: number;
|
|
9
|
-
tracesSampleRate: number;
|
|
10
|
-
enabled: boolean;
|
|
11
|
-
sessionSampleRate: number;
|
|
12
|
-
beforeSend?: (event: Sentry.ErrorEvent, hint: Sentry.EventHint) => Sentry.ErrorEvent | null;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// 开发环境配置
|
|
16
|
-
const developmentConfig: Partial<SentryConfig> = {
|
|
17
|
-
enabled: true, // 开发环境可以选择关闭
|
|
18
|
-
sampleRate: 1.0,
|
|
19
|
-
tracesSampleRate: 1.0,
|
|
20
|
-
sessionSampleRate: 1.0, // 开发环境记录所有会话
|
|
21
|
-
beforeSend: (event, hint) => {
|
|
22
|
-
console.group('🐛 Sentry Event (Development)');
|
|
23
|
-
console.log('Event:', event);
|
|
24
|
-
console.log('Hint:', hint);
|
|
25
|
-
console.log('Event:', event);
|
|
26
|
-
console.groupEnd();
|
|
27
|
-
|
|
28
|
-
return event;
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
// 生产环境配置
|
|
33
|
-
const productionConfig: Partial<SentryConfig> = {
|
|
34
|
-
enabled: true,
|
|
35
|
-
sampleRate: 1.0, // 临时设置为100%以排查问题,后续可调整
|
|
36
|
-
tracesSampleRate: 0.1, // 提高到10%性能采样
|
|
37
|
-
sessionSampleRate: 1.0, // 记录所有会话以获得准确的健康度数据
|
|
38
|
-
beforeSend: (event, hint) => {
|
|
39
|
-
// 生产环境也打印日志以便调试
|
|
40
|
-
console.log('🐛 Sentry Event (Production):', event);
|
|
41
|
-
|
|
42
|
-
// 过滤敏感信息
|
|
43
|
-
if (event.exception) {
|
|
44
|
-
const error = event.exception.values?.[0];
|
|
45
|
-
if (error?.value?.includes('密码') || error?.value?.includes('token')) {
|
|
46
|
-
return null; // 不发送包含敏感信息的错误
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return event;
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
// 获取环境配置
|
|
54
|
-
const getEnvironmentConfig = (): Partial<SentryConfig> => {
|
|
55
|
-
const env = process.env.NODE_ENV || 'development';
|
|
56
|
-
console.log(env, 'env');
|
|
57
|
-
switch (env) {
|
|
58
|
-
case 'development':
|
|
59
|
-
return developmentConfig;
|
|
60
|
-
case 'production':
|
|
61
|
-
return productionConfig;
|
|
62
|
-
default:
|
|
63
|
-
return developmentConfig;
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
// 基础配置
|
|
68
|
-
const baseConfig: SentryConfig = {
|
|
69
|
-
dsn: process.env.REACT_APP_SENTRY_DSN || '',
|
|
70
|
-
environment: process.env.SENTRY_ENV || 'development',
|
|
71
|
-
enabled: true,
|
|
72
|
-
sampleRate: 1.0,
|
|
73
|
-
tracesSampleRate: 1.0,
|
|
74
|
-
sessionSampleRate: 1.0, // 默认记录所有会话
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
// 合并配置
|
|
78
|
-
export const sentryConfig: SentryConfig = {
|
|
79
|
-
...baseConfig,
|
|
80
|
-
...getEnvironmentConfig(),
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
// 安全的会话重放集成初始化
|
|
84
|
-
const getSafeReplayIntegration = () => {
|
|
85
|
-
try {
|
|
86
|
-
return Sentry.replayIntegration({
|
|
87
|
-
maskAllText: false,
|
|
88
|
-
maskAllInputs: false,
|
|
89
|
-
blockAllMedia: true,
|
|
90
|
-
networkDetailAllowUrls: [window.location.origin],
|
|
91
|
-
}) as any; // 添加类型断言
|
|
92
|
-
} catch (error) {
|
|
93
|
-
console.warn('会话重放初始化失败:', error);
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
// 初始化 Sentry
|
|
99
|
-
export const initSentry = () => {
|
|
100
|
-
// 修复 fetch 上下文问题
|
|
101
|
-
if (typeof window !== 'undefined' && window.fetch) {
|
|
102
|
-
window.fetch = window.fetch.bind(window);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (!sentryConfig.enabled || !sentryConfig.dsn) {
|
|
106
|
-
console.warn('❌ Sentry not enabled or DSN not provided');
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const integrations = [Sentry.browserTracingIntegration()];
|
|
111
|
-
|
|
112
|
-
// 安全地添加会话重放集成
|
|
113
|
-
const replayIntegration = getSafeReplayIntegration();
|
|
114
|
-
if (replayIntegration && !window.__GARFISH__) {
|
|
115
|
-
// 目前微服务无法使用会话重放
|
|
116
|
-
integrations.push(replayIntegration);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
Sentry.init({
|
|
120
|
-
dsn: sentryConfig.dsn,
|
|
121
|
-
environment: sentryConfig.environment,
|
|
122
|
-
sampleRate: sentryConfig.sampleRate,
|
|
123
|
-
tracesSampleRate: sentryConfig.tracesSampleRate,
|
|
124
|
-
beforeSend: sentryConfig.beforeSend,
|
|
125
|
-
|
|
126
|
-
// 使用自定义传输层,确保fetch上下文正确
|
|
127
|
-
transport: Sentry.makeBrowserOfflineTransport((options) => Sentry.makeFetchTransport(options, window.fetch.bind(window))),
|
|
128
|
-
|
|
129
|
-
// 设置追踪的 URL 匹配规则
|
|
130
|
-
tracePropagationTargets: ['localhost', /^https:\/\/yourapi\.domain\.com\/api/],
|
|
131
|
-
|
|
132
|
-
// 使用安全的集成配置
|
|
133
|
-
integrations,
|
|
134
|
-
|
|
135
|
-
// 错误过滤
|
|
136
|
-
ignoreErrors: [
|
|
137
|
-
// 忽略常见的无害错误
|
|
138
|
-
'Non-Error promise rejection captured',
|
|
139
|
-
'ResizeObserver loop limit exceeded',
|
|
140
|
-
'Script error.',
|
|
141
|
-
'Network Error',
|
|
142
|
-
'Loading chunk',
|
|
143
|
-
'Loading CSS chunk',
|
|
144
|
-
],
|
|
145
|
-
|
|
146
|
-
// URL 过滤
|
|
147
|
-
denyUrls: [
|
|
148
|
-
// 忽略浏览器扩展
|
|
149
|
-
/extensions\//i,
|
|
150
|
-
/^chrome:\/\//i,
|
|
151
|
-
/^moz-extension:\/\//i,
|
|
152
|
-
],
|
|
153
|
-
|
|
154
|
-
// 只在会话重放可用时设置这些选项
|
|
155
|
-
...(replayIntegration && {
|
|
156
|
-
replaysSessionSampleRate: 0.1,
|
|
157
|
-
replaysOnErrorSampleRate: 1.0,
|
|
158
|
-
}),
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
// 设置应用上下文
|
|
162
|
-
Sentry.setContext('app', {
|
|
163
|
-
name: process.env.APP_NAME || 'React App',
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
// ✨ 手动开始会话(确保会话被正确追踪)
|
|
167
|
-
Sentry.startSession();
|
|
168
|
-
|
|
169
|
-
console.log('✅ Sentry initialized successfully with session tracking');
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
// ✨ 新增:会话管理工具
|
|
173
|
-
export const sentrySession = {
|
|
174
|
-
// 开始新会话
|
|
175
|
-
startSession: () => {
|
|
176
|
-
Sentry.startSession();
|
|
177
|
-
},
|
|
178
|
-
|
|
179
|
-
// 结束当前会话
|
|
180
|
-
endSession: () => {
|
|
181
|
-
Sentry.endSession();
|
|
182
|
-
},
|
|
183
|
-
|
|
184
|
-
// 标记会话为崩溃
|
|
185
|
-
captureSession: (crashed: boolean = false) => {
|
|
186
|
-
Sentry.captureSession(crashed);
|
|
187
|
-
},
|
|
188
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
|
-
import { useLocation, matchRoutes } from 'react-router';
|
|
3
|
-
import { useAppData } from '@config/router/appContext';
|
|
4
|
-
|
|
5
|
-
const APP_NAME = process.env.APP_NAME!;
|
|
6
|
-
|
|
7
|
-
export const useRouteTitle = () => {
|
|
8
|
-
const location = useLocation();
|
|
9
|
-
const { routes } = useAppData();
|
|
10
|
-
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
// 将路由配置转换为适合 matchRoutes 的格式
|
|
13
|
-
const routesList = Object.keys(routes).map((key) => {
|
|
14
|
-
const route = routes[key];
|
|
15
|
-
return {
|
|
16
|
-
path: route.absPath,
|
|
17
|
-
meta: route.props,
|
|
18
|
-
id: key,
|
|
19
|
-
};
|
|
20
|
-
});
|
|
21
|
-
// 匹配当前路径的路由
|
|
22
|
-
const matchedRoutes = matchRoutes(routesList, location);
|
|
23
|
-
|
|
24
|
-
if (matchedRoutes && matchedRoutes.length > 0) {
|
|
25
|
-
// 找到最后一个匹配的路由(叶子路由)
|
|
26
|
-
const leafRoute = matchedRoutes[matchedRoutes.length - 1];
|
|
27
|
-
const title = leafRoute.route.meta?.title;
|
|
28
|
-
|
|
29
|
-
if (title) {
|
|
30
|
-
document.title = title;
|
|
31
|
-
} else {
|
|
32
|
-
document.title = APP_NAME;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}, [location.pathname, routes]);
|
|
36
|
-
};
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
|
-
import { useLocation } from 'react-router';
|
|
3
|
-
import { sentryPerformance, sentryContext, sentryError, sentrySession } from '@/utils/sentry';
|
|
4
|
-
|
|
5
|
-
// 页面性能监控 Hook
|
|
6
|
-
export const useSentryPageTracking = (pageName: string) => {
|
|
7
|
-
const location = useLocation();
|
|
8
|
-
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
// ✨ 记录页面访问(保持会话活跃)
|
|
11
|
-
sentrySession.recordPageView(pageName, `${location.pathname}${location.search}`);
|
|
12
|
-
|
|
13
|
-
const cleanup = sentryPerformance.withSpan(`Page: ${pageName}`, 'navigation', () => {
|
|
14
|
-
sentryContext.setContext('page', {
|
|
15
|
-
name: pageName,
|
|
16
|
-
path: location.pathname,
|
|
17
|
-
search: location.search,
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
sentryPerformance.addBreadcrumb(`Navigation to ${pageName}`, 'navigation', 'info');
|
|
21
|
-
|
|
22
|
-
return () => {
|
|
23
|
-
// 清理函数
|
|
24
|
-
};
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
return cleanup;
|
|
28
|
-
}, [pageName, location]);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
// 组件性能监控 Hook
|
|
32
|
-
export const useSentryComponentTracking = (componentName: string) => {
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
return sentryPerformance.withSpan(`Component: ${componentName}`, 'ui.react.mount', () => {
|
|
35
|
-
sentryPerformance.addBreadcrumb(`Component ${componentName} mounted`, 'ui', 'info');
|
|
36
|
-
|
|
37
|
-
return () => {
|
|
38
|
-
sentryPerformance.addBreadcrumb(`Component ${componentName} unmounted`, 'ui', 'info');
|
|
39
|
-
};
|
|
40
|
-
});
|
|
41
|
-
}, [componentName]);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
// 错误处理 Hook
|
|
45
|
-
export const useSentryErrorHandler = () => {
|
|
46
|
-
return {
|
|
47
|
-
captureError: (error: Error, context?: Record<string, any>) => {
|
|
48
|
-
sentryError.captureException(error, context);
|
|
49
|
-
},
|
|
50
|
-
captureMessage: (message: string, level?: 'info' | 'warning' | 'error') => {
|
|
51
|
-
sentryError.captureMessage(message, level);
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
// 点击事件追踪 Hook
|
|
57
|
-
export const useSentryClickTracking = () => {
|
|
58
|
-
return {
|
|
59
|
-
trackClick: (
|
|
60
|
-
buttonName: string,
|
|
61
|
-
context?: {
|
|
62
|
-
buttonId?: string;
|
|
63
|
-
location?: string;
|
|
64
|
-
extraData?: Record<string, any>;
|
|
65
|
-
},
|
|
66
|
-
) => {
|
|
67
|
-
const clickData = {
|
|
68
|
-
buttonName,
|
|
69
|
-
buttonId: context?.buttonId,
|
|
70
|
-
location: context?.location || window.location.pathname,
|
|
71
|
-
clickTime: new Date().toISOString(),
|
|
72
|
-
timestamp: Date.now(),
|
|
73
|
-
...context?.extraData,
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
// ✨ 主动发送点击事件到 Sentry(这会立即发送)
|
|
77
|
-
sentryError.captureMessage(`Button Click: ${buttonName}`, 'info');
|
|
78
|
-
|
|
79
|
-
// 设置点击上下文(会包含在上面的消息中)
|
|
80
|
-
sentryContext.setContext('clickData', clickData);
|
|
81
|
-
|
|
82
|
-
// 记录用户操作(用于埋点统计)
|
|
83
|
-
sentrySession.recordUserAction(`Button Click: ${buttonName}`, clickData);
|
|
84
|
-
|
|
85
|
-
// 添加面包屑用于调试
|
|
86
|
-
sentryPerformance.addBreadcrumb(`Button clicked: ${buttonName}`, 'user.click', 'info');
|
|
87
|
-
|
|
88
|
-
// 设置点击上下文
|
|
89
|
-
sentryContext.setContext('lastClick', clickData);
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { useThemeStore } from '@store/theme';
|
|
2
|
-
import { Button } from 'antd';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
|
|
5
|
-
export default function BasePage() {
|
|
6
|
-
const theme = useThemeStore(state => state.theme);
|
|
7
|
-
const setTheme = useThemeStore(state => state.setTheme);
|
|
8
|
-
|
|
9
|
-
return (
|
|
10
|
-
<>
|
|
11
|
-
<Button type="primary">antd按钮</Button>
|
|
12
|
-
<button
|
|
13
|
-
type="button"
|
|
14
|
-
className={
|
|
15
|
-
' dark:text-red-600 dark:bg-[var(--tailwindssantd-color-primary)] bg-[var(--tailwindssantd-color-primary)]'
|
|
16
|
-
}
|
|
17
|
-
>
|
|
18
|
-
tailwind按钮
|
|
19
|
-
</button>
|
|
20
|
-
<button type="button" onClick={() => setTheme('dark')}>
|
|
21
|
-
切换主题({theme})
|
|
22
|
-
</button>
|
|
23
|
-
</>
|
|
24
|
-
);
|
|
25
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 字节转换函数
|
|
3
|
-
* @param kb
|
|
4
|
-
* @returns
|
|
5
|
-
*/
|
|
6
|
-
interface FormatSizeUnitsProps {
|
|
7
|
-
kb: number;
|
|
8
|
-
units?: string[];
|
|
9
|
-
}
|
|
10
|
-
export function formatSizeUnits(props: FormatSizeUnitsProps) {
|
|
11
|
-
const { kb, units = ['KB', 'MB', 'GB', 'TB', 'PB'] } = props;
|
|
12
|
-
let newKb = kb;
|
|
13
|
-
let unitIndex = 0;
|
|
14
|
-
|
|
15
|
-
while (kb >= 1024 && unitIndex < units.length - 1) {
|
|
16
|
-
newKb = newKb / 1024;
|
|
17
|
-
unitIndex++;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return `${kb.toFixed(2)} ${units[unitIndex]}`;
|
|
21
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// 创建一个空数组来存储匹配的对象
|
|
2
|
-
let matchedObjects: any[] = [];
|
|
3
|
-
|
|
4
|
-
// 定义一个递归函数来遍历子路由对象
|
|
5
|
-
function traverseRoutes(routes) {
|
|
6
|
-
for (const route of routes) {
|
|
7
|
-
// 检查当前子路由对象是否具有"microApp"属性
|
|
8
|
-
if (Object.prototype.hasOwnProperty.call(route, 'microApp')) {
|
|
9
|
-
// 如果有,将该子路由对象添加到结果数组中
|
|
10
|
-
matchedObjects.push(route);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// 检查当前子路由对象是否还有更深层级的子路由
|
|
14
|
-
if (Object.prototype.hasOwnProperty.call(route, 'routes')) {
|
|
15
|
-
// 递归调用自身来遍历更深层级的子路由对象
|
|
16
|
-
traverseRoutes(route.routes);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const getMicroApp = (a: any[]) => {
|
|
22
|
-
matchedObjects = [];
|
|
23
|
-
// 遍历变量a中的每个对象
|
|
24
|
-
for (const obj of a) {
|
|
25
|
-
// 检查当前对象是否具有"microApp"属性
|
|
26
|
-
if (Object.prototype.hasOwnProperty.call(obj, 'microApp')) {
|
|
27
|
-
// 如果有,将该对象添加到结果数组中
|
|
28
|
-
matchedObjects.push(obj);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// 检查当前对象是否具有"routes"属性
|
|
32
|
-
if (Object.prototype.hasOwnProperty.call(obj, 'routes')) {
|
|
33
|
-
// 调用递归函数来遍历子路由对象
|
|
34
|
-
traverseRoutes(obj.routes);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return matchedObjects;
|
|
39
|
-
};
|