@coze-arch/cli 0.0.1-alpha.77c1b0 → 0.0.1-alpha.8e1417

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 (163) 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 +35 -0
  6. package/lib/__templates__/expo/_gitignore +1 -1
  7. package/lib/__templates__/expo/_npmrc +3 -5
  8. package/lib/__templates__/expo/{app.json → client/app.json} +4 -4
  9. package/lib/__templates__/expo/client/metro.config.js +51 -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/{constants → src/constants}/theme.ts +10 -0
  14. package/lib/__templates__/expo/client/src/contexts/AuthContext.tsx +49 -0
  15. package/lib/__templates__/expo/client/{hooks → src/hooks}/useTheme.ts +1 -1
  16. package/lib/__templates__/expo/client/{screens → src/screens}/home/index.tsx +1 -5
  17. package/lib/__templates__/expo/client/src/screens/home/styles.ts +60 -0
  18. package/lib/__templates__/expo/client/{utils → src/utils}/index.ts +1 -2
  19. package/lib/__templates__/expo/client/tsconfig.json +24 -0
  20. package/lib/__templates__/expo/package.json +27 -13
  21. package/lib/__templates__/expo/pnpm-lock.yaml +426 -514
  22. package/lib/__templates__/expo/pnpm-workspace.yaml +3 -0
  23. package/lib/__templates__/expo/server/package.json +17 -0
  24. package/lib/__templates__/expo/{src → server/src}/index.ts +2 -2
  25. package/lib/__templates__/expo/template.config.js +1 -1
  26. package/lib/__templates__/expo/tsconfig.json +1 -24
  27. package/lib/__templates__/nextjs/.coze +3 -3
  28. package/lib/__templates__/nextjs/README.md +341 -19
  29. package/lib/__templates__/nextjs/_npmrc +1 -1
  30. package/lib/__templates__/nextjs/components.json +21 -0
  31. package/lib/__templates__/nextjs/package.json +54 -1
  32. package/lib/__templates__/nextjs/pnpm-lock.yaml +7947 -1523
  33. package/lib/__templates__/nextjs/scripts/dev.sh +9 -27
  34. package/lib/__templates__/nextjs/src/app/globals.css +114 -11
  35. package/lib/__templates__/nextjs/src/app/layout.tsx +18 -18
  36. package/lib/__templates__/nextjs/src/components/ui/accordion.tsx +66 -0
  37. package/lib/__templates__/nextjs/src/components/ui/alert-dialog.tsx +157 -0
  38. package/lib/__templates__/nextjs/src/components/ui/alert.tsx +66 -0
  39. package/lib/__templates__/nextjs/src/components/ui/aspect-ratio.tsx +11 -0
  40. package/lib/__templates__/nextjs/src/components/ui/avatar.tsx +53 -0
  41. package/lib/__templates__/nextjs/src/components/ui/badge.tsx +46 -0
  42. package/lib/__templates__/nextjs/src/components/ui/breadcrumb.tsx +109 -0
  43. package/lib/__templates__/nextjs/src/components/ui/button-group.tsx +83 -0
  44. package/lib/__templates__/nextjs/src/components/ui/button.tsx +62 -0
  45. package/lib/__templates__/nextjs/src/components/ui/calendar.tsx +220 -0
  46. package/lib/__templates__/nextjs/src/components/ui/card.tsx +92 -0
  47. package/lib/__templates__/nextjs/src/components/ui/carousel.tsx +241 -0
  48. package/lib/__templates__/nextjs/src/components/ui/chart.tsx +357 -0
  49. package/lib/__templates__/nextjs/src/components/ui/checkbox.tsx +32 -0
  50. package/lib/__templates__/nextjs/src/components/ui/collapsible.tsx +33 -0
  51. package/lib/__templates__/nextjs/src/components/ui/command.tsx +184 -0
  52. package/lib/__templates__/nextjs/src/components/ui/context-menu.tsx +252 -0
  53. package/lib/__templates__/nextjs/src/components/ui/dialog.tsx +143 -0
  54. package/lib/__templates__/nextjs/src/components/ui/drawer.tsx +135 -0
  55. package/lib/__templates__/nextjs/src/components/ui/dropdown-menu.tsx +257 -0
  56. package/lib/__templates__/nextjs/src/components/ui/empty.tsx +104 -0
  57. package/lib/__templates__/nextjs/src/components/ui/field.tsx +248 -0
  58. package/lib/__templates__/nextjs/src/components/ui/form.tsx +167 -0
  59. package/lib/__templates__/nextjs/src/components/ui/hover-card.tsx +44 -0
  60. package/lib/__templates__/nextjs/src/components/ui/input-group.tsx +170 -0
  61. package/lib/__templates__/nextjs/src/components/ui/input-otp.tsx +77 -0
  62. package/lib/__templates__/nextjs/src/components/ui/input.tsx +21 -0
  63. package/lib/__templates__/nextjs/src/components/ui/item.tsx +193 -0
  64. package/lib/__templates__/nextjs/src/components/ui/kbd.tsx +28 -0
  65. package/lib/__templates__/nextjs/src/components/ui/label.tsx +24 -0
  66. package/lib/__templates__/nextjs/src/components/ui/menubar.tsx +276 -0
  67. package/lib/__templates__/nextjs/src/components/ui/navigation-menu.tsx +168 -0
  68. package/lib/__templates__/nextjs/src/components/ui/pagination.tsx +127 -0
  69. package/lib/__templates__/nextjs/src/components/ui/popover.tsx +48 -0
  70. package/lib/__templates__/nextjs/src/components/ui/progress.tsx +31 -0
  71. package/lib/__templates__/nextjs/src/components/ui/radio-group.tsx +45 -0
  72. package/lib/__templates__/nextjs/src/components/ui/resizable.tsx +56 -0
  73. package/lib/__templates__/nextjs/src/components/ui/scroll-area.tsx +58 -0
  74. package/lib/__templates__/nextjs/src/components/ui/select.tsx +190 -0
  75. package/lib/__templates__/nextjs/src/components/ui/separator.tsx +28 -0
  76. package/lib/__templates__/nextjs/src/components/ui/sheet.tsx +139 -0
  77. package/lib/__templates__/nextjs/src/components/ui/sidebar.tsx +726 -0
  78. package/lib/__templates__/nextjs/src/components/ui/skeleton.tsx +13 -0
  79. package/lib/__templates__/nextjs/src/components/ui/slider.tsx +63 -0
  80. package/lib/__templates__/nextjs/src/components/ui/sonner.tsx +40 -0
  81. package/lib/__templates__/nextjs/src/components/ui/spinner.tsx +16 -0
  82. package/lib/__templates__/nextjs/src/components/ui/switch.tsx +31 -0
  83. package/lib/__templates__/nextjs/src/components/ui/table.tsx +116 -0
  84. package/lib/__templates__/nextjs/src/components/ui/tabs.tsx +66 -0
  85. package/lib/__templates__/nextjs/src/components/ui/textarea.tsx +18 -0
  86. package/lib/__templates__/nextjs/src/components/ui/toggle-group.tsx +83 -0
  87. package/lib/__templates__/nextjs/src/components/ui/toggle.tsx +47 -0
  88. package/lib/__templates__/nextjs/src/components/ui/tooltip.tsx +61 -0
  89. package/lib/__templates__/nextjs/src/hooks/use-mobile.ts +19 -0
  90. package/lib/__templates__/nextjs/src/lib/utils.ts +6 -0
  91. package/lib/__templates__/nextjs/template.config.js +2 -2
  92. package/lib/__templates__/templates.json +6 -37
  93. package/lib/__templates__/vite/.coze +3 -3
  94. package/lib/__templates__/vite/README.md +204 -26
  95. package/lib/__templates__/vite/_npmrc +1 -1
  96. package/lib/__templates__/vite/package.json +1 -1
  97. package/lib/__templates__/vite/pnpm-lock.yaml +120 -120
  98. package/lib/__templates__/vite/scripts/dev.sh +7 -26
  99. package/lib/__templates__/vite/template.config.js +11 -2
  100. package/lib/__templates__/vite/vite.config.ts +3 -3
  101. package/lib/cli.js +426 -249
  102. package/package.json +7 -4
  103. package/lib/__templates__/expo/babel.config.js +0 -9
  104. package/lib/__templates__/expo/client/app/(tabs)/_layout.tsx +0 -43
  105. package/lib/__templates__/expo/client/app/(tabs)/home.tsx +0 -1
  106. package/lib/__templates__/expo/client/app/(tabs)/index.tsx +0 -7
  107. package/lib/__templates__/expo/client/app/+not-found.tsx +0 -79
  108. package/lib/__templates__/expo/client/contexts/AuthContext.tsx +0 -142
  109. package/lib/__templates__/expo/client/index.js +0 -12
  110. package/lib/__templates__/expo/client/screens/home/styles.ts +0 -332
  111. package/lib/__templates__/expo/metro.config.js +0 -53
  112. package/lib/__templates__/react-rsbuild/.coze +0 -11
  113. package/lib/__templates__/react-rsbuild/.vscode/settings.json +0 -121
  114. package/lib/__templates__/react-rsbuild/README.md +0 -61
  115. package/lib/__templates__/react-rsbuild/_gitignore +0 -97
  116. package/lib/__templates__/react-rsbuild/_npmrc +0 -22
  117. package/lib/__templates__/react-rsbuild/package.json +0 -31
  118. package/lib/__templates__/react-rsbuild/pnpm-lock.yaml +0 -997
  119. package/lib/__templates__/react-rsbuild/rsbuild.config.ts +0 -13
  120. package/lib/__templates__/react-rsbuild/scripts/build.sh +0 -14
  121. package/lib/__templates__/react-rsbuild/scripts/dev.sh +0 -51
  122. package/lib/__templates__/react-rsbuild/scripts/start.sh +0 -15
  123. package/lib/__templates__/react-rsbuild/src/App.tsx +0 -60
  124. package/lib/__templates__/react-rsbuild/src/index.css +0 -21
  125. package/lib/__templates__/react-rsbuild/src/index.html +0 -12
  126. package/lib/__templates__/react-rsbuild/src/index.tsx +0 -16
  127. package/lib/__templates__/react-rsbuild/tailwind.config.js +0 -9
  128. package/lib/__templates__/react-rsbuild/template.config.js +0 -54
  129. package/lib/__templates__/react-rsbuild/tsconfig.json +0 -17
  130. package/lib/__templates__/rsbuild/.coze +0 -11
  131. package/lib/__templates__/rsbuild/.vscode/settings.json +0 -7
  132. package/lib/__templates__/rsbuild/README.md +0 -61
  133. package/lib/__templates__/rsbuild/_gitignore +0 -97
  134. package/lib/__templates__/rsbuild/_npmrc +0 -22
  135. package/lib/__templates__/rsbuild/package.json +0 -24
  136. package/lib/__templates__/rsbuild/pnpm-lock.yaml +0 -888
  137. package/lib/__templates__/rsbuild/rsbuild.config.ts +0 -12
  138. package/lib/__templates__/rsbuild/scripts/build.sh +0 -14
  139. package/lib/__templates__/rsbuild/scripts/dev.sh +0 -51
  140. package/lib/__templates__/rsbuild/scripts/start.sh +0 -15
  141. package/lib/__templates__/rsbuild/src/index.css +0 -21
  142. package/lib/__templates__/rsbuild/src/index.html +0 -12
  143. package/lib/__templates__/rsbuild/src/index.ts +0 -5
  144. package/lib/__templates__/rsbuild/src/main.ts +0 -65
  145. package/lib/__templates__/rsbuild/tailwind.config.js +0 -9
  146. package/lib/__templates__/rsbuild/template.config.js +0 -56
  147. package/lib/__templates__/rsbuild/tsconfig.json +0 -16
  148. /package/lib/__templates__/expo/{eslint-formatter-simple.mjs → client/eslint-formatter-simple.mjs} +0 -0
  149. /package/lib/__templates__/expo/{eslint.config.mjs → client/eslint.config.mjs} +0 -0
  150. /package/lib/__templates__/expo/client/{app → src/app}/_layout.tsx +0 -0
  151. /package/lib/__templates__/expo/client/{assets → src/assets}/fonts/SpaceMono-Regular.ttf +0 -0
  152. /package/lib/__templates__/expo/client/{assets → src/assets}/images/adaptive-icon.png +0 -0
  153. /package/lib/__templates__/expo/client/{assets → src/assets}/images/default-avatar.png +0 -0
  154. /package/lib/__templates__/expo/client/{assets → src/assets}/images/favicon.png +0 -0
  155. /package/lib/__templates__/expo/client/{assets → src/assets}/images/icon.png +0 -0
  156. /package/lib/__templates__/expo/client/{assets → src/assets}/images/partial-react-logo.png +0 -0
  157. /package/lib/__templates__/expo/client/{assets → src/assets}/images/react-logo.png +0 -0
  158. /package/lib/__templates__/expo/client/{assets → src/assets}/images/react-logo@2x.png +0 -0
  159. /package/lib/__templates__/expo/client/{assets → src/assets}/images/react-logo@3x.png +0 -0
  160. /package/lib/__templates__/expo/client/{assets → src/assets}/images/splash-icon.png +0 -0
  161. /package/lib/__templates__/expo/client/{components → src/components}/Screen.tsx +0 -0
  162. /package/lib/__templates__/expo/client/{components → src/components}/SmartDateInput.tsx +0 -0
  163. /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.77c1b0",
