@yyp92-cli/template-react-pc 2.2.0 → 2.4.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 +79 -0
- package/package.json +1 -4
- 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 +15 -0
- package/template/gitignore.template +24 -0
- package/template/index.html +13 -0
- package/template/package.json +42 -0
- package/template/pnpm-lock.yaml +3570 -0
- package/template/public/vite.svg +1 -0
- package/template/src/antdTheme/darkTheme.ts +285 -0
- package/template/src/antdTheme/lightTheme.ts +286 -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 +109 -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 +115 -0
- package/template/src/components/layout/index.module.scss +8 -0
- package/template/src/components/layout/index.tsx +47 -0
- package/template/src/components/layout/side/index.module.scss +31 -0
- package/template/src/components/layout/side/index.tsx +109 -0
- package/template/src/components/layout-horizontal/content/index.module.scss +22 -0
- package/template/src/components/layout-horizontal/content/index.tsx +105 -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 +115 -0
- package/template/src/components/layout-horizontal/index.module.scss +8 -0
- package/template/src/components/layout-horizontal/index.tsx +48 -0
- package/template/src/components/layout-horizontal/side/index.module.scss +32 -0
- package/template/src/components/layout-horizontal/side/index.tsx +104 -0
- package/template/src/components/login/index.module.scss +23 -0
- package/template/src/components/login/index.tsx +133 -0
- package/template/src/global/constants.ts +5 -0
- package/template/src/pages/home/index.module.scss +0 -0
- package/template/src/pages/home/index.tsx +90 -0
- package/template/src/router/router.tsx +190 -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 +267 -0
- package/template/src/service/request/type.ts +5 -0
- package/template/src/service/service.ts +27 -0
- package/template/src/store/antdToken.ts +35 -0
- package/template/src/store/login.ts +38 -0
- package/template/src/store/menus.ts +30 -0
- package/template/src/store/permission.ts +30 -0
- package/template/src/store/token.ts +30 -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,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
|
+
})
|