提交
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
// 从商品联邦模块导入领域层资源
|
||||
import {
|
||||
ProductApplicationService,
|
||||
HttpProductRepository,
|
||||
ProductRepository
|
||||
} from 'productModule/ProductDomain';
|
||||
import {HttpProductRepository, ProductApplicationService, ProductRepository} from 'product/ProductDomain';
|
||||
|
||||
/**
|
||||
* 商品领域的依赖注入配置
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
|
||||
import { productRouter } from 'productModule/ProductRouter'
|
||||
import {createRouter, createWebHistory, RouteRecordRaw} from 'vue-router'
|
||||
import {productRouter} from 'product/ProductRouter'
|
||||
|
||||
console.log("productRouter: ", productRouter)
|
||||
|
||||
const baseRouter: Array<RouteRecordRaw> = [
|
||||
{
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { defineComponent, reactive, onMounted } from 'vue'
|
||||
import {defineComponent, onMounted, reactive} from 'vue'
|
||||
import Header from '@/components/Header'
|
||||
import { HttpConfig } from '@shared/config/index'
|
||||
import { UrlCheckUtils } from '@shared/utils'
|
||||
import { useCounterStore } from '@/stores/counter'
|
||||
import { storeToRefs } from 'pinia'
|
||||
// @ts-ignore
|
||||
import {UrlCheckUtils} from 'shared/utils'
|
||||
import {useCounterStore} from '@/stores/counter'
|
||||
import {storeToRefs} from 'pinia'
|
||||
|
||||
interface stateType {
|
||||
list: ListItemType[]
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
export class HttpConfig {
|
||||
public static DevBaseUrl: string = "http://127.0.0.1:3000/api"
|
||||
public static prodBaseUrl: string = "http://127.0.0.1:3000/api/"
|
||||
public static apiList: string = ""
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
export class ThemeConfig {
|
||||
public static primaryColor: string = '#1890ff'; // 主色调
|
||||
public static layoutType: 'side' | 'top' = 'side'; // 侧边栏布局
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
# 临时占位,上传空文件夹,保存文件结构用,后面删除
|
||||
@@ -1 +0,0 @@
|
||||
# 临时占位,上传空文件夹,保存文件结构用,后面删除
|
||||
@@ -1,3 +0,0 @@
|
||||
export * from "./config/HttpConfig"
|
||||
export * from "./config/ThemeConfig"
|
||||
export { default as http } from "./infra/AxiosInfra"
|
||||
@@ -1,93 +0,0 @@
|
||||
import axios, { type AxiosInstance, AxiosError, type AxiosRequestConfig, type InternalAxiosRequestConfig } from "axios";
|
||||
import { UrlCheckUtils } from '@shared/utils/index'
|
||||
|
||||
|
||||
class AxiosInfra {
|
||||
public instance: AxiosInstance;
|
||||
|
||||
public constructor() {
|
||||
this.instance = axios.create({
|
||||
baseURL: UrlCheckUtils.check(),
|
||||
timeout: 10000,
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
});
|
||||
this.ResponseInterceptor();
|
||||
this.RequestInterceptor();
|
||||
}
|
||||
|
||||
public async get(params: AxiosRequestConfig): Promise<any> {
|
||||
return await this.instance.get(<string>params.url, {
|
||||
params: params.data,
|
||||
headers: Object.assign({ Authorization: localStorage.getItem("token") }, params.headers)
|
||||
});
|
||||
}
|
||||
|
||||
public async post(params: AxiosRequestConfig): Promise<any> {
|
||||
return await this.instance.post(<string>params.url, params.data, {
|
||||
headers: Object.assign({ Authorization: localStorage.getItem("token") }, params.headers)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Put 请求
|
||||
* 请求参数请参考接口:RequestParams
|
||||
* @param params
|
||||
*/
|
||||
public async put(params: AxiosRequestConfig): Promise<any> {
|
||||
return await this.instance.put(<string>params.url, params.data)
|
||||
}
|
||||
|
||||
/**
|
||||
* delete 请求
|
||||
* 请求参数请参考接口:RequestParams
|
||||
* @param params
|
||||
*/
|
||||
public async delete(params: AxiosRequestConfig): Promise<any> {
|
||||
return await this.instance.delete(<string>params.url, { params: params.data })
|
||||
}
|
||||
|
||||
/**
|
||||
* 响应拦截器
|
||||
* @constructor
|
||||
*/
|
||||
public async ResponseInterceptor(): Promise<any> {
|
||||
this.instance.interceptors.response.use(
|
||||
(response: any) => {
|
||||
return response.data.result;
|
||||
},
|
||||
(error: AxiosError) => {
|
||||
console.log(`
|
||||
❌ 请求错误 ❌
|
||||
1、基地址: ${error.config?.baseURL}
|
||||
2、短地址: ${error.config?.url}
|
||||
3、请求 方式: ${error.config?.method}
|
||||
4、请求 参数: ${JSON.stringify(error.config?.params)}
|
||||
5、请求 头 : ${JSON.stringify(error.config?.headers)}
|
||||
|
||||
------------------------------------------------------------
|
||||
|
||||
6、错误信息为: ${error.message}
|
||||
7、错误代码为: ${error.stack}
|
||||
`);
|
||||
return Promise.reject(error)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加请求拦截器
|
||||
* @constructor
|
||||
*/
|
||||
public async RequestInterceptor(): Promise<any> {
|
||||
this.instance.interceptors.request.use((config: any) => {
|
||||
return config
|
||||
}, function (error: AxiosError) {
|
||||
return Promise.reject(error)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
export default new AxiosInfra();
|
||||
@@ -1 +0,0 @@
|
||||
# 临时占位,上传空文件夹,保存文件结构用,后面删除
|
||||
@@ -1,6 +1,5 @@
|
||||
// 声明领域层类型
|
||||
declare module 'productModule/ProductDomain' {
|
||||
import type { DefineComponent } from 'vue';
|
||||
declare module 'product/ProductDomain' {
|
||||
// 商品实体类型(与联邦模块一致)
|
||||
export class Product {
|
||||
id: number;
|
||||
@@ -36,6 +35,6 @@ declare module 'productModule/ProductDomain' {
|
||||
// export const ProductDetail: DefineComponent; // 商品详情页
|
||||
// }
|
||||
|
||||
declare module 'productModule/ProductRouter' {
|
||||
declare module 'product/ProductRouter' {
|
||||
export const productRouter: RouteRecordRaw[];
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
declare module '*.vue' {
|
||||
import Vue from 'vue';
|
||||
export default Vue;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import { HttpConfig } from '@shared/config/HttpConfig'
|
||||
|
||||
export default class UrlCheckUtils {
|
||||
|
||||
public static check() {
|
||||
if (import.meta.env.MODE === 'production') {
|
||||
return HttpConfig.prodBaseUrl;
|
||||
} else {
|
||||
return HttpConfig.DevBaseUrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
import UrlCheckUtils from './UrlCheckUtils';
|
||||
|
||||
export { UrlCheckUtils };
|
||||
Reference in New Issue
Block a user