Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
monorepo
/
venus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 1b9120f1
authored
Jan 22, 2026
by
Lin
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat: 依赖组件库导入优化
1 parent
9949661e
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
122 deletions
apps/web/venus-agentic/venus-agentic-assisant/src/main.ts
apps/web/venus-agentic/venus-agentic-assisant/vite.config.ts
apps/web/venus-agentic/venus-agentic-base/src/main.ts
apps/web/venus-agentic/venus-agentic-base/vite.config.ts
apps/web/venus-agentic/venus-agentic-assisant/src/main.ts
View file @
1b9120f
...
@@ -9,6 +9,7 @@ import {
...
@@ -9,6 +9,7 @@ import {
qiankunWindow
,
qiankunWindow
,
renderWithQiankun
,
renderWithQiankun
,
}
from
'vite-plugin-qiankun/dist/helper'
;
}
from
'vite-plugin-qiankun/dist/helper'
;
import
CommonUI
from
'@venus/common-ui-vue'
;
import
App
from
'./App.vue'
;
import
App
from
'./App.vue'
;
import
{
createRouter
}
from
'./router'
;
import
{
createRouter
}
from
'./router'
;
...
@@ -28,6 +29,9 @@ async function render(props: QiankunProps = {}) {
...
@@ -28,6 +29,9 @@ async function render(props: QiankunProps = {}) {
app
=
createApp
(
App
);
app
=
createApp
(
App
);
// 注册通用 UI 组件库
app
.
use
(
CommonUI
);
// 配置 Pinia
// 配置 Pinia
app
.
use
(
createPinia
());
app
.
use
(
createPinia
());
...
...
apps/web/venus-agentic/venus-agentic-assisant/vite.config.ts
View file @
1b9120f
...
@@ -19,39 +19,18 @@ const __dirname = dirname(__filename);
...
@@ -19,39 +19,18 @@ const __dirname = dirname(__filename);
const
PORT
=
8081
;
const
PORT
=
8081
;
const
APP_NAME
=
"assisant"
;
// 与基座配置的 name 一致
const
APP_NAME
=
"assisant"
;
// 与基座配置的 name 一致
// 获取源码路径
const
commonUiSourcePath
=
resolve
(
__dirname
,
"../../../../packages/common-ui/vue-ui/src/index.ts"
,
);
const
toolsSourcePath
=
resolve
(
const
toolsSourcePath
=
resolve
(
__dirname
,
__dirname
,
"../../../../packages/tools/src"
,
"../../../../packages/tools/src"
,
);
);
// 自定义插件:强制解析 workspace 包
// 自定义插件:强制解析
@venus/tools
workspace 包
function
resolveWorkspacePackage
():
Plugin
{
function
resolveWorkspacePackage
():
Plugin
{
return
{
return
{
name
:
"resolve-workspace-package"
,
name
:
"resolve-workspace-package"
,
enforce
:
"pre"
,
// 在其他插件之前执行
enforce
:
"pre"
,
// 在其他插件之前执行
resolveId
(
id
,
importer
)
{
resolveId
(
id
,
importer
)
{
// 解析 @venus/common-ui-vue
if
(
id
===
"@venus/common-ui-vue"
||
id
.
startsWith
(
"@venus/common-ui-vue/"
)
)
{
// 验证文件是否存在
if
(
existsSync
(
commonUiSourcePath
))
{
return
{
id
:
commonUiSourcePath
,
external
:
false
,
};
}
console
.
warn
(
`[resolve-workspace-package] 文件不存在:
${
commonUiSourcePath
}
`
,
);
}
// 解析 @venus/tools
// 解析 @venus/tools
if
(
id
.
startsWith
(
"@venus/tools/"
))
{
if
(
id
.
startsWith
(
"@venus/tools/"
))
{
const
subPath
=
id
.
replace
(
"@venus/tools/"
,
""
);
const
subPath
=
id
.
replace
(
"@venus/tools/"
,
""
);
...
@@ -177,23 +156,10 @@ export default defineConfig(({ mode, command }) => {
...
@@ -177,23 +156,10 @@ export default defineConfig(({ mode, command }) => {
}),
}),
],
],
resolve
:
{
resolve
:
{
alias
:
[
alias
:
{
{
"@"
:
resolve
(
__dirname
,
"src"
),
find
:
"@"
,
"@public"
:
resolve
(
__dirname
,
"public"
),
replacement
:
resolve
(
__dirname
,
"src"
),
},
{
find
:
"@public"
,
replacement
:
resolve
(
__dirname
,
"public"
),
},
},
{
find
:
"@venus/common-ui-vue"
,
replacement
:
resolve
(
__dirname
,
"../../../../packages/common-ui/vue-ui/src/index.ts"
,
),
},
],
// 设置条件导出优先使用 development
// 设置条件导出优先使用 development
conditions
:
[
"development"
,
"module"
,
"import"
,
"default"
],
conditions
:
[
"development"
,
"module"
,
"import"
,
"default"
],
},
},
...
...
apps/web/venus-agentic/venus-agentic-base/src/main.ts
View file @
1b9120f
import
{
createApp
}
from
'vue'
;
import
{
createApp
}
from
"vue"
;
import
{
createPinia
}
from
'pinia'
;
import
App
from
'./App.vue'
;
import
CommonUI
from
"@venus/common-ui-vue"
;
import
{
fetchConfig
}
from
'./config/center'
;
import
{
setupQiankun
}
from
'./qiankun'
;
import
{
createPinia
}
from
"pinia"
;
import
router
,
{
loadDynamicRoutes
}
from
'./router'
;
import
{
useAppStore
,
useUserStore
}
from
'./stores'
;
import
App
from
"./App.vue"
;
import
{
getToken
}
from
'./utils/auth'
;
import
{
fetchConfig
}
from
"./config/center"
;
import
{
auth
}
from
'./directives/auth'
;
import
{
auth
}
from
"./directives/auth"
;
import
'./styles/element/index.scss'
;
import
{
setupQiankun
}
from
"./qiankun"
;
import
'element-plus/dist/index.css'
;
import
router
,
{
loadDynamicRoutes
}
from
"./router"
;
import
'./style.css'
;
import
{
useAppStore
,
useUserStore
}
from
"./stores"
;
import
{
getToken
}
from
"./utils/auth"
;
import
"./styles/element/index.scss"
;
import
"element-plus/dist/index.css"
;
import
"./style.css"
;
// 创建应用实例
// 创建应用实例
const
app
=
createApp
(
App
);
const
app
=
createApp
(
App
);
// 注册通用 UI 组件库
app
.
use
(
CommonUI
);
// 注册权限指令
// 注册权限指令
app
.
directive
(
'auth'
,
auth
);
app
.
directive
(
"auth"
,
auth
);
// 创建 pinia 实例
// 创建 pinia 实例
const
pinia
=
createPinia
();
const
pinia
=
createPinia
();
...
@@ -48,7 +56,7 @@ async function initApp() {
...
@@ -48,7 +56,7 @@ async function initApp() {
}
}
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
'[基座] 应用初始化失败:'
,
error
);
console
.
error
(
"[基座] 应用初始化失败:"
,
error
);
}
}
}
}
...
@@ -65,10 +73,10 @@ function setupStoreSync() {
...
@@ -65,10 +73,10 @@ function setupStoreSync() {
// 监听主题变化,同步到 qiankun 全局状态
// 监听主题变化,同步到 qiankun 全局状态
appStore
.
$subscribe
((
_mutation
,
state
)
=>
{
appStore
.
$subscribe
((
_mutation
,
state
)
=>
{
import
(
'./qiankun/communication'
).
then
(({
communicationManager
})
=>
{
import
(
"./qiankun/communication"
).
then
(({
communicationManager
})
=>
{
communicationManager
.
updateTheme
({
communicationManager
.
updateTheme
({
mode
:
state
.
theme
,
mode
:
state
.
theme
,
primaryColor
:
state
.
theme
===
'dark'
?
'#177ddc'
:
'#1890ff'
,
primaryColor
:
state
.
theme
===
"dark"
?
"#177ddc"
:
"#1890ff"
,
});
});
});
});
});
});
...
@@ -76,16 +84,16 @@ function setupStoreSync() {
...
@@ -76,16 +84,16 @@ function setupStoreSync() {
// 获取配置中心配置
// 获取配置中心配置
fetchConfig
()
fetchConfig
()
.
then
((
config
)
=>
{
.
then
((
config
)
=>
{
console
.
log
(
'[基座] 当前配置数据:'
,
config
);
console
.
log
(
"[基座] 当前配置数据:"
,
config
);
})
})
.
catch
((
error
)
=>
{
.
catch
((
error
)
=>
{
console
.
error
(
'[基座] 配置中心配置获取失败:'
,
error
);
console
.
error
(
"[基座] 配置中心配置获取失败:"
,
error
);
})
})
.
finally
(()
=>
{
.
finally
(()
=>
{
// 初始化应用
// 初始化应用
initApp
().
then
(()
=>
{
initApp
().
then
(()
=>
{
// 挂载应用
// 挂载应用
app
.
mount
(
'#app'
);
app
.
mount
(
"#app"
);
// 设置 Store 同步机制
// 设置 Store 同步机制
setupStoreSync
();
setupStoreSync
();
...
...
apps/web/venus-agentic/venus-agentic-base/vite.config.ts
View file @
1b9120f
import
type
{
Plugin
}
from
'vite'
;
import
{
dirname
,
resolve
}
from
"node:path"
;
import
{
fileURLToPath
}
from
"node:url"
;
import
{
existsSync
}
from
'node:fs'
;
import
vue
from
"@vitejs/plugin-vue"
;
import
{
resolve
}
from
'node:path'
;
import
vueJsx
from
"@vitejs/plugin-vue-jsx"
;
import
AutoImport
from
"unplugin-auto-import/vite"
;
import
{
ElementPlusResolver
}
from
"unplugin-vue-components/resolvers"
;
import
Components
from
"unplugin-vue-components/vite"
;
import
{
defineConfig
}
from
"vite"
;
import
vue
from
'@vitejs/plugin-vue'
;
// 获取 __dirname 的 ES 模块兼容方式
import
vueJsx
from
'@vitejs/plugin-vue-jsx'
;
const
__filename
=
fileURLToPath
(
import
.
meta
.
url
);
import
AutoImport
from
'unplugin-auto-import/vite'
;
const
__dirname
=
dirname
(
__filename
);
import
{
ElementPlusResolver
}
from
'unplugin-vue-components/resolvers'
;
import
Components
from
'unplugin-vue-components/vite'
;
import
{
defineConfig
}
from
'vite'
;
// 获取源码路径
const
commonUiSourcePath
=
resolve
(
__dirname
,
'../../../../packages/common-ui/vue-ui/src/index.ts'
,
);
// 自定义插件:强制解析 @venus/common-ui-vue
function
resolveWorkspacePackage
():
Plugin
{
return
{
name
:
'resolve-workspace-package'
,
enforce
:
'pre'
,
// 在其他插件之前执行
resolveId
(
id
,
importer
)
{
// 精确匹配包名
if
(
id
===
'@venus/common-ui-vue'
||
id
.
startsWith
(
'@venus/common-ui-vue/'
)
)
{
// 验证文件是否存在
if
(
existsSync
(
commonUiSourcePath
))
{
return
{
id
:
commonUiSourcePath
,
external
:
false
,
};
}
console
.
warn
(
`[resolve-workspace-package] 文件不存在:
${
commonUiSourcePath
}
`
,
);
}
return
null
;
},
};
}
export
default
defineConfig
({
export
default
defineConfig
({
plugins
:
[
plugins
:
[
resolveWorkspacePackage
(),
vue
(),
vue
(),
vueJsx
(),
vueJsx
(),
AutoImport
({
AutoImport
({
imports
:
[
'vue'
,
'vue-router'
,
'pinia'
],
imports
:
[
"vue"
,
"vue-router"
,
"pinia"
],
resolvers
:
[
ElementPlusResolver
()
],
resolvers
:
[
ElementPlusResolver
()
],
dts
:
'src/auto-imports.d.ts'
,
dts
:
"src/auto-imports.d.ts"
,
}),
}),
Components
({
Components
({
resolvers
:
[
ElementPlusResolver
()
],
resolvers
:
[
ElementPlusResolver
()
],
dts
:
'src/components.d.ts'
,
dts
:
"src/components.d.ts"
,
}),
}),
],
],
resolve
:
{
resolve
:
{
alias
:
[
alias
:
{
{
"@"
:
resolve
(
__dirname
,
"src"
),
find
:
'@'
,
replacement
:
resolve
(
__dirname
,
'src'
),
},
},
{
// 配置条件导出优先级,让打包时也使用 development 模式的源码
find
:
'@venus/common-ui-vue'
,
conditions
:
[
"development"
,
"module"
,
"import"
,
"default"
],
replacement
:
resolve
(
__dirname
,
'../../../../packages/common-ui/vue-ui/src/index.ts'
,
),
},
],
// 设置条件导出优先使用 development
conditions
:
[
'development'
,
'module'
,
'import'
,
'default'
],
},
},
// 优化依赖预构建,排除 workspace 包
// 优化依赖预构建,排除 workspace 包
optimizeDeps
:
{
optimizeDeps
:
{
exclude
:
[
'@venus/common-ui-vue'
],
exclude
:
[
"@venus/common-ui-vue"
],
include
:
[],
include
:
[],
},
},
server
:
{
server
:
{
...
@@ -86,7 +44,7 @@ export default defineConfig({
...
@@ -86,7 +44,7 @@ export default defineConfig({
host
:
true
,
host
:
true
,
},
},
build
:
{
build
:
{
target
:
'esnext'
,
target
:
"esnext"
,
minify
:
false
,
minify
:
false
,
cssCodeSplit
:
false
,
cssCodeSplit
:
false
,
},
},
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment