@coze-arch/cli 0.0.1-alpha.f74941 → 0.0.1-alpha.f9be02

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.
Files changed (167) hide show
  1. package/lib/__templates__/expo/.coze +7 -2
  2. package/lib/__templates__/expo/.cozeproj/scripts/{deploy_build.sh → dev_build.sh} +25 -25
  3. package/lib/__templates__/expo/.cozeproj/scripts/{deploy_run.sh → dev_run.sh} +45 -63
  4. package/lib/__templates__/expo/.cozeproj/scripts/prod_build.sh +47 -0
  5. package/lib/__templates__/expo/.cozeproj/scripts/prod_run.sh +34 -0
  6. package/lib/__templates__/expo/_gitignore +1 -1
  7. package/lib/__templates__/expo/_npmrc +3 -5
  8. package/lib/__templates__/expo/client/app.config.ts +71 -0
  9. package/lib/__templates__/expo/client/metro.config.js +121 -0
  10. package/lib/__templates__/expo/client/package.json +92 -0
  11. package/lib/__templates__/expo/client/scripts/install-missing-deps.js +36 -12
  12. package/lib/__templates__/expo/client/src/app/index.ts +1 -0
  13. package/lib/__templates__/expo/client/src/components/ThemedText.tsx +33 -0
  14. package/lib/__templates__/expo/client/src/components/ThemedView.tsx +38 -0
  15. package/lib/__templates__/expo/client/src/constants/theme.ts +850 -0
  16. package/lib/__templates__/expo/client/src/contexts/AuthContext.tsx +49 -0
  17. package/lib/__templates__/expo/client/{hooks → src/hooks}/useTheme.ts +1 -1
  18. package/lib/__templates__/expo/client/{screens → src/screens}/home/index.tsx +1 -5
  19. package/lib/__templates__/expo/client/src/screens/home/styles.ts +60 -0
  20. package/lib/__templates__/expo/client/{utils → src/utils}/index.ts +1 -2
  21. package/lib/__templates__/expo/client/tsconfig.json +24 -0
  22. package/lib/__templates__/expo/package.json +29 -14
  23. package/lib/__templates__/expo/pnpm-lock.yaml +549 -351
  24. package/lib/__templates__/expo/pnpm-workspace.yaml +3 -0
  25. package/lib/__templates__/expo/server/package.json +17 -0
  26. package/lib/__templates__/expo/{src → server/src}/index.ts +2 -2
  27. package/lib/__templates__/expo/template.config.js +1 -1
  28. package/lib/__templates__/expo/tsconfig.json +1 -24
  29. package/lib/__templates__/nextjs/.coze +3 -3
  30. package/lib/__templates__/nextjs/README.md +341 -19
  31. package/lib/__templates__/nextjs/_npmrc +1 -1
  32. package/lib/__templates__/nextjs/components.json +21 -0
  33. package/lib/__templates__/nextjs/package.json +54 -1
  34. package/lib/__templates__/nextjs/pnpm-lock.yaml +7947 -1523
  35. package/lib/__templates__/nextjs/scripts/dev.sh +9 -27
  36. package/lib/__templates__/nextjs/src/app/globals.css +114 -11
  37. package/lib/__templates__/nextjs/src/app/layout.tsx +18 -18
  38. package/lib/__templates__/nextjs/src/components/ui/accordion.tsx +66 -0
  39. package/lib/__templates__/nextjs/src/components/ui/alert-dialog.tsx +157 -0
  40. package/lib/__templates__/nextjs/src/components/ui/alert.tsx +66 -0
  41. package/lib/__templates__/nextjs/src/components/ui/aspect-ratio.tsx +11 -0
  42. package/lib/__templates__/nextjs/src/components/ui/avatar.tsx +53 -0
  43. package/lib/__templates__/nextjs/src/components/ui/badge.tsx +46 -0
  44. package/lib/__templates__/nextjs/src/components/ui/breadcrumb.tsx +109 -0
  45. package/lib/__templates__/nextjs/src/components/ui/button-group.tsx +83 -0
  46. package/lib/__templates__/nextjs/src/components/ui/button.tsx +62 -0
  47. package/lib/__templates__/nextjs/src/components/ui/calendar.tsx +220 -0
  48. package/lib/__templates__/nextjs/src/components/ui/card.tsx +92 -0
  49. package/lib/__templates__/nextjs/src/components/ui/carousel.tsx +241 -0
  50. package/lib/__templates__/nextjs/src/components/ui/chart.tsx +357 -0
  51. package/lib/__templates__/nextjs/src/components/ui/checkbox.tsx +32 -0
  52. package/lib/__templates__/nextjs/src/components/ui/collapsible.tsx +33 -0
  53. package/lib/__templates__/nextjs/src/components/ui/command.tsx +184 -0
  54. package/lib/__templates__/nextjs/src/components/ui/context-menu.tsx +252 -0
  55. package/lib/__templates__/nextjs/src/components/ui/dialog.tsx +143 -0
  56. package/lib/__templates__/nextjs/src/components/ui/drawer.tsx +135 -0
  57. package/lib/__templates__/nextjs/src/components/ui/dropdown-menu.tsx +257 -0
  58. package/lib/__templates__/nextjs/src/components/ui/empty.tsx +104 -0
  59. package/lib/__templates__/nextjs/src/components/ui/field.tsx +248 -0
  60. package/lib/__templates__/nextjs/src/components/ui/form.tsx +167 -0
  61. package/lib/__templates__/nextjs/src/components/ui/hover-card.tsx +44 -0
  62. package/lib/__templates__/nextjs/src/components/ui/input-group.tsx +170 -0
  63. package/lib/__templates__/nextjs/src/components/ui/input-otp.tsx +77 -0
  64. package/lib/__templates__/nextjs/src/components/ui/input.tsx +21 -0
  65. package/lib/__templates__/nextjs/src/components/ui/item.tsx +193 -0
  66. package/lib/__templates__/nextjs/src/components/ui/kbd.tsx +28 -0
  67. package/lib/__templates__/nextjs/src/components/ui/label.tsx +24 -0
  68. package/lib/__templates__/nextjs/src/components/ui/menubar.tsx +276 -0
  69. package/lib/__templates__/nextjs/src/components/ui/navigation-menu.tsx +168 -0
  70. package/lib/__templates__/nextjs/src/components/ui/pagination.tsx +127 -0
  71. package/lib/__templates__/nextjs/src/components/ui/popover.tsx +48 -0
  72. package/lib/__templates__/nextjs/src/components/ui/progress.tsx +31 -0
  73. package/lib/__templates__/nextjs/src/components/ui/radio-group.tsx +45 -0
  74. package/lib/__templates__/nextjs/src/components/ui/resizable.tsx +56 -0
  75. package/lib/__templates__/nextjs/src/components/ui/scroll-area.tsx +58 -0
  76. package/lib/__templates__/nextjs/src/components/ui/select.tsx +190 -0
  77. package/lib/__templates__/nextjs/src/components/ui/separator.tsx +28 -0
  78. package/lib/__templates__/nextjs/src/components/ui/sheet.tsx +139 -0
  79. package/lib/__templates__/nextjs/src/components/ui/sidebar.tsx +726 -0
  80. package/lib/__templates__/nextjs/src/components/ui/skeleton.tsx +13 -0
  81. package/lib/__templates__/nextjs/src/components/ui/slider.tsx +63 -0
  82. package/lib/__templates__/nextjs/src/components/ui/sonner.tsx +40 -0
  83. package/lib/__templates__/nextjs/src/components/ui/spinner.tsx +16 -0
  84. package/lib/__templates__/nextjs/src/components/ui/switch.tsx +31 -0
  85. package/lib/__templates__/nextjs/src/components/ui/table.tsx +116 -0
  86. package/lib/__templates__/nextjs/src/components/ui/tabs.tsx +66 -0
  87. package/lib/__templates__/nextjs/src/components/ui/textarea.tsx +18 -0
  88. package/lib/__templates__/nextjs/src/components/ui/toggle-group.tsx +83 -0
  89. package/lib/__templates__/nextjs/src/components/ui/toggle.tsx +47 -0
  90. package/lib/__templates__/nextjs/src/components/ui/tooltip.tsx +61 -0
  91. package/lib/__templates__/nextjs/src/hooks/use-mobile.ts +19 -0
  92. package/lib/__templates__/nextjs/src/lib/utils.ts +6 -0
  93. package/lib/__templates__/nextjs/template.config.js +2 -2
  94. package/lib/__templates__/templates.json +6 -37
  95. package/lib/__templates__/vite/.coze +3 -3
  96. package/lib/__templates__/vite/README.md +204 -26
  97. package/lib/__templates__/vite/_npmrc +1 -1
  98. package/lib/__templates__/vite/package.json +1 -1
  99. package/lib/__templates__/vite/pnpm-lock.yaml +120 -120
  100. package/lib/__templates__/vite/scripts/dev.sh +7 -26
  101. package/lib/__templates__/vite/template.config.js +11 -2
  102. package/lib/__templates__/vite/vite.config.ts +3 -3
  103. package/lib/cli.js +426 -249
  104. package/package.json +9 -4
  105. package/lib/__templates__/expo/app.json +0 -63
  106. package/lib/__templates__/expo/babel.config.js +0 -9
  107. package/lib/__templates__/expo/client/app/(tabs)/_layout.tsx +0 -43
  108. package/lib/__templates__/expo/client/app/(tabs)/home.tsx +0 -1
  109. package/lib/__templates__/expo/client/app/(tabs)/index.tsx +0 -7
  110. package/lib/__templates__/expo/client/app/+not-found.tsx +0 -79
  111. package/lib/__templates__/expo/client/constants/theme.ts +0 -118
  112. package/lib/__templates__/expo/client/contexts/AuthContext.tsx +0 -142
  113. package/lib/__templates__/expo/client/index.js +0 -11
  114. package/lib/__templates__/expo/client/screens/home/styles.ts +0 -332
  115. package/lib/__templates__/expo/metro.config.js +0 -53
  116. package/lib/__templates__/react-rsbuild/.coze +0 -11
  117. package/lib/__templates__/react-rsbuild/.vscode/settings.json +0 -121
  118. package/lib/__templates__/react-rsbuild/README.md +0 -61
  119. package/lib/__templates__/react-rsbuild/_gitignore +0 -97
  120. package/lib/__templates__/react-rsbuild/_npmrc +0 -22
  121. package/lib/__templates__/react-rsbuild/package.json +0 -31
  122. package/lib/__templates__/react-rsbuild/pnpm-lock.yaml +0 -997
  123. package/lib/__templates__/react-rsbuild/rsbuild.config.ts +0 -13
  124. package/lib/__templates__/react-rsbuild/scripts/build.sh +0 -14
  125. package/lib/__templates__/react-rsbuild/scripts/dev.sh +0 -51
  126. package/lib/__templates__/react-rsbuild/scripts/start.sh +0 -15
  127. package/lib/__templates__/react-rsbuild/src/App.tsx +0 -60
  128. package/lib/__templates__/react-rsbuild/src/index.css +0 -21
  129. package/lib/__templates__/react-rsbuild/src/index.html +0 -12
  130. package/lib/__templates__/react-rsbuild/src/index.tsx +0 -16
  131. package/lib/__templates__/react-rsbuild/tailwind.config.js +0 -9
  132. package/lib/__templates__/react-rsbuild/template.config.js +0 -54
  133. package/lib/__templates__/react-rsbuild/tsconfig.json +0 -17
  134. package/lib/__templates__/rsbuild/.coze +0 -11
  135. package/lib/__templates__/rsbuild/.vscode/settings.json +0 -7
  136. package/lib/__templates__/rsbuild/README.md +0 -61
  137. package/lib/__templates__/rsbuild/_gitignore +0 -97
  138. package/lib/__templates__/rsbuild/_npmrc +0 -22
  139. package/lib/__templates__/rsbuild/package.json +0 -24
  140. package/lib/__templates__/rsbuild/pnpm-lock.yaml +0 -888
  141. package/lib/__templates__/rsbuild/rsbuild.config.ts +0 -12
  142. package/lib/__templates__/rsbuild/scripts/build.sh +0 -14
  143. package/lib/__templates__/rsbuild/scripts/dev.sh +0 -51
  144. package/lib/__templates__/rsbuild/scripts/start.sh +0 -15
  145. package/lib/__templates__/rsbuild/src/index.css +0 -21
  146. package/lib/__templates__/rsbuild/src/index.html +0 -12
  147. package/lib/__templates__/rsbuild/src/index.ts +0 -5
  148. package/lib/__templates__/rsbuild/src/main.ts +0 -65
  149. package/lib/__templates__/rsbuild/tailwind.config.js +0 -9
  150. package/lib/__templates__/rsbuild/template.config.js +0 -56
  151. package/lib/__templates__/rsbuild/tsconfig.json +0 -16
  152. /package/lib/__templates__/expo/{eslint-formatter-simple.mjs → client/eslint-formatter-simple.mjs} +0 -0
  153. /package/lib/__templates__/expo/{eslint.config.mjs → client/eslint.config.mjs} +0 -0
  154. /package/lib/__templates__/expo/client/{app → src/app}/_layout.tsx +0 -0
  155. /package/lib/__templates__/expo/client/{assets → src/assets}/fonts/SpaceMono-Regular.ttf +0 -0
  156. /package/lib/__templates__/expo/client/{assets → src/assets}/images/adaptive-icon.png +0 -0
  157. /package/lib/__templates__/expo/client/{assets → src/assets}/images/default-avatar.png +0 -0
  158. /package/lib/__templates__/expo/client/{assets → src/assets}/images/favicon.png +0 -0
  159. /package/lib/__templates__/expo/client/{assets → src/assets}/images/icon.png +0 -0
  160. /package/lib/__templates__/expo/client/{assets → src/assets}/images/partial-react-logo.png +0 -0
  161. /package/lib/__templates__/expo/client/{assets → src/assets}/images/react-logo.png +0 -0
  162. /package/lib/__templates__/expo/client/{assets → src/assets}/images/react-logo@2x.png +0 -0
  163. /package/lib/__templates__/expo/client/{assets → src/assets}/images/react-logo@3x.png +0 -0
  164. /package/lib/__templates__/expo/client/{assets → src/assets}/images/splash-icon.png +0 -0
  165. /package/lib/__templates__/expo/client/{components → src/components}/Screen.tsx +0 -0
  166. /package/lib/__templates__/expo/client/{components → src/components}/SmartDateInput.tsx +0 -0
  167. /package/lib/__templates__/expo/client/{hooks → src/hooks}/useColorScheme.ts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coze-arch/cli",
