实现 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

@@ -10,7 +10,7 @@
<body>
<div id="app"></div>
<script src="/src/index.ts" type="module"></script>
<script src="/src/main.ts" type="module"></script>
</body>
</html>

View File

@@ -22,6 +22,7 @@
},
"devDependencies": {
"@vitejs/plugin-vue": "^6.0.1",
"@vitejs/plugin-vue-jsx": "^5.1.1",
"rollup-plugin-visualizer": "^6.0.3",
"typescript": "~5.8.3",
"vite": "^7.1.6"

View File

@@ -0,0 +1,24 @@
import { defineComponent, onMounted } from 'vue'
export default defineComponent({
setup() {
onMounted({})
return () => (
<>
<div class="order-federation-placeholder">
<h2>-</h2>
<p>
</p>
{/*<h2>本模块包含的功能:</h2>*/ }
{/*<ul>*/ }
{/* <li>1获取商品首页的数据和展示</li>*/ }
{/* <li>2点击视频进入详情页</li>*/ }
{/*</ul>*/ }
{/*<p></p>*/ }
</div>
</>
)
}
})

View File

@@ -1,9 +1,9 @@
export class HttpConfig {
// public static DevBaseUrl: string = "http://127.0.0.1:3210/api"
public static DevBaseUrl: string = import.meta.env.VITE_DEVBASEURL
public static DevBaseUrl: string = window.__APP_CONFIG__.VITE_DEVBASEURL
// public static ProdBaseUrl: string = "http://127.0.0.1:3210/api/"
public static ProdBaseUrl: string = import.meta.env.VITE_PRODBASEURL
public static ProdBaseUrl: string = window.__APP_CONFIG__.VITE_PRODBASEURL
public static apiList: string = ""
}

View File

@@ -7,14 +7,13 @@ import axios, {
} from "axios";
import { UrlCheckUtils } from '../utils/index'
class AxiosInfra {
public instance: AxiosInstance;
public constructor() {
this.instance = axios.create({
baseURL: UrlCheckUtils.check(),
timeout: Number(import.meta.env.VITE_HTTPTIMEOUT),
timeout: Number(window.__APP_CONFIG__.VITE_HTTPTIMEOUT),
headers: {
"Content-Type": "application/json"
}

View File

@@ -0,0 +1,8 @@
import { createApp } from 'vue'
import App from './App'
createApp(App)
.mount('#app')

View File

@@ -0,0 +1,13 @@
export interface AppConfig {
VITE_DEVBASEURL: string;
VITE_PRODBASEURL: string;
VITE_HTTPTIMEOUT: string;
}
declare global {
interface Window {
__APP_CONFIG__: AppConfig;
}
}
export {};

View File

@@ -16,6 +16,8 @@
"DOM",
"DOM.Iterable"
],
"jsx": "preserve",
"jsxImportSource": "vue",
"module": "ESNext",
"moduleResolution": "bundler",
"esModuleInterop": true,

View File

@@ -1,14 +1,18 @@
import { defineConfig, loadEnv, UserConfig } from 'vite'
import federation from "@originjs/vite-plugin-federation";
import { nacosRegVitePlugin } from "nacos-federation";
// @ts-ignore
import vueJsx from '@vitejs/plugin-vue-jsx'
// @ts-ignore
import vue from '@vitejs/plugin-vue';
import visualizer from 'rollup-plugin-visualizer';
export default defineConfig(async ({ mode }): Promise<UserConfig> => {
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',
@@ -16,7 +20,7 @@ export default defineConfig(async ({ mode }): Promise<UserConfig> => {
cors: true
},
plugins: [
nacosRegVitePlugin(),
// nacosRegVitePlugin(),
federation({
name: env.VITE_SERVER_NAME,
exposes: {
@@ -34,6 +38,7 @@ export default defineConfig(async ({ mode }): Promise<UserConfig> => {
}
}),
vue(),
vueJsx(),
visualizer({
title: "共享模块依赖分析",
filename: 'dist/stats.html', // 分析文件输出路径
@@ -47,7 +52,6 @@ export default defineConfig(async ({ mode }): Promise<UserConfig> => {
minify: false,
cssCodeSplit: true,
rollupOptions: {
input: './src/index.ts',
output: {
format: 'esm',
minifyInternalExports: false