Skip to content

Commit

Permalink
2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jekip committed Sep 14, 2024
1 parent 1ae5372 commit 7a62de3
Show file tree
Hide file tree
Showing 62 changed files with 1,988 additions and 2,930 deletions.
3 changes: 0 additions & 3 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,3 @@ VITE_GLOB_APP_TITLE = AdminPro

# spa shortname
VITE_GLOB_APP_SHORT_NAME = AdminPro

# 生产环境 开启mock
VITE_GLOB_PROD_MOCK = true
18 changes: 9 additions & 9 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ VITE_PORT = 8001
# 网站根目录
VITE_PUBLIC_PATH = /

# 是否开启mock
# 是否开启 mock
VITE_USE_MOCK = true

# 网站前缀
VITE_BASE_URL = /
# 是否开启控制台打印 mock 请求信息
VITE_LOGGER_MOCK = true

# 是否删除console
VITE_DROP_CONSOLE = true
Expand All @@ -20,11 +20,11 @@ VITE_DROP_CONSOLE = true
# API 接口地址
VITE_GLOB_API_URL =

# 图片上传地址
VITE_GLOB_UPLOAD_URL=

# 图片前缀地址
VITE_GLOB_IMG_URL=

# 接口前缀
VITE_GLOB_API_URL_PREFIX = /api

# 文件上传地址
VITE_GLOB_UPLOAD_URL=

# 文件前缀地址
VITE_GLOB_FILE_URL=
9 changes: 3 additions & 6 deletions .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,21 @@ VITE_USE_MOCK = true
# 网站根目录
VITE_PUBLIC_PATH = /

# 网站前缀
VITE_BASE_URL = /

# 是否删除console
VITE_DROP_CONSOLE = true

# API
VITE_GLOB_API_URL =

# 接口前缀
VITE_GLOB_API_URL_PREFIX = /api

# 图片上传地址
VITE_GLOB_UPLOAD_URL=

# 图片前缀地址
VITE_GLOB_IMG_URL=

# 接口前缀
VITE_GLOB_API_URL_PREFIX = /api

# 是否启用gzip压缩或brotli压缩
# 可选: gzip | brotli | none
# 如果你需要多种形式,你可以用','来分隔
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# CHANGELOG

## 2.0.0

- 新增 `alova` 请求库
- 新增 `@faker-js/faker` 可配合 `mock` 数据模拟
- 新增 `VITE_USE_MOCK` 环境变量-开启 `mock`
- 新增 `demo` 实例,新增/编辑角色
- 移除 `axios` 请求封装,使用 `alova` 代替
- 移除 `vite-plugin-mock` 使用 `@alova/mock` 代替
- 移除 `VITE_GLOB_PROD_MOCK` 环境变量
- 变更 `VITE_GLOB_IMG_URL` 环境变量变更成 `VITE_GLOB_FILE_URL`
- 优化 `BasicTable` 组件相关样式
- 优化 `TS` 类型定义
- 依赖升级

## 1.9.2

- 升级 `vite``5.x` 版本
Expand Down
10 changes: 3 additions & 7 deletions build/vite/plugin/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import type { Plugin,PluginOption } from 'vite';
import type { Plugin, PluginOption } from 'vite';
import Components from 'unplugin-vue-components/vite';
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers';

import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';

import { configHtmlPlugin } from './html';
import { configMockPlugin } from './mock';
import { configCompressPlugin } from './compress';

