Commit dfb3df3b by Lin

feat: 微应用修改配置

1 parent d33d1806
<script setup> <script setup>
import { onMounted, reactive, ref } from 'vue'; import { onMounted, reactive, ref } from 'vue';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { GLButton } from '@venus/common-ui-vue'; import { GLButton } from "@venus/common-ui-vue";
import { assistantList, assistantStatus } from '@/api/assistant'; import { assistantList, assistantStatus } from '@/api/assistant';
import { findDeptTree } from '@/api/dept'; import { findDeptTree } from '@/api/dept';
import { ElMessage } from 'element-plus'; import { ElMessage } from 'element-plus';
...@@ -198,8 +198,11 @@ const handleCurrentChange = (val) => { ...@@ -198,8 +198,11 @@ const handleCurrentChange = (val) => {
<!-- <el-button class="search-btn w-[60px] h-8" @click="handleSearch">查询</el-button> <!-- <el-button class="search-btn w-[60px] h-8" @click="handleSearch">查询</el-button>
<el-button class="w-[60px] h-8" @click="handleReset">重置</el-button> --> <el-button class="w-[60px] h-8" @click="handleReset">重置</el-button> -->
<GLButton class="search-btn w-[60px] h-8" @click="handleSearch">查询</GLButton> <GLButton class="search-btn w-[60px] h-8" @click="handleSearch">查询</GLButton>
<GLButton class="w-[60px] h-8" @click="handleReset">重置-</GLButton> <GLButton class="w-[60px] h-8" @click="handleReset">重置</GLButton>
<!-- <div <GLButton>
普通按钮
</GLButton>
<!-- <div
class="search-btn-custom w-[60px] h-8 rounded-[5px] border border-[#8baefe] bg-white flex items-center justify-center cursor-pointer text-[#1956FE] transition-all duration-200" class="search-btn-custom w-[60px] h-8 rounded-[5px] border border-[#8baefe] bg-white flex items-center justify-center cursor-pointer text-[#1956FE] transition-all duration-200"
@click="handleSearch" @click="handleSearch"
> >
......
import type { Plugin } from 'vite';
import { existsSync } from 'node:fs';
import { resolve } from 'node:path'; import { resolve } from 'node:path';
import vue from '@vitejs/plugin-vue'; import vue from '@vitejs/plugin-vue';
...@@ -9,7 +12,38 @@ import qiankun from 'vite-plugin-qiankun'; ...@@ -9,7 +12,38 @@ import qiankun from 'vite-plugin-qiankun';
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',
);
// 自定义插件:强制解析 @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(({ mode, command }) => { export default defineConfig(({ mode, command }) => {
const isDev = mode === 'development'; const isDev = mode === 'development';
const isServe = command === 'serve'; const isServe = command === 'serve';
...@@ -19,6 +53,7 @@ export default defineConfig(({ mode, command }) => { ...@@ -19,6 +53,7 @@ export default defineConfig(({ mode, command }) => {
return { return {
base: basePath, // 生产环境使用 /child/ 前缀作为基础路径,Vite 会自动应用到所有资源路径 base: basePath, // 生产环境使用 /child/ 前缀作为基础路径,Vite 会自动应用到所有资源路径
plugins: [ plugins: [
resolveWorkspacePackage(),
vue(), vue(),
vueJsx(), vueJsx(),
// 自动导入 Vue 相关函数 // 自动导入 Vue 相关函数
...@@ -39,14 +74,30 @@ export default defineConfig(({ mode, command }) => { ...@@ -39,14 +74,30 @@ export default defineConfig(({ mode, command }) => {
}), }),
], ],
resolve: { resolve: {
alias: { alias: [
'@': resolve(__dirname, 'src'), {
'@public': resolve(__dirname, 'public'), find: '@',
}, replacement: resolve(__dirname, 'src'),
conditions: ['development', 'browser', 'import'], },
{
find: '@public',
replacement: resolve(__dirname, 'public'),
},
{
find: '@venus/common-ui-vue',
replacement: resolve(
__dirname,
'../../../../packages/common-ui/vue-ui/src/index.ts',
),
},
],
// 设置条件导出优先使用 development
conditions: ['development', 'module', 'import', 'default'],
}, },
// 优化依赖预构建,排除 workspace 包
optimizeDeps: { optimizeDeps: {
exclude: ['jiti'], exclude: ['@venus/common-ui-vue', 'jiti'],
include: [],
}, },
server: { server: {
port: PORT, port: PORT,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!