@coze-arch/cli 0.0.1-alpha.e665f4 → 0.0.1-alpha.e70f72
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/.cozeproj/scripts/server_dev_run.sh +1 -1
- package/lib/__templates__/expo/client/components/Screen.tsx +2 -2
- package/lib/__templates__/expo/client/eslint.config.mjs +4 -0
- package/lib/__templates__/expo/client/metro.config.js +3 -0
- package/lib/__templates__/expo/client/package.json +35 -35
- package/lib/__templates__/expo/client/scripts/install-missing-deps.js +10 -10
- 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/package.json +1 -1
- package/lib/__templates__/expo/pnpm-lock.yaml +394 -221
- package/lib/__templates__/expo/server/package.json +9 -7
- package/lib/__templates__/expo/server/src/index.ts +1 -0
- package/lib/__templates__/expo/template.config.js +1 -1
- 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/README.md +5 -0
- package/lib/__templates__/nextjs/eslint.config.mjs +5 -0
- package/lib/__templates__/nextjs/next.config.ts +1 -2
- package/lib/__templates__/nextjs/package.json +5 -6
- package/lib/__templates__/nextjs/pnpm-lock.yaml +1145 -109
- package/lib/__templates__/nextjs/scripts/build.sh +4 -1
- package/lib/__templates__/nextjs/scripts/dev.sh +4 -4
- package/lib/__templates__/nextjs/scripts/start.sh +1 -1
- package/lib/__templates__/nextjs/src/app/layout.tsx +1 -1
- package/lib/__templates__/nextjs/src/app/page.tsx +4 -3
- package/lib/__templates__/nextjs/src/server.ts +35 -0
- 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__/nuxt-vue/_npmrc +23 -0
- package/lib/__templates__/nuxt-vue/app/app.vue +6 -0
- package/lib/__templates__/nuxt-vue/app/pages/index.vue +23 -0
- package/lib/__templates__/nuxt-vue/assets/css/main.css +24 -0
- 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__/nuxt-vue/scripts/build.sh +14 -0
- package/lib/__templates__/nuxt-vue/scripts/dev.sh +32 -0
- package/lib/__templates__/nuxt-vue/scripts/prepare.sh +14 -0
- package/lib/__templates__/nuxt-vue/scripts/start.sh +15 -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/.cozeproj/scripts/deploy_build.sh +2 -2
- package/lib/__templates__/taro/.cozeproj/scripts/deploy_run.sh +4 -3
- package/lib/__templates__/taro/.cozeproj/scripts/dev_build.sh +0 -15
- package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +117 -24
- package/lib/__templates__/taro/.cozeproj/scripts/pack.sh +24 -1
- package/lib/__templates__/taro/README.md +81 -17
- package/lib/__templates__/taro/config/index.ts +87 -37
- package/lib/__templates__/taro/config/prod.ts +4 -5
- package/lib/__templates__/taro/eslint.config.mjs +27 -4
- package/lib/__templates__/taro/package.json +16 -4
- package/lib/__templates__/taro/patches/@tarojs__plugin-mini-ci@4.1.9.patch +30 -0
- package/lib/__templates__/taro/pnpm-lock.yaml +785 -115
- package/lib/__templates__/taro/server/package.json +3 -1
- package/lib/__templates__/taro/server/src/main.ts +14 -2
- package/lib/__templates__/taro/src/app.css +18 -18
- package/lib/__templates__/taro/src/app.tsx +9 -0
- package/lib/__templates__/taro/src/index.html +20 -1
- 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 +201 -0
- package/lib/__templates__/taro/src/presets/h5-styles.ts +142 -0
- package/lib/__templates__/taro/src/presets/index.tsx +18 -0
- package/lib/__templates__/templates.json +43 -0
- package/lib/__templates__/vite/README.md +190 -11
- package/lib/__templates__/vite/_gitignore +1 -0
- package/lib/__templates__/vite/eslint.config.mjs +6 -1
- package/lib/__templates__/vite/package.json +14 -3
- package/lib/__templates__/vite/pnpm-lock.yaml +820 -1593
- package/lib/__templates__/vite/scripts/build.sh +4 -1
- package/lib/__templates__/vite/scripts/dev.sh +5 -4
- package/lib/__templates__/vite/scripts/start.sh +3 -3
- package/lib/__templates__/vite/server/routes/index.ts +31 -0
- package/lib/__templates__/vite/server/server.ts +55 -0
- package/lib/__templates__/vite/server/vite.ts +71 -0
- package/lib/__templates__/vite/src/main.ts +2 -2
- package/lib/__templates__/vite/tsconfig.json +4 -3
- package/lib/__templates__/vite/vite.config.ts +1 -0
- package/lib/cli.js +123 -156
- package/package.json +7 -3
- package/lib/__templates__/taro/src/app.ts +0 -14
- package/lib/__templates__/taro/src/utils/h5-styles.ts +0 -22
- package/lib/__templates__/taro/src/utils/wx-debug.ts +0 -23
- /package/lib/__templates__/expo/patches/{expo@54.0.32.patch → expo@54.0.33.patch} +0 -0
|
@@ -16,8 +16,10 @@
|
|
|
16
16
|
"@nestjs/common": "^10.4.15",
|
|
17
17
|
"@nestjs/core": "^10.4.15",
|
|
18
18
|
"@nestjs/platform-express": "^10.4.15",
|
|
19
|
+
"@supabase/supabase-js": "2.95.3",
|
|
19
20
|
"better-sqlite3": "^11.9.1",
|
|
20
|
-
"coze-coding-dev-sdk": "^0.7.
|
|
21
|
+
"coze-coding-dev-sdk": "^0.7.16",
|
|
22
|
+
"dotenv": "^17.2.3",
|
|
21
23
|
"drizzle-kit": "^0.31.8",
|
|
22
24
|
"drizzle-orm": "^0.45.1",
|
|
23
25
|
"drizzle-zod": "^0.8.3",
|
|
@@ -3,6 +3,18 @@ import { AppModule } from '@/app.module';
|
|
|
3
3
|
import * as express from 'express';
|
|
4
4
|
import { HttpStatusInterceptor } from '@/interceptors/http-status.interceptor';
|
|
5
5
|
|
|
6
|
+
function parsePort(): number {
|
|
7
|
+
const args = process.argv.slice(2);
|
|
8
|
+
const portIndex = args.indexOf('-p');
|
|
9
|
+
if (portIndex !== -1 && args[portIndex + 1]) {
|
|
10
|
+
const port = parseInt(args[portIndex + 1], 10);
|
|
11
|
+
if (!isNaN(port) && port > 0 && port < 65536) {
|
|
12
|
+
return port;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return <%= serverPort %>;
|
|
16
|
+
}
|
|
17
|
+
|
|
6
18
|
async function bootstrap() {
|
|
7
19
|
const app = await NestFactory.create(AppModule);
|
|
8
20
|
|
|
@@ -19,8 +31,8 @@ async function bootstrap() {
|
|
|
19
31
|
// 1. 开启优雅关闭 Hooks (关键!)
|
|
20
32
|
app.enableShutdownHooks();
|
|
21
33
|
|
|
22
|
-
// 2.
|
|
23
|
-
const port =
|
|
34
|
+
// 2. 解析端口
|
|
35
|
+
const port = parsePort();
|
|
24
36
|
try {
|
|
25
37
|
await app.listen(port);
|
|
26
38
|
console.log(`Server running on http://localhost:${port}`);
|
|
@@ -2,51 +2,51 @@
|
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
* H5 端 rem 适配:与小程序 rpx 缩放一致
|
|
5
|
-
* 375px 屏幕:1rem = 16px,小程序 32rpx = 16px
|
|
5
|
+
* 375px 屏幕:1rem = 16px,小程序 32rpx = 16px
|
|
6
6
|
*/
|
|
7
7
|
html {
|
|
8
|
-
|
|
8
|
+
font-size: 4vw !important;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
/* 小程序页面容器高度设置,确保垂直居中生效 */
|
|
12
12
|
/* stylelint-disable-next-line selector-type-no-unknown */
|
|
13
13
|
page {
|
|
14
|
-
|
|
14
|
+
height: 100%;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
/* H5 端组件默认样式修复 */
|
|
18
18
|
taro-view-core {
|
|
19
|
-
|
|
19
|
+
display: block;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
taro-text-core {
|
|
23
|
-
|
|
23
|
+
display: inline;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
taro-input-core {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
display: block;
|
|
28
|
+
width: 100%;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
taro-input-core input {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
width: 100%;
|
|
33
|
+
background: transparent;
|
|
34
|
+
border: none;
|
|
35
|
+
outline: none;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/* 全局按钮样式重置 */
|
|
39
39
|
taro-button-core,
|
|
40
40
|
button {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
margin: 0 !important;
|
|
42
|
+
padding: 0 !important;
|
|
43
|
+
line-height: inherit;
|
|
44
|
+
display: flex;
|
|
45
|
+
align-items: center;
|
|
46
|
+
justify-content: center;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
taro-button-core::after,
|
|
50
50
|
button::after {
|
|
51
|
-
|
|
51
|
+
border: none;
|
|
52
52
|
}
|
|
@@ -14,7 +14,26 @@
|
|
|
14
14
|
</head>
|
|
15
15
|
|
|
16
16
|
<body>
|
|
17
|
-
<div id="app"
|
|
17
|
+
<div id="app">
|
|
18
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="lab(2.86037 0.455312 0.568903)"
|
|
19
|
+
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="
|
|
20
|
+
position: fixed;
|
|
21
|
+
inset: 0;
|
|
22
|
+
margin: auto;
|
|
23
|
+
width: 24px;
|
|
24
|
+
height: 24px;
|
|
25
|
+
animation: __app-loading-spin 1s linear infinite;
|
|
26
|
+
">
|
|
27
|
+
<path d="M21 12a9 9 0 1 1-6.219-8.56" />
|
|
28
|
+
</svg>
|
|
29
|
+
<style>
|
|
30
|
+
@keyframes __app-loading-spin {
|
|
31
|
+
to {
|
|
32
|
+
transform: rotate(360deg);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
</style>
|
|
36
|
+
</div>
|
|
18
37
|
</body>
|
|
19
38
|
|
|
20
39
|
</html>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import Taro from '@tarojs/taro';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 小程序调试工具
|
|
5
|
+
* 在开发版/体验版自动开启调试模式
|
|
6
|
+
* 支持微信小程序和抖音小程序
|
|
7
|
+
*/
|
|
8
|
+
export function devDebug() {
|
|
9
|
+
const env = Taro.getEnv();
|
|
10
|
+
if (env === Taro.ENV_TYPE.WEAPP || env === Taro.ENV_TYPE.TT) {
|
|
11
|
+
try {
|
|
12
|
+
const accountInfo = Taro.getAccountInfoSync();
|
|
13
|
+
const envVersion = accountInfo.miniProgram.envVersion;
|
|
14
|
+
console.log('[Debug] envVersion:', envVersion);
|
|
15
|
+
|
|
16
|
+
if (envVersion !== 'release') {
|
|
17
|
+
Taro.setEnableDebug({ enableDebug: true });
|
|
18
|
+
}
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.error('[Debug] 开启调试模式失败:', error);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { H5NavBar } from './h5-navbar';
|
|
3
|
+
|
|
4
|
+
export const H5Container = ({ children }: PropsWithChildren) => {
|
|
5
|
+
if (TARO_ENV !== 'h5') {
|
|
6
|
+
return <>{children}</>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<>
|
|
11
|
+
<H5NavBar />
|
|
12
|
+
{children}
|
|
13
|
+
</>
|
|
14
|
+
);
|
|
15
|
+
};
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { View, Text } from '@tarojs/components';
|
|
2
|
+
import Taro, { useDidShow, usePageScroll } from '@tarojs/taro';
|
|
3
|
+
import { useState, useEffect, useCallback } from 'react';
|
|
4
|
+
import { ChevronLeft, House } from 'lucide-react-taro';
|
|
5
|
+
|
|
6
|
+
interface NavConfig {
|
|
7
|
+
navigationBarTitleText?: string;
|
|
8
|
+
navigationBarBackgroundColor?: string;
|
|
9
|
+
navigationBarTextStyle?: 'black' | 'white';
|
|
10
|
+
navigationStyle?: 'default' | 'custom';
|
|
11
|
+
transparentTitle?: 'none' | 'always' | 'auto';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
enum LeftIcon {
|
|
15
|
+
Back = 'back',
|
|
16
|
+
Home = 'home',
|
|
17
|
+
None = 'none',
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface NavState {
|
|
21
|
+
visible: boolean;
|
|
22
|
+
title: string;
|
|
23
|
+
bgColor: string;
|
|
24
|
+
textStyle: 'black' | 'white';
|
|
25
|
+
navStyle: 'default' | 'custom';
|
|
26
|
+
transparent: 'none' | 'always' | 'auto';
|
|
27
|
+
leftIcon: LeftIcon;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const DEFAULT_NAV_STATE: NavState = {
|
|
31
|
+
visible: false,
|
|
32
|
+
title: '',
|
|
33
|
+
bgColor: '#ffffff',
|
|
34
|
+
textStyle: 'black',
|
|
35
|
+
navStyle: 'default',
|
|
36
|
+
transparent: 'none',
|
|
37
|
+
leftIcon: LeftIcon.None,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const getGlobalWindowConfig = (): Partial<NavConfig> => {
|
|
41
|
+
const app = Taro.getApp();
|
|
42
|
+
return app?.config?.window || {};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const getTabBarPages = (): Set<string> => {
|
|
46
|
+
const tabBar = Taro.getApp()?.config?.tabBar;
|
|
47
|
+
return new Set(
|
|
48
|
+
tabBar?.list?.map((item: { pagePath: string }) => item.pagePath) || [],
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const computeLeftIcon = (
|
|
53
|
+
route: string,
|
|
54
|
+
tabBarPages: Set<string>,
|
|
55
|
+
historyLength: number,
|
|
56
|
+
): LeftIcon => {
|
|
57
|
+
if (!route) return LeftIcon.None;
|
|
58
|
+
|
|
59
|
+
const isHomePage =
|
|
60
|
+
route === 'pages/index/index' || route === '/pages/index/index';
|
|
61
|
+
const isTabBarPage = tabBarPages.has(route);
|
|
62
|
+
const hasHistory = historyLength > 1;
|
|
63
|
+
|
|
64
|
+
if (isTabBarPage || isHomePage) return LeftIcon.None;
|
|
65
|
+
if (hasHistory) return LeftIcon.Back;
|
|
66
|
+
return LeftIcon.Home;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const H5NavBar = () => {
|
|
70
|
+
const [navState, setNavState] = useState<NavState>(DEFAULT_NAV_STATE);
|
|
71
|
+
const [scrollOpacity, setScrollOpacity] = useState(0);
|
|
72
|
+
|
|
73
|
+
const updateNavState = useCallback(() => {
|
|
74
|
+
const pages = Taro.getCurrentPages();
|
|
75
|
+
const currentPage = pages[pages.length - 1];
|
|
76
|
+
const route = currentPage?.route || '';
|
|
77
|
+
const pageConfig: NavConfig = (currentPage as any)?.config || {};
|
|
78
|
+
const globalConfig = getGlobalWindowConfig();
|
|
79
|
+
const tabBarPages = getTabBarPages();
|
|
80
|
+
|
|
81
|
+
const isHomePage =
|
|
82
|
+
route === 'pages/index/index' || route === '/pages/index/index';
|
|
83
|
+
const isTabBarPage = tabBarPages.has(route);
|
|
84
|
+
const shouldHideNav =
|
|
85
|
+
tabBarPages.size <= 1 &&
|
|
86
|
+
pages.length <= 1 &&
|
|
87
|
+
(isHomePage || isTabBarPage);
|
|
88
|
+
|
|
89
|
+
setNavState({
|
|
90
|
+
visible: !shouldHideNav,
|
|
91
|
+
title:
|
|
92
|
+
pageConfig.navigationBarTitleText ||
|
|
93
|
+
globalConfig.navigationBarTitleText ||
|
|
94
|
+
'',
|
|
95
|
+
bgColor:
|
|
96
|
+
pageConfig.navigationBarBackgroundColor ||
|
|
97
|
+
globalConfig.navigationBarBackgroundColor ||
|
|
98
|
+
'#ffffff',
|
|
99
|
+
textStyle:
|
|
100
|
+
pageConfig.navigationBarTextStyle ||
|
|
101
|
+
globalConfig.navigationBarTextStyle ||
|
|
102
|
+
'black',
|
|
103
|
+
navStyle:
|
|
104
|
+
pageConfig.navigationStyle || globalConfig.navigationStyle || 'default',
|
|
105
|
+
transparent:
|
|
106
|
+
pageConfig.transparentTitle || globalConfig.transparentTitle || 'none',
|
|
107
|
+
leftIcon: shouldHideNav
|
|
108
|
+
? LeftIcon.None
|
|
109
|
+
: computeLeftIcon(route, tabBarPages, pages.length),
|
|
110
|
+
});
|
|
111
|
+
}, []);
|
|
112
|
+
|
|
113
|
+
useDidShow(() => {
|
|
114
|
+
updateNavState();
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
usePageScroll(({ scrollTop }) => {
|
|
118
|
+
if (navState.transparent === 'auto') {
|
|
119
|
+
setScrollOpacity(Math.min(scrollTop / 100, 1));
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
if (TARO_ENV !== 'h5') return;
|
|
125
|
+
|
|
126
|
+
const titleEl = document.querySelector('title') || document.head;
|
|
127
|
+
const observer = new MutationObserver(() => updateNavState());
|
|
128
|
+
observer.observe(titleEl, {
|
|
129
|
+
subtree: true,
|
|
130
|
+
childList: true,
|
|
131
|
+
characterData: true,
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
return () => observer.disconnect();
|
|
135
|
+
}, [updateNavState]);
|
|
136
|
+
|
|
137
|
+
const shouldRender =
|
|
138
|
+
TARO_ENV === 'h5' && navState.visible && navState.navStyle !== 'custom';
|
|
139
|
+
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
if (TARO_ENV !== 'h5') return;
|
|
142
|
+
if (shouldRender) {
|
|
143
|
+
document.body.classList.add('h5-navbar-visible');
|
|
144
|
+
} else {
|
|
145
|
+
document.body.classList.remove('h5-navbar-visible');
|
|
146
|
+
}
|
|
147
|
+
}, [shouldRender]);
|
|
148
|
+
|
|
149
|
+
if (!shouldRender) {
|
|
150
|
+
return <></>;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const iconColor = navState.textStyle === 'white' ? '#fff' : '#333';
|
|
154
|
+
const textColorClass =
|
|
155
|
+
navState.textStyle === 'white' ? 'text-white' : 'text-gray-800';
|
|
156
|
+
|
|
157
|
+
const getBgStyle = () => {
|
|
158
|
+
if (navState.transparent === 'always') {
|
|
159
|
+
return { backgroundColor: 'transparent' };
|
|
160
|
+
}
|
|
161
|
+
if (navState.transparent === 'auto') {
|
|
162
|
+
return { backgroundColor: navState.bgColor, opacity: scrollOpacity };
|
|
163
|
+
}
|
|
164
|
+
return { backgroundColor: navState.bgColor };
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const handleBack = () => Taro.navigateBack();
|
|
168
|
+
const handleGoHome = () => Taro.reLaunch({ url: '/pages/index/index' });
|
|
169
|
+
|
|
170
|
+
return (
|
|
171
|
+
<>
|
|
172
|
+
<View
|
|
173
|
+
className="fixed top-0 left-0 right-0 h-11 flex items-center justify-center z-1000"
|
|
174
|
+
style={getBgStyle()}
|
|
175
|
+
>
|
|
176
|
+
{navState.leftIcon === LeftIcon.Back && (
|
|
177
|
+
<View
|
|
178
|
+
className="absolute left-2 top-1/2 -translate-y-1/2 p-1 flex items-center justify-center"
|
|
179
|
+
onClick={handleBack}
|
|
180
|
+
>
|
|
181
|
+
<ChevronLeft size={24} color={iconColor} />
|
|
182
|
+
</View>
|
|
183
|
+
)}
|
|
184
|
+
{navState.leftIcon === LeftIcon.Home && (
|
|
185
|
+
<View
|
|
186
|
+
className="absolute left-2 top-1/2 -translate-y-1/2 p-1 flex items-center justify-center"
|
|
187
|
+
onClick={handleGoHome}
|
|
188
|
+
>
|
|
189
|
+
<House size={22} color={iconColor} />
|
|
190
|
+
</View>
|
|
191
|
+
)}
|
|
192
|
+
<Text
|
|
193
|
+
className={`text-base font-medium max-w-3/5 truncate ${textColorClass}`}
|
|
194
|
+
>
|
|
195
|
+
{navState.title}
|
|
196
|
+
</Text>
|
|
197
|
+
</View>
|
|
198
|
+
<View className="h-11 shrink-0" />
|
|
199
|
+
</>
|
|
200
|
+
);
|
|
201
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* H5 端特殊样式注入
|
|
3
|
+
* 如无必要,请勿修改本文件
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const H5_BASE_STYLES = `
|
|
7
|
+
/* H5 端隐藏 TabBar 空图标(只隐藏没有 src 的图标) */
|
|
8
|
+
.weui-tabbar__icon:not([src]),
|
|
9
|
+
.weui-tabbar__icon[src=''] {
|
|
10
|
+
display: none !important;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.weui-tabbar__item:has(.weui-tabbar__icon:not([src])) .weui-tabbar__label,
|
|
14
|
+
.weui-tabbar__item:has(.weui-tabbar__icon[src='']) .weui-tabbar__label {
|
|
15
|
+
margin-top: 0 !important;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* Vite 错误覆盖层无法选择文本的问题 */
|
|
19
|
+
vite-error-overlay {
|
|
20
|
+
/* stylelint-disable-next-line property-no-vendor-prefix */
|
|
21
|
+
-webkit-user-select: text !important;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
vite-error-overlay::part(window) {
|
|
25
|
+
max-width: 90vw;
|
|
26
|
+
padding: 10px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.taro_page {
|
|
30
|
+
overflow: auto;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
::-webkit-scrollbar {
|
|
34
|
+
width: 4px;
|
|
35
|
+
height: 4px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
::-webkit-scrollbar-track {
|
|
39
|
+
background: transparent;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
::-webkit-scrollbar-thumb {
|
|
43
|
+
background: rgba(0, 0, 0, 0.2);
|
|
44
|
+
border-radius: 2px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
::-webkit-scrollbar-thumb:hover {
|
|
48
|
+
background: rgba(0, 0, 0, 0.3);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* H5 导航栏页面自动添加顶部间距 */
|
|
52
|
+
body.h5-navbar-visible .taro_page {
|
|
53
|
+
padding-top: 44px;
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
56
|
+
|
|
57
|
+
const PC_WIDESCREEN_STYLES = `
|
|
58
|
+
/* PC 宽屏适配 - 基础布局 */
|
|
59
|
+
@media (min-width: 769px) {
|
|
60
|
+
html {
|
|
61
|
+
font-size: 15px !important;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
body {
|
|
65
|
+
background-color: #f3f4f6 !important;
|
|
66
|
+
display: flex !important;
|
|
67
|
+
justify-content: center !important;
|
|
68
|
+
align-items: center !important;
|
|
69
|
+
min-height: 100vh !important;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
`;
|
|
73
|
+
|
|
74
|
+
const PC_WIDESCREEN_PHONE_FRAME = `
|
|
75
|
+
/* PC 宽屏适配 - 手机框样式(有 TabBar 页面) */
|
|
76
|
+
@media (min-width: 769px) {
|
|
77
|
+
.taro-tabbar__container {
|
|
78
|
+
width: 375px !important;
|
|
79
|
+
max-width: 375px !important;
|
|
80
|
+
height: calc(100vh - 40px) !important;
|
|
81
|
+
max-height: 900px !important;
|
|
82
|
+
background-color: #fff !important;
|
|
83
|
+
transform: translateX(0) !important;
|
|
84
|
+
box-shadow: 0 0 20px rgba(0, 0, 0, 0.1) !important;
|
|
85
|
+
border-radius: 20px !important;
|
|
86
|
+
overflow: hidden !important;
|
|
87
|
+
position: relative !important;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.taro-tabbar__panel {
|
|
91
|
+
height: 100% !important;
|
|
92
|
+
overflow: auto !important;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/* PC 宽屏适配 - 手机框样式(无 TabBar 页面,通过 JS 添加 no-tabbar 类) */
|
|
97
|
+
@media (min-width: 769px) {
|
|
98
|
+
body.no-tabbar #app {
|
|
99
|
+
width: 375px !important;
|
|
100
|
+
max-width: 375px !important;
|
|
101
|
+
height: calc(100vh - 40px) !important;
|
|
102
|
+
max-height: 900px !important;
|
|
103
|
+
background-color: #fff !important;
|
|
104
|
+
box-shadow: 0 0 20px rgba(0, 0, 0, 0.1) !important;
|
|
105
|
+
border-radius: 20px !important;
|
|
106
|
+
overflow: hidden !important;
|
|
107
|
+
position: relative !important;
|
|
108
|
+
transform: translateX(0) !important;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
body.no-tabbar #app .taro_router {
|
|
112
|
+
height: 100% !important;
|
|
113
|
+
overflow: auto !important;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
`;
|
|
117
|
+
|
|
118
|
+
function injectStyles() {
|
|
119
|
+
const style = document.createElement('style');
|
|
120
|
+
style.innerHTML =
|
|
121
|
+
H5_BASE_STYLES + PC_WIDESCREEN_STYLES + PC_WIDESCREEN_PHONE_FRAME;
|
|
122
|
+
document.head.appendChild(style);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function setupTabbarDetection() {
|
|
126
|
+
const checkTabbar = () => {
|
|
127
|
+
const hasTabbar = !!document.querySelector('.taro-tabbar__container');
|
|
128
|
+
document.body.classList.toggle('no-tabbar', !hasTabbar);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
checkTabbar();
|
|
132
|
+
|
|
133
|
+
const observer = new MutationObserver(checkTabbar);
|
|
134
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export function injectH5Styles() {
|
|
138
|
+
if (TARO_ENV !== 'h5') return;
|
|
139
|
+
|
|
140
|
+
injectStyles();
|
|
141
|
+
setupTabbarDetection();
|
|
142
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useLaunch } from '@tarojs/taro';
|
|
2
|
+
import { PropsWithChildren } from 'react';
|
|
3
|
+
import { injectH5Styles } from './h5-styles';
|
|
4
|
+
import { devDebug } from './dev-debug';
|
|
5
|
+
import { H5Container } from './h5-container';
|
|
6
|
+
|
|
7
|
+
export const Preset = ({ children }: PropsWithChildren) => {
|
|
8
|
+
useLaunch(() => {
|
|
9
|
+
devDebug();
|
|
10
|
+
injectH5Styles();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
if (TARO_ENV === 'h5') {
|
|
14
|
+
return <H5Container>{children}</H5Container>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return <>{children}</>;
|
|
18
|
+
};
|
|
@@ -26,6 +26,17 @@
|
|
|
26
26
|
"additionalProperties": false
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
|
+
{
|
|
30
|
+
"name": "native-static",
|
|
31
|
+
"description": "Native Static(纯静态):`coze init ${COZE_WORKSPACE_PATH} --template native-static`\n- 适用:纯静态 HTML/CSS/JS 项目、静态网站\n- 使用 Python http.server 作为开发服务器\n- 不需要 Node.js 环境,适合简单静态内容",
|
|
32
|
+
"location": "./native-static",
|
|
33
|
+
"paramsSchema": {
|
|
34
|
+
"type": "object",
|
|
35
|
+
"properties": {},
|
|
36
|
+
"required": [],
|
|
37
|
+
"additionalProperties": false
|
|
38
|
+
}
|
|
39
|
+
},
|
|
29
40
|
{
|
|
30
41
|
"name": "nextjs",
|
|
31
42
|
"description": "Next.js(复杂项目):`coze init ${COZE_WORKSPACE_PATH} --template nextjs`\n- 适用:全栈应用、复杂多页面等复杂项目\n- 使用默认nextjs项目规范\n - **目录规范**: 默认开启src目录(打开--src-dir选项):项目文件(如 app 目录、pages 目录、components 等)初始化到 src/ 目录下。\n - **项目理解加速**:初始可以依赖项目下 `package.json` 文件理解项目类型,如果没有或无法理解退化成阅读其他文件。\n - **UI设计与组件规范**:Next.js项目**必须默认**采用 shadcn/ui 风格和规范,`shadcn/ui`组件默认完整的预装在`src/components/ui/`目录下",
|
|
@@ -51,6 +62,38 @@
|
|
|
51
62
|
"additionalProperties": false
|
|
52
63
|
}
|
|
53
64
|
},
|
|
65
|
+
{
|
|
66
|
+
"name": "nuxt-vue",
|
|
67
|
+
"description": "Nuxt.js(服务端 + Vue):`coze init ${COZE_WORKSPACE_PATH} --template nuxt-vue`\n- 适用:全栈应用、需要服务端接口能力的 Vue 项目\n- 特点:\n - **服务端能力**:内置服务端 API 路由,可直接创建后端接口\n - **Vue 3**:基于最新的 Vue 3 Composition API\n - **Vite**:使用 Vite 作为构建工具,开发体验极佳\n - **TypeScript**:完整的 TypeScript 支持\n - **文件路由**:基于文件系统的自动路由\n - **项目理解加速**:可依赖项目下 `package.json` 和 `nuxt.config.ts` 理解项目配置",
|
|
68
|
+
"location": "./nuxt-vue",
|
|
69
|
+
"paramsSchema": {
|
|
70
|
+
"type": "object",
|
|
71
|
+
"properties": {
|
|
72
|
+
"appName": {
|
|
73
|
+
"type": "string",
|
|
74
|
+
"minLength": 1,
|
|
75
|
+
"pattern": "^[a-z0-9-]+$",
|
|
76
|
+
"description": "Application name (lowercase, alphanumeric and hyphens only)"
|
|
77
|
+
},
|
|
78
|
+
"port": {
|
|
79
|
+
"type": "number",
|
|
80
|
+
"default": 5000,
|
|
81
|
+
"minimum": 1024,
|
|
82
|
+
"maximum": 65535,
|
|
83
|
+
"description": "Development server port (for Nuxt dev server)"
|
|
84
|
+
},
|
|
85
|
+
"hmrPort": {
|
|
86
|
+
"type": "number",
|
|
87
|
+
"default": 6000,
|
|
88
|
+
"minimum": 1024,
|
|
89
|
+
"maximum": 65535,
|
|
90
|
+
"description": "Hot Module Replacement (HMR) port"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"required": [],
|
|
94
|
+
"additionalProperties": false
|
|
95
|
+
}
|
|
96
|
+
},
|
|
54
97
|
{
|
|
55
98
|
"name": "taro",
|
|
56
99
|
"description": "Taro(小程序 + H5):`coze init ${COZE_WORKSPACE_PATH} --template taro`\n- 适用:微信小程序、H5 跨端应用\n- 前后端分离架构:Taro 4 + NestJS\n- 支持微信小程序和 H5 双端构建\n- 使用 TailwindCSS + weapp-tailwindcss 实现跨端样式",
|