@yyp92-cli/template-react-pc 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/package.json +15 -0
- package/template/.env.development +5 -0
- package/template/.env.production +4 -0
- package/template/.env.test +4 -0
- package/template/.eslintrc.cjs +18 -0
- package/template/README.md +9 -0
- package/template/index.html +13 -0
- package/template/package.json +42 -0
- package/template/pnpm-lock.yaml +3583 -0
- package/template/public/vite.svg +1 -0
- package/template/src/antdTheme/darkTheme.ts +1 -0
- package/template/src/antdTheme/lightTheme.ts +68 -0
- package/template/src/app.scss +29 -0
- package/template/src/app.tsx +14 -0
- package/template/src/assets/iconfont/demo.css +539 -0
- package/template/src/assets/iconfont/demo_index.html +211 -0
- package/template/src/assets/iconfont/iconfont.css +19 -0
- package/template/src/assets/iconfont/iconfont.js +1 -0
- package/template/src/assets/iconfont/iconfont.json +16 -0
- package/template/src/assets/iconfont/iconfont.ttf +0 -0
- package/template/src/assets/iconfont/iconfont.woff +0 -0
- package/template/src/assets/iconfont/iconfont.woff2 +0 -0
- package/template/src/assets/react.svg +1 -0
- package/template/src/components/403/index.tsx +22 -0
- package/template/src/components/404/index.tsx +24 -0
- package/template/src/components/index.ts +3 -0
- package/template/src/components/layout/content/index.module.scss +22 -0
- package/template/src/components/layout/content/index.tsx +77 -0
- package/template/src/components/layout/footer/index.module.scss +12 -0
- package/template/src/components/layout/footer/index.tsx +15 -0
- package/template/src/components/layout/header/index.module.scss +21 -0
- package/template/src/components/layout/header/index.tsx +104 -0
- package/template/src/components/layout/index.module.scss +8 -0
- package/template/src/components/layout/index.tsx +59 -0
- package/template/src/components/layout/side/index.module.scss +31 -0
- package/template/src/components/layout/side/index.tsx +116 -0
- package/template/src/components/layout-horizontal/content/index.module.scss +22 -0
- package/template/src/components/layout-horizontal/content/index.tsx +73 -0
- package/template/src/components/layout-horizontal/footer/index.module.scss +12 -0
- package/template/src/components/layout-horizontal/footer/index.tsx +15 -0
- package/template/src/components/layout-horizontal/header/index.module.scss +23 -0
- package/template/src/components/layout-horizontal/header/index.tsx +105 -0
- package/template/src/components/layout-horizontal/index.module.scss +8 -0
- package/template/src/components/layout-horizontal/index.tsx +59 -0
- package/template/src/components/layout-horizontal/side/index.module.scss +32 -0
- package/template/src/components/layout-horizontal/side/index.tsx +115 -0
- package/template/src/components/login/index.module.scss +23 -0
- package/template/src/components/login/index.tsx +121 -0
- package/template/src/global/constants.ts +4 -0
- package/template/src/pages/home/index.module.scss +0 -0
- package/template/src/pages/home/index.tsx +85 -0
- package/template/src/router/router.tsx +164 -0
- package/template/src/service/api.ts +9 -0
- package/template/src/service/config.ts +9 -0
- package/template/src/service/index.ts +1 -0
- package/template/src/service/request/index.ts +265 -0
- package/template/src/service/request/type.ts +5 -0
- package/template/src/service/service.ts +27 -0
- package/template/src/store/login.ts +40 -0
- package/template/src/store/menus.ts +28 -0
- package/template/src/store/permission.ts +28 -0
- package/template/src/theme/darkTheme.scss +47 -0
- package/template/src/theme/lightTheme.scss +49 -0
- package/template/src/utils/base64ToBlob.ts +41 -0
- package/template/src/utils/cache.ts +44 -0
- package/template/src/utils/changeTheme.ts +14 -0
- package/template/src/utils/download.ts +45 -0
- package/template/src/utils/filterMenu.ts +34 -0
- package/template/src/utils/index.ts +5 -0
- package/template/src/vite-env.d.ts +5 -0
- package/template/tsconfig.json +45 -0
- package/template/tsconfig.node.json +10 -0
- package/template/vite.config.ts +49 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* * 用户信息
|
|
3
|
+
*/
|
|
4
|
+
import { create } from 'zustand'
|
|
5
|
+
import { persist } from 'zustand/middleware'
|
|
6
|
+
import { USER_INFO} from '@/global/constants'
|
|
7
|
+
|
|
8
|
+
type UserInfoStoreState = {
|
|
9
|
+
userInfo: {
|
|
10
|
+
userId: string,
|
|
11
|
+
userName: string
|
|
12
|
+
},
|
|
13
|
+
token: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type UserInfoStoreActions = {
|
|
17
|
+
setUserInfo: (
|
|
18
|
+
userInfo: UserInfoStoreState['userInfo']
|
|
19
|
+
) => void,
|
|
20
|
+
setToken: (token: string) => void
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type UserInfoStore = UserInfoStoreState & UserInfoStoreActions
|
|
24
|
+
|
|
25
|
+
export const userInfoStore = create<UserInfoStore>()(
|
|
26
|
+
persist(
|
|
27
|
+
(set) => ({
|
|
28
|
+
userInfo: {
|
|
29
|
+
userName: '小明',
|
|
30
|
+
userId: '111'
|
|
31
|
+
},
|
|
32
|
+
token: '',
|
|
33
|
+
setUserInfo: (userInfo) => set({userInfo}),
|
|
34
|
+
setToken: (token) => set({token})
|
|
35
|
+
}),
|
|
36
|
+
{
|
|
37
|
+
name: USER_INFO
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* * 用户菜单
|
|
3
|
+
*/
|
|
4
|
+
import { create } from 'zustand'
|
|
5
|
+
import { persist } from 'zustand/middleware'
|
|
6
|
+
import { MENUS} from '@/global/constants'
|
|
7
|
+
|
|
8
|
+
type MenusStoreState = {
|
|
9
|
+
menus: any[]
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type MenusStoreActions = {
|
|
13
|
+
setMenus: (menus: string[]) => void,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type MenusStore = MenusStoreState & MenusStoreActions
|
|
17
|
+
|
|
18
|
+
export const menusStore = create<MenusStore>()(
|
|
19
|
+
persist(
|
|
20
|
+
(set) => ({
|
|
21
|
+
menus: [],
|
|
22
|
+
setMenus: (menus) => set({menus})
|
|
23
|
+
}),
|
|
24
|
+
{
|
|
25
|
+
name: MENUS
|
|
26
|
+
}
|
|
27
|
+
)
|
|
28
|
+
)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* * 用户信息
|
|
3
|
+
*/
|
|
4
|
+
import { create } from 'zustand'
|
|
5
|
+
import { persist } from 'zustand/middleware'
|
|
6
|
+
import { PERMISSION} from '@/global/constants'
|
|
7
|
+
|
|
8
|
+
type PermissionStoreState = {
|
|
9
|
+
permissions: string[]
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type PermissionStoreActions = {
|
|
13
|
+
setPermissions: (permissions: string[]) => void,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type PermissionStore = PermissionStoreState & PermissionStoreActions
|
|
17
|
+
|
|
18
|
+
export const permissionStore = create<PermissionStore>()(
|
|
19
|
+
persist(
|
|
20
|
+
(set) => ({
|
|
21
|
+
permissions: [],
|
|
22
|
+
setPermissions: (permissions) => set({permissions})
|
|
23
|
+
}),
|
|
24
|
+
{
|
|
25
|
+
name: PERMISSION
|
|
26
|
+
}
|
|
27
|
+
)
|
|
28
|
+
)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
:root[data-theme="dark"] {
|
|
2
|
+
--primary-text-color: #FFFFFF;
|
|
3
|
+
--primary-white-color: #2A2A2D;
|
|
4
|
+
|
|
5
|
+
// 全局主色
|
|
6
|
+
--primary-color: #3591F4;
|
|
7
|
+
--primary-color1: rgba(53, 145, 244, 0.1);
|
|
8
|
+
// 链接色
|
|
9
|
+
--link-color: #3591F4;
|
|
10
|
+
// 成功色
|
|
11
|
+
--success-color: #0CAA43;
|
|
12
|
+
--success-color1: rgba(12, 170, 67, 0.1);
|
|
13
|
+
// 警告色
|
|
14
|
+
--warning-color: #FFA00A;
|
|
15
|
+
--warning-color1: rgba(255, 160, 10, 0.1);
|
|
16
|
+
// 错误色
|
|
17
|
+
--error-color: #F43835;
|
|
18
|
+
--error-color1: rgba(244, 56, 53, 0.1);
|
|
19
|
+
|
|
20
|
+
// 主文本色
|
|
21
|
+
--text-color: #FFFFFF;
|
|
22
|
+
// 次文本色
|
|
23
|
+
--text-color-secondary: #898D97;
|
|
24
|
+
|
|
25
|
+
// 白的背景
|
|
26
|
+
--bg-white-color: #1C1C1C;
|
|
27
|
+
--bg-grey-color: #161616;
|
|
28
|
+
--bg-grey-color1: transparent;
|
|
29
|
+
--bg-black2-color: #222222;
|
|
30
|
+
--bg-hover-color: rgba(53, 145, 244, 0.1);
|
|
31
|
+
--bg-white-color1: rgba(0, 0, 0, 0.5);
|
|
32
|
+
|
|
33
|
+
// 边框、输入框、分割线
|
|
34
|
+
--border-color-base: #2A2A2D;
|
|
35
|
+
// icon
|
|
36
|
+
--icon-color: #898D97;
|
|
37
|
+
|
|
38
|
+
// 主字号
|
|
39
|
+
--font-size-base: 14px;
|
|
40
|
+
|
|
41
|
+
// 组件/浮层圆角
|
|
42
|
+
--border-radius-base: 4px;
|
|
43
|
+
--modal-border-radius-base: 5px;
|
|
44
|
+
|
|
45
|
+
// 阴影
|
|
46
|
+
--box-shadow-color: #000000;
|
|
47
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
:root[data-theme="light"] {
|
|
2
|
+
--primary-text-color: #FFFFFF;
|
|
3
|
+
--primary-white-color: #FFFFFF;
|
|
4
|
+
|
|
5
|
+
// 全局主色
|
|
6
|
+
--primary-color: #3591F4;
|
|
7
|
+
--primary-color1: rgba(53, 145, 244, 0.1);
|
|
8
|
+
// 链接色
|
|
9
|
+
--link-color: var(--primary-color);
|
|
10
|
+
// 成功色
|
|
11
|
+
--success-color: #0CAA43;
|
|
12
|
+
--success-color1: rgba(12, 170, 67, 0.1);
|
|
13
|
+
// 警告色
|
|
14
|
+
--warning-color: #FFA00A;
|
|
15
|
+
--warning-color1: rgba(255, 160, 10, 0.1);
|
|
16
|
+
// 错误色
|
|
17
|
+
--error-color: #F43835;
|
|
18
|
+
--error-color1: rgba(244, 56, 53, 0.1);
|
|
19
|
+
|
|
20
|
+
// 主文本色
|
|
21
|
+
--text-color: #363A45;
|
|
22
|
+
// 次文本色
|
|
23
|
+
--text-color-secondary: #898D97;
|
|
24
|
+
|
|
25
|
+
// 白的背景
|
|
26
|
+
--bg-white-color: var(--primary-white-color);
|
|
27
|
+
--bg-grey-color: #F2F4F9;
|
|
28
|
+
--bg-grey-color1: var(--bg-grey-color);
|
|
29
|
+
--bg-black2-color: var(--primary-white-color);
|
|
30
|
+
--bg-hover-color: rgba(53, 145, 244, 0.1);
|
|
31
|
+
--bg-white-color1: rgba(255, 255, 255, 0.5);
|
|
32
|
+
|
|
33
|
+
// 边框、输入框、分割线
|
|
34
|
+
--border-color-base: #DDE6F0;
|
|
35
|
+
// icon
|
|
36
|
+
--icon-color: #CCD6DD;
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
// 主字号
|
|
41
|
+
--font-size-base: 14px;
|
|
42
|
+
|
|
43
|
+
// 组件/浮层圆角
|
|
44
|
+
--border-radius-base: 4px;
|
|
45
|
+
--modal-border-radius-base: 5px;
|
|
46
|
+
|
|
47
|
+
// 阴影
|
|
48
|
+
--box-shadow-color: #000000;
|
|
49
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { v4 as uuidv4 } from 'uuid'
|
|
2
|
+
|
|
3
|
+
export const base64ToBlob = (
|
|
4
|
+
base64String: any,
|
|
5
|
+
type: string,
|
|
6
|
+
fileName: string
|
|
7
|
+
) => {
|
|
8
|
+
type = type || 'png'
|
|
9
|
+
let base64Arr = [];
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
base64Arr = base64String?.split?.(",");
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
base64String = `data:image/${type || "png"};base64,` + base64String;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
base64Arr = base64String?.split(",");
|
|
19
|
+
|
|
20
|
+
let mime = base64Arr?.[0]?.match(/:(.*?);/)?.[1] || `image/${type}`;
|
|
21
|
+
// 去掉url的头,并转化为byte
|
|
22
|
+
let bytes = window.atob(base64Arr[1]);
|
|
23
|
+
// 处理异常,将ascii码小于0的转换为大于0
|
|
24
|
+
let ab = new window.ArrayBuffer(bytes.length);
|
|
25
|
+
// 生成视图(直接针对内存):8位无符号整数,长度1个字节
|
|
26
|
+
let ia = new window.Uint8Array(ab);
|
|
27
|
+
|
|
28
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
29
|
+
ia[i] = bytes.charCodeAt(i);
|
|
30
|
+
}
|
|
31
|
+
let dateTime = new Date();
|
|
32
|
+
let name = uuidv4();
|
|
33
|
+
const blobObject: any = new window.Blob([ab], {
|
|
34
|
+
type: mime,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
//禁止改动
|
|
38
|
+
blobObject.name = `${name}.${type}`;
|
|
39
|
+
|
|
40
|
+
return blobObject;
|
|
41
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
enum CacheType {
|
|
2
|
+
Local,
|
|
3
|
+
Session
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
class Cache {
|
|
7
|
+
storage: Storage
|
|
8
|
+
|
|
9
|
+
constructor(type: CacheType) {
|
|
10
|
+
this.storage = type === CacheType.Local
|
|
11
|
+
? localStorage
|
|
12
|
+
: sessionStorage
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
setCache(key: string, value: any) {
|
|
16
|
+
if (value) {
|
|
17
|
+
this.storage.setItem(key, JSON.stringify(value))
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
getCache(key: string) {
|
|
22
|
+
const value = this.storage.getItem(key)
|
|
23
|
+
|
|
24
|
+
if (value) {
|
|
25
|
+
return JSON.parse(value)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
removeCache(key: string) {
|
|
30
|
+
this.storage.removeItem(key)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
clear() {
|
|
34
|
+
this.storage.clear()
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const localCache = new Cache(CacheType.Local)
|
|
39
|
+
const sessionCache = new Cache(CacheType.Session)
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
localCache,
|
|
43
|
+
sessionCache
|
|
44
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// 主题切换
|
|
2
|
+
export const getDarkTheme = (isDark: boolean) => {
|
|
3
|
+
// 获取根元素
|
|
4
|
+
const root = document.documentElement;
|
|
5
|
+
|
|
6
|
+
if (!isDark) {
|
|
7
|
+
// 修改 data-theme 属性的值为 "light"
|
|
8
|
+
root.setAttribute('data-theme', 'light');
|
|
9
|
+
return
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// 修改 data-theme 属性的值为 "dark"
|
|
13
|
+
root.setAttribute('data-theme', 'dark');
|
|
14
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {isFunction} from 'lodash-es'
|
|
2
|
+
|
|
3
|
+
// 下载文件
|
|
4
|
+
export const downloadFile = (
|
|
5
|
+
output: any,
|
|
6
|
+
downloadFileName: string = '未命名文件',
|
|
7
|
+
handleCancel: () => void = () => {}
|
|
8
|
+
) => {
|
|
9
|
+
if (!output && isFunction(handleCancel)) {
|
|
10
|
+
handleCancel()
|
|
11
|
+
return
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
fetch(output, {responseType: 'blob'} as any)
|
|
15
|
+
.then((res: any) => res?.blob?.())
|
|
16
|
+
.then((res: any) => {
|
|
17
|
+
if ((window?.navigator as any)?.msSaveBlob) {
|
|
18
|
+
const suffix = output?.split?.('.')?.pop?.();
|
|
19
|
+
downloadFileName = downloadFileName === '未命名文件'
|
|
20
|
+
? downloadFileName + '.' + suffix
|
|
21
|
+
: downloadFileName;
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
(window?.navigator as any)?.msSaveBlob(res, downloadFileName);
|
|
25
|
+
}
|
|
26
|
+
catch(e) {
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
const link = document.createElement('a');
|
|
32
|
+
link.href = window.URL.createObjectURL(res);
|
|
33
|
+
link.download = downloadFileName;
|
|
34
|
+
link.style.display = 'none';
|
|
35
|
+
document.body.appendChild(link);
|
|
36
|
+
link.click();
|
|
37
|
+
}
|
|
38
|
+
}).catch(e => {
|
|
39
|
+
// console.error(e)
|
|
40
|
+
// handleCancel()
|
|
41
|
+
})
|
|
42
|
+
.finally(() => {
|
|
43
|
+
isFunction(handleCancel) && handleCancel()
|
|
44
|
+
})
|
|
45
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* * 根据权限来生成菜单
|
|
3
|
+
* @param menu
|
|
4
|
+
* @param permissions
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export const filterMenu = (menu: any[], permissions: string[]) => {
|
|
8
|
+
const newList: any = []
|
|
9
|
+
|
|
10
|
+
menu.forEach((group: any) => {
|
|
11
|
+
if (permissions.includes(group.key)) {
|
|
12
|
+
const data = {...group}
|
|
13
|
+
delete data.hideInMenu
|
|
14
|
+
delete data.showFullScreen
|
|
15
|
+
|
|
16
|
+
if (Array.isArray(data?.children)) {
|
|
17
|
+
const children = data.children
|
|
18
|
+
.filter((item: any) => permissions.includes(item.key) && !item?.hideInMenu)
|
|
19
|
+
.map((item: any) => {
|
|
20
|
+
const newItem = {...item}
|
|
21
|
+
delete newItem.hideInMenu
|
|
22
|
+
delete newItem.showFullScreen
|
|
23
|
+
|
|
24
|
+
return newItem
|
|
25
|
+
})
|
|
26
|
+
data.children = children
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
newList.push(data)
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
return newList
|
|
34
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"useDefineForClassFields": true,
|
|
5
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
|
|
9
|
+
/* Bundler mode */
|
|
10
|
+
/*
|
|
11
|
+
* 报错:配置文件报错及 React.StrictNode报错:类型“Element”的参数不能赋给类型“ReactNode”的参数
|
|
12
|
+
*
|
|
13
|
+
* 解决:
|
|
14
|
+
* 1.改为node
|
|
15
|
+
* 2.删除这行 "resolveJsonModule": true
|
|
16
|
+
*/
|
|
17
|
+
"moduleResolution": "node",
|
|
18
|
+
|
|
19
|
+
/*
|
|
20
|
+
* import 导入的react报错
|
|
21
|
+
* 解决: 增加这行:"esModuleInterop": true,
|
|
22
|
+
*/
|
|
23
|
+
"esModuleInterop": true,
|
|
24
|
+
"allowSyntheticDefaultImports": true,
|
|
25
|
+
"isolatedModules": true,
|
|
26
|
+
"noEmit": true,
|
|
27
|
+
"jsx": "react-jsx",
|
|
28
|
+
|
|
29
|
+
/* Linting */
|
|
30
|
+
"strict": true,
|
|
31
|
+
"noUnusedLocals": true,
|
|
32
|
+
"noUnusedParameters": true,
|
|
33
|
+
"noFallthroughCasesInSwitch": true,
|
|
34
|
+
|
|
35
|
+
"baseUrl": ".",
|
|
36
|
+
"paths": {
|
|
37
|
+
"@/*": ["src/*"],
|
|
38
|
+
"@components/*": ["src/components/*"],
|
|
39
|
+
"@utils/*": ["src/utils/*"]
|
|
40
|
+
// 其他路径别名...
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"include": ["src"],
|
|
44
|
+
"references": [{ "path": "./tsconfig.node.json" }]
|
|
45
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { defineConfig, loadEnv } from 'vite'
|
|
2
|
+
import type {ConfigEnv} from 'vite'
|
|
3
|
+
import react from '@vitejs/plugin-react'
|
|
4
|
+
import path from 'path'
|
|
5
|
+
|
|
6
|
+
// https://vitejs.dev/config/
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
base: './',
|
|
9
|
+
|
|
10
|
+
server: {
|
|
11
|
+
proxy: {
|
|
12
|
+
'/api': {
|
|
13
|
+
target: 'https://httpbin.org',
|
|
14
|
+
changeOrigin: true,
|
|
15
|
+
rewrite: (path) => path.replace(/^\/api/, '')
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
build: {
|
|
21
|
+
sourcemap: true,
|
|
22
|
+
outDir: 'dist'
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
plugins: [
|
|
26
|
+
react()
|
|
27
|
+
],
|
|
28
|
+
|
|
29
|
+
css: {
|
|
30
|
+
preprocessorOptions: {
|
|
31
|
+
scss: {
|
|
32
|
+
// 启用现代 API(关键配置)
|
|
33
|
+
api: 'modern-compiler'
|
|
34
|
+
},
|
|
35
|
+
sass: {
|
|
36
|
+
// sass 和 scss 都需要配置
|
|
37
|
+
api: 'modern-compiler'
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
resolve: {
|
|
43
|
+
alias: {
|
|
44
|
+
// 在这里添加路径别名
|
|
45
|
+
'@': path.resolve("./src")
|
|
46
|
+
// 其他路径别名...
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
})
|