Skip to content

Commit

Permalink
Merge branch 'main' of github.com:pure-admin/vue-pure-admin into feat…
Browse files Browse the repository at this point in the history
…/menu-manage
  • Loading branch information
xiaoxian521 committed Oct 22, 2023
2 parents 961bccb + 2a3fa34 commit fe96dae
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 10 deletions.
7 changes: 4 additions & 3 deletions build/info.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import type { Plugin } from "vite";
import picocolors from "picocolors";
import dayjs, { Dayjs } from "dayjs";
import utils from "@pureadmin/utils";
import { getPackageSize } from "./utils";
import duration from "dayjs/plugin/duration";
import { green, blue, bold } from "picocolors";
dayjs.extend(duration);

export function viteBuildInfo(): Plugin {
let config: { command: string };
let startTime: Dayjs;
let endTime: Dayjs;
let outDir: string;
const { green, blue, bold } = picocolors;
return {
name: "vite:buildInfo",
configResolved(resolvedConfig) {
Expand All @@ -33,7 +34,7 @@ export function viteBuildInfo(): Plugin {
closeBundle() {
if (config.command === "build") {
endTime = dayjs(new Date());
utils.getPackageSize({
getPackageSize({
folder: outDir,
callback: (size: string) => {
console.log(
Expand Down
2 changes: 1 addition & 1 deletion build/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { viteMockServe } from "vite-plugin-mock";
import { configCompressPlugin } from "./compress";
import { visualizer } from "rollup-plugin-visualizer";
import removeConsole from "vite-plugin-remove-console";
import themePreprocessorPlugin from "@pureadmin/theme";
import { themePreprocessorPlugin } from "@pureadmin/theme";
import VueI18nPlugin from "@intlify/unplugin-vue-i18n/vite";
import { genScssMultipleScopeVars } from "../src/layout/theme";

Expand Down
34 changes: 34 additions & 0 deletions build/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { readdir, stat } from "node:fs";
import { sum, formatBytes } from "@pureadmin/utils";

const fileListTotal: number[] = [];

/**
* @description 获取指定文件夹中所有文件的总大小
*/
export const getPackageSize = options => {
const { folder = "dist", callback, format = true } = options;
readdir(folder, (err, files: string[]) => {
if (err) throw err;
let count = 0;
const checkEnd = () => {
++count == files.length &&
callback(format ? formatBytes(sum(fileListTotal)) : sum(fileListTotal));
};
files.forEach((item: string) => {
stat(`${folder}/${item}`, async (err, stats) => {
if (err) throw err;
if (stats.isFile()) {
fileListTotal.push(stats.size);
checkEnd();
} else if (stats.isDirectory()) {
getPackageSize({
folder: `${folder}/${item}/`,
callback: checkEnd
});
}
});
});
files.length === 0 && callback(0);
});
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"@iconify-icons/ri": "^1.2.10",
"@iconify/vue": "^4.1.1",
"@intlify/unplugin-vue-i18n": "^1.4.0",
"@pureadmin/theme": "^3.1.0",
"@pureadmin/theme": "^3.2.0",
"@types/intro.js": "^5.1.2",
"@types/js-cookie": "^3.0.4",
"@types/mockjs": "^1.0.8",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/utils/http/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class PureHttp {
return config;
}
/** 请求白名单,放置一些不需要token的接口(通过设置请求白名单,防止token过期后再请求造成的死循环问题) */
const whiteList = ["/refreshToken", "/login"];
const whiteList = ["/refresh-token", "/login"];
return whiteList.find(url => url === config.url)
? config
: new Promise(resolve => {
Expand Down

0 comments on commit fe96dae

Please sign in to comment.