3
+ "version": "0.0.1-alpha.8e1417",
4
4
  "private": false,
5
5
  "description": "coze coding devtools cli",
6
6
  "license": "MIT",
@@ -19,12 +19,12 @@
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",
23
22
  "lint": "eslint ./ --cache",
23
+ "postpublish": "bash scripts/sync-npmmirror.sh",
24
24
  "test": "vitest --run --passWithNoTests",
25
25
  "test:all": "bash scripts/test-coverage.sh",
26
26
  "test:cov": "vitest --run --passWithNoTests --coverage",
27
- "test:e2e": "vitest run --config vitest.e2e.config.ts",
27
+ "test:e2e": "bash scripts/e2e.sh",
28
28
  "test:perf": "vitest bench --run --config vitest.perf.config.ts",
29
29
  "test:perf:compare": "bash scripts/compare-perf.sh",
30
30
  "test:perf:save": "bash scripts/run-perf-with-output.sh"
@@ -37,6 +37,7 @@
37
37
  "commander": "~12.1.0",
38
38
  "ejs": "^3.1.10",
39
39
  "js-yaml": "^4.1.0",
40
+ "minimist": "^1.2.5",
40
41
  "shelljs": "^0.10.0"
41
42
  },
42
43
  "devDependencies": {
@@ -50,6 +51,7 @@
50
51
  "@types/ejs": "^3.1.5",
51
52
  "@types/iarna__toml": "^2.0.5",
52
53
  "@types/js-yaml": "^4.0.9",
54
+ "@types/minimist": "^1.2.5",
53
55
  "@types/node": "^24",
54
56
  "@types/shelljs": "^0.10.0",
55
57
  "@vitest/coverage-v8": "~4.0.16",
@@ -60,7 +62,8 @@
60
62
  "vitest": "~4.0.16"
61
63
  },
