@coze-arch/cli 0.0.1-beta.5 → 0.0.2
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/README.md +1 -0
- package/lib/__templates__/expo/.coze +7 -2
- package/lib/__templates__/expo/.cozeproj/scripts/dev_build.sh +46 -0
- package/lib/__templates__/expo/.cozeproj/scripts/dev_run.sh +229 -0
- package/lib/__templates__/expo/.cozeproj/scripts/prod_build.sh +47 -0
- package/lib/__templates__/expo/.cozeproj/scripts/prod_run.sh +34 -0
- package/lib/__templates__/expo/.cozeproj/scripts/server_dev_run.sh +46 -0
- package/lib/__templates__/expo/README.md +68 -7
- package/lib/__templates__/expo/_gitignore +1 -1
- package/lib/__templates__/{react-rsbuild → expo}/_npmrc +4 -5
- package/lib/__templates__/expo/client/app/+not-found.tsx +15 -64
- package/lib/__templates__/expo/client/app/_layout.tsx +15 -12
- package/lib/__templates__/expo/client/app/index.tsx +1 -0
- package/lib/__templates__/expo/client/app.config.ts +76 -0
- package/lib/__templates__/expo/client/components/Screen.tsx +22 -38
- package/lib/__templates__/expo/client/components/ThemedText.tsx +33 -0
- package/lib/__templates__/expo/client/components/ThemedView.tsx +37 -0
- package/lib/__templates__/expo/client/constants/theme.ts +117 -58
- package/lib/__templates__/expo/client/contexts/AuthContext.tsx +14 -107
- package/lib/__templates__/expo/client/declarations.d.ts +5 -0
- package/lib/__templates__/expo/{eslint.config.mjs → client/eslint.config.mjs} +40 -10
- package/lib/__templates__/expo/client/hooks/useColorScheme.tsx +48 -0
- package/lib/__templates__/expo/client/hooks/useSafeRouter.ts +152 -0
- package/lib/__templates__/expo/client/hooks/useTheme.ts +26 -6
- package/lib/__templates__/expo/client/metro.config.js +124 -0
- package/lib/__templates__/expo/client/package.json +95 -0
- package/lib/__templates__/expo/client/screens/demo/index.tsx +25 -0
- package/lib/__templates__/expo/client/screens/demo/styles.ts +28 -0
- package/lib/__templates__/expo/client/scripts/install-missing-deps.js +47 -22
- package/lib/__templates__/expo/client/tsconfig.json +24 -0
- package/lib/__templates__/expo/client/utils/index.ts +23 -2
- package/lib/__templates__/expo/eslint-plugins/fontawesome6/index.js +9 -0
- package/lib/__templates__/expo/eslint-plugins/fontawesome6/names.js +1889 -0
- package/lib/__templates__/expo/eslint-plugins/fontawesome6/rule.js +174 -0
- package/lib/__templates__/expo/eslint-plugins/fontawesome6/v5-only-names.js +388 -0
- package/lib/__templates__/expo/eslint-plugins/forbid-emoji/index.js +9 -0
- package/lib/__templates__/expo/eslint-plugins/forbid-emoji/rule.js +112 -0
- package/lib/__templates__/expo/eslint-plugins/forbid-emoji/tech.md +94 -0
- package/lib/__templates__/expo/eslint-plugins/react-native/index.js +9 -0
- package/lib/__templates__/expo/eslint-plugins/react-native/rule.js +64 -0
- package/lib/__templates__/expo/eslint-plugins/reanimated/index.js +9 -0
- package/lib/__templates__/expo/eslint-plugins/reanimated/rule.js +88 -0
- package/lib/__templates__/expo/eslint-plugins/restrict-linear-gradient/index.js +9 -0
- package/lib/__templates__/expo/eslint-plugins/restrict-linear-gradient/rule.js +120 -0
- package/lib/__templates__/expo/eslint-plugins/restrict-linear-gradient/tech.md +58 -0
- package/lib/__templates__/expo/package.json +16 -91
- package/lib/__templates__/expo/patches/expo@54.0.33.patch +45 -0
- package/lib/__templates__/expo/pnpm-lock.yaml +1805 -3126
- package/lib/__templates__/expo/pnpm-workspace.yaml +3 -0
- package/lib/__templates__/expo/server/build.js +21 -0
- package/lib/__templates__/expo/server/package.json +34 -0
- package/lib/__templates__/expo/server/src/index.ts +20 -0
- package/lib/__templates__/expo/server/tsconfig.json +24 -0
- package/lib/__templates__/expo/template.config.js +58 -1
- package/lib/__templates__/expo/tsconfig.json +1 -24
- package/lib/__templates__/native-static/.coze +11 -0
- package/lib/__templates__/native-static/index.html +33 -0
- package/lib/__templates__/native-static/styles/main.css +136 -0
- package/lib/__templates__/native-static/template.config.js +22 -0
- package/lib/__templates__/nextjs/.babelrc +15 -0
- package/lib/__templates__/nextjs/.coze +4 -3
- package/lib/__templates__/nextjs/README.md +346 -19
- package/lib/__templates__/nextjs/_npmrc +2 -1
- package/lib/__templates__/nextjs/components.json +21 -0
- package/lib/__templates__/nextjs/eslint.config.mjs +5 -0
- package/lib/__templates__/nextjs/next.config.ts +11 -0
- package/lib/__templates__/nextjs/package.json +63 -2
- package/lib/__templates__/nextjs/pnpm-lock.yaml +10053 -1710
- package/lib/__templates__/nextjs/scripts/build.sh +4 -1
- package/lib/__templates__/nextjs/scripts/dev.sh +15 -27
- package/lib/__templates__/{react-rsbuild/scripts/build.sh → nextjs/scripts/prepare.sh} +0 -5
- package/lib/__templates__/nextjs/scripts/start.sh +7 -1
- package/lib/__templates__/nextjs/src/app/globals.css +124 -13
- package/lib/__templates__/nextjs/src/app/layout.tsx +56 -16
- package/lib/__templates__/nextjs/src/app/page.tsx +18 -49
- package/lib/__templates__/nextjs/src/app/robots.ts +11 -0
- package/lib/__templates__/nextjs/src/components/ui/accordion.tsx +66 -0
- package/lib/__templates__/nextjs/src/components/ui/alert-dialog.tsx +157 -0
- package/lib/__templates__/nextjs/src/components/ui/alert.tsx +66 -0
- package/lib/__templates__/nextjs/src/components/ui/aspect-ratio.tsx +11 -0
- package/lib/__templates__/nextjs/src/components/ui/avatar.tsx +53 -0
- package/lib/__templates__/nextjs/src/components/ui/badge.tsx +46 -0
- package/lib/__templates__/nextjs/src/components/ui/breadcrumb.tsx +109 -0
- package/lib/__templates__/nextjs/src/components/ui/button-group.tsx +83 -0
- package/lib/__templates__/nextjs/src/components/ui/button.tsx +62 -0
- package/lib/__templates__/nextjs/src/components/ui/calendar.tsx +220 -0
- package/lib/__templates__/nextjs/src/components/ui/card.tsx +92 -0
- package/lib/__templates__/nextjs/src/components/ui/carousel.tsx +241 -0
- package/lib/__templates__/nextjs/src/components/ui/chart.tsx +357 -0
- package/lib/__templates__/nextjs/src/components/ui/checkbox.tsx +32 -0
- package/lib/__templates__/nextjs/src/components/ui/collapsible.tsx +33 -0
- package/lib/__templates__/nextjs/src/components/ui/command.tsx +184 -0
- package/lib/__templates__/nextjs/src/components/ui/context-menu.tsx +252 -0
- package/lib/__templates__/nextjs/src/components/ui/dialog.tsx +143 -0
- package/lib/__templates__/nextjs/src/components/ui/drawer.tsx +135 -0
- package/lib/__templates__/nextjs/src/components/ui/dropdown-menu.tsx +257 -0
- package/lib/__templates__/nextjs/src/components/ui/empty.tsx +104 -0
- package/lib/__templates__/nextjs/src/components/ui/field.tsx +248 -0
- package/lib/__templates__/nextjs/src/components/ui/form.tsx +167 -0
- package/lib/__templates__/nextjs/src/components/ui/hover-card.tsx +44 -0
- package/lib/__templates__/nextjs/src/components/ui/input-group.tsx +170 -0
- package/lib/__templates__/nextjs/src/components/ui/input-otp.tsx +77 -0
- package/lib/__templates__/nextjs/src/components/ui/input.tsx +21 -0
- package/lib/__templates__/nextjs/src/components/ui/item.tsx +193 -0
- package/lib/__templates__/nextjs/src/components/ui/kbd.tsx +28 -0
- package/lib/__templates__/nextjs/src/components/ui/label.tsx +24 -0
- package/lib/__templates__/nextjs/src/components/ui/menubar.tsx +276 -0
- package/lib/__templates__/nextjs/src/components/ui/navigation-menu.tsx +168 -0
- package/lib/__templates__/nextjs/src/components/ui/pagination.tsx +127 -0
- package/lib/__templates__/nextjs/src/components/ui/popover.tsx +48 -0
- package/lib/__templates__/nextjs/src/components/ui/progress.tsx +31 -0
- package/lib/__templates__/nextjs/src/components/ui/radio-group.tsx +45 -0
- package/lib/__templates__/nextjs/src/components/ui/resizable.tsx +63 -0
- package/lib/__templates__/nextjs/src/components/ui/scroll-area.tsx +58 -0
- package/lib/__templates__/nextjs/src/components/ui/select.tsx +190 -0
- package/lib/__templates__/nextjs/src/components/ui/separator.tsx +28 -0
- package/lib/__templates__/nextjs/src/components/ui/sheet.tsx +139 -0
- package/lib/__templates__/nextjs/src/components/ui/sidebar.tsx +724 -0
- package/lib/__templates__/nextjs/src/components/ui/skeleton.tsx +13 -0
- package/lib/__templates__/nextjs/src/components/ui/slider.tsx +63 -0
- package/lib/__templates__/nextjs/src/components/ui/sonner.tsx +40 -0
- package/lib/__templates__/nextjs/src/components/ui/spinner.tsx +16 -0
- package/lib/__templates__/nextjs/src/components/ui/switch.tsx +31 -0
- package/lib/__templates__/nextjs/src/components/ui/table.tsx +116 -0
- package/lib/__templates__/nextjs/src/components/ui/tabs.tsx +66 -0
- package/lib/__templates__/nextjs/src/components/ui/textarea.tsx +18 -0
- package/lib/__templates__/nextjs/src/components/ui/toggle-group.tsx +83 -0
- package/lib/__templates__/nextjs/src/components/ui/toggle.tsx +47 -0
- package/lib/__templates__/nextjs/src/components/ui/tooltip.tsx +61 -0
- package/lib/__templates__/nextjs/src/hooks/use-mobile.ts +19 -0
- package/lib/__templates__/nextjs/src/lib/utils.ts +6 -0
- package/lib/__templates__/nextjs/src/server.ts +35 -0
- package/lib/__templates__/nextjs/template.config.js +70 -5
- package/lib/__templates__/nextjs/tsconfig.json +1 -1
- package/lib/__templates__/nuxt-vue/.coze +12 -0
- package/lib/__templates__/nuxt-vue/README.md +73 -0
- package/lib/__templates__/nuxt-vue/_gitignore +24 -0
- package/lib/__templates__/{rsbuild → nuxt-vue}/_npmrc +2 -1
- package/lib/__templates__/nuxt-vue/app/app.vue +6 -0
- package/lib/__templates__/nuxt-vue/app/pages/index.vue +23 -0
- package/lib/__templates__/{rsbuild/src/index.css → nuxt-vue/assets/css/main.css} +7 -4
- package/lib/__templates__/nuxt-vue/nuxt.config.ts +116 -0
- package/lib/__templates__/nuxt-vue/package.json +35 -0
- package/lib/__templates__/nuxt-vue/pnpm-lock.yaml +8759 -0
- package/lib/__templates__/nuxt-vue/postcss.config.mjs +8 -0
- package/lib/__templates__/nuxt-vue/public/favicon.ico +0 -0
- package/lib/__templates__/nuxt-vue/public/robots.txt +2 -0
- package/lib/__templates__/{rsbuild → nuxt-vue}/scripts/build.sh +2 -2
- package/lib/__templates__/nuxt-vue/scripts/dev.sh +39 -0
- package/lib/__templates__/nuxt-vue/scripts/prepare.sh +14 -0
- package/lib/__templates__/nuxt-vue/scripts/start.sh +21 -0
- package/lib/__templates__/nuxt-vue/server/api/hello.ts +10 -0
- package/lib/__templates__/nuxt-vue/server/middleware/logger.ts +10 -0
- package/lib/__templates__/nuxt-vue/server/routes/health.ts +10 -0
- package/lib/__templates__/nuxt-vue/tailwind.config.js +13 -0
- package/lib/__templates__/nuxt-vue/template.config.js +87 -0
- package/lib/__templates__/nuxt-vue/tsconfig.json +18 -0
- package/lib/__templates__/taro/.coze +14 -0
- package/lib/__templates__/taro/.cozeproj/scripts/deploy_build.sh +19 -0
- package/lib/__templates__/taro/.cozeproj/scripts/deploy_run.sh +14 -0
- package/lib/__templates__/taro/.cozeproj/scripts/dev_build.sh +2 -0
- package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +151 -0
- package/lib/__templates__/taro/.cozeproj/scripts/init_env.sh +5 -0
- package/lib/__templates__/taro/.cozeproj/scripts/pack.sh +24 -0
- package/lib/__templates__/taro/README.md +763 -0
- package/lib/__templates__/taro/_gitignore +40 -0
- package/lib/__templates__/taro/_npmrc +18 -0
- package/lib/__templates__/taro/babel.config.js +12 -0
- package/lib/__templates__/taro/config/dev.ts +9 -0
- package/lib/__templates__/taro/config/index.ts +238 -0
- package/lib/__templates__/taro/config/prod.ts +34 -0
- package/lib/__templates__/taro/eslint.config.mjs +135 -0
- package/lib/__templates__/taro/key/private.appid.key +0 -0
- package/lib/__templates__/taro/package.json +112 -0
- package/lib/__templates__/taro/patches/@tarojs__plugin-mini-ci@4.1.9.patch +30 -0
- package/lib/__templates__/taro/pnpm-lock.yaml +23412 -0
- package/lib/__templates__/taro/pnpm-workspace.yaml +2 -0
- package/lib/__templates__/taro/project.config.json +15 -0
- package/lib/__templates__/taro/server/nest-cli.json +10 -0
- package/lib/__templates__/taro/server/package.json +40 -0
- package/lib/__templates__/taro/server/src/app.controller.ts +23 -0
- package/lib/__templates__/taro/server/src/app.module.ts +10 -0
- package/lib/__templates__/taro/server/src/app.service.ts +8 -0
- package/lib/__templates__/taro/server/src/interceptors/http-status.interceptor.ts +23 -0
- package/lib/__templates__/taro/server/src/main.ts +49 -0
- package/lib/__templates__/taro/server/tsconfig.json +24 -0
- package/lib/__templates__/taro/src/app.config.ts +11 -0
- package/lib/__templates__/taro/src/app.css +156 -0
- package/lib/__templates__/taro/src/app.tsx +9 -0
- package/lib/__templates__/taro/src/components/ui/accordion.tsx +159 -0
- package/lib/__templates__/taro/src/components/ui/alert-dialog.tsx +260 -0
- package/lib/__templates__/taro/src/components/ui/alert.tsx +60 -0
- package/lib/__templates__/taro/src/components/ui/aspect-ratio.tsx +36 -0
- package/lib/__templates__/taro/src/components/ui/avatar.tsx +84 -0
- package/lib/__templates__/taro/src/components/ui/badge.tsx +37 -0
- package/lib/__templates__/taro/src/components/ui/breadcrumb.tsx +117 -0
- package/lib/__templates__/taro/src/components/ui/button-group.tsx +83 -0
- package/lib/__templates__/taro/src/components/ui/button.tsx +67 -0
- package/lib/__templates__/taro/src/components/ui/calendar.tsx +394 -0
- package/lib/__templates__/taro/src/components/ui/card.tsx +108 -0
- package/lib/__templates__/taro/src/components/ui/carousel.tsx +228 -0
- package/lib/__templates__/taro/src/components/ui/checkbox.tsx +58 -0
- package/lib/__templates__/taro/src/components/ui/code-block.tsx +169 -0
- package/lib/__templates__/taro/src/components/ui/collapsible.tsx +71 -0
- package/lib/__templates__/taro/src/components/ui/command.tsx +385 -0
- package/lib/__templates__/taro/src/components/ui/context-menu.tsx +614 -0
- package/lib/__templates__/taro/src/components/ui/dialog.tsx +256 -0
- package/lib/__templates__/taro/src/components/ui/drawer.tsx +192 -0
- package/lib/__templates__/taro/src/components/ui/dropdown-menu.tsx +561 -0
- package/lib/__templates__/taro/src/components/ui/field.tsx +228 -0
- package/lib/__templates__/taro/src/components/ui/hover-card.tsx +282 -0
- package/lib/__templates__/taro/src/components/ui/input-group.tsx +197 -0
- package/lib/__templates__/taro/src/components/ui/input-otp.tsx +136 -0
- package/lib/__templates__/taro/src/components/ui/input.tsx +56 -0
- package/lib/__templates__/taro/src/components/ui/label.tsx +24 -0
- package/lib/__templates__/taro/src/components/ui/menubar.tsx +595 -0
- package/lib/__templates__/taro/src/components/ui/navigation-menu.tsx +264 -0
- package/lib/__templates__/taro/src/components/ui/pagination.tsx +118 -0
- package/lib/__templates__/taro/src/components/ui/popover.tsx +291 -0
- package/lib/__templates__/taro/src/components/ui/portal.tsx +19 -0
- package/lib/__templates__/taro/src/components/ui/progress.tsx +28 -0
- package/lib/__templates__/taro/src/components/ui/radio-group.tsx +64 -0
- package/lib/__templates__/taro/src/components/ui/resizable.tsx +346 -0
- package/lib/__templates__/taro/src/components/ui/scroll-area.tsx +34 -0
- package/lib/__templates__/taro/src/components/ui/select.tsx +438 -0
- package/lib/__templates__/taro/src/components/ui/separator.tsx +30 -0
- package/lib/__templates__/taro/src/components/ui/sheet.tsx +262 -0
- package/lib/__templates__/taro/src/components/ui/skeleton.tsx +17 -0
- package/lib/__templates__/taro/src/components/ui/slider.tsx +203 -0
- package/lib/__templates__/taro/src/components/ui/sonner.tsx +1 -0
- package/lib/__templates__/taro/src/components/ui/switch.tsx +55 -0
- package/lib/__templates__/taro/src/components/ui/table.tsx +142 -0
- package/lib/__templates__/taro/src/components/ui/tabs.tsx +114 -0
- package/lib/__templates__/taro/src/components/ui/textarea.tsx +54 -0
- package/lib/__templates__/taro/src/components/ui/toast.tsx +517 -0
- package/lib/__templates__/taro/src/components/ui/toggle-group.tsx +120 -0
- package/lib/__templates__/taro/src/components/ui/toggle.tsx +77 -0
- package/lib/__templates__/taro/src/components/ui/tooltip.tsx +455 -0
- package/lib/__templates__/taro/src/index.html +39 -0
- package/lib/__templates__/taro/src/lib/hooks/use-keyboard-offset.ts +37 -0
- package/lib/__templates__/taro/src/lib/measure.ts +115 -0
- package/lib/__templates__/taro/src/lib/platform.ts +12 -0
- package/lib/__templates__/taro/src/lib/utils.ts +6 -0
- package/lib/__templates__/taro/src/network.ts +39 -0
- package/lib/__templates__/taro/src/pages/index/index.config.ts +3 -0
- package/lib/__templates__/taro/src/pages/index/index.css +1 -0
- package/lib/__templates__/taro/src/pages/index/index.tsx +33 -0
- package/lib/__templates__/taro/src/presets/dev-debug.ts +23 -0
- package/lib/__templates__/taro/src/presets/h5-container.tsx +15 -0
- package/lib/__templates__/taro/src/presets/h5-navbar.tsx +238 -0
- package/lib/__templates__/taro/src/presets/h5-styles.ts +220 -0
- package/lib/__templates__/taro/src/presets/index.tsx +18 -0
- package/lib/__templates__/taro/stylelint.config.mjs +4 -0
- package/lib/__templates__/taro/template.config.js +68 -0
- package/lib/__templates__/taro/tsconfig.json +29 -0
- package/lib/__templates__/taro/types/global.d.ts +32 -0
- package/lib/__templates__/templates.json +126 -64
- package/lib/__templates__/vite/.coze +4 -3
- package/lib/__templates__/vite/README.md +383 -26
- package/lib/__templates__/vite/_gitignore +1 -0
- package/lib/__templates__/vite/_npmrc +2 -1
- package/lib/__templates__/vite/eslint.config.mjs +14 -0
- package/lib/__templates__/vite/package.json +23 -3
- package/lib/__templates__/vite/pnpm-lock.yaml +2509 -293
- package/lib/__templates__/vite/scripts/build.sh +4 -1
- package/lib/__templates__/vite/scripts/dev.sh +16 -28
- package/lib/__templates__/vite/scripts/prepare.sh +9 -0
- package/lib/__templates__/vite/scripts/start.sh +9 -3
- package/lib/__templates__/vite/server/routes/index.ts +31 -0
- package/lib/__templates__/vite/server/server.ts +65 -0
- package/lib/__templates__/vite/server/vite.ts +67 -0
- package/lib/__templates__/vite/src/main.ts +17 -48
- package/lib/__templates__/vite/template.config.js +82 -10
- package/lib/__templates__/vite/tsconfig.json +4 -3
- package/lib/__templates__/vite/vite.config.ts +8 -3
- package/lib/cli.js +1544 -488
- package/package.json +18 -7
- package/lib/__templates__/expo/.cozeproj/scripts/deploy_build.sh +0 -109
- package/lib/__templates__/expo/.cozeproj/scripts/deploy_run.sh +0 -257
- package/lib/__templates__/expo/app.json +0 -63
- package/lib/__templates__/expo/babel.config.js +0 -9
- package/lib/__templates__/expo/client/app/(tabs)/_layout.tsx +0 -43
- package/lib/__templates__/expo/client/app/(tabs)/home.tsx +0 -1
- package/lib/__templates__/expo/client/app/(tabs)/index.tsx +0 -7
- package/lib/__templates__/expo/client/hooks/useColorScheme.ts +0 -1
- package/lib/__templates__/expo/client/index.js +0 -11
- package/lib/__templates__/expo/client/screens/home/index.tsx +0 -54
- package/lib/__templates__/expo/client/screens/home/styles.ts +0 -332
- package/lib/__templates__/expo/metro.config.js +0 -53
- package/lib/__templates__/expo/src/index.ts +0 -12
- package/lib/__templates__/nextjs/.vscode/settings.json +0 -121
- package/lib/__templates__/react-rsbuild/.coze +0 -11
- package/lib/__templates__/react-rsbuild/.vscode/settings.json +0 -121
- package/lib/__templates__/react-rsbuild/README.md +0 -61
- package/lib/__templates__/react-rsbuild/_gitignore +0 -97
- package/lib/__templates__/react-rsbuild/package.json +0 -31
- package/lib/__templates__/react-rsbuild/pnpm-lock.yaml +0 -997
- package/lib/__templates__/react-rsbuild/rsbuild.config.ts +0 -13
- package/lib/__templates__/react-rsbuild/scripts/dev.sh +0 -51
- package/lib/__templates__/react-rsbuild/scripts/start.sh +0 -15
- package/lib/__templates__/react-rsbuild/src/App.tsx +0 -60
- package/lib/__templates__/react-rsbuild/src/index.css +0 -21
- package/lib/__templates__/react-rsbuild/src/index.html +0 -12
- package/lib/__templates__/react-rsbuild/src/index.tsx +0 -16
- package/lib/__templates__/react-rsbuild/tailwind.config.js +0 -9
- package/lib/__templates__/react-rsbuild/template.config.js +0 -54
- package/lib/__templates__/react-rsbuild/tsconfig.json +0 -17
- package/lib/__templates__/rsbuild/.coze +0 -11
- package/lib/__templates__/rsbuild/.vscode/settings.json +0 -7
- package/lib/__templates__/rsbuild/README.md +0 -61
- package/lib/__templates__/rsbuild/_gitignore +0 -97
- package/lib/__templates__/rsbuild/package.json +0 -24
- package/lib/__templates__/rsbuild/pnpm-lock.yaml +0 -888
- package/lib/__templates__/rsbuild/rsbuild.config.ts +0 -12
- package/lib/__templates__/rsbuild/scripts/dev.sh +0 -51
- package/lib/__templates__/rsbuild/scripts/start.sh +0 -15
- package/lib/__templates__/rsbuild/src/index.html +0 -12
- package/lib/__templates__/rsbuild/src/index.ts +0 -5
- package/lib/__templates__/rsbuild/src/main.ts +0 -65
- package/lib/__templates__/rsbuild/tailwind.config.js +0 -9
- package/lib/__templates__/rsbuild/template.config.js +0 -54
- package/lib/__templates__/rsbuild/tsconfig.json +0 -16
- package/lib/__templates__/vite/.vscode/settings.json +0 -7
- /package/lib/__templates__/expo/{eslint-formatter-simple.mjs → client/eslint-formatter-simple.mjs} +0 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ExpoConfig, ConfigContext } from 'expo/config';
|
|
2
|
+
|
|
3
|
+
const appName = process.env.COZE_PROJECT_NAME || process.env.EXPO_PUBLIC_COZE_PROJECT_NAME || '应用';
|
|
4
|
+
const projectId = process.env.COZE_PROJECT_ID || process.env.EXPO_PUBLIC_COZE_PROJECT_ID;
|
|
5
|
+
const slugAppName = projectId ? `app${projectId}` : 'myapp';
|
|
6
|
+
|
|
7
|
+
export default ({ config }: ConfigContext): ExpoConfig => {
|
|
8
|
+
return {
|
|
9
|
+
...config,
|
|
10
|
+
"name": appName,
|
|
11
|
+
"slug": slugAppName,
|
|
12
|
+
"version": "1.0.0",
|
|
13
|
+
"orientation": "portrait",
|
|
14
|
+
"icon": "./assets/images/icon.png",
|
|
15
|
+
"scheme": "myapp",
|
|
16
|
+
"userInterfaceStyle": "automatic",
|
|
17
|
+
"newArchEnabled": true,
|
|
18
|
+
"ios": {
|
|
19
|
+
"supportsTablet": true
|
|
20
|
+
},
|
|
21
|
+
"android": {
|
|
22
|
+
"adaptiveIcon": {
|
|
23
|
+
"foregroundImage": "./assets/images/adaptive-icon.png",
|
|
24
|
+
"backgroundColor": "#ffffff"
|
|
25
|
+
},
|
|
26
|
+
"package": `com.anonymous.x${projectId || '0'}`
|
|
27
|
+
},
|
|
28
|
+
"web": {
|
|
29
|
+
"bundler": "metro",
|
|
30
|
+
"output": "single",
|
|
31
|
+
"favicon": "./assets/images/favicon.png"
|
|
32
|
+
},
|
|
33
|
+
"plugins": [
|
|
34
|
+
process.env.EXPO_PUBLIC_BACKEND_BASE_URL ? [
|
|
35
|
+
"expo-router",
|
|
36
|
+
{
|
|
37
|
+
"origin": process.env.EXPO_PUBLIC_BACKEND_BASE_URL
|
|
38
|
+
}
|
|
39
|
+
] : 'expo-router',
|
|
40
|
+
[
|
|
41
|
+
"expo-splash-screen",
|
|
42
|
+
{
|
|
43
|
+
"image": "./assets/images/splash-icon.png",
|
|
44
|
+
"imageWidth": 200,
|
|
45
|
+
"resizeMode": "contain",
|
|
46
|
+
"backgroundColor": "#ffffff"
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
[
|
|
50
|
+
"expo-image-picker",
|
|
51
|
+
{
|
|
52
|
+
"photosPermission": `允许${appName}访问您的相册,以便您上传或保存图片。`,
|
|
53
|
+
"cameraPermission": `允许${appName}使用您的相机,以便您直接拍摄照片上传。`,
|
|
54
|
+
"microphonePermission": `允许${appName}访问您的麦克风,以便您拍摄带有声音的视频。`
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
[
|
|
58
|
+
"expo-location",
|
|
59
|
+
{
|
|
60
|
+
"locationWhenInUsePermission": `${appName}需要访问您的位置以提供周边服务及导航功能。`
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
[
|
|
64
|
+
"expo-camera",
|
|
65
|
+
{
|
|
66
|
+
"cameraPermission": `${appName}需要访问相机以拍摄照片和视频。`,
|
|
67
|
+
"microphonePermission": `${appName}需要访问麦克风以录制视频声音。`,
|
|
68
|
+
"recordAudioAndroid": true
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
],
|
|
72
|
+
"experiments": {
|
|
73
|
+
"typedRoutes": true
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -22,30 +22,30 @@ import {
|
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* # Screen 组件使用指南
|
|
25
|
-
*
|
|
25
|
+
*
|
|
26
26
|
* 核心原则:统一使用手动安全区管理 (padding),支持沉浸式布局,解决 iOS/Android 状态栏一致性问题。
|
|
27
|
-
*
|
|
27
|
+
*
|
|
28
28
|
* ## 1. 普通页面 (默认)
|
|
29
29
|
* - 场景:标准的白底或纯色背景页面,Header 在安全区下方。
|
|
30
30
|
* - 用法:`<Screen>{children}</Screen>`
|
|
31
31
|
* - 行为:自动处理上下左右安全区,状态栏文字黑色。
|
|
32
|
-
*
|
|
32
|
+
*
|
|
33
33
|
* ## 2. 沉浸式 Header (推荐)
|
|
34
34
|
* - 场景:Header 背景色/图片需要延伸到状态栏 (如首页、个人中心)。
|
|
35
|
-
* - 用法:`<Screen safeAreaEdges={['left', 'right', 'bottom']}>` (
|
|
35
|
+
* - 用法:`<Screen safeAreaEdges={['left', 'right', 'bottom']}>` (去掉 'top')
|
|
36
36
|
* - 配合:页面内部 Header 组件必须手动添加 paddingTop:
|
|
37
37
|
* ```tsx
|
|
38
38
|
* const insets = useSafeAreaInsets();
|
|
39
39
|
* <View style={{ paddingTop: insets.top + 12, backgroundColor: '...' }}>
|
|
40
40
|
* ```
|
|
41
|
-
*
|
|
41
|
+
*
|
|
42
42
|
* ## 3. 底部有 TabBar 或 悬浮按钮
|
|
43
43
|
* - 场景:页面底部有固定导航栏,或者需要精细控制底部留白。
|
|
44
|
-
* - 用法:`<Screen safeAreaEdges={['top', 'left', 'right']}>` (
|
|
44
|
+
* - 用法:`<Screen safeAreaEdges={['top', 'left', 'right']}>` (去掉 'bottom')
|
|
45
45
|
* - 配合:
|
|
46
46
|
* - 若是滚动页:`<ScrollView contentContainerStyle={{ paddingBottom: insets.bottom + 80 }}>`
|
|
47
47
|
* - 若是固定页:`<View style={{ paddingBottom: insets.bottom + 60 }}>`
|
|
48
|
-
*
|
|
48
|
+
*
|
|
49
49
|
* ## 4. 滚动列表/表单
|
|
50
50
|
* - 场景:长内容,需要键盘避让。
|
|
51
51
|
* - 用法:`<Screen>{children}</Screen>`
|
|
@@ -56,19 +56,19 @@ interface ScreenProps {
|
|
|
56
56
|
children: React.ReactNode;
|
|
57
57
|
/** 背景色,默认 #fff */
|
|
58
58
|
backgroundColor?: string;
|
|
59
|
-
/**
|
|
59
|
+
/**
|
|
60
60
|
* 状态栏样式
|
|
61
61
|
* - 'dark': 黑色文字 (默认)
|
|
62
62
|
* - 'light': 白色文字 (深色背景时用)
|
|
63
63
|
*/
|
|
64
64
|
statusBarStyle?: 'auto' | 'inverted' | 'light' | 'dark';
|
|
65
|
-
/**
|
|
65
|
+
/**
|
|
66
66
|
* 状态栏背景色
|
|
67
67
|
* - 默认 'transparent' 以支持沉浸式
|
|
68
68
|
* - Android 下如果需要不透明,可传入具体颜色
|
|
69
69
|
*/
|
|
70
70
|
statusBarColor?: string;
|
|
71
|
-
/**
|
|
71
|
+
/**
|
|
72
72
|
* 安全区控制 (关键属性)
|
|
73
73
|
* - 默认: ['top', 'left', 'right', 'bottom'] (全避让)
|
|
74
74
|
* - 沉浸式 Header: 去掉 'top'
|
|
@@ -96,7 +96,7 @@ const KeyboardAwareScrollable = ({
|
|
|
96
96
|
const styleArray = Array.isArray(originStyle) ? originStyle : originStyle ? [originStyle] : [];
|
|
97
97
|
const merged = Object.assign({}, ...styleArray);
|
|
98
98
|
const currentPB = typeof merged.paddingBottom === 'number' ? merged.paddingBottom : 0;
|
|
99
|
-
|
|
99
|
+
|
|
100
100
|
// 合并 paddingBottom (安全区 + 额外留白)
|
|
101
101
|
const enhancedContentStyle = [{ ...merged, paddingBottom: currentPB + extraPadding }];
|
|
102
102
|
|
|
@@ -123,7 +123,7 @@ const KeyboardAwareScrollable = ({
|
|
|
123
123
|
if (t === ScrollView) {
|
|
124
124
|
return <KeyboardAwareScrollView {...commonProps} />;
|
|
125
125
|
}
|
|
126
|
-
|
|
126
|
+
|
|
127
127
|
if (t === FlatList) {
|
|
128
128
|
return <KeyboardAwareFlatList {...commonProps} />;
|
|
129
129
|
}
|
|
@@ -145,12 +145,12 @@ export const Screen = ({
|
|
|
145
145
|
backgroundColor = '#fff',
|
|
146
146
|
statusBarStyle = 'dark',
|
|
147
147
|
statusBarColor = 'transparent',
|
|
148
|
-
safeAreaEdges = [],
|
|
148
|
+
safeAreaEdges = ['top', 'left', 'right', 'bottom'],
|
|
149
149
|
style,
|
|
150
150
|
}: ScreenProps) => {
|
|
151
151
|
const insets = useSafeAreaInsets();
|
|
152
152
|
const [keyboardShown, setKeyboardShown] = React.useState(false);
|
|
153
|
-
|
|
153
|
+
|
|
154
154
|
useEffect(() => {
|
|
155
155
|
const showEvent = Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow';
|
|
156
156
|
const hideEvent = Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide';
|
|
@@ -197,26 +197,10 @@ export const Screen = ({
|
|
|
197
197
|
// 强制禁用 iOS 自动调整内容区域,完全由手动 padding 控制,消除系统自动计算带来的多余空白
|
|
198
198
|
const contentInsetBehaviorIOS = 'never';
|
|
199
199
|
|
|
200
|
-
// 1. 外层容器样式
|
|
201
|
-
// 负责:背景色、Top/Left/Right 安全区、以及非滚动模式下的 Bottom 安全区
|
|
202
|
-
const childArray = React.Children.toArray(children);
|
|
203
|
-
let firstChild: React.ReactElement<any, any> | null = null;
|
|
204
|
-
for (let i = 0; i < childArray.length; i++) {
|
|
205
|
-
const el = childArray[i];
|
|
206
|
-
if (React.isValidElement(el)) { firstChild = el as React.ReactElement<any, any>; break; }
|
|
207
|
-
}
|
|
208
|
-
const firstChildHasInlinePaddingTop = (() => {
|
|
209
|
-
if (!firstChild) return false;
|
|
210
|
-
const st: any = (firstChild as any).props?.style;
|
|
211
|
-
const arr = Array.isArray(st) ? st : st ? [st] : [];
|
|
212
|
-
return arr.some((s) => s && typeof s === 'object' && typeof (s as any).paddingTop === 'number' && (s as any).paddingTop > 10);
|
|
213
|
-
})();
|
|
214
|
-
const applyTopInset = hasTop && !firstChildHasInlinePaddingTop;
|
|
215
|
-
|
|
216
200
|
const wrapperStyle: ViewStyle = {
|
|
217
201
|
flex: 1,
|
|
218
202
|
backgroundColor,
|
|
219
|
-
paddingTop:
|
|
203
|
+
paddingTop: hasTop ? insets.top : 0,
|
|
220
204
|
paddingLeft: hasLeft ? insets.left : 0,
|
|
221
205
|
paddingRight: hasRight ? insets.right : 0,
|
|
222
206
|
// 当页面不使用外层 ScrollView 时(子树本身可滚动),由外层 View 负责底部安全区
|
|
@@ -227,16 +211,16 @@ export const Screen = ({
|
|
|
227
211
|
|
|
228
212
|
// 若子树不可滚动,则外层使用 KeyboardAwareScrollView 提供“全局页面滑动”能力
|
|
229
213
|
const useScrollContainer = !childIsNativeScrollable;
|
|
230
|
-
|
|
214
|
+
|
|
231
215
|
// 2. 滚动容器配置
|
|
232
216
|
// 如果使用滚动容器,则使用 KeyboardAwareScrollView 替代原有的 ScrollView
|
|
233
217
|
const Container = useScrollContainer ? KeyboardAwareScrollView : View;
|
|
234
218
|
|
|
235
219
|
const containerProps = useScrollContainer ? {
|
|
236
|
-
contentContainerStyle: {
|
|
220
|
+
contentContainerStyle: {
|
|
237
221
|
flexGrow: 1,
|
|
238
222
|
// 滚动模式下,Bottom 安全区由内容容器处理,保证内容能完整显示且不被 Home Indicator 遮挡,同时背景色能延伸到底部
|
|
239
|
-
paddingBottom: hasBottom ? (keyboardShown ? 0 : insets.bottom) : 0,
|
|
223
|
+
paddingBottom: hasBottom ? (keyboardShown ? 0 : insets.bottom) : 0,
|
|
240
224
|
},
|
|
241
225
|
keyboardShouldPersistTaps: 'handled' as const,
|
|
242
226
|
showsVerticalScrollIndicator: false,
|
|
@@ -290,8 +274,8 @@ export const Screen = ({
|
|
|
290
274
|
// 核心原则:严禁使用 SafeAreaView,统一使用 View + padding 手动管理
|
|
291
275
|
<View style={wrapperStyle}>
|
|
292
276
|
{/* 状态栏配置:强制透明背景 + 沉浸式,以支持背景图延伸 */}
|
|
293
|
-
<StatusBar
|
|
294
|
-
style={statusBarStyle}
|
|
277
|
+
<StatusBar
|
|
278
|
+
style={statusBarStyle}
|
|
295
279
|
backgroundColor={statusBarColor}
|
|
296
280
|
translucent
|
|
297
281
|
/>
|
|
@@ -325,6 +309,6 @@ const styles = StyleSheet.create({
|
|
|
325
309
|
innerContainer: {
|
|
326
310
|
flex: 1,
|
|
327
311
|
// 确保内部容器透明,避免背景色遮挡
|
|
328
|
-
backgroundColor: 'transparent',
|
|
312
|
+
backgroundColor: 'transparent',
|
|
329
313
|
},
|
|
330
|
-
});
|
|
314
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text, TextProps, TextStyle } from 'react-native';
|
|
3
|
+
import { useTheme } from '@/hooks/useTheme';
|
|
4
|
+
import { Typography } from '@/constants/theme';
|
|
5
|
+
|
|
6
|
+
type TypographyVariant = keyof typeof Typography;
|
|
7
|
+
|
|
8
|
+
interface ThemedTextProps extends TextProps {
|
|
9
|
+
variant?: TypographyVariant;
|
|
10
|
+
color?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function ThemedText({
|
|
14
|
+
variant = 'body',
|
|
15
|
+
color,
|
|
16
|
+
style,
|
|
17
|
+
children,
|
|
18
|
+
...props
|
|
19
|
+
}: ThemedTextProps) {
|
|
20
|
+
const { theme } = useTheme();
|
|
21
|
+
const typographyStyle = Typography[variant];
|
|
22
|
+
|
|
23
|
+
const textStyle: TextStyle = {
|
|
24
|
+
...typographyStyle,
|
|
25
|
+
color: color ?? theme.textPrimary,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<Text style={[textStyle, style]} {...props}>
|
|
30
|
+
{children}
|
|
31
|
+
</Text>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, ViewProps, ViewStyle } from 'react-native';
|
|
3
|
+
import { useTheme } from '@/hooks/useTheme';
|
|
4
|
+
|
|
5
|
+
type BackgroundLevel = 'root' | 'default' | 'tertiary';
|
|
6
|
+
|
|
7
|
+
interface ThemedViewProps extends ViewProps {
|
|
8
|
+
level?: BackgroundLevel;
|
|
9
|
+
backgroundColor?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const backgroundMap: Record<BackgroundLevel, string> = {
|
|
13
|
+
root: 'backgroundRoot',
|
|
14
|
+
default: 'backgroundDefault',
|
|
15
|
+
tertiary: 'backgroundTertiary',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export function ThemedView({
|
|
19
|
+
level = 'root',
|
|
20
|
+
backgroundColor,
|
|
21
|
+
style,
|
|
22
|
+
children,
|
|
23
|
+
...props
|
|
24
|
+
}: ThemedViewProps) {
|
|
25
|
+
const { theme } = useTheme();
|
|
26
|
+
const bgColor = backgroundColor ?? (theme as any)[backgroundMap[level]];
|
|
27
|
+
|
|
28
|
+
const viewStyle: ViewStyle = {
|
|
29
|
+
backgroundColor: bgColor,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<View style={[viewStyle, style]} {...props}>
|
|
34
|
+
{children}
|
|
35
|
+
</View>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -1,30 +1,35 @@
|
|
|
1
|
-
import { Platform } from "react-native";
|
|
2
|
-
|
|
3
|
-
const tintColorLight = "#007AFF";
|
|
4
|
-
const tintColorDark = "#0A84FF";
|
|
5
|
-
|
|
6
1
|
export const Colors = {
|
|
7
2
|
light: {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
textPrimary: "#1C1917",
|
|
4
|
+
textSecondary: "#78716c",
|
|
5
|
+
textMuted: "#9CA3AF",
|
|
6
|
+
primary: "#4F46E5", // Indigo-600 - 品牌主色,代表科技与智能
|
|
7
|
+
accent: "#8B5CF6", // Violet-500 - 辅助色,代表创造力
|
|
8
|
+
success: "#10B981", // Emerald-500
|
|
9
|
+
error: "#EF4444",
|
|
10
|
+
backgroundRoot: "#FAFAFA",
|
|
11
|
+
backgroundDefault: "#FFFFFF",
|
|
12
|
+
backgroundTertiary: "#F9FAFB", // 更浅的背景色,用于去线留白
|
|
13
|
+
buttonPrimaryText: "#FFFFFF",
|
|
14
|
+
tabIconSelected: "#4F46E5",
|
|
15
|
+
border: "#E5E7EB",
|
|
16
|
+
borderLight: "#F3F4F6",
|
|
17
17
|
},
|
|
18
18
|
dark: {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
textPrimary: "#FAFAF9",
|
|
20
|
+
textSecondary: "#A8A29E",
|
|
21
|
+
textMuted: "#6F767E",
|
|
22
|
+
primary: "#818CF8", // Indigo-400 - 暗色模式品牌主色
|
|
23
|
+
accent: "#A78BFA", // Violet-400
|
|
24
|
+
success: "#34D399",
|
|
25
|
+
error: "#F87171",
|
|
26
|
+
backgroundRoot: "#09090B", // 更深的背景色
|
|
27
|
+
backgroundDefault: "#1C1C1E",
|
|
28
|
+
backgroundTertiary: "#1F1F22", // 暗色模式去线留白背景
|
|
29
|
+
buttonPrimaryText: "#09090B",
|
|
30
|
+
tabIconSelected: "#818CF8",
|
|
31
|
+
border: "#3F3F46",
|
|
32
|
+
borderLight: "#27272A",
|
|
28
33
|
},
|
|
29
34
|
};
|
|
30
35
|
|
|
@@ -38,22 +43,39 @@ export const Spacing = {
|
|
|
38
43
|
"3xl": 32,
|
|
39
44
|
"4xl": 40,
|
|
40
45
|
"5xl": 48,
|
|
41
|
-
|
|
42
|
-
buttonHeight: 52,
|
|
46
|
+
"6xl": 64,
|
|
43
47
|
};
|
|
44
48
|
|
|
45
49
|
export const BorderRadius = {
|
|
46
|
-
xs:
|
|
47
|
-
sm:
|
|
48
|
-
md:
|
|
49
|
-
lg:
|
|
50
|
-
xl:
|
|
51
|
-
"2xl":
|
|
52
|
-
"3xl":
|
|
50
|
+
xs: 4,
|
|
51
|
+
sm: 8,
|
|
52
|
+
md: 12,
|
|
53
|
+
lg: 16,
|
|
54
|
+
xl: 20,
|
|
55
|
+
"2xl": 24,
|
|
56
|
+
"3xl": 28,
|
|
57
|
+
"4xl": 32,
|
|
53
58
|
full: 9999,
|
|
54
59
|
};
|
|
55
60
|
|
|
56
61
|
export const Typography = {
|
|
62
|
+
display: {
|
|
63
|
+
fontSize: 112,
|
|
64
|
+
lineHeight: 112,
|
|
65
|
+
fontWeight: "200" as const,
|
|
66
|
+
letterSpacing: -4,
|
|
67
|
+
},
|
|
68
|
+
displayLarge: {
|
|
69
|
+
fontSize: 112,
|
|
70
|
+
lineHeight: 112,
|
|
71
|
+
fontWeight: "200" as const,
|
|
72
|
+
letterSpacing: -2,
|
|
73
|
+
},
|
|
74
|
+
displayMedium: {
|
|
75
|
+
fontSize: 48,
|
|
76
|
+
lineHeight: 56,
|
|
77
|
+
fontWeight: "200" as const,
|
|
78
|
+
},
|
|
57
79
|
h1: {
|
|
58
80
|
fontSize: 32,
|
|
59
81
|
lineHeight: 40,
|
|
@@ -67,52 +89,89 @@ export const Typography = {
|
|
|
67
89
|
h3: {
|
|
68
90
|
fontSize: 24,
|
|
69
91
|
lineHeight: 32,
|
|
70
|
-
fontWeight: "
|
|
92
|
+
fontWeight: "300" as const,
|
|
71
93
|
},
|
|
72
94
|
h4: {
|
|
73
95
|
fontSize: 20,
|
|
74
96
|
lineHeight: 28,
|
|
75
97
|
fontWeight: "600" as const,
|
|
76
98
|
},
|
|
99
|
+
title: {
|
|
100
|
+
fontSize: 18,
|
|
101
|
+
lineHeight: 24,
|
|
102
|
+
fontWeight: "700" as const,
|
|
103
|
+
},
|
|
77
104
|
body: {
|
|
78
105
|
fontSize: 16,
|
|
79
106
|
lineHeight: 24,
|
|
80
107
|
fontWeight: "400" as const,
|
|
81
108
|
},
|
|
109
|
+
bodyMedium: {
|
|
110
|
+
fontSize: 16,
|
|
111
|
+
lineHeight: 24,
|
|
112
|
+
fontWeight: "500" as const,
|
|
113
|
+
},
|
|
82
114
|
small: {
|
|
83
115
|
fontSize: 14,
|
|
84
116
|
lineHeight: 20,
|
|
85
117
|
fontWeight: "400" as const,
|
|
86
118
|
},
|
|
119
|
+
smallMedium: {
|
|
120
|
+
fontSize: 14,
|
|
121
|
+
lineHeight: 20,
|
|
122
|
+
fontWeight: "500" as const,
|
|
123
|
+
},
|
|
124
|
+
caption: {
|
|
125
|
+
fontSize: 12,
|
|
126
|
+
lineHeight: 16,
|
|
127
|
+
fontWeight: "400" as const,
|
|
128
|
+
},
|
|
129
|
+
captionMedium: {
|
|
130
|
+
fontSize: 12,
|
|
131
|
+
lineHeight: 16,
|
|
132
|
+
fontWeight: "500" as const,
|
|
133
|
+
},
|
|
134
|
+
label: {
|
|
135
|
+
fontSize: 14,
|
|
136
|
+
lineHeight: 20,
|
|
137
|
+
fontWeight: "500" as const,
|
|
138
|
+
letterSpacing: 2,
|
|
139
|
+
textTransform: "uppercase" as const,
|
|
140
|
+
},
|
|
141
|
+
labelSmall: {
|
|
142
|
+
fontSize: 12,
|
|
143
|
+
lineHeight: 16,
|
|
144
|
+
fontWeight: "500" as const,
|
|
145
|
+
letterSpacing: 1,
|
|
146
|
+
textTransform: "uppercase" as const,
|
|
147
|
+
},
|
|
148
|
+
labelTitle: {
|
|
149
|
+
fontSize: 14,
|
|
150
|
+
lineHeight: 20,
|
|
151
|
+
fontWeight: "700" as const,
|
|
152
|
+
letterSpacing: 2,
|
|
153
|
+
textTransform: "uppercase" as const,
|
|
154
|
+
},
|
|
87
155
|
link: {
|
|
88
156
|
fontSize: 16,
|
|
89
157
|
lineHeight: 24,
|
|
90
158
|
fontWeight: "400" as const,
|
|
91
159
|
},
|
|
160
|
+
stat: {
|
|
161
|
+
fontSize: 30,
|
|
162
|
+
lineHeight: 36,
|
|
163
|
+
fontWeight: "300" as const,
|
|
164
|
+
},
|
|
165
|
+
tiny: {
|
|
166
|
+
fontSize: 10,
|
|
167
|
+
lineHeight: 14,
|
|
168
|
+
fontWeight: "400" as const,
|
|
169
|
+
},
|
|
170
|
+
navLabel: {
|
|
171
|
+
fontSize: 10,
|
|
172
|
+
lineHeight: 14,
|
|
173
|
+
fontWeight: "500" as const,
|
|
174
|
+
},
|
|
92
175
|
};
|
|
93
176
|
|
|
94
|
-
export
|
|
95
|
-
ios: {
|
|
96
|
-
/** iOS `UIFontDescriptorSystemDesignDefault` */
|
|
97
|
-
sans: "system-ui",
|
|
98
|
-
/** iOS `UIFontDescriptorSystemDesignSerif` */
|
|
99
|
-
serif: "ui-serif",
|
|
100
|
-
/** iOS `UIFontDescriptorSystemDesignRounded` */
|
|
101
|
-
rounded: "ui-rounded",
|
|
102
|
-
/** iOS `UIFontDescriptorSystemDesignMonospaced` */
|
|
103
|
-
mono: "ui-monospace",
|
|
104
|
-
},
|
|
105
|
-
default: {
|
|
106
|
-
sans: "normal",
|
|
107
|
-
serif: "serif",
|
|
108
|
-
rounded: "normal",
|
|
109
|
-
mono: "monospace",
|
|
110
|
-
},
|
|
111
|
-
web: {
|
|
112
|
-
sans: "system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",
|
|
113
|
-
serif: "Georgia, 'Times New Roman', serif",
|
|
114
|
-
rounded:
|
|
115
|
-
"'SF Pro Rounded', 'Hiragino Maru Gothic ProN', Meiryo, 'MS PGothic', sans-serif",
|
|
116
|
-
mono: "SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace",
|
|
117
|
-
},
|
|
118
|
-
});
|
|
177
|
+
export type Theme = typeof Colors.light;
|
|
@@ -4,19 +4,15 @@
|
|
|
4
4
|
*
|
|
5
5
|
* 基于固定的 API 接口实现,可复用到其他项目
|
|
6
6
|
* 其他项目使用时,只需修改 @api 的导入路径指向项目的 api 模块
|
|
7
|
+
*
|
|
8
|
+
* 注意:
|
|
9
|
+
* - 如果需要登录/鉴权场景,请扩展本文件,完善 login/logout、token 管理、用户信息获取与刷新等逻辑
|
|
10
|
+
* - 将示例中的占位实现替换为项目实际的接口调用与状态管理
|
|
7
11
|
*/
|
|
8
|
-
import React, {
|
|
9
|
-
createContext,
|
|
10
|
-
useContext,
|
|
11
|
-
useState,
|
|
12
|
-
useEffect,
|
|
13
|
-
ReactNode,
|
|
14
|
-
} from "react";
|
|
15
|
-
import AsyncStorage from "@react-native-async-storage/async-storage";
|
|
16
|
-
//import { UserOut, UsersService, AuthenticationService } from "@api";
|
|
12
|
+
import React, { createContext, useContext, ReactNode } from "react";
|
|
17
13
|
|
|
18
14
|
interface UserOut {
|
|
19
|
-
|
|
15
|
+
|
|
20
16
|
}
|
|
21
17
|
|
|
22
18
|
interface AuthContextType {
|
|
@@ -31,105 +27,16 @@ interface AuthContextType {
|
|
|
31
27
|
|
|
32
28
|
const AuthContext = createContext<AuthContextType | undefined>(undefined);
|
|
33
29
|
|
|
34
|
-
export const AuthProvider: React.FC<{ children: ReactNode }> = ({
|
|
35
|
-
children,
|
|
36
|
-
}) => {
|
|
37
|
-
const [user, setUser] = useState<UserOut | null>(null);
|
|
38
|
-
const [token, setToken] = useState<string | null>(null);
|
|
39
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
40
|
-
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
loadAuthData();
|
|
43
|
-
}, []);
|
|
44
|
-
|
|
45
|
-
const loadAuthData = async () => {
|
|
46
|
-
try {
|
|
47
|
-
const results = await AsyncStorage.multiGet(["access_token", "user_data"]);
|
|
48
|
-
const storedToken = results?.[0]?.[1] ?? null;
|
|
49
|
-
const storedUser = results?.[1]?.[1] ?? null;
|
|
50
|
-
|
|
51
|
-
if (!storedToken) {
|
|
52
|
-
setToken(null);
|
|
53
|
-
setUser(null);
|
|
54
|
-
await AsyncStorage.multiRemove(["access_token", "user_data"]);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (storedToken && storedUser) {
|
|
59
|
-
setToken(storedToken);
|
|
60
|
-
setUser(JSON.parse(storedUser));
|
|
61
|
-
} else if (storedToken && !storedUser) {
|
|
62
|
-
// 若仅有 token,主动拉取当前用户信息
|
|
63
|
-
setToken(storedToken);
|
|
64
|
-
try {
|
|
65
|
-
// const me = await UsersService.getCurrentUserApiV1UsersMeGet();
|
|
66
|
-
//if (me?.success && me.data) {
|
|
67
|
-
// setUser(me.data);
|
|
68
|
-
// await AsyncStorage.setItem("user_data", JSON.stringify(me.data));
|
|
69
|
-
//}
|
|
70
|
-
} catch (e) {
|
|
71
|
-
// 拉取失败则保持未登录状态
|
|
72
|
-
console.error("Failed to fetch current user with stored token:", e);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
} catch (error) {
|
|
76
|
-
console.error("Failed to load auth data:", error);
|
|
77
|
-
} finally {
|
|
78
|
-
setIsLoading(false);
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const login = async (newToken: string) => {
|
|
83
|
-
try {
|
|
84
|
-
setToken(newToken);
|
|
85
|
-
// 统一写入 access_token,供 OpenAPI 读取并自动携带
|
|
86
|
-
await AsyncStorage.setItem("access_token", newToken);
|
|
87
|
-
// 登录后拉取当前用户并缓存
|
|
88
|
-
try {
|
|
89
|
-
const me = await UsersService.getCurrentUserApiV1UsersMeGet();
|
|
90
|
-
if (me?.success && me.data) {
|
|
91
|
-
setUser(me.data);
|
|
92
|
-
await AsyncStorage.setItem("user_data", JSON.stringify(me.data));
|
|
93
|
-
}
|
|
94
|
-
} catch (e) {
|
|
95
|
-
console.error("Fetch current user after login failed:", e);
|
|
96
|
-
}
|
|
97
|
-
} catch (error) {
|
|
98
|
-
console.error("Login failed:", error);
|
|
99
|
-
throw error;
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
const logout = async () => {
|
|
104
|
-
try {
|
|
105
|
-
// await AuthenticationService.logoutApiV1AuthLogoutPost(true);
|
|
106
|
-
} catch(error) {
|
|
107
|
-
console.warn('Logout failed:', error);
|
|
108
|
-
}
|
|
109
|
-
// remove token
|
|
110
|
-
setToken(null);
|
|
111
|
-
setUser(null);
|
|
112
|
-
await AsyncStorage.multiRemove(["auth_token", "access_token", "user_data"]);
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const updateUser = (userData: Partial<UserOut>) => {
|
|
116
|
-
if (user) {
|
|
117
|
-
const updatedUser = { ...user, ...userData };
|
|
118
|
-
setUser(updatedUser);
|
|
119
|
-
AsyncStorage.setItem("user_data", JSON.stringify(updatedUser));
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
|
|
30
|
+
export const AuthProvider: React.FC<{ children: ReactNode }> = ({ children }) => {
|
|
123
31
|
const value: AuthContextType = {
|
|
124
|
-
user,
|
|
125
|
-
token,
|
|
126
|
-
isAuthenticated:
|
|
127
|
-
isLoading,
|
|
128
|
-
login,
|
|
129
|
-
logout,
|
|
130
|
-
updateUser,
|
|
32
|
+
user: null,
|
|
33
|
+
token: null,
|
|
34
|
+
isAuthenticated: false,
|
|
35
|
+
isLoading: false,
|
|
36
|
+
login: async (token: string) => {},
|
|
37
|
+
logout: async () => {},
|
|
38
|
+
updateUser: () => {},
|
|
131
39
|
};
|
|
132
|
-
|
|
133
40
|
return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
|
|
134
41
|
};
|
|
135
42
|
|