Merge pull request 'optimize: ♻️ 自动更新访问地址' (#9) from dev into master
Reviewed-on: #9 自动更新访问地址
This commit is contained in:
commit
318d56691e
|
@ -1,18 +1,18 @@
|
|||
import type { Plugin } from 'vite';
|
||||
import { getPackageSize } from './utils';
|
||||
import boxen, { type Options as BoxenOptions } from 'boxen';
|
||||
import dayjs, { type Dayjs } from 'dayjs';
|
||||
import duration from 'dayjs/plugin/duration';
|
||||
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);
|
||||
const { VITE_PORT } = wrapperEnv(loadEnv('dev', root));
|
||||
|
||||
const welcomeMessage = gradientString('cyan', 'magenta').multiline(
|
||||
`您好! 欢迎使用 bunny-admin 后台管理
|
||||
项目开发访问地址如下:
|
||||
http://localhost:6262/
|
||||
项目生产访问地址如下:
|
||||
http://localhost:6262/`,
|
||||
`您好! 欢迎使用 bunny 系列开发模板
|
||||
项目访问地址如下:
|
||||
http://localhost:${VITE_PORT}`,
|
||||
);
|
||||
|
||||
const boxenOptions: BoxenOptions = {
|
||||
|
@ -44,7 +44,14 @@ export function viteBuildInfo(): Plugin {
|
|||
getPackageSize({
|
||||
folder: outDir,
|
||||
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 = {
|
||||
port: 6261,
|
||||
port: VITE_PORT,
|
||||
host: '0.0.0.0',
|
||||
open: true,
|
||||
cors: true,
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: process.env.VITE_APP_URL,
|
||||
target: VITE_APP_URL,
|
||||
changeOrigin: true,
|
||||
rewrite: (path: string) => path.replace(/^\/api/, '/api'),
|
||||
},
|
||||
'/mock': {
|
||||
target: process.env.VITE_APP_MOCK_URL,
|
||||
target: VITE_APP_MOCK_URL,
|
||||
changeOrigin: true,
|
||||
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 { formatBytes, Recordable, sum } from '@pureadmin/utils';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { dirname, resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
/** 启动`node`进程时所在工作目录的绝对路径 */
|
||||
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 = () => {
|
||||
return Request({
|
||||
url: "/getI18n",
|
||||
method: "GET"
|
||||
});
|
||||
return Request({
|
||||
url: '/getI18n',
|
||||
method: 'GET',
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { ResultEnum } from '@/enums/httpEnum';
|
||||
import { ResultEnum } from '@/enums/httpEnum.ts';
|
||||
import axios from 'axios';
|
||||
|
||||
const request = axios.create({
|
|
@ -1,4 +1,4 @@
|
|||
import { ResultEnum } from '@/enums/httpEnum';
|
||||
import { ResultEnum } from '@/enums/httpEnum.ts';
|
||||
import axios from 'axios';
|
||||
|
||||
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 = () => {
|
||||
return Request({
|
||||
|
|
Loading…
Reference in New Issue