Skip to content

Commit 2fc0092

Browse files
authored
feat:设计器支持上传到obs桶 (#170)
1 parent 12f464b commit 2fc0092

File tree

11 files changed

+111
-25
lines changed

11 files changed

+111
-25
lines changed

.github/workflows/deploy-obs.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,23 @@ jobs:
6262
VITE_CONTEXT: /vue-pro/pages/
6363
VITE_BASE_API: /tiny-pro-vue/api
6464
VITE_MOCK_SERVER_HOST: /tiny-pro-vue/api/mock
65+
# 是否启用设计器
66+
VITE_LOWCODE_DESIGNER_ENABLED: true
67+
# 配置设计器链接,部署后使用相对路径 /designer
68+
VITE_LOWCODE_DESIGNER_URL: https://ai.opentiny.design/designer/
69+
- name: Build lowcode-designer
70+
run: |
71+
export NODE_OPTIONS="--max-old-space-size=8192"
72+
cd template/lowcode-designer
73+
pnpm build
74+
env:
75+
# 配置设计器的 base 路径,部署到 /designer/ 目录下
76+
VITE_DESIGNER_BASE: /designer/
77+
- name: Copy lowcode-designer to vue-pro/designer
78+
run: |
79+
# 将 lowcode-designer 的构建产物放入 vue-pro/designer 目录下
80+
mkdir -p ./template/tinyvue/dist/vue-pro/designer
81+
cp -r ./template/lowcode-designer/dist/* ./template/tinyvue/dist/vue-pro/designer/
6582
- name: Copy files
6683
run: |
6784
cp ./template/tinyvue/dist/vue-pro/pages/index.html ./template/tinyvue/dist/vue-pro/pages/404.html

package.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@
3131
],
3232
"repository": "https://github.com/opentiny/tiny-pro",
3333
"homepage": "https://opentiny.design/pro/",
34+
"pnpm": {
35+
"overrides": {
36+
"@opentiny/tiny-engine-common>@opentiny/vue-renderless": "~3.20.0",
37+
"@opentiny/tiny-engine-plugin-datasource>@opentiny/vue-renderless": "~3.20.0",
38+
"@opentiny/tiny-engine-plugin-block>@opentiny/vue-renderless": "~3.20.0",
39+
"@opentiny/tiny-engine-plugin-canvas>@opentiny/vue-renderless": "~3.20.0",
40+
"@opentiny/tiny-engine-plugin-tree>@opentiny/vue-renderless": "~3.20.0",
41+
"@opentiny/tiny-engine-setting-styles>@opentiny/vue-renderless": "~3.20.0",
42+
"@opentiny/tiny-engine-plugin-materials>@opentiny/vue-renderless": "~3.20.0",
43+
"@opentiny/tiny-engine-plugin-page>@opentiny/vue-renderless": "~3.20.0"
44+
}
45+
},
3446
"scripts": {
3547
"dev": "pnpm -F tiny-pro-vue start",
3648
"dev:backend": "pnpm -F tinyui-nestjs-server start",
@@ -153,4 +165,4 @@
153165
]
154166
}
155167
]
156-
}
168+
}

template/lowcode-designer/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
"@opentiny/tiny-engine-generate-code-tinypro": "^0.1.0",
1717
"@opentiny/tiny-engine-meta-register": "^2.7.0",
1818
"@opentiny/tiny-engine-utils": "^2.7.0",
19-
"@opentiny/vue": "^3.27.0",
20-
"@opentiny/vue-design-smb": "^3.27.0",
21-
"@opentiny/vue-icon": "^3.27.0",
22-
"@opentiny/vue-locale": "^3.27.0",
23-
"@opentiny/vue-renderless": "^3.27.0",
24-
"@opentiny/vue-theme": "^3.27.0",
19+
"@opentiny/vue": "~3.20.0",
20+
"@opentiny/vue-design-smb": "~3.20.0",
21+
"@opentiny/vue-icon": "~3.20.0",
22+
"@opentiny/vue-locale": "~3.20.0",
23+
"@opentiny/vue-renderless": "~3.20.0",
24+
"@opentiny/vue-theme": "~3.20.0",
2525
"@vueuse/core": "^9.6.0",
2626
"vue": "^3.4.21"
2727
},
@@ -33,4 +33,4 @@
3333
"cross-env": "^7.0.3",
3434
"vite": "^5.4.2"
3535
}
36-
}
36+
}

template/lowcode-designer/vite.config.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
import path from 'node:path';
2-
import { defineConfig, mergeConfig } from 'vite';
2+
import { defineConfig, mergeConfig, loadEnv } from 'vite';
33
import { useTinyEngineBaseConfig } from '@opentiny/tiny-engine-vite-config';
44

55
export default defineConfig((configEnv) => {
6+
// 加载环境变量(从 env 目录加载)
7+
const env = loadEnv(configEnv.mode, path.resolve(__dirname, './env'), '');
8+
9+
// 获取 base 路径,默认为 '/',可通过 VITE_DESIGNER_BASE 环境变量配置
10+
// 例如:VITE_DESIGNER_BASE=/designer/ 用于部署到 /designer/ 路径下
11+
const base = env.VITE_DESIGNER_BASE || '/';
12+
613
const baseConfig = useTinyEngineBaseConfig({
714
viteConfigEnv: configEnv,
815
root: __dirname,
@@ -15,6 +22,7 @@ export default defineConfig((configEnv) => {
1522
});
1623

1724
const customConfig = {
25+
base, // 配置静态资源前缀
1826
envDir: './env',
1927
publicDir: path.resolve(__dirname, './public'),
2028
server: {
@@ -27,6 +35,11 @@ export default defineConfig((configEnv) => {
2735
},
2836
},
2937
},
38+
build: {
39+
// 确保构建时使用正确的 base 路径
40+
outDir: 'dist',
41+
assetsDir: 'assets',
42+
},
3043
};
3144

3245
return mergeConfig(baseConfig, customConfig);

template/tinyvue/config/vite.config.base.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,24 @@ const config = {
4040
},
4141
{
4242
find: '@opentiny/vue-icon',
43-
replacement: resolve('node_modules/@opentiny/vue-icon'), // compile template
43+
replacement: resolve(__dirname, '../node_modules/@opentiny/vue-icon'), // compile template
44+
},
45+
{
46+
find: '@opentiny/vue-theme',
47+
replacement: resolve(__dirname, '../node_modules/@opentiny/vue-theme'),
4448
},
4549
],
46-
extensions: ['.ts', '.js'],
50+
extensions: ['.ts', '.js', '.css'],
51+
preserveSymlinks: false,
4752
},
4853
define: {
4954
'BUILD_TOOLS': "'VITE'",
5055
},
56+
optimizeDeps: {
57+
esbuildOptions: {
58+
resolveExtensions: ['.ts', '.js', '.css'],
59+
},
60+
},
5161
css: {
5262
preprocessorOptions: {
5363
less: {

template/tinyvue/config/vite.config.dev.ts

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
11
import { mergeConfig, loadEnv } from 'vite';
22
import eslint from 'vite-plugin-eslint';
33
import baseConfig from './vite.config.base';
4+
import { resolve } from 'path';
5+
import { configDotenv } from 'dotenv';
6+
7+
// 加载 dev.env 文件
8+
configDotenv({
9+
path: resolve(__dirname, '../dev.env'),
10+
});
11+
12+
// 加载环境变量(development 模式会读取 .env.development 和 .env)
13+
const env = loadEnv('development', process.cwd());
414

515
const proxyConfig = {
6-
[loadEnv('', process.cwd()).VITE_BASE_API]: {
7-
target: loadEnv('', process.cwd()).VITE_SERVER_HOST,
16+
[env.VITE_BASE_API]: {
17+
target: env.VITE_SERVER_HOST,
818
changeOrigin: true,
919
logLevel: 'debug',
1020
rewrite: (path: string) =>
1121
path.replace(
12-
new RegExp(`${loadEnv('', process.cwd()).VITE_BASE_API}`),
22+
new RegExp(`${env.VITE_BASE_API}`),
1323
'',
1424
),
1525
},
16-
[loadEnv('', process.cwd()).VITE_MOCK_SERVER_HOST]: {
17-
target: loadEnv('', process.cwd()).VITE_SERVER_HOST,
26+
[env.VITE_MOCK_SERVER_HOST]: {
27+
target: env.VITE_SERVER_HOST,
1828
changeOrigin: true,
1929
rewrite: (path: string) => {
2030

21-
return path.replace(new RegExp(`${loadEnv('', process.cwd()).VITE_MOCK_SERVER_HOST}`), '/mock')
31+
return path.replace(new RegExp(`${env.VITE_MOCK_SERVER_HOST}`), '/mock')
2232
},
2333
},
2434
};
@@ -34,6 +44,16 @@ export default mergeConfig(
3444
...proxyConfig,
3545
},
3646
},
47+
define: {
48+
// 确保 VITE_LOWCODE_DESIGNER_ENABLED 被注入到客户端代码
49+
'import.meta.env.VITE_LOWCODE_DESIGNER_ENABLED': JSON.stringify(
50+
process.env.VITE_LOWCODE_DESIGNER_ENABLED || 'false'
51+
),
52+
// 确保 VITE_LOWCODE_DESIGNER_URL 被注入到客户端代码
53+
'import.meta.env.VITE_LOWCODE_DESIGNER_URL': JSON.stringify(
54+
process.env.VITE_LOWCODE_DESIGNER_URL || 'http://localhost:8090'
55+
),
56+
},
3757
plugins: [
3858
eslint({
3959
include: ['src/**/*.ts', 'src/**/*.tsx', 'src/**/*.vue'],

template/tinyvue/config/vite.config.prod.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ export default mergeConfig(
88
mode: 'production',
99
base: loadEnv('', process.cwd()).VITE_BASE || '/',
1010
plugins: [configCompressPlugin('gzip'), configVisualizerPlugin()],
11+
define: {
12+
// 确保环境变量被注入到客户端代码
13+
'import.meta.env.VITE_LOWCODE_DESIGNER_ENABLED': JSON.stringify(
14+
process.env.VITE_LOWCODE_DESIGNER_ENABLED || 'false'
15+
),
16+
'import.meta.env.VITE_LOWCODE_DESIGNER_URL': JSON.stringify(
17+
process.env.VITE_LOWCODE_DESIGNER_URL || '/designer'
18+
),
19+
},
1120
build: {
1221
rollupOptions: {
1322
output: {

template/tinyvue/dev.env

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ VITE_USE_MOCK= false
66
VITE_MOCK_IGNORE= /api/user/userInfo,/api/user/login,/api/user/register,/api/employee/getEmployee
77

88
VITE_MOCK_SERVER_HOST=/mock
9-
VITE_LOWCODE_DESIGNER_ENABLED=false
9+
VITE_LOWCODE_DESIGNER_ENABLED=true
10+
# 设计器链接配置,开发环境默认为 http://localhost:8090,生产环境可配置为 /designer 或完整 URL
11+
VITE_LOWCODE_DESIGNER_URL=http://localhost:8090

template/tinyvue/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@
3939
"@babel/core": "^7.25.2",
4040
"@gaonengwww/mock-server": "^1.0.5",
4141
"@opentiny/icons": "^0.1.3",
42-
"@opentiny/vue": "^3.27.0",
43-
"@opentiny/vue-huicharts": "^3.27.0",
44-
"@opentiny/vue-icon": "^3.27.0",
45-
"@opentiny/vue-locale": "^3.27.0",
42+
"@opentiny/vue": "^3.28.0",
43+
"@opentiny/vue-huicharts": "~3.28.0",
44+
"@opentiny/vue-icon": "~3.28.0",
45+
"@opentiny/vue-locale": "~3.28.0",
4646
"@opentiny/vue-search-box": "^0.1.3",
47-
"@opentiny/vue-theme": "^3.27.0",
47+
"@opentiny/vue-theme": "~3.28.0",
4848
"@types/mockjs": "^1.0.10",
4949
"@types/node": "^22.7.4",
5050
"@vueuse/core": "^10.11.1",
@@ -136,4 +136,4 @@
136136
"bin-wrapper": "npm:bin-wrapper-china",
137137
"gifsicle": "5.2.0"
138138
}
139-
}
139+
}

template/tinyvue/src/components/navbar/index.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,9 @@
246246
247247
// 设计器
248248
const openLowCodeDesigner = () => {
249-
window.open(`http://localhost:8090/?type=app&id=1&tenant=1&pageid=1`, '_blank');
249+
// 支持通过环境变量配置设计器链接,默认为开发环境地址
250+
const designerUrl = import.meta.env.VITE_LOWCODE_DESIGNER_URL || 'http://localhost:8090';
251+
window.open(`${designerUrl}/?type=app&id=1&tenant=1&pageid=1`, '_blank');
250252
};
251253
252254
// 用户设置

0 commit comments

Comments
 (0)