mirror of
https://github.com/Tencent/tdesign-vue-next-starter.git
synced 2024-12-23 14:56:36 +08:00
Merge branch 'develop' of github.com:Tencent/tdesign-vue-next-starter into main
This commit is contained in:
commit
1138652bf4
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "tdesign-vue-next-starter",
|
"name": "tdesign-vue-next-starter",
|
||||||
"version": "0.3.0",
|
"version": "0.3.5",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev:mock": "vite --open --mode mock",
|
"dev:mock": "vite --open --mode mock",
|
||||||
"dev": "vite --open --mode development",
|
"dev": "vite --open --mode development",
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
"qrcode.vue": "^3.2.2",
|
"qrcode.vue": "^3.2.2",
|
||||||
"qs": "^6.10.5",
|
"qs": "^6.10.5",
|
||||||
"tdesign-icons-vue-next": "^0.1.1",
|
"tdesign-icons-vue-next": "^0.1.1",
|
||||||
"tdesign-vue-next": "0.17.3",
|
"tdesign-vue-next": "0.17.4",
|
||||||
"tvision-color": "^1.3.1",
|
"tvision-color": "^1.3.1",
|
||||||
"vue": "^3.2.31",
|
"vue": "^3.2.31",
|
||||||
"vue-clipboard3": "^2.0.0",
|
"vue-clipboard3": "^2.0.0",
|
||||||
|
|
19
src/api/detail.ts
Normal file
19
src/api/detail.ts
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import { request } from '@/utils/request';
|
||||||
|
import type { ProjectListResult, PurchaseListResult } from '@/api/model/detailModel';
|
||||||
|
|
||||||
|
const Api = {
|
||||||
|
PurchaseList: '/get-purchase-list',
|
||||||
|
ProjectList: '/get-project-list',
|
||||||
|
};
|
||||||
|
|
||||||
|
export function getPurchaseList() {
|
||||||
|
return request.get<PurchaseListResult>({
|
||||||
|
url: Api.PurchaseList,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getProjectList() {
|
||||||
|
return request.get<ProjectListResult>({
|
||||||
|
url: Api.ProjectList,
|
||||||
|
});
|
||||||
|
}
|
19
src/api/list.ts
Normal file
19
src/api/list.ts
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import { request } from '@/utils/request';
|
||||||
|
import type { CardListResult, ListResult } from '@/api/model/listModel';
|
||||||
|
|
||||||
|
const Api = {
|
||||||
|
BaseList: '/get-list',
|
||||||
|
CardList: '/get-card-list',
|
||||||
|
};
|
||||||
|
|
||||||
|
export function getList() {
|
||||||
|
return request.get<ListResult>({
|
||||||
|
url: Api.BaseList,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getCardList() {
|
||||||
|
return request.get<CardListResult>({
|
||||||
|
url: Api.CardList,
|
||||||
|
});
|
||||||
|
}
|
23
src/api/model/detailModel.ts
Normal file
23
src/api/model/detailModel.ts
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
export interface PurchaseListResult {
|
||||||
|
list: Array<PurchaseInfo>;
|
||||||
|
}
|
||||||
|
export interface PurchaseInfo {
|
||||||
|
adminName: string;
|
||||||
|
index: string;
|
||||||
|
pdName: string;
|
||||||
|
pdNum: string;
|
||||||
|
pdType: string;
|
||||||
|
purchaseNum: number;
|
||||||
|
updateTime: Date;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ProjectListResult {
|
||||||
|
list: Array<ProjectInfo>;
|
||||||
|
}
|
||||||
|
export interface ProjectInfo {
|
||||||
|
adminName: string;
|
||||||
|
adminPhone: string;
|
||||||
|
index: number;
|
||||||
|
name: string;
|
||||||
|
updateTime: Date;
|
||||||
|
}
|
26
src/api/model/listModel.ts
Normal file
26
src/api/model/listModel.ts
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
export interface ListResult {
|
||||||
|
list: Array<ListModel>;
|
||||||
|
}
|
||||||
|
export interface ListModel {
|
||||||
|
adminName: string;
|
||||||
|
amount: string;
|
||||||
|
contractType: number;
|
||||||
|
index: number;
|
||||||
|
name: string;
|
||||||
|
no: string;
|
||||||
|
paymentType: number;
|
||||||
|
status: number;
|
||||||
|
updateTime: Date;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CardListResult {
|
||||||
|
list: Array<CardList>;
|
||||||
|
}
|
||||||
|
export interface CardList {
|
||||||
|
banner: string;
|
||||||
|
description: string;
|
||||||
|
index: number;
|
||||||
|
isSetup: boolean;
|
||||||
|
name: string;
|
||||||
|
type: number;
|
||||||
|
}
|
|
@ -17,6 +17,11 @@ const crumbs = computed(() => {
|
||||||
pathArray.shift();
|
pathArray.shift();
|
||||||
|
|
||||||
const breadcrumbs = pathArray.reduce((breadcrumbArray, path, idx) => {
|
const breadcrumbs = pathArray.reduce((breadcrumbArray, path, idx) => {
|
||||||
|
// 如果路由下有hiddenBreadcrumb或当前遍历到参数则隐藏
|
||||||
|
if (route.matched[idx]?.meta?.hiddenBreadcrumb || Object.values(route.params).includes(path)) {
|
||||||
|
return breadcrumbArray;
|
||||||
|
}
|
||||||
|
|
||||||
breadcrumbArray.push({
|
breadcrumbArray.push({
|
||||||
path,
|
path,
|
||||||
to: breadcrumbArray[idx - 1] ? `/${breadcrumbArray[idx - 1].path}/${path}` : `/${path}`,
|
to: breadcrumbArray[idx - 1] ? `/${breadcrumbArray[idx - 1].path}/${path}` : `/${path}`,
|
||||||
|
|
|
@ -7,6 +7,10 @@ const getMenuList = (list: MenuRoute[], basePath?: string): MenuRoute[] => {
|
||||||
if (!list) {
|
if (!list) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
// 如果meta中有orderNo则按照从小到大排序
|
||||||
|
list.sort((a, b) => {
|
||||||
|
return (a.meta?.orderNo || 0) - (b.meta?.orderNo || 0);
|
||||||
|
});
|
||||||
return list
|
return list
|
||||||
.map((item) => {
|
.map((item) => {
|
||||||
const path = basePath ? `${basePath}/${item.path}` : item.path;
|
const path = basePath ? `${basePath}/${item.path}` : item.path;
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<t-badge :count="unreadMsg.length" :offset="[15, 21]">
|
<t-badge :count="unreadMsg.length" :offset="[12, 8]">
|
||||||
<t-button theme="default" shape="square" variant="text">
|
<t-button theme="default" shape="square" variant="text">
|
||||||
<t-icon name="mail" />
|
<t-icon name="mail" />
|
||||||
</t-button>
|
</t-button>
|
||||||
|
|
|
@ -41,14 +41,10 @@ export function constructInitDashboardDataset(type: string) {
|
||||||
{ type: 'min', name: '最小值' },
|
{ type: 'min', name: '最小值' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
itemStyle: {
|
|
||||||
normal: {
|
|
||||||
lineStyle: {
|
lineStyle: {
|
||||||
width: 2,
|
width: 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
return lineDataset;
|
return lineDataset;
|
||||||
|
@ -278,17 +274,13 @@ export function getLineChartDataSet({
|
||||||
symbol: 'circle',
|
symbol: 'circle',
|
||||||
symbolSize: 8,
|
symbolSize: 8,
|
||||||
itemStyle: {
|
itemStyle: {
|
||||||
normal: {
|
|
||||||
borderColor,
|
borderColor,
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
},
|
},
|
||||||
},
|
|
||||||
areaStyle: {
|
areaStyle: {
|
||||||
normal: {
|
|
||||||
opacity: 0.1,
|
opacity: 0.1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: '上月',
|
name: '上月',
|
||||||
data: inArray,
|
data: inArray,
|
||||||
|
@ -298,12 +290,10 @@ export function getLineChartDataSet({
|
||||||
symbol: 'circle',
|
symbol: 'circle',
|
||||||
symbolSize: 8,
|
symbolSize: 8,
|
||||||
itemStyle: {
|
itemStyle: {
|
||||||
normal: {
|
|
||||||
borderColor,
|
borderColor,
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
return dataSet;
|
return dataSet;
|
||||||
|
@ -352,7 +342,6 @@ export function getPieChartDataSet({
|
||||||
radius: ['48%', '60%'],
|
radius: ['48%', '60%'],
|
||||||
avoidLabelOverlap: true,
|
avoidLabelOverlap: true,
|
||||||
selectedMode: true,
|
selectedMode: true,
|
||||||
hoverAnimation: true,
|
|
||||||
silent: true,
|
silent: true,
|
||||||
itemStyle: {
|
itemStyle: {
|
||||||
borderColor: containerColor,
|
borderColor: containerColor,
|
||||||
|
@ -377,6 +366,7 @@ export function getPieChartDataSet({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
emphasis: {
|
emphasis: {
|
||||||
|
scale: true,
|
||||||
label: {
|
label: {
|
||||||
show: true,
|
show: true,
|
||||||
formatter: ['{value|{d}%}', '{name|{b}渠道占比}'].join('\n'),
|
formatter: ['{value|{d}%}', '{name|{b}渠道占比}'].join('\n'),
|
||||||
|
|
|
@ -188,12 +188,10 @@ export function getFolderLineDataSet({
|
||||||
],
|
],
|
||||||
type: 'line',
|
type: 'line',
|
||||||
itemStyle: {
|
itemStyle: {
|
||||||
normal: {
|
|
||||||
borderColor,
|
borderColor,
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
{
|
{
|
||||||
showSymbol: true,
|
showSymbol: true,
|
||||||
symbol: 'circle',
|
symbol: 'circle',
|
||||||
|
@ -211,12 +209,10 @@ export function getFolderLineDataSet({
|
||||||
],
|
],
|
||||||
type: 'line',
|
type: 'line',
|
||||||
itemStyle: {
|
itemStyle: {
|
||||||
normal: {
|
|
||||||
borderColor,
|
borderColor,
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
{
|
{
|
||||||
showSymbol: true,
|
showSymbol: true,
|
||||||
symbol: 'circle',
|
symbol: 'circle',
|
||||||
|
@ -234,12 +230,10 @@ export function getFolderLineDataSet({
|
||||||
],
|
],
|
||||||
type: 'line',
|
type: 'line',
|
||||||
itemStyle: {
|
itemStyle: {
|
||||||
normal: {
|
|
||||||
borderColor,
|
borderColor,
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
{
|
{
|
||||||
showSymbol: true,
|
showSymbol: true,
|
||||||
symbol: 'circle',
|
symbol: 'circle',
|
||||||
|
@ -257,12 +251,10 @@ export function getFolderLineDataSet({
|
||||||
],
|
],
|
||||||
type: 'line',
|
type: 'line',
|
||||||
itemStyle: {
|
itemStyle: {
|
||||||
normal: {
|
|
||||||
borderColor,
|
borderColor,
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,8 +120,7 @@ export default {
|
||||||
import { ref, onMounted } from 'vue';
|
import { ref, onMounted } from 'vue';
|
||||||
import { prefix } from '@/config/global';
|
import { prefix } from '@/config/global';
|
||||||
import { BASE_INFO_DATA, TABLE_COLUMNS_DATA as columns, PRODUCT_LIST } from './constants';
|
import { BASE_INFO_DATA, TABLE_COLUMNS_DATA as columns, PRODUCT_LIST } from './constants';
|
||||||
import { request } from '@/utils/request';
|
import { getPurchaseList } from '@/api/detail';
|
||||||
import { ResDataType } from '@/types/interface';
|
|
||||||
|
|
||||||
import Product from './components/Product.vue';
|
import Product from './components/Product.vue';
|
||||||
|
|
||||||
|
@ -145,15 +144,12 @@ const stepUpdate = () => {
|
||||||
|
|
||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
try {
|
try {
|
||||||
const res: ResDataType = await request.get({ url: '/api/get-purchase-list' });
|
const { list } = await getPurchaseList();
|
||||||
if (res.code === 0) {
|
|
||||||
const { list = [] } = res.data;
|
|
||||||
data.value = list;
|
data.value = list;
|
||||||
pagination.value = {
|
pagination.value = {
|
||||||
...pagination.value,
|
...pagination.value,
|
||||||
total: list.length,
|
total: list.length,
|
||||||
};
|
};
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,11 +82,9 @@ export function getSmoothLineDataSet({
|
||||||
symbol: 'circle',
|
symbol: 'circle',
|
||||||
symbolSize: 8,
|
symbolSize: 8,
|
||||||
areaStyle: {
|
areaStyle: {
|
||||||
normal: {
|
|
||||||
opacity: 0.1,
|
opacity: 0.1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: '本月',
|
name: '本月',
|
||||||
data: [
|
data: [
|
||||||
|
|
|
@ -89,8 +89,7 @@ import { BASE_INFO_DATA, TABLE_COLUMNS as columns } from './constants';
|
||||||
import { changeChartsTheme } from '@/utils/color';
|
import { changeChartsTheme } from '@/utils/color';
|
||||||
|
|
||||||
import { prefix } from '@/config/global';
|
import { prefix } from '@/config/global';
|
||||||
import { ResDataType } from '@/types/interface';
|
import { getProjectList } from '@/api/detail';
|
||||||
import { request } from '@/utils/request';
|
|
||||||
|
|
||||||
echarts.use([
|
echarts.use([
|
||||||
TitleComponent,
|
TitleComponent,
|
||||||
|
@ -115,15 +114,12 @@ const pagination = ref({
|
||||||
|
|
||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
try {
|
try {
|
||||||
const res: ResDataType = await request.get({ url: '/api/get-project-list' });
|
const { list } = await getProjectList();
|
||||||
if (res.code === 0) {
|
|
||||||
const { list = [] } = res.data;
|
|
||||||
data.value = list;
|
data.value = list;
|
||||||
pagination.value = {
|
pagination.value = {
|
||||||
...pagination.value,
|
...pagination.value,
|
||||||
total: list.length,
|
total: list.length,
|
||||||
};
|
};
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,8 +81,7 @@ import { MessagePlugin } from 'tdesign-vue-next';
|
||||||
|
|
||||||
import { CONTRACT_STATUS, CONTRACT_TYPES, CONTRACT_PAYMENT_TYPES } from '@/constants';
|
import { CONTRACT_STATUS, CONTRACT_TYPES, CONTRACT_PAYMENT_TYPES } from '@/constants';
|
||||||
import Trend from '@/components/trend/index.vue';
|
import Trend from '@/components/trend/index.vue';
|
||||||
import { ResDataType } from '@/types/interface';
|
import { getList } from '@/api/list';
|
||||||
import { request } from '@/utils/request';
|
|
||||||
import { useSettingStore } from '@/store';
|
import { useSettingStore } from '@/store';
|
||||||
|
|
||||||
import { COLUMNS } from './constants';
|
import { COLUMNS } from './constants';
|
||||||
|
@ -102,15 +101,12 @@ const dataLoading = ref(false);
|
||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
dataLoading.value = true;
|
dataLoading.value = true;
|
||||||
try {
|
try {
|
||||||
const res: ResDataType = await request.get({ url: '/api/get-list' });
|
const { list } = await getList();
|
||||||
if (res.code === 0) {
|
|
||||||
const { list = [] } = res.data;
|
|
||||||
data.value = list;
|
data.value = list;
|
||||||
pagination.value = {
|
pagination.value = {
|
||||||
...pagination.value,
|
...pagination.value,
|
||||||
total: list.length,
|
total: list.length,
|
||||||
};
|
};
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -73,8 +73,7 @@ import { SearchIcon } from 'tdesign-icons-vue-next';
|
||||||
import { MessagePlugin } from 'tdesign-vue-next';
|
import { MessagePlugin } from 'tdesign-vue-next';
|
||||||
import ProductCard from '@/components/product-card/index.vue';
|
import ProductCard from '@/components/product-card/index.vue';
|
||||||
import DialogForm from './components/DialogForm.vue';
|
import DialogForm from './components/DialogForm.vue';
|
||||||
import { request } from '@/utils/request';
|
import { getCardList } from '@/api/list';
|
||||||
import { ResDataType } from '@/types/interface';
|
|
||||||
|
|
||||||
const INITIAL_DATA = {
|
const INITIAL_DATA = {
|
||||||
name: '',
|
name: '',
|
||||||
|
@ -93,15 +92,12 @@ const dataLoading = ref(true);
|
||||||
|
|
||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
try {
|
try {
|
||||||
const res: ResDataType = await request.get({ url: '/api/get-card-list' });
|
const { list } = await getCardList();
|
||||||
if (res.code === 0) {
|
|
||||||
const { list = [] } = res.data;
|
|
||||||
productList.value = list;
|
productList.value = list;
|
||||||
pagination.value = {
|
pagination.value = {
|
||||||
...pagination.value,
|
...pagination.value,
|
||||||
total: list.length,
|
total: list.length,
|
||||||
};
|
};
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -116,8 +116,7 @@
|
||||||
import { ref, computed, onMounted } from 'vue';
|
import { ref, computed, onMounted } from 'vue';
|
||||||
import { MessagePlugin } from 'tdesign-vue-next';
|
import { MessagePlugin } from 'tdesign-vue-next';
|
||||||
import Trend from '@/components/trend/index.vue';
|
import Trend from '@/components/trend/index.vue';
|
||||||
import { request } from '@/utils/request';
|
import { getList } from '@/api/list';
|
||||||
import { ResDataType } from '@/types/interface';
|
|
||||||
import { useSettingStore } from '@/store';
|
import { useSettingStore } from '@/store';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -198,15 +197,12 @@ const dataLoading = ref(false);
|
||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
dataLoading.value = true;
|
dataLoading.value = true;
|
||||||
try {
|
try {
|
||||||
const res: ResDataType = await request.get({ url: '/api/get-list' });
|
const { list } = await getList();
|
||||||
if (res.code === 0) {
|
|
||||||
const { list = [] } = res.data;
|
|
||||||
data.value = list;
|
data.value = list;
|
||||||
pagination.value = {
|
pagination.value = {
|
||||||
...pagination.value,
|
...pagination.value,
|
||||||
total: list.length,
|
total: list.length,
|
||||||
};
|
};
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -77,12 +77,10 @@ export function getFolderLineDataSet({
|
||||||
],
|
],
|
||||||
type: 'line',
|
type: 'line',
|
||||||
itemStyle: {
|
itemStyle: {
|
||||||
normal: {
|
|
||||||
borderColor,
|
borderColor,
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
{
|
{
|
||||||
showSymbol: true,
|
showSymbol: true,
|
||||||
symbol: 'circle',
|
symbol: 'circle',
|
||||||
|
@ -100,12 +98,10 @@ export function getFolderLineDataSet({
|
||||||
],
|
],
|
||||||
type: 'line',
|
type: 'line',
|
||||||
itemStyle: {
|
itemStyle: {
|
||||||
normal: {
|
|
||||||
borderColor,
|
borderColor,
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
{
|
{
|
||||||
showSymbol: true,
|
showSymbol: true,
|
||||||
symbol: 'circle',
|
symbol: 'circle',
|
||||||
|
@ -123,12 +119,10 @@ export function getFolderLineDataSet({
|
||||||
],
|
],
|
||||||
type: 'line',
|
type: 'line',
|
||||||
itemStyle: {
|
itemStyle: {
|
||||||
normal: {
|
|
||||||
borderColor,
|
borderColor,
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
{
|
{
|
||||||
showSymbol: true,
|
showSymbol: true,
|
||||||
symbol: 'circle',
|
symbol: 'circle',
|
||||||
|
@ -146,12 +140,10 @@ export function getFolderLineDataSet({
|
||||||
],
|
],
|
||||||
type: 'line',
|
type: 'line',
|
||||||
itemStyle: {
|
itemStyle: {
|
||||||
normal: {
|
|
||||||
borderColor,
|
borderColor,
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,21 @@
|
||||||
import { useRoute, createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router';
|
import { useRoute, createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router';
|
||||||
|
|
||||||
import baseRouters from './modules/base';
|
// 自动导入modules文件夹下所有ts文件
|
||||||
import componentsRouters from './modules/components';
|
const modules = import.meta.globEager('./modules/**/*.ts');
|
||||||
import othersRouters from './modules/others';
|
|
||||||
|
// 路由暂存
|
||||||
|
const routeModuleList: Array<RouteRecordRaw> = [];
|
||||||
|
|
||||||
|
Object.keys(modules).forEach((key) => {
|
||||||
|
const mod = modules[key].default || {};
|
||||||
|
const modList = Array.isArray(mod) ? [...mod] : [mod];
|
||||||
|
routeModuleList.push(...modList);
|
||||||
|
});
|
||||||
|
|
||||||
// 关于单层路由,meta 中设置 { single: true } 即可为单层路由,{ hidden: true } 即可在侧边栏隐藏该路由
|
// 关于单层路由,meta 中设置 { single: true } 即可为单层路由,{ hidden: true } 即可在侧边栏隐藏该路由
|
||||||
|
|
||||||
// 存放动态路由
|
// 存放动态路由
|
||||||
export const asyncRouterList: Array<RouteRecordRaw> = [...baseRouters, ...componentsRouters, ...othersRouters];
|
export const asyncRouterList: Array<RouteRecordRaw> = [...routeModuleList];
|
||||||
|
|
||||||
// 存放固定的路由
|
// 存放固定的路由
|
||||||
const defaultRouterList: Array<RouteRecordRaw> = [
|
const defaultRouterList: Array<RouteRecordRaw> = [
|
||||||
|
|
4
src/types/axios.d.ts
vendored
4
src/types/axios.d.ts
vendored
|
@ -19,9 +19,7 @@ export interface RequestOptions {
|
||||||
|
|
||||||
export interface Result<T = any> {
|
export interface Result<T = any> {
|
||||||
code: number;
|
code: number;
|
||||||
type: 'success' | 'error' | 'warning';
|
data: T;
|
||||||
message: string;
|
|
||||||
result: T;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AxiosRequestConfigRetry extends AxiosRequestConfig {
|
export interface AxiosRequestConfigRetry extends AxiosRequestConfig {
|
||||||
|
|
7
src/types/globals.d.ts
vendored
7
src/types/globals.d.ts
vendored
|
@ -10,13 +10,6 @@ declare module '*.vue' {
|
||||||
|
|
||||||
declare type ClassName = { [className: string]: any } | ClassName[] | string;
|
declare type ClassName = { [className: string]: any } | ClassName[] | string;
|
||||||
|
|
||||||
declare interface ImportMeta {
|
|
||||||
env: {
|
|
||||||
MODE: 'mock' | 'development' | 'test' | 'release';
|
|
||||||
};
|
|
||||||
glob: (url: string) => { url };
|
|
||||||
}
|
|
||||||
|
|
||||||
declare module '*.svg' {
|
declare module '*.svg' {
|
||||||
const CONTENT: string;
|
const CONTENT: string;
|
||||||
export default CONTENT;
|
export default CONTENT;
|
||||||
|
|
5
src/types/interface.d.ts
vendored
5
src/types/interface.d.ts
vendored
|
@ -1,11 +1,6 @@
|
||||||
import { RouteRecordName } from 'vue-router';
|
import { RouteRecordName } from 'vue-router';
|
||||||
import STYLE_CONFIG from '@/config/style';
|
import STYLE_CONFIG from '@/config/style';
|
||||||
|
|
||||||
export interface ResDataType {
|
|
||||||
code: number;
|
|
||||||
data: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface MenuRoute {
|
export interface MenuRoute {
|
||||||
path: string;
|
path: string;
|
||||||
title?: string;
|
title?: string;
|
||||||
|
|
|
@ -40,16 +40,16 @@ const transform: AxiosTransform = {
|
||||||
throw new Error('请求接口错误');
|
throw new Error('请求接口错误');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 这里 message为 后台统一的字段,需要在 types.ts内修改为项目自己的接口返回格式
|
// 这里 code为 后台统一的字段,需要在 types.ts内修改为项目自己的接口返回格式
|
||||||
const { message } = data;
|
const { code } = data;
|
||||||
|
|
||||||
// 这里逻辑可以根据项目进行修改
|
// 这里逻辑可以根据项目进行修改
|
||||||
const hasSuccess = data && !Reflect.has(data, 'error');
|
const hasSuccess = data && code === 0;
|
||||||
if (hasSuccess) {
|
if (hasSuccess) {
|
||||||
return data;
|
return data.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error(message);
|
throw new Error(`请求接口错误, 错误码: ${code}`);
|
||||||
},
|
},
|
||||||
|
|
||||||
// 请求前处理配置
|
// 请求前处理配置
|
||||||
|
@ -162,7 +162,7 @@ function createAxios(opt?: Partial<CreateAxiosOptions>) {
|
||||||
// 接口地址
|
// 接口地址
|
||||||
apiUrl: host,
|
apiUrl: host,
|
||||||
// 是否自动添加接口前缀
|
// 是否自动添加接口前缀
|
||||||
isJoinPrefix: false,
|
isJoinPrefix: true,
|
||||||
// 接口前缀
|
// 接口前缀
|
||||||
// 例如: https://www.baidu.com/api
|
// 例如: https://www.baidu.com/api
|
||||||
// urlPrefix: '/api'
|
// urlPrefix: '/api'
|
||||||
|
|
|
@ -7,7 +7,10 @@
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
"lib": ["esnext", "dom"],
|
"lib": ["esnext", "dom"],
|
||||||
|
"types": ["vite/client"],
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"baseUrl": "./",
|
"baseUrl": "./",
|
||||||
"paths": {
|
"paths": {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user