export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean, prodMock) {
const { VITE_USE_MOCK, VITE_BUILD_COMPRESS, VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE } = viteEnv;
export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) {
const { VITE_BUILD_COMPRESS, VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE } = viteEnv;

const vitePlugins: (Plugin | Plugin[] | PluginOption[])[] = [
// have to
Expand All @@ -28,9 +27,6 @@ export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean, prodMock)
// vite-plugin-html
vitePlugins.push(configHtmlPlugin(viteEnv, isBuild));

// vite-plugin-mock
VITE_USE_MOCK && vitePlugins.push(configMockPlugin(isBuild, prodMock));

if (isBuild) {
// rollup-plugin-gzip
vitePlugins.push(
Expand Down
19 changes: 0 additions & 19 deletions build/vite/plugin/mock.ts

This file was deleted.

22 changes: 0 additions & 22 deletions mock/_createProductionServer.ts

This file was deleted.

54 changes: 27 additions & 27 deletions mock/dashboard/console.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
import { Random } from 'mockjs';
import { defineMock } from '@alova/mock';
import { faker } from '@faker-js/faker';
import { resultSuccess } from '../_util';

const consoleInfo = {
function getRandom(options) {
return Number(faker.commerce.price(options));
}

const result = {
//访问量
visits: {
dayVisits: Random.float(10000, 99999, 2, 2),
rise: Random.float(10, 99),
decline: Random.float(10, 99),
amount: Random.float(99999, 999999, 3, 5),
dayVisits: getRandom({ min: 10000, max: 99999, dec: 2 }),
rise: getRandom({ min: 10000, max: 99999, dec: 0 }),
decline: getRandom({ min: 10000, max: 99999, dec: 0 }),
amount: getRandom({ min: 10000, max: 99999, dec: 2 }),
},
//销售额
saleroom: {
weekSaleroom: Random.float(10000, 99999, 2, 2),
amount: Random.float(99999, 999999, 2, 2),
degree: Random.float(10, 99),
weekSaleroom: getRandom({ min: 10000, max: 99999, dec: 2 }),
amount: getRandom({ min: 10000, max: 99999, dec: 2 }),
degree: getRandom({ min: 10000, max: 99999, dec: 0 }),
},
//订单量
orderLarge: {
weekLarge: Random.float(10000, 99999, 2, 2),
rise: Random.float(10, 99),
decline: Random.float(10, 99),
amount: Random.float(99999, 999999, 2, 2),
weekLarge: getRandom({ min: 10000, max: 99999, dec: 2 }),
rise: getRandom({ min: 10000, max: 99999, dec: 0 }),
decline: getRandom({ min: 10000, max: 99999, dec: 0 }),
amount: getRandom({ min: 10000, max: 99999, dec: 2 }),
},
//成交额度
volume: {
weekLarge: Random.float(10000, 99999, 2, 2),
rise: Random.float(10, 99),
decline: Random.float(10, 99),
amount: Random.float(99999, 999999, 2, 2),
weekLarge: getRandom({ min: 10000, max: 99999, dec: 2 }),
rise: getRandom({ min: 10000, max: 99999, dec: 0 }),
decline: getRandom({ min: 10000, max: 99999, dec: 0 }),
amount: getRandom({ min: 10000, max: 99999, dec: 2 }),
},
};

export default [
//主控台 卡片数据
{
url: '/api/dashboard/console',
timeout: 1000,
method: 'get',
response: () => {
return resultSuccess(consoleInfo);
},
export default defineMock({
// 主控台数据
'/api/dashboard/console': () => {
return resultSuccess(result);
},
];
});
33 changes: 20 additions & 13 deletions mock/system/menu.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import { defineMock } from '@alova/mock';
import { resultSuccess } from '../_util';

export interface ListDate {
label: string;
key: string;
type: number;
subtitle: string;
openType: number;
auth: string;
path: string;
children?: ListDate[];
}

const menuList = () => {
const result: any[] = [
const result: ListDate[] = [
{
label: 'Dashboard',
key: 'dashboard',
Expand Down Expand Up @@ -74,16 +86,11 @@ const menuList = () => {
return result;
};

export default [
{
url: '/api/menu/list',
timeout: 1000,
method: 'get',
response: () => {
const list = menuList();
return resultSuccess({
list,
});
},
export default defineMock({
'/api/menu/list': () => {
const list = menuList();
return resultSuccess({
list,
});
},
];
});
48 changes: 24 additions & 24 deletions mock/system/role.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { defineMock } from '@alova/mock';
import { faker } from '@faker-js/faker';
import { resultSuccess, doCustomTimes } from '../_util';

import dayjs from 'dayjs';
function getMenuKeys() {
const keys = ['dashboard', 'console', 'workplace', 'basic-form', 'step-form', 'detail'];
const newKeys = [];
doCustomTimes(parseInt(Math.random() * 6), () => {
const key = keys[Math.floor(Math.random() * keys.length)];
newKeys.push(key);
newKeys.push(key as never);
});
return Array.from(new Set(newKeys));
}
Expand All @@ -14,32 +16,30 @@ const roleList = (pageSize) => {
const result: any[] = [];
doCustomTimes(pageSize, () => {
result.push({
id: '@integer(10,100)',
name: '@cname()',
explain: '@cname()',
isDefault: '@boolean()',
id: faker.string.numeric(4),
name: faker.person.firstName(),
explain: faker.lorem.sentence({ min: 2, max: 4 }),
isDefault: faker.helpers.arrayElement([true, false]),
menu_keys: getMenuKeys(),
create_date: `@date('yyyy-MM-dd hh:mm:ss')`,
'status|1': ['normal', 'enable', 'disable'],
create_date: dayjs(faker.date.anytime()).format('YYYY-MM-DD HH:mm'),
status: faker.helpers.arrayElement(['normal', 'enable', 'disable']),
});
});
return result;
};

export default [
{
url: '/api/role/list',
timeout: 1000,
method: 'get',
response: ({ query }) => {
const { page = 1, pageSize = 10 } = query;
const list = roleList(Number(pageSize));
return resultSuccess({
page: Number(page),
pageSize: Number(pageSize),
pageCount: 60,
list,
});
},
export default defineMock({
'/api/role/list': ({ query }) => {
const { page = 1, pageSize = 10, name } = query;
const list = roleList(Number(pageSize));
// 并非真实,只是为了模拟搜索结果
const count = name ? 30 : 60;
return resultSuccess({
page: Number(page),
pageSize: Number(pageSize),
pageCount: count,
itemCount: count * Number(pageSize),
list,
});
},
];
});
Loading

0 comments on commit 7a62de3

Please sign in to comment.