3
- "version": "0.0.1-alpha.f74941",
3
+ "version": "0.0.1-alpha.f9be02",
4
4
  "private": false,
5
5
  "description": "coze coding devtools cli",
6
6
  "license": "MIT",
@@ -19,24 +19,27 @@
19
19
  "scripts": {
20
20
  "prebuild": "tsx scripts/prebuild.ts",
21
21
  "build": "tsx scripts/build.ts",
22
- "generate-templates": "tsx scripts/generate-templates-config.ts",
22
+ "create": "tsx scripts/create-template.ts",
23
23
  "lint": "eslint ./ --cache",
24
+ "postpublish": "bash scripts/sync-npmmirror.sh",
24
25
  "test": "vitest --run --passWithNoTests",
25
26
  "test:all": "bash scripts/test-coverage.sh",
26
27
  "test:cov": "vitest --run --passWithNoTests --coverage",
27
- "test:e2e": "vitest run --config vitest.e2e.config.ts",
28
+ "test:e2e": "bash scripts/e2e.sh",
28
29
  "test:perf": "vitest bench --run --config vitest.perf.config.ts",
29
30
  "test:perf:compare": "bash scripts/compare-perf.sh",
30
31
  "test:perf:save": "bash scripts/run-perf-with-output.sh"
31
32
  },