62
64
  "publishConfig": {
63
- "access": "public"
65
+ "access": "public",
66
+ "registry": "https://registry.npmjs.org"
64
67
  },
65
68
  "cozePublishConfig": {
66
69
  "bin": {
@@ -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,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,12 +0,0 @@
1
- import '@expo/metro-runtime';
2
- import { registerRootComponent } from 'expo';
3
- import { ExpoRoot } from 'expo-router';
4
-
5
- // 显式定义 App 组件
6
- export function App() {
7
- // eslint-disable-next-line no-undef
8
- const ctx = require.context('./app');
9
- return <ExpoRoot context={ctx} />;
10
- }
11
-
12
- registerRootComponent(App);
@@ -1,332 +0,0 @@
1
- import { StyleSheet, Platform } from 'react-native';
2
-
3
- const styles = StyleSheet.create({
4
- loadingContainer: {
5
- flex: 1,
6
- justifyContent: 'center',
7
- alignItems: 'center',
8
- },
9
- loadingText: {
10
- marginTop: 12,
11
- fontSize: 14,
12
- color: '#64748B',
13
- },
14
- errorContainer: {
15
- flex: 1,
16
- justifyContent: 'center',
17
- alignItems: 'center',
18
- paddingHorizontal: 24,
19
- },
20
- errorText: {
21
- marginTop: 16,
22
- fontSize: 16,
23
- color: '#64748B',
24
- },
25
- retryButton: {
26
- marginTop: 20,
27
- paddingHorizontal: 24,
28
- paddingVertical: 12,
29
- backgroundColor: '#2563EB',
30
- borderRadius: 8,
31
- },
32
- retryButtonText: {
33
- color: '#FFFFFF',
34
- fontSize: 14,
35
- fontWeight: '600',
36
- },
37
- header: {
38
- flexDirection: 'row',
39
- justifyContent: 'space-between',
40
- alignItems: 'center',
41
- paddingHorizontal: 16,
42
- // paddingBottom: 16,
43
- backgroundColor: '#FFFFFF',
44
- // borderBottomWidth: 1,
45
- borderBottomColor: '#E2E8F0',
46
- },
47
- headerLeft: {
48
- flexDirection: 'row',
49
- alignItems: 'center',
50
- gap: 10,
51
- },
52
- logoContainer: {
53
- width: 32,
54
- height: 32,
55
- backgroundColor: '#2563EB',
56
- borderRadius: 8,
57
- justifyContent: 'center',
58
- alignItems: 'center',
59
- ...Platform.select({
60
- ios: {
61
- shadowColor: '#000',
62
- shadowOffset: { width: 0, height: 1 },
63
- shadowOpacity: 0.1,
64
- shadowRadius: 2,
65
- },
66
- android: {
67
- elevation: 2,
68
- },
69
- }),
70
- },
71
- logoText: {
72
- fontSize: 18,
73
- fontWeight: '700',
74
- color: '#1E293B',
75
- letterSpacing: -0.5,
76
- },
77
- userMenuContainer: {
78
- flexDirection: 'row',
79
- alignItems: 'center',
80
- gap: 10,
81
- paddingLeft: 16,
82
- borderLeftWidth: 1,
83
- borderLeftColor: '#E2E8F0',
84
- },
85
- userInfo: {
86
- alignItems: 'flex-end',
87
- },
88
- userName: {
89
- fontSize: 14,
90
- fontWeight: '500',
91
- color: '#1E293B',
92
- },
93
- userRole: {
94
- fontSize: 12,
95
- color: '#64748B',
96
- },
97
- avatar: {
98
- width: 36,
99
- height: 36,
100
- borderRadius: 18,
101
- borderWidth: 2,
102
- borderColor: '#FFFFFF',
103
- ...Platform.select({
104
- ios: {
105
- shadowColor: '#000',
106
- shadowOffset: { width: 0, height: 1 },
107
- shadowOpacity: 0.1,
108
- shadowRadius: 2,
109
- },
110
- android: {
111
- elevation: 2,
112
- },
113
- }),
114
- },
115
- avatarPlaceholder: {
116
- width: 36,
117
- height: 36,
118
- borderRadius: 18,
119
- justifyContent: 'center',
120
- alignItems: 'center',
121
- borderWidth: 2,
122
- borderColor: '#FFFFFF',
123
- backgroundColor: '#3B82F6',
124
- ...Platform.select({
125
- ios: {
126
- shadowColor: '#000',
127
- shadowOffset: { width: 0, height: 1 },
128
- shadowOpacity: 0.1,
129
- shadowRadius: 2,
130
- },
131
- android: {
132
- elevation: 2,
133
- },
134
- }),
135
- },
136
- avatarInitial: {
137
- fontSize: 14,
138
- fontWeight: '700',
139
- color: '#FFFFFF',
140
- },
141
- content: {
142
- paddingHorizontal: 16,
143
- paddingTop: 24,
144
- },
145
- welcomeSection: {
146
- marginBottom: 24,
147
- },
148
- welcomeTitle: {
149
- fontSize: 22,
150
- fontWeight: '700',
151
- color: '#1E293B',
152
- marginBottom: 4,
153
- },
154
- welcomeSubtitle: {
155
- fontSize: 14,
156
- color: '#64748B',
157
- },
158
- statsGrid: {
159
- flexDirection: 'row',
160
- gap: 12,
161
- marginBottom: 24,
162
- },
163
- statCard: {
164
- flex: 1,
165
- backgroundColor: '#FFFFFF',
166
- borderRadius: 12,
167
- padding: 16,
168
- ...Platform.select({
169
- ios: {
170
- shadowColor: '#000',
171
- shadowOffset: { width: 0, height: 1 },
172
- shadowOpacity: 0.05,
173
- shadowRadius: 3,
174
- },
175
- android: {
176
- elevation: 2,
177
- },
178
- }),
179
- },
180
- statCardHeader: {
181
- flexDirection: 'row',
182
- justifyContent: 'space-between',
183
- alignItems: 'flex-start',
184
- marginBottom: 12,
185
- },
186
- statIconContainer: {
187
- width: 40,
188
- height: 40,
189
- borderRadius: 10,
190
- justifyContent: 'center',
191
- alignItems: 'center',
192
- },
193
- statIconBlue: {
194
- backgroundColor: '#EFF6FF',
195
- },
196
- statIconRed: {
197
- backgroundColor: '#FEF2F2',
198
- },
199
- statIconGreen: {
200
- backgroundColor: '#ECFDF5',
201
- },
202
- attentionBadge: {
203
- backgroundColor: '#FEF2F2',
204
- paddingHorizontal: 6,
205
- paddingVertical: 2,
206
- borderRadius: 10,
207
- },
208
- attentionBadgeText: {
209
- fontSize: 10,
210
- fontWeight: '500',
211
- color: '#EF4444',
212
- },
213
- rateBadge: {
214
- backgroundColor: '#ECFDF5',
215
- paddingHorizontal: 6,
216
- paddingVertical: 2,
217
- borderRadius: 10,
218
- },
219
- rateBadgeText: {
220
- fontSize: 10,
221
- fontWeight: '500',
222
- color: '#10B981',
223
- },
224
- statValue: {
225
- fontSize: 28,
226
- fontWeight: '700',
227
- color: '#1E293B',
228
- marginBottom: 2,
229
- },
230
- statLabel: {
231
- fontSize: 13,
232
- color: '#64748B',
233
- },
234
- shortcutsSection: {
235
- gap: 12,
236
- marginBottom: 24,
237
- },
238
- shortcutCard: {
239
- flexDirection: 'row',
240
- justifyContent: 'space-between',
241
- alignItems: 'center',
242
- backgroundColor: '#FFFFFF',
243
- borderRadius: 12,
244
- padding: 16,
245
- ...Platform.select({
246
- ios: {
247
- shadowColor: '#000',
248
- shadowOffset: { width: 0, height: 1 },
249
- shadowOpacity: 0.05,
250
- shadowRadius: 3,
251
- },
252
- android: {
253
- elevation: 2,
254
- },
255
- }),
256
- },
257
- shortcutContent: {
258
- flex: 1,
259
- marginRight: 16,
260
- },
261
- shortcutTitle: {
262
- fontSize: 16,
263
- fontWeight: '600',
264
- color: '#1E293B',
265
- marginBottom: 6,
266
- },
267
- shortcutDescription: {
268
- fontSize: 13,
269
- color: '#64748B',
270
- marginBottom: 10,
271
- lineHeight: 18,
272
- },
273
- shortcutAction: {
274
- flexDirection: 'row',
275
- alignItems: 'center',
276
- gap: 6,
277
- },
278
- shortcutActionText: {
279
- fontSize: 13,
280
- fontWeight: '500',
281
- color: '#2563EB',
282
- },
283
- shortcutIconContainer: {
284
- width: 56,
285
- height: 56,
286
- borderRadius: 28,
287
- justifyContent: 'center',
288
- alignItems: 'center',
289
- },
290
- shortcutIconBlue: {
291
- backgroundColor: '#EFF6FF',
292
- },
293
- shortcutIconGreen: {
294
- backgroundColor: '#ECFDF5',
295
- },
296
- bannerContainer: {
297
- height: 160,
298
- borderRadius: 12,
299
- overflow: 'hidden',
300
- backgroundColor: '#1E3A8A',
301
- },
302
- bannerOverlay: {
303
- flex: 1,
304
- justifyContent: 'center',
305
- paddingHorizontal: 20,
306
- },
307
- bannerTitle: {
308
- fontSize: 18,
309
- fontWeight: '700',
310
- color: '#FFFFFF',
311
- marginBottom: 6,
312
- },
313
- bannerSubtitle: {
314
- fontSize: 13,
315
- color: '#BFDBFE',
316
- marginBottom: 16,
317
- },
318
- bannerButton: {
319
- alignSelf: 'flex-start',
320
- backgroundColor: '#FFFFFF',
321
- paddingHorizontal: 20,
322
- paddingVertical: 10,
323
- borderRadius: 8,
324
- },
325
- bannerButtonText: {
326
- fontSize: 13,
327
- fontWeight: '500',
328
- color: '#2563EB',
329
- },
330
- });
331
-
332
- export default styles;