实现 nacos 的分布式集群部署配置

This commit is contained in:
编码猿
2025-09-29 05:07:42 +08:00
parent ced7662d98
commit 04754a1f77
82 changed files with 991 additions and 62852 deletions

View File

@@ -22,6 +22,7 @@ export default defineComponent({
onMounted(() => {
loadProductList()
})

View File

@@ -5,6 +5,7 @@ import { createPinia } from 'pinia'
import App from './App'
createApp(App)
.use(createPinia())
.mount('#app')

View File

@@ -4,13 +4,13 @@ import vueJsx from '@vitejs/plugin-vue-jsx'
import vueDevTools from 'vite-plugin-vue-devtools'
import federation from '@originjs/vite-plugin-federation';
import { fileURLToPath, URL } from "node:url";
import { nacosRegVitePlugin } from "nacos-federation";
import { visualizer } from 'rollup-plugin-visualizer';
export default defineConfig(async ({ mode }) => {
const env = loadEnv(mode, process.cwd());
return {
base: `${ env.VITE_PREFIX }${ env.VITE_TRAEFIK_ADDRESS }/${ env.VITE_SERVER_NAME }`,
server: {
port: Number(env.VITE_SERVER_PORT),
host: '0.0.0.0',
@@ -18,11 +18,11 @@ export default defineConfig(async ({ mode }) => {
cors: true
},
plugins: [
nacosRegVitePlugin(),
// nacosRegVitePlugin(),
federation({
name: env.VITE_SERVER_NAME,
remotes: {
shared: `http://${ env.VITE_TRAEFIK_ADDRESS }/${ env.VITE_MODEL_SHARED_NAME }/assets/remoteEntry.js`
shared: `${ env.VITE_PREFIX }${ env.VITE_TRAEFIK_ADDRESS }/${ env.VITE_MODEL_SHARED_NAME }/assets/remoteEntry.js`
},
exposes: { // 暴露给主应用的资源(按功能分组)
'./ProductDomain': './src/domains/product/index.ts', // 领域层(实体、服务、接口等)