32
33
  "dependencies": {
33
34
  "@iarna/toml": "^2.2.5",
35
+ "@inquirer/prompts": "^3.2.0",
34
36
  "ajv": "^8.17.1",
35
37
  "ajv-formats": "^3.0.1",
36
38
  "change-case": "^5.4.4",
37
39
  "commander": "~12.1.0",
38
40
  "ejs": "^3.1.10",
39
41
  "js-yaml": "^4.1.0",
42
+ "minimist": "^1.2.5",
40
43
  "shelljs": "^0.10.0"
41
44
  },
42
45
  "devDependencies": {
@@ -50,6 +53,7 @@
50
53
  "@types/ejs": "^3.1.5",
51
54
  "@types/iarna__toml": "^2.0.5",
52
55
  "@types/js-yaml": "^4.0.9",
56
+ "@types/minimist": "^1.2.5",
53
57
  "@types/node": "^24",
54
58
  "@types/shelljs": "^0.10.0",
55
59
  "@vitest/coverage-v8": "~4.0.16",
@@ -60,7 +64,8 @@
60
64
  "vitest": "~4.0.16"
61
65
  },
62
66
  "publishConfig": {
63
- "access": "public"
67
+ "access": "public",
68
+ "registry": "https://registry.npmjs.org"
64
69
  },
