@coze-arch/cli 0.0.1-alpha.14a431 → 0.0.1-alpha.179868
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/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 +220 -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 +45 -0
- package/lib/__templates__/expo/README.md +68 -7
- package/lib/__templates__/expo/_gitignore +1 -1
- package/lib/__templates__/expo/_npmrc +2 -4
- 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 +1 -17
- 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/declarations.d.ts +5 -0
- package/lib/__templates__/expo/{eslint.config.mjs → client/eslint.config.mjs} +17 -10
- package/lib/__templates__/expo/client/hooks/useColorScheme.tsx +48 -0
- package/lib/__templates__/expo/client/hooks/useTheme.ts +26 -6
- package/lib/__templates__/expo/client/metro.config.js +121 -0
- package/lib/__templates__/expo/client/package.json +93 -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 +1 -0
- package/lib/__templates__/expo/client/tsconfig.json +24 -0
- package/lib/__templates__/expo/client/utils/index.ts +22 -0
- 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/reanimated/index.js +9 -0
- package/lib/__templates__/expo/eslint-plugins/reanimated/rule.js +88 -0
- package/lib/__templates__/expo/package.json +13 -103
- package/lib/__templates__/expo/pnpm-lock.yaml +451 -867
- 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 +32 -0
- package/lib/__templates__/expo/server/src/index.ts +19 -0
- package/lib/__templates__/expo/server/tsconfig.json +24 -0
- package/lib/__templates__/expo/template.config.js +1 -0
- package/lib/__templates__/expo/tsconfig.json +1 -24
- package/lib/__templates__/nextjs/.babelrc +15 -0
- package/lib/__templates__/nextjs/.coze +1 -0
- package/lib/__templates__/nextjs/_npmrc +1 -0
- package/lib/__templates__/nextjs/next.config.ts +12 -0
- package/lib/__templates__/nextjs/package.json +11 -2
- package/lib/__templates__/nextjs/pnpm-lock.yaml +2486 -1707
- package/lib/__templates__/nextjs/scripts/dev.sh +7 -26
- package/lib/__templates__/nextjs/scripts/prepare.sh +9 -0
- package/lib/__templates__/nextjs/src/app/globals.css +109 -89
- package/lib/__templates__/nextjs/src/app/layout.tsx +5 -14
- package/lib/__templates__/nextjs/src/app/page.tsx +35 -23
- package/lib/__templates__/nextjs/src/components/ui/resizable.tsx +29 -22
- package/lib/__templates__/nextjs/src/components/ui/sidebar.tsx +228 -230
- package/lib/__templates__/nextjs/template.config.js +30 -0
- package/lib/__templates__/templates.json +61 -43
- package/lib/__templates__/vite/.coze +1 -0
- package/lib/__templates__/vite/_npmrc +1 -0
- package/lib/__templates__/vite/eslint.config.mjs +9 -0
- package/lib/__templates__/vite/package.json +11 -2
- package/lib/__templates__/vite/pnpm-lock.yaml +3232 -243
- package/lib/__templates__/vite/scripts/dev.sh +7 -26
- package/lib/__templates__/vite/scripts/prepare.sh +9 -0
- package/lib/__templates__/vite/src/main.ts +1 -2
- package/lib/__templates__/vite/template.config.js +30 -4
- package/lib/__templates__/vite/vite.config.ts +3 -3
- package/lib/cli.js +691 -130
- package/package.json +8 -3
- package/lib/__templates__/expo/.cozeproj/scripts/deploy_build.sh +0 -116
- package/lib/__templates__/expo/.cozeproj/scripts/deploy_run.sh +0 -239
- 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 -12
- package/lib/__templates__/expo/client/screens/home/index.tsx +0 -51
- package/lib/__templates__/expo/client/screens/home/styles.ts +0 -60
- 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__/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
|
+
}
|
|
@@ -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 负责底部安全区
|
|
@@ -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;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import js from
|
|
2
|
-
import globals from
|
|
3
|
-
import tseslint from
|
|
4
|
-
import pluginReact from
|
|
5
|
-
import reactHooks from
|
|
6
|
-
import regexp from
|
|
7
|
-
import pluginImport from
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import globals from 'globals';
|
|
3
|
+
import tseslint from 'typescript-eslint';
|
|
4
|
+
import pluginReact from 'eslint-plugin-react';
|
|
5
|
+
import reactHooks from 'eslint-plugin-react-hooks';
|
|
6
|
+
import regexp from 'eslint-plugin-regexp';
|
|
7
|
+
import pluginImport from 'eslint-plugin-import';
|
|
8
|
+
import fontawesome6 from '../eslint-plugins/fontawesome6/index.js';
|
|
9
|
+
import reanimated from '../eslint-plugins/reanimated/index.js'
|
|
8
10
|
|
|
9
11
|
export default [
|
|
10
12
|
{
|
|
@@ -15,19 +17,20 @@ export default [
|
|
|
15
17
|
'src/api/**', // 排除 src 下的自动生成 API
|
|
16
18
|
'.expo/**', // 排除 Expo 自动生成的文件
|
|
17
19
|
'tailwind.config.js', // 排除 Tailwind 配置文件
|
|
20
|
+
'**/*.d.ts',
|
|
18
21
|
],
|
|
19
22
|
},
|
|
20
23
|
regexp.configs["flat/recommended"],
|
|
21
24
|
js.configs.recommended,
|
|
22
25
|
...tseslint.configs.recommended,
|
|
23
|
-
|
|
26
|
+
|
|
24
27
|
// React 的推荐配置
|
|
25
28
|
pluginReact.configs.flat.recommended,
|
|
26
29
|
pluginReact.configs.flat['jsx-runtime'],
|
|
27
30
|
reactHooks.configs.flat.recommended,
|
|
28
31
|
{
|
|
29
32
|
files: ["**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],
|
|
30
|
-
|
|
33
|
+
|
|
31
34
|
// 语言选项:设置全局变量
|
|
32
35
|
languageOptions: {
|
|
33
36
|
globals: {
|
|
@@ -52,6 +55,8 @@ export default [
|
|
|
52
55
|
|
|
53
56
|
plugins: {
|
|
54
57
|
import: pluginImport,
|
|
58
|
+
fontawesome6,
|
|
59
|
+
reanimated,
|
|
55
60
|
},
|
|
56
61
|
rules: {
|
|
57
62
|
// 关闭代码风格规则
|
|
@@ -70,6 +75,8 @@ export default [
|
|
|
70
75
|
'no-prototype-builtins': 'off',
|
|
71
76
|
'react/react-in-jsx-scope': 'off',
|
|
72
77
|
'react/jsx-uses-react': 'off',
|
|
78
|
+
'fontawesome6/valid-name': 'error',
|
|
79
|
+
'reanimated/ban-mix-use': 'error',
|
|
73
80
|
},
|
|
74
81
|
},
|
|
75
82
|
|
|
@@ -91,7 +98,7 @@ export default [
|
|
|
91
98
|
// 在 .js 文件中关闭 TS 规则
|
|
92
99
|
'@typescript-eslint/no-require-imports': 'off',
|
|
93
100
|
// 在 Node.js 文件中允许 require
|
|
94
|
-
'@typescript-eslint/no-var-requires': 'off',
|
|
101
|
+
'@typescript-eslint/no-var-requires': 'off',
|
|
95
102
|
'no-undef': 'off',
|
|
96
103
|
},
|
|
97
104
|
},
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { createContext, Dispatch, ReactNode, SetStateAction, useContext, useEffect, useState } from 'react';
|
|
2
|
+
import { ColorSchemeName, useColorScheme as useReactNativeColorScheme, Platform } from 'react-native';
|
|
3
|
+
|
|
4
|
+
const ColorSchemeContext = createContext<'light' | 'dark' | null | undefined>(null);
|
|
5
|
+
|
|
6
|
+
const ColorSchemeProvider = function ({ children }: { children?: ReactNode }) {
|
|
7
|
+
const systemColorScheme = useReactNativeColorScheme();
|
|
8
|
+
const [colorScheme, setColorScheme] = useState(systemColorScheme);
|
|
9
|
+
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
setColorScheme(systemColorScheme);
|
|
12
|
+
}, [systemColorScheme]);
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
function handleMessage(e: MessageEvent<{ event: string; colorScheme: ColorSchemeName; } | undefined>) {
|
|
16
|
+
if (e.data?.event === 'coze.workbench.colorScheme') {
|
|
17
|
+
const cs = e.data.colorScheme;
|
|
18
|
+
if (typeof cs === 'string' && typeof setColorScheme === 'function') {
|
|
19
|
+
setColorScheme(cs);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (Platform.OS === 'web') {
|
|
25
|
+
window.addEventListener('message', handleMessage, false);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return () => {
|
|
29
|
+
if (Platform.OS === 'web') {
|
|
30
|
+
window.removeEventListener('message', handleMessage, false);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}, [setColorScheme]);
|
|
34
|
+
|
|
35
|
+
return <ColorSchemeContext.Provider value={colorScheme}>
|
|
36
|
+
{children}
|
|
37
|
+
</ColorSchemeContext.Provider>
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
function useColorScheme() {
|
|
41
|
+
const colorScheme = useContext(ColorSchemeContext);
|
|
42
|
+
return colorScheme;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export {
|
|
46
|
+
ColorSchemeProvider,
|
|
47
|
+
useColorScheme,
|
|
48
|
+
}
|
|
@@ -1,13 +1,33 @@
|
|
|
1
|
-
import { Colors } from
|
|
2
|
-
import { useColorScheme } from
|
|
1
|
+
import { Colors } from '@/constants/theme';
|
|
2
|
+
import { useColorScheme } from '@/hooks/useColorScheme';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
enum COLOR_SCHEME_CHOICE {
|
|
5
|
+
FOLLOW_SYSTEM = 'follow-system', // 跟随系统自动变化
|
|
6
|
+
DARK = 'dark', // 固定为 dark 主题,不随系统变化
|
|
7
|
+
LIGHT = 'light', // 固定为 light 主题,不随系统变化
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const userPreferColorScheme: COLOR_SCHEME_CHOICE = COLOR_SCHEME_CHOICE.FOLLOW_SYSTEM;
|
|
11
|
+
|
|
12
|
+
function getTheme(colorScheme?: 'dark' | 'light' | null) {
|
|
13
|
+
const isDark = colorScheme === 'dark';
|
|
14
|
+
const theme = Colors[colorScheme ?? 'light'];
|
|
8
15
|
|
|
9
16
|
return {
|
|
10
17
|
theme,
|
|
11
18
|
isDark,
|
|
12
19
|
};
|
|
13
20
|
}
|
|
21
|
+
|
|
22
|
+
function useTheme() {
|
|
23
|
+
const systemColorScheme = useColorScheme()
|
|
24
|
+
const colorScheme = userPreferColorScheme === COLOR_SCHEME_CHOICE.FOLLOW_SYSTEM ?
|
|
25
|
+
systemColorScheme :
|
|
26
|
+
userPreferColorScheme;
|
|
27
|
+
|
|
28
|
+
return getTheme(colorScheme);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
useTheme,
|
|
33
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
const { getDefaultConfig } = require('expo/metro-config');
|
|
2
|
+
const { createProxyMiddleware } = require('http-proxy-middleware');
|
|
3
|
+
const connect = require('connect');
|
|
4
|
+
|
|
5
|
+
const config = getDefaultConfig(__dirname);
|
|
6
|
+
|
|
7
|
+
// 安全地获取 Expo 的默认排除列表
|
|
8
|
+
const existingBlockList = [].concat(config.resolver.blockList || []);
|
|
9
|
+
|
|
10
|
+
config.resolver.blockList = [
|
|
11
|
+
...existingBlockList,
|
|
12
|
+
/.*\/\.expo\/.*/, // Expo 的缓存和构建产物目录
|
|
13
|
+
|
|
14
|
+
// 1. 原生代码 (Java/C++/Objective-C)
|
|
15
|
+
/.*\/react-native\/ReactAndroid\/.*/,
|
|
16
|
+
/.*\/react-native\/ReactCommon\/.*/,
|
|
17
|
+
|
|
18
|
+
// 2. 纯开发和调试工具
|
|
19
|
+
// 这些工具只在开发电脑上运行,不会被打包到应用中
|
|
20
|
+
/.*\/@typescript-eslint\/eslint-plugin\/.*/,
|
|
21
|
+
|
|
22
|
+
// 3. 构建时数据
|
|
23
|
+
// 这个数据库只在打包过程中使用,应用运行时不需要
|
|
24
|
+
/.*\/caniuse-lite\/data\/.*/,
|
|
25
|
+
|
|
26
|
+
// 4. 通用规则
|
|
27
|
+
/.*\/__tests__\/.*/, // 排除所有测试目录
|
|
28
|
+
/.*\.git\/.*/, // 排除 Git 目录
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
const BACKEND_TARGET = 'http://localhost:9091';
|
|
32
|
+
|
|
33
|
+
const apiProxy = createProxyMiddleware({
|
|
34
|
+
target: BACKEND_TARGET,
|
|
35
|
+
changeOrigin: true,
|
|
36
|
+
logLevel: 'debug',
|
|
37
|
+
proxyTimeout: 86400000,
|
|
38
|
+
onProxyReq: (proxyReq, req) => {
|
|
39
|
+
const accept = req.headers.accept || '';
|
|
40
|
+
if (accept.includes('text/event-stream')) {
|
|
41
|
+
proxyReq.setHeader('accept-encoding', 'identity');
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
onProxyRes: (proxyRes, req, res) => {
|
|
45
|
+
const contentType = proxyRes.headers['content-type'] || '';
|
|
46
|
+
if (contentType.includes('text/event-stream') || contentType.includes('application/stream')) {
|
|
47
|
+
res.setHeader('Cache-Control', 'no-cache');
|
|
48
|
+
res.setHeader('Connection', 'keep-alive');
|
|
49
|
+
res.setHeader('X-Accel-Buffering', 'no');
|
|
50
|
+
if (typeof res.flushHeaders === 'function') {
|
|
51
|
+
try { res.flushHeaders(); } catch {}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const streamProxy = createProxyMiddleware({
|
|
58
|
+
target: BACKEND_TARGET,
|
|
59
|
+
changeOrigin: true,
|
|
60
|
+
logLevel: 'debug',
|
|
61
|
+
ws: true,
|
|
62
|
+
proxyTimeout: 86400000,
|
|
63
|
+
onProxyReq: (proxyReq, req) => {
|
|
64
|
+
const upgrade = req.headers.upgrade;
|
|
65
|
+
const accept = req.headers.accept || '';
|
|
66
|
+
if (upgrade && upgrade.toLowerCase() === 'websocket') {
|
|
67
|
+
proxyReq.setHeader('Connection', 'upgrade');
|
|
68
|
+
proxyReq.setHeader('Upgrade', req.headers.upgrade);
|
|
69
|
+
} else if (accept.includes('text/event-stream')) {
|
|
70
|
+
proxyReq.setHeader('accept-encoding', 'identity');
|
|
71
|
+
proxyReq.setHeader('Connection', 'keep-alive');
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
onProxyRes: (proxyRes, req, res) => {
|
|
75
|
+
const contentType = proxyRes.headers['content-type'] || '';
|
|
76
|
+
if (contentType.includes('text/event-stream') || contentType.includes('application/stream')) {
|
|
77
|
+
res.setHeader('Cache-Control', 'no-cache');
|
|
78
|
+
res.setHeader('Connection', 'keep-alive');
|
|
79
|
+
res.setHeader('X-Accel-Buffering', 'no');
|
|
80
|
+
if (typeof res.flushHeaders === 'function') {
|
|
81
|
+
try { res.flushHeaders(); } catch {}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const shouldProxyToBackend = (url) => {
|
|
88
|
+
if (!url) return false;
|
|
89
|
+
if (/^\/api\/v\d+\//.test(url)) {
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
return false;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const isWebSocketRequest = (req) =>
|
|
96
|
+
!!(req.headers.upgrade && req.headers.upgrade.toLowerCase() === 'websocket');
|
|
97
|
+
const isSSERequest = (req) => {
|
|
98
|
+
const accept = req.headers.accept || '';
|
|
99
|
+
return accept.includes('text/event-stream');
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
config.server = {
|
|
103
|
+
...config.server,
|
|
104
|
+
enhanceMiddleware: (metroMiddleware, metroServer) => {
|
|
105
|
+
return connect()
|
|
106
|
+
.use((req, res, next) => {
|
|
107
|
+
if (shouldProxyToBackend(req.url)) {
|
|
108
|
+
console.log(`[Metro Proxy] Forwarding ${req.method} ${req.url}`);
|
|
109
|
+
|
|
110
|
+
if (isWebSocketRequest(req) || isSSERequest(req)) {
|
|
111
|
+
return streamProxy(req, res, next);
|
|
112
|
+
}
|
|
113
|
+
return apiProxy(req, res, next);
|
|
114
|
+
}
|
|
115
|
+
next();
|
|
116
|
+
})
|
|
117
|
+
.use(metroMiddleware);
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
module.exports = config;
|