完成对app-shared 的拆分
This commit is contained in:
@@ -26,8 +26,8 @@
|
|||||||
## 开发任务
|
## 开发任务
|
||||||
|
|
||||||
- [x] 基于DDD理念改造
|
- [x] 基于DDD理念改造
|
||||||
- [ ] 【即将完成】基于 vite-plugin-federation 拆分领域模块为联邦模块,实现微前端
|
- [x] 基于 vite-plugin-federation 拆分领域模块为联邦模块,实现微前端
|
||||||
- [ ] 领域模块实现 docker自动化构建部署上线
|
- [ ] 领域模块实现 docker 自动化构建部署上线
|
||||||
- [ ] Deno集成GraphQL
|
- [ ] Deno集成GraphQL
|
||||||
|
|
||||||
## 文件夹结构
|
## 文件夹结构
|
||||||
@@ -39,8 +39,8 @@
|
|||||||
├── back-end # 【后端】基于Deno写的后端 测试接口,仅供测试
|
├── back-end # 【后端】基于Deno写的后端 测试接口,仅供测试
|
||||||
├── doc # 一些markdown笔记
|
├── doc # 一些markdown笔记
|
||||||
├── front-end # 前端 微服务 项目
|
├── front-end # 前端 微服务 项目
|
||||||
│ ├── app-car # 独立的【购物车】领域模块
|
|
||||||
│ ├── app-product # 独立的【商品】领域模块
|
│ ├── app-product # 独立的【商品】领域模块
|
||||||
|
│ ├── app-shared # 独立的 共享资源 模块
|
||||||
│ ├── .... # 实际项目还会有更多其他的领域模块
|
│ ├── .... # 实际项目还会有更多其他的领域模块
|
||||||
│ └── main-app # 主应用(入口应用)
|
│ └── main-app # 主应用(入口应用)
|
||||||
└── README.md # 帮助文档
|
└── README.md # 帮助文档
|
||||||
|
|||||||
@@ -7,10 +7,9 @@
|
|||||||
"node": "^20.19.0 || >=22.12.0"
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite --port 5001 --strictPort",
|
"dev": "concurrently \"npm run build\" \"npm run serve\"",
|
||||||
"serve": "vite preview --port 5001 --strictPort",
|
"serve": "vite preview --port 1301 --strictPort",
|
||||||
"build": "vite build",
|
"build": "vite build --watch",
|
||||||
"all": "npm run build && npm run serve",
|
|
||||||
"type-check": "vue-tsc --build"
|
"type-check": "vue-tsc --build"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
// 从商品联邦模块导入领域层资源
|
// 从商品联邦模块导入领域层资源
|
||||||
import {HttpProductRepository, ProductApplicationService, ProductRepository} from 'product/ProductDomain';
|
import {ProductRepository} from "@domains/product/ports/repositories/ProductRepository";
|
||||||
|
import {HttpProductRepository} from "@domains/product/infr/api/HttpProductRepository";
|
||||||
|
import {ProductApplicationService} from "@domains/product/application/services/ProductApplicationService";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品领域的依赖注入配置
|
* 商品领域的依赖注入配置
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { product } from 'mainApp/productService';
|
import {product} from '@domains/product/di/productModule';
|
||||||
import { ProductType } from '@domains/product/domain/type/ProductType';
|
import {ProductType} from '@domains/product/domain/type/ProductType';
|
||||||
import { defineComponent, onMounted, reactive } from 'vue'
|
import {defineComponent, onMounted, reactive} from 'vue'
|
||||||
import { useRoute } from 'vue-router'
|
import {useRoute} from 'vue-router'
|
||||||
|
|
||||||
interface storeType {
|
interface storeType {
|
||||||
item: ProductType
|
item: ProductType
|
||||||
@@ -9,7 +9,6 @@ interface storeType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "productModule-ProductDetail",
|
|
||||||
setup() {
|
setup() {
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const productService = product.createProductApplicationService();
|
const productService = product.createProductApplicationService();
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
import { defineComponent, onMounted, reactive } from 'vue'
|
import {defineComponent, onMounted, reactive} from 'vue'
|
||||||
import { useRouter } from 'vue-router';
|
import {useRouter} from 'vue-router';
|
||||||
import { product } from 'mainApp/productService';
|
import {product} from '@domains/product/di/productModule';
|
||||||
import { ProductType } from '@domains/product/domain/type/ProductType';
|
import {ProductType} from '@domains/product/domain/type/ProductType';
|
||||||
|
|
||||||
interface storeType {
|
interface storeType {
|
||||||
list: Array<ProductType>
|
list: Array<ProductType>
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "productModule-ProductList",
|
|
||||||
setup() {
|
setup() {
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -30,7 +29,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
return () => (
|
return () => (
|
||||||
<div class="ProductList">
|
<div class="ProductList">
|
||||||
<h1>商品领域模块 - 商品列表页面</h1>
|
<h1>商品领域模块 - 商品列表页面3</h1>
|
||||||
<hr />
|
<hr />
|
||||||
<h2>从Deno 后端 加载的数据,点击进详情</h2>
|
<h2>从Deno 后端 加载的数据,点击进详情</h2>
|
||||||
<ul>
|
<ul>
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
declare module 'mainApp/productService' {
|
|
||||||
export const product: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
declare module 'shared/infra' {
|
declare module 'shared/infra' {
|
||||||
export const http: any;
|
export const http: any;
|
||||||
}
|
}
|
||||||
@@ -6,12 +6,16 @@ import federation from '@originjs/vite-plugin-federation';
|
|||||||
import {fileURLToPath, URL} from "node:url";
|
import {fileURLToPath, URL} from "node:url";
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
|
server: {
|
||||||
|
port: 1301,
|
||||||
|
host: '0.0.0.0',
|
||||||
|
strictPort: true,
|
||||||
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
federation({
|
federation({
|
||||||
name: 'product',
|
name: 'product',
|
||||||
remotes: {
|
remotes: {
|
||||||
mainApp: "http://localhost:5000/assets/remoteEntry.js",
|
shared: 'http://localhost:1333/assets/remoteEntry.js'
|
||||||
shared: 'http://localhost:5555/assets/remoteEntry.js'
|
|
||||||
},
|
},
|
||||||
exposes: { // 暴露给主应用的资源(按功能分组)
|
exposes: { // 暴露给主应用的资源(按功能分组)
|
||||||
'./ProductDomain': './src/domains/product/index.ts', // 领域层(实体、服务、接口等)
|
'./ProductDomain': './src/domains/product/index.ts', // 领域层(实体、服务、接口等)
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite --port 5555 --strictPort",
|
"dev": "concurrently \"npm run build\" \"npm run serve\"",
|
||||||
"build": "vite build",
|
"serve": "vite preview --port 1333 --strictPort",
|
||||||
"serve": "vite preview --port 5555 --strictPort",
|
"build": "vite build --watch",
|
||||||
"all": "npm run build && npm run serve"
|
"type-check": "vue-tsc --build"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.12.2"
|
"axios": "^1.12.2"
|
||||||
|
|||||||
@@ -3,6 +3,11 @@ import federation from '@originjs/vite-plugin-federation';
|
|||||||
|
|
||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
|
server: {
|
||||||
|
port: 1333,
|
||||||
|
host: '0.0.0.0',
|
||||||
|
strictPort: true,
|
||||||
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
federation({
|
federation({
|
||||||
name: 'shared',
|
name: 'shared',
|
||||||
|
|||||||
@@ -7,10 +7,9 @@
|
|||||||
"node": "^20.19.0 || >=22.12.0"
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite --port 5000 --strictPort",
|
"dev": "concurrently \"npm run build\" \"npm run serve\"",
|
||||||
"serve": "vite preview --port 5000 --strictPort",
|
"serve": "vite preview --port 1300 --strictPort",
|
||||||
"build": "vite build",
|
"build": "vite build --watch",
|
||||||
"all": "npm run build && npm run serve",
|
|
||||||
"type-check": "vue-tsc --build"
|
"type-check": "vue-tsc --build"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import {createRouter, createWebHistory, RouteRecordRaw} from 'vue-router'
|
import {createRouter, createWebHistory, RouteRecordRaw} from 'vue-router'
|
||||||
import {productRouter} from 'product/ProductRouter'
|
import {productRouter} from 'product/ProductRouter'
|
||||||
|
|
||||||
console.log("productRouter: ", productRouter)
|
|
||||||
|
|
||||||
const baseRouter: Array<RouteRecordRaw> = [
|
const baseRouter: Array<RouteRecordRaw> = [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ import federation from '@originjs/vite-plugin-federation';
|
|||||||
|
|
||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
|
server: {
|
||||||
|
port: 1300,
|
||||||
|
host: '0.0.0.0',
|
||||||
|
strictPort: true,
|
||||||
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
vue(),
|
vue(),
|
||||||
vueJsx(),
|
vueJsx(),
|
||||||
@@ -15,11 +20,8 @@ export default defineConfig({
|
|||||||
federation({
|
federation({
|
||||||
name: 'mainApp', // 主应用模块名(联邦模块需通过此名引用)
|
name: 'mainApp', // 主应用模块名(联邦模块需通过此名引用)
|
||||||
remotes: { // 配置远程联邦模块地址(开发/生产需对应)
|
remotes: { // 配置远程联邦模块地址(开发/生产需对应)
|
||||||
product: 'http://localhost:5001/assets/remoteEntry.js',
|
product: 'http://localhost:1301/assets/remoteEntry.js',
|
||||||
shared: 'http://localhost:5555/assets/remoteEntry.js'
|
shared: 'http://localhost:1333/assets/remoteEntry.js'
|
||||||
},
|
|
||||||
exposes: {
|
|
||||||
"./productService": "./src/app/di/productModule.ts",
|
|
||||||
},
|
},
|
||||||
shared: {
|
shared: {
|
||||||
vue: { requiredVersion: '^3.5.18' },
|
vue: { requiredVersion: '^3.5.18' },
|
||||||
|
|||||||
Reference in New Issue
Block a user