optimize: ♻️ 自动更新访问地址 #9
|
@ -1,18 +1,18 @@
|
||||||
import type { Plugin } from 'vite';
|
import boxen, { type Options as BoxenOptions } from 'boxen';
|
||||||
import { getPackageSize } from './utils';
|
|
||||||
import dayjs, { type Dayjs } from 'dayjs';
|
import dayjs, { type Dayjs } from 'dayjs';
|
||||||
import duration from 'dayjs/plugin/duration';
|
import duration from 'dayjs/plugin/duration';
|
||||||
import gradientString from 'gradient-string';
|
import gradientString from 'gradient-string';
|
||||||
import boxen, { type Options as BoxenOptions } from 'boxen';
|
import type { Plugin } from 'vite';
|
||||||
|
import { loadEnv } from 'vite';
|
||||||
|
import { getPackageSize, root, wrapperEnv } from './utils';
|
||||||
|
|
||||||
dayjs.extend(duration);
|
dayjs.extend(duration);
|
||||||
|
const { VITE_PORT } = wrapperEnv(loadEnv('dev', root));
|
||||||
|
|
||||||
const welcomeMessage = gradientString('cyan', 'magenta').multiline(
|
const welcomeMessage = gradientString('cyan', 'magenta').multiline(
|
||||||
`您好! 欢迎使用 bunny-admin 后台管理
|
`您好! 欢迎使用 bunny 系列开发模板
|
||||||
项目开发访问地址如下:
|
项目访问地址如下:
|
||||||
http://localhost:6262/
|
http://localhost:${VITE_PORT}`,
|
||||||
项目生产访问地址如下:
|
|
||||||
http://localhost:6262/`,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const boxenOptions: BoxenOptions = {
|
const boxenOptions: BoxenOptions = {
|
||||||
|
@ -44,7 +44,14 @@ export function viteBuildInfo(): Plugin {
|
||||||
getPackageSize({
|
getPackageSize({
|
||||||
folder: outDir,
|
folder: outDir,
|
||||||
callback: (size: string) => {
|
callback: (size: string) => {
|
||||||
console.log(boxen(gradientString('cyan', 'magenta').multiline(`🎉 恭喜打包完成(总用时${dayjs.duration(endTime.diff(startTime)).format('mm分ss秒')},打包后的大小为${size})`), boxenOptions));
|
console.log(
|
||||||
|
boxen(
|
||||||
|
gradientString('cyan', 'magenta').multiline(
|
||||||
|
`🎉 恭喜打包完成(总用时${dayjs.duration(endTime.diff(startTime)).format('mm分ss秒')},打包后的大小为${size})`,
|
||||||
|
),
|
||||||
|
boxenOptions,
|
||||||
|
),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,22 @@
|
||||||
import { type ServerOptions } from 'vite';
|
import { loadEnv, type ServerOptions } from 'vite';
|
||||||
|
import { root, wrapperEnv } from './utils';
|
||||||
|
|
||||||
|
export const serverOptions = (mode: string) => {
|
||||||
|
const { VITE_APP_URL, VITE_APP_MOCK_URL, VITE_PORT } = wrapperEnv(loadEnv(mode, root));
|
||||||
|
|
||||||
export const serverOptions = () => {
|
|
||||||
const options: ServerOptions = {
|
const options: ServerOptions = {
|
||||||
port: 6261,
|
port: VITE_PORT,
|
||||||
host: '0.0.0.0',
|
host: '0.0.0.0',
|
||||||
open: true,
|
open: true,
|
||||||
cors: true,
|
cors: true,
|
||||||
proxy: {
|
proxy: {
|
||||||
'/api': {
|
'/api': {
|
||||||
target: process.env.VITE_APP_URL,
|
target: VITE_APP_URL,
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: (path: string) => path.replace(/^\/api/, '/api'),
|
rewrite: (path: string) => path.replace(/^\/api/, '/api'),
|
||||||
},
|
},
|
||||||
'/mock': {
|
'/mock': {
|
||||||
target: process.env.VITE_APP_MOCK_URL,
|
target: VITE_APP_MOCK_URL,
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: (path: string) => path.replace(/^\/mock/, '/mock'),
|
rewrite: (path: string) => path.replace(/^\/mock/, '/mock'),
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
import { Recordable, formatBytes, sum } from '@pureadmin/utils';
|
||||||
import { readdir, stat } from 'node:fs';
|
import { readdir, stat } from 'node:fs';
|
||||||
import { formatBytes, Recordable, sum } from '@pureadmin/utils';
|
|
||||||
import { fileURLToPath } from 'node:url';
|
|
||||||
import { dirname, resolve } from 'node:path';
|
import { dirname, resolve } from 'node:path';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
|
||||||
/** 启动`node`进程时所在工作目录的绝对路径 */
|
/** 启动`node`进程时所在工作目录的绝对路径 */
|
||||||
const root: string = process.cwd();
|
const root: string = process.cwd();
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import Request from "@/service/request-mock.ts";
|
import Request from '@/api/service/request-mock.ts';
|
||||||
|
|
||||||
export const fetchGetI18n = () => {
|
export const fetchGetI18n = () => {
|
||||||
return Request({
|
return Request({
|
||||||
url: "/getI18n",
|
url: '/getI18n',
|
||||||
method: "GET"
|
method: 'GET',
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { ResultEnum } from '@/enums/httpEnum';
|
import { ResultEnum } from '@/enums/httpEnum.ts';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
const request = axios.create({
|
const request = axios.create({
|
|
@ -1,4 +1,4 @@
|
||||||
import { ResultEnum } from '@/enums/httpEnum';
|
import { ResultEnum } from '@/enums/httpEnum.ts';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
const request = axios.create({
|
const request = axios.create({
|
|
@ -1,8 +0,0 @@
|
||||||
import Request from '@/service/request';
|
|
||||||
|
|
||||||
export const reqGetLoadBoard = () => {
|
|
||||||
return Request({
|
|
||||||
url: '/board/loadBoard',
|
|
||||||
method: 'GET',
|
|
||||||
});
|
|
||||||
};
|
|
|
@ -1,4 +1,4 @@
|
||||||
import Request from '@/service/request';
|
import Request from '@/api/service/request';
|
||||||
|
|
||||||
export const reqGetLoadBoard = () => {
|
export const reqGetLoadBoard = () => {
|
||||||
return Request({
|
return Request({
|
||||||
|
|
Loading…
Reference in New Issue