mirror of
https://github.com/jekip/naive-ui-admin.git
synced 2026-02-04 13:42:27 +08:00
2.1.0-publish
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
- 优化 `登录页面` 排版
|
- 优化 `登录页面` 排版
|
||||||
- 新增 `构建分包策略`
|
- 新增 `构建分包策略`
|
||||||
|
- 新增 `useLocalSetting` hook
|
||||||
- 依赖升级
|
- 依赖升级
|
||||||
|
|
||||||
## 2.0.0
|
## 2.0.0
|
||||||
|
|||||||
@@ -49,6 +49,7 @@
|
|||||||
"@commitlint/config-conventional": "^17.8.1",
|
"@commitlint/config-conventional": "^17.8.1",
|
||||||
"@faker-js/faker": "^9.9.0",
|
"@faker-js/faker": "^9.9.0",
|
||||||
"@types/lodash": "^4.17.20",
|
"@types/lodash": "^4.17.20",
|
||||||
|
"@types/lodash-es": "^4.17.12",
|
||||||
"@types/node": "^18.19.122",
|
"@types/node": "^18.19.122",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
||||||
"@typescript-eslint/parser": "^5.62.0",
|
"@typescript-eslint/parser": "^5.62.0",
|
||||||
|
|||||||
3
pnpm-lock.yaml
generated
3
pnpm-lock.yaml
generated
@@ -75,6 +75,9 @@ importers:
|
|||||||
'@types/lodash':
|
'@types/lodash':
|
||||||
specifier: ^4.17.20
|
specifier: ^4.17.20
|
||||||
version: 4.17.20
|
version: 4.17.20
|
||||||
|
'@types/lodash-es':
|
||||||
|
specifier: ^4.17.12
|
||||||
|
version: 4.17.12
|
||||||
'@types/node':
|
'@types/node':
|
||||||
specifier: ^18.19.122
|
specifier: ^18.19.122
|
||||||
version: 18.19.122
|
version: 18.19.122
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import type { GlobConfig } from '/#/config';
|
import type { GlobConfig, LocalConfig } from '/#/config';
|
||||||
|
|
||||||
import { getAppEnvConfig } from '@/utils/env';
|
import { getAppEnvConfig } from '@/utils/env';
|
||||||
import { warn } from '@/utils/log';
|
import { warn } from '@/utils/log';
|
||||||
|
|
||||||
|
// 这里的 useGlobSetting 用于获取全局配置,以下环境变量 带 VITE_GLOB_开头 会打包到 app.config 中去
|
||||||
export const useGlobSetting = (): Readonly<GlobConfig> => {
|
export const useGlobSetting = (): Readonly<GlobConfig> => {
|
||||||
const {
|
const {
|
||||||
VITE_GLOB_APP_TITLE,
|
VITE_GLOB_APP_TITLE,
|
||||||
@@ -11,8 +12,6 @@ export const useGlobSetting = (): Readonly<GlobConfig> => {
|
|||||||
VITE_GLOB_API_URL_PREFIX,
|
VITE_GLOB_API_URL_PREFIX,
|
||||||
VITE_GLOB_UPLOAD_URL,
|
VITE_GLOB_UPLOAD_URL,
|
||||||
VITE_GLOB_FILE_URL,
|
VITE_GLOB_FILE_URL,
|
||||||
VITE_USE_MOCK,
|
|
||||||
VITE_LOGGER_MOCK,
|
|
||||||
} = getAppEnvConfig();
|
} = getAppEnvConfig();
|
||||||
|
|
||||||
if (!/[a-zA-Z\_]*/.test(VITE_GLOB_APP_SHORT_NAME)) {
|
if (!/[a-zA-Z\_]*/.test(VITE_GLOB_APP_SHORT_NAME)) {
|
||||||
@@ -22,15 +21,25 @@ export const useGlobSetting = (): Readonly<GlobConfig> => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Take global configuration
|
// Take global configuration
|
||||||
const glob: Readonly<GlobConfig> = {
|
return {
|
||||||
title: VITE_GLOB_APP_TITLE,
|
title: VITE_GLOB_APP_TITLE,
|
||||||
apiUrl: VITE_GLOB_API_URL,
|
apiUrl: VITE_GLOB_API_URL,
|
||||||
shortName: VITE_GLOB_APP_SHORT_NAME,
|
shortName: VITE_GLOB_APP_SHORT_NAME,
|
||||||
urlPrefix: VITE_GLOB_API_URL_PREFIX,
|
urlPrefix: VITE_GLOB_API_URL_PREFIX,
|
||||||
uploadUrl: VITE_GLOB_UPLOAD_URL,
|
uploadUrl: VITE_GLOB_UPLOAD_URL,
|
||||||
fileUrl: VITE_GLOB_FILE_URL,
|
fileUrl: VITE_GLOB_FILE_URL,
|
||||||
useMock: VITE_USE_MOCK === 'true',
|
|
||||||
loggerMock: VITE_LOGGER_MOCK === 'true',
|
|
||||||
};
|
};
|
||||||
return glob as Readonly<GlobConfig>;
|
};
|
||||||
|
|
||||||
|
// 这里的 useLocalSetting 用于获取本地配置,以下环境变量不会打包到 app.config 中去
|
||||||
|
export const useLocalSetting = (): Readonly<LocalConfig> => {
|
||||||
|
const { VITE_USE_MOCK, VITE_LOGGER_MOCK } = import.meta.env;
|
||||||
|
|
||||||
|
function strToBoolean(val): boolean {
|
||||||
|
return val === 'true';
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
useMock: strToBoolean(VITE_USE_MOCK),
|
||||||
|
loggerMock: strToBoolean(VITE_LOGGER_MOCK),
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,12 +6,14 @@ import { isString } from 'lodash-es';
|
|||||||
import mocks from './mocks';
|
import mocks from './mocks';
|
||||||
import { useUser } from '@/store/modules/user';
|
import { useUser } from '@/store/modules/user';
|
||||||
import { storage } from '@/utils/Storage';
|
import { storage } from '@/utils/Storage';
|
||||||
import { useGlobSetting } from '@/hooks/setting';
|
import { useGlobSetting, useLocalSetting } from '@/hooks/setting';
|
||||||
import { PageEnum } from '@/enums/pageEnum';
|
import { PageEnum } from '@/enums/pageEnum';
|
||||||
import { ResultEnum } from '@/enums/httpEnum';
|
import { ResultEnum } from '@/enums/httpEnum';
|
||||||
import { isUrl } from '@/utils';
|
import { isUrl } from '@/utils';
|
||||||
|
|
||||||
const { useMock, apiUrl, urlPrefix, loggerMock } = useGlobSetting();
|
const { apiUrl, urlPrefix } = useGlobSetting();
|
||||||
|
|
||||||
|
const { useMock, loggerMock } = useLocalSetting();
|
||||||
|
|
||||||
const mockAdapter = createAlovaMockAdapter([...mocks], {
|
const mockAdapter = createAlovaMockAdapter([...mocks], {
|
||||||
// 全局控制是否启用mock接口,默认为true
|
// 全局控制是否启用mock接口,默认为true
|
||||||
|
|||||||
7
types/config.d.ts
vendored
7
types/config.d.ts
vendored
@@ -52,8 +52,13 @@ export interface GlobConfig {
|
|||||||
shortName: string;
|
shortName: string;
|
||||||
urlPrefix?: string;
|
urlPrefix?: string;
|
||||||
uploadUrl?: string;
|
uploadUrl?: string;
|
||||||
useMock: boolean;
|
|
||||||
fileUrl?: string;
|
fileUrl?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LocalConfig {
|
||||||
|
// 生产环境开启 mock
|
||||||
|
useMock: boolean;
|
||||||
|
// 打印 mock 请求信息
|
||||||
loggerMock: boolean;
|
loggerMock: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
1
types/global.d.ts
vendored
1
types/global.d.ts
vendored
@@ -66,6 +66,7 @@ declare global {
|
|||||||
declare interface ViteEnv {
|
declare interface ViteEnv {
|
||||||
VITE_PORT: number;
|
VITE_PORT: number;
|
||||||
VITE_USE_MOCK: boolean;
|
VITE_USE_MOCK: boolean;
|
||||||
|
VITE_LOGGER_MOCK: boolean;
|
||||||
VITE_PUBLIC_PATH: string;
|
VITE_PUBLIC_PATH: string;
|
||||||
VITE_GLOB_APP_TITLE: string;
|
VITE_GLOB_APP_TITLE: string;
|
||||||
VITE_GLOB_APP_SHORT_NAME: string;
|
VITE_GLOB_APP_SHORT_NAME: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user