65
70
  "cozePublishConfig": {
66
71
  "bin": {
@@ -1,63 +0,0 @@
1
- {
2
- "expo": {
3
- "name": "${app_name}",
4
- "slug": "${slug}",
5
- "version": "1.0.0",
6
- "orientation": "portrait",
7
- "icon": "./client/assets/images/icon.png",
8
- "scheme": "myapp",
9
- "userInterfaceStyle": "automatic",
10
- "newArchEnabled": true,
11
- "ios": {
12
- "supportsTablet": true
13
- },
14
- "android": {
15
- "adaptiveIcon": {
16
- "foregroundImage": "./client/assets/images/adaptive-icon.png",
17
- "backgroundColor": "#ffffff"
18
- }
19
- },
20
- "web": {
21
- "bundler": "metro",
22
- "output": "static",
23
- "favicon": "./client/assets/images/favicon.png"
24
- },
25
- "plugins": [
26
- "expo-router",
27
- [
28
- "expo-splash-screen",
29
- {
30
- "image": "./client/assets/images/splash-icon.png",
31
- "imageWidth": 200,
32
- "resizeMode": "contain",
33
- "backgroundColor": "#ffffff"
34
- }
35
- ],
36
- [
37
- "expo-image-picker",
38
- {
39
- "photosPermission": "允许${app_name}访问您的相册,以便您上传或保存图片。",
40
- "cameraPermission": "允许${app_name}使用您的相机,以便您直接拍摄照片上传。",
41
- "microphonePermission": "允许${app_name}访问您的麦克风,以便您拍摄带有声音的视频。"
42
- }
43
- ],
44
- [
45
- "expo-location",
46
- {
47
- "locationWhenInUsePermission": "${app_name}需要访问您的位置以提供周边服务及导航功能。"
48
- }
49
- ],
50
- [
51
- "expo-camera",
52
- {
53
- "cameraPermission": "${app_name}需要访问相机以拍摄照片和视频。",
54
- "microphonePermission": "${app_name}需要访问麦克风以录制视频声音。",
55
- "recordAudioAndroid": true
56
- }
57
- ]
58
- ],
59
- "experiments": {
60
- "typedRoutes": true
61
- }
62
- }
63
- }
@@ -1,9 +0,0 @@
1
- module.exports = function (api) {
2
- api.cache(true);
3
- return {
4
- presets: ["babel-preset-expo"],
5
- plugins: [
6
- "react-native-reanimated/plugin",
7
- ],
8
- };
9
- };
@@ -1,43 +0,0 @@
1
- import { Tabs } from 'expo-router';
2
- import { FontAwesome6 } from '@expo/vector-icons';
3
- import { useSafeAreaInsets } from 'react-native-safe-area-context';
4
- import { useTheme } from '@/hooks/useTheme';
5
-
6
- export default function TabLayout() {
7
- const insets = useSafeAreaInsets();
8
- const { theme } = useTheme();
9
- const tabBarHeight = 56 + Math.max(insets.bottom, 8);
10
-
11
- return (
12
- <Tabs
13
- backBehavior='history'
14
- screenOptions={{
15
- headerShown: false,
16
- tabBarActiveTintColor: theme.tabIconSelected,
17
- tabBarInactiveTintColor: theme.tabIconDefault,
18
- tabBarStyle: {
19
- backgroundColor: theme.backgroundRoot,
20
- borderTopColor: theme.backgroundSecondary,
21
- borderTopWidth: 1,
22
- height: tabBarHeight,
23
- paddingBottom: Math.max(insets.bottom, 8),
24
- paddingTop: 6,
25
- },
26
- }}
27
- >
28
- <Tabs.Screen
29
- name='index'
30
- options={{ href: null }}
31
- />
32
- <Tabs.Screen
33
- name='home'
34
- options={{
35
- title: '首页',
36
- tabBarIcon: ({ color }) => (
37
- <FontAwesome6 name='house' size={20} color={color} />
38
- ),
39
- }}
40
- />
41
- </Tabs>
42
- );
43
- }
@@ -1 +0,0 @@
1
- export { default } from "@/screens/home";
@@ -1,7 +0,0 @@
1
- import { Redirect } from 'expo-router';
2
-
3
- const Index = () => {
4
- return <Redirect href="./home" relativeToDirectory />;
5
- };
6
-
7
- export default Index;
@@ -1,79 +0,0 @@
1
- import { useRouter } from 'expo-router';
2
- import { StyleSheet, View, Text, Pressable, Platform } from 'react-native';
3
-
4
- export default function NotFoundScreen() {
5
- const router = useRouter();
6
-
7
- const goBack = () => {
8
- if (router.canGoBack()) {
9
- router.back();
10
- }
11
- };
12
-
13
- return (
14
- <View style={styles.container}>
15
- <Text style={styles.heading}>404</Text>
16
- <Text style={styles.textStyle}>页面未找到</Text>
17
- <Text style={styles.subTextStyle}>
18
- 抱歉!您访问的页面不存在,当前页面功能待完善。
19
- </Text>
20
- <Pressable onPress={goBack} style={styles.button}>
21
- <Text style={styles.buttonText}>返回上一页</Text>
22
- </Pressable>
23
- </View>
24
- );
25
- }
26
-
27
- const styles = StyleSheet.create({
28
- container: {
29
- flex: 1,
30
- alignItems: 'center',
31
- justifyContent: 'center',
32
- backgroundColor: '#f3f5ff',
33
- padding: 16,
34
- },
35
- heading: {
36
- fontSize: 120,
37
- fontWeight: '900',
38
- color: '#4a5568',
39
- textShadowColor: 'rgba(0, 0, 0, 0.05)',
40
- textShadowOffset: { width: 0, height: 4 },
41
- textShadowRadius: 8,
42
- },
43
- textStyle: {
44
- fontSize: 24,
45
- fontWeight: '500',
46
- marginTop: -16,
47
- marginBottom: 16,
48
- color: '#4a5568',
49
- },
50
- subTextStyle: {
51
- fontSize: 16,
52
- color: '#718096',
53
- marginBottom: 32,
54
- maxWidth: 400,
55
- textAlign: 'center',
56
- },
57
- button: {
58
- paddingVertical: 12,
59
- paddingHorizontal: 24,
60
- backgroundColor: '#6366f1',
61
- borderRadius: 9999,
62
- ...Platform.select({
63
- ios: {
64
- shadowColor: 'rgba(0, 0, 0, 0.1)',
65
- shadowOffset: { width: 0, height: 10 },
66
- shadowOpacity: 1,
67
- shadowRadius: 15,
68
- },
69
- android: {
70
- elevation: 5,
71
- },
72
- }),
73
- },
74
- buttonText: {
75
- fontSize: 16,
76
- fontWeight: '600',
77
- color: '#ffffff',
78
- },
79
- });
@@ -1,118 +0,0 @@
1
- import { Platform } from "react-native";
2
-
3
- const tintColorLight = "#007AFF";
4
- const tintColorDark = "#0A84FF";
5
-
6
- export const Colors = {
7
- light: {
8
- text: "#11181C",
9
- buttonText: "#FFFFFF",
10
- tabIconDefault: "#687076",
11
- tabIconSelected: tintColorLight,
12
- link: "#007AFF",
13
- backgroundRoot: "#FFFFFF", // Elevation 0
14
- backgroundDefault: "#F2F2F2", // Elevation 1
15
- backgroundSecondary: "#E6E6E6", // Elevation 2
16
- backgroundTertiary: "#D9D9D9", // Elevation 3
17
- },
18
- dark: {
19
- text: "#ECEDEE",
20
- buttonText: "#FFFFFF",
21
- tabIconDefault: "#9BA1A6",
22
- tabIconSelected: tintColorDark,
23
- link: "#0A84FF",
24
- backgroundRoot: "#1F2123", // Elevation 0
25
- backgroundDefault: "#2A2C2E", // Elevation 1
26
- backgroundSecondary: "#353739", // Elevation 2
27
- backgroundTertiary: "#404244", // Elevation 3
28
- },
29
- };
30
-
31
- export const Spacing = {
32
- xs: 4,
33
- sm: 8,
34
- md: 12,
35
- lg: 16,
36
- xl: 20,
37
- "2xl": 24,
38
- "3xl": 32,
39
- "4xl": 40,
40
- "5xl": 48,
41
- inputHeight: 48,
42
- buttonHeight: 52,
43
- };
44
-
45
- export const BorderRadius = {
46
- xs: 8,
47
- sm: 12,
48
- md: 18,
49
- lg: 24,
50
- xl: 30,
51
- "2xl": 40,
52
- "3xl": 50,
53
- full: 9999,
54
- };
55
-
56
- export const Typography = {
57
- h1: {
58
- fontSize: 32,
59
- lineHeight: 40,
60
- fontWeight: "700" as const,
61
- },
62
- h2: {
63
- fontSize: 28,
64
- lineHeight: 36,
65
- fontWeight: "700" as const,
66
- },
67
- h3: {
68
- fontSize: 24,
69
- lineHeight: 32,
70
- fontWeight: "600" as const,
71
- },
72
- h4: {
73
- fontSize: 20,
74
- lineHeight: 28,
75
- fontWeight: "600" as const,
76
- },
77
- body: {
78
- fontSize: 16,
79
- lineHeight: 24,
80
- fontWeight: "400" as const,
81
- },
82
- small: {
83
- fontSize: 14,
84
- lineHeight: 20,
85
- fontWeight: "400" as const,
86
- },
87
- link: {
88
- fontSize: 16,
89
- lineHeight: 24,
90
- fontWeight: "400" as const,
91
- },
92
- };
93
-
94
- export const Fonts = Platform.select({
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
- });
@@ -1,142 +0,0 @@
1
- // @ts-nocheck
2
- /**
3
- * 通用认证上下文
4
- *
5
- * 基于固定的 API 接口实现,可复用到其他项目
6
- * 其他项目使用时,只需修改 @api 的导入路径指向项目的 api 模块
7
- */
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";
17
-
18
- interface UserOut {
19
-
20
- }
21
-
22
- interface AuthContextType {
23
- user: UserOut | null;
24
- token: string | null;
25
- isAuthenticated: boolean;
26
- isLoading: boolean;
27
- login: (token: string) => Promise<void>;
28
- logout: () => Promise<void>;
29
- updateUser: (userData: Partial<UserOut>) => void;
30
- }
31
-
32
- const AuthContext = createContext<AuthContextType | undefined>(undefined);
33
-
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
-
123
- const value: AuthContextType = {
124
- user,
125
- token,
126
- isAuthenticated: !!token && !!user,
127
- isLoading,
128
- login,
129
- logout,
130
- updateUser,
131
- };
132
-
133
- return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
134
- };
135
-
136
- export const useAuth = (): AuthContextType => {
137
- const context = useContext(AuthContext);
138
- if (context === undefined) {
139
- throw new Error("useAuth must be used within an AuthProvider");
140
- }
141
- return context;
142
- };
@@ -1,11 +0,0 @@
1
- import { registerRootComponent } from 'expo';
2
- import { ExpoRoot } from 'expo-router';
3
-
4
- // 显式定义 App 组件
5
- export function App() {
6
- // eslint-disable-next-line no-undef
7
- const ctx = require.context('./app');
8
- return <ExpoRoot context={ctx} />;
9
- }
10
-
11
- registerRootComponent(App);