@yyp92-cli/template-react-mobile 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 +5 -0
- package/template/.env.test +5 -0
- package/template/README.md +30 -0
- package/template/index.html +13 -0
- package/template/package.json +40 -0
- package/template/pnpm-lock.yaml +3365 -0
- package/template/postcss.config.js +25 -0
- package/template/public/vite.svg +1 -0
- package/template/src/app.scss +12 -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 +21 -0
- package/template/src/components/404/index.tsx +23 -0
- package/template/src/components/index.ts +3 -0
- package/template/src/components/layout/content/index.module.scss +20 -0
- package/template/src/components/layout/content/index.tsx +55 -0
- package/template/src/components/layout/index.module.scss +5 -0
- package/template/src/components/layout/index.tsx +33 -0
- package/template/src/components/layout/navBar/index.module.scss +5 -0
- package/template/src/components/layout/navBar/index.tsx +48 -0
- package/template/src/components/layout/tabBar/index.module.scss +7 -0
- package/template/src/components/layout/tabBar/index.tsx +69 -0
- package/template/src/components/login/index.module.scss +20 -0
- package/template/src/components/login/index.tsx +127 -0
- package/template/src/global/constants.ts +4 -0
- package/template/src/pages/home/index.module.scss +4 -0
- package/template/src/pages/home/index.tsx +55 -0
- package/template/src/pages/message/index.module.scss +4 -0
- package/template/src/pages/message/index.tsx +13 -0
- package/template/src/pages/mine/index.module.scss +3 -0
- package/template/src/pages/mine/index.tsx +35 -0
- package/template/src/pages/todo/index.module.scss +4 -0
- package/template/src/pages/todo/index.tsx +13 -0
- package/template/src/router/router.tsx +129 -0
- package/template/src/service/api.ts +7 -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/login.ts +39 -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/cache.ts +44 -0
- package/template/src/utils/changeTheme.ts +14 -0
- package/template/src/utils/filterMenu.ts +21 -0
- package/template/src/utils/index.ts +3 -0
- package/template/src/vite-env.d.ts +4 -0
- package/template/tsconfig.json +42 -0
- package/template/tsconfig.node.json +10 -0
- package/template/vite.config.ts +57 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import requestFn from './request'
|
|
2
|
+
import {apiUrl} from './api'
|
|
3
|
+
|
|
4
|
+
// 具体的接口
|
|
5
|
+
export const getDemo = () => {
|
|
6
|
+
const queryData = {}
|
|
7
|
+
|
|
8
|
+
return requestFn.get({
|
|
9
|
+
url: apiUrl.demoUrl,
|
|
10
|
+
params: {
|
|
11
|
+
name: '111',
|
|
12
|
+
age: 20
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const postDemo = () => {
|
|
18
|
+
const queryData = {}
|
|
19
|
+
|
|
20
|
+
return requestFn.post({
|
|
21
|
+
url: apiUrl.demoUrl1,
|
|
22
|
+
data: {
|
|
23
|
+
name: '111222',
|
|
24
|
+
age: 20
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* * 用户信息
|
|
3
|
+
*/
|
|
4
|
+
import { create } from 'zustand'
|
|
5
|
+
import { persist } from 'zustand/middleware';
|
|
6
|
+
|
|
7
|
+
type UserInfoStoreState = {
|
|
8
|
+
userInfo: {
|
|
9
|
+
userId: string,
|
|
10
|
+
userName: string
|
|
11
|
+
},
|
|
12
|
+
token: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type UserInfoStoreActions = {
|
|
16
|
+
setUserInfo: (
|
|
17
|
+
nextUserInfo: UserInfoStoreState['userInfo']
|
|
18
|
+
) => void,
|
|
19
|
+
setToken: (token: string) => void
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type UserInfoStore = UserInfoStoreState & UserInfoStoreActions
|
|
23
|
+
|
|
24
|
+
export const userInfoStore = create<UserInfoStore>()(
|
|
25
|
+
persist(
|
|
26
|
+
(set) => ({
|
|
27
|
+
userInfo: {
|
|
28
|
+
userName: '小明',
|
|
29
|
+
userId: '111'
|
|
30
|
+
},
|
|
31
|
+
token: '',
|
|
32
|
+
setUserInfo: (userInfo) => set({userInfo}),
|
|
33
|
+
setToken: (token) => set({token})
|
|
34
|
+
}),
|
|
35
|
+
{
|
|
36
|
+
name: 'userInfo-local'
|
|
37
|
+
}
|
|
38
|
+
)
|
|
39
|
+
)
|
|
@@ -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,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 = (theme: number) => {
|
|
3
|
+
// 获取根元素
|
|
4
|
+
const root = document.documentElement;
|
|
5
|
+
|
|
6
|
+
if (theme != 1) {
|
|
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,21 @@
|
|
|
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((item: any) => {
|
|
11
|
+
if (permissions.includes(item.key) && !item?.hideInMenu) {
|
|
12
|
+
const data = {...item}
|
|
13
|
+
delete data.hideInMenu
|
|
14
|
+
delete data.showFullScreen
|
|
15
|
+
|
|
16
|
+
newList.push(data)
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
return newList
|
|
21
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"baseUrl": ".",
|
|
4
|
+
"paths": {
|
|
5
|
+
"@/*": ["src/*"]
|
|
6
|
+
},
|
|
7
|
+
"target": "ES2020",
|
|
8
|
+
"useDefineForClassFields": true,
|
|
9
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable", "ESNext"],
|
|
10
|
+
"module": "ESNext",
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
|
|
13
|
+
/* Bundler mode */
|
|
14
|
+
/*
|
|
15
|
+
* 报错:配置文件报错及 React.StrictNode报错:类型“Element”的参数不能赋给类型“ReactNode”的参数
|
|
16
|
+
*
|
|
17
|
+
* 解决:
|
|
18
|
+
* 1.改为node
|
|
19
|
+
* 2.删除这行 "resolveJsonModule": true
|
|
20
|
+
*/
|
|
21
|
+
"moduleResolution": "node",
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
* import 导入的react报错
|
|
25
|
+
* 解决: 增加这行:"esModuleInterop": true,
|
|
26
|
+
*/
|
|
27
|
+
"esModuleInterop": true,
|
|
28
|
+
|
|
29
|
+
"allowSyntheticDefaultImports": true,
|
|
30
|
+
"isolatedModules": true,
|
|
31
|
+
"noEmit": true,
|
|
32
|
+
"jsx": "react-jsx",
|
|
33
|
+
|
|
34
|
+
/* Linting */
|
|
35
|
+
"strict": true,
|
|
36
|
+
"noUnusedLocals": true,
|
|
37
|
+
"noUnusedParameters": true,
|
|
38
|
+
"noFallthroughCasesInSwitch": true
|
|
39
|
+
},
|
|
40
|
+
"include": ["src/**/*"],
|
|
41
|
+
"references": [{ "path": "./tsconfig.node.json" }]
|
|
42
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { defineConfig } from 'vite'
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import react from '@vitejs/plugin-react'
|
|
4
|
+
import autoprefixer from 'autoprefixer';
|
|
5
|
+
import postcsspxtoviewport from 'postcss-px-to-viewport';
|
|
6
|
+
|
|
7
|
+
// https://vitejs.dev/config/
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
base:'./',
|
|
10
|
+
|
|
11
|
+
server: {
|
|
12
|
+
proxy: {
|
|
13
|
+
'/api': {
|
|
14
|
+
target: 'https://httpbin.org',
|
|
15
|
+
changeOrigin: true,
|
|
16
|
+
rewrite: (path) => path.replace(/^\/api/, '')
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
build: {
|
|
22
|
+
sourcemap: true,
|
|
23
|
+
outDir: 'dist'
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
plugins: [
|
|
27
|
+
react(),
|
|
28
|
+
],
|
|
29
|
+
|
|
30
|
+
css: {
|
|
31
|
+
preprocessorOptions: {
|
|
32
|
+
scss: {
|
|
33
|
+
// 启用现代 API(关键配置)
|
|
34
|
+
api: 'modern-compiler'
|
|
35
|
+
},
|
|
36
|
+
sass: {
|
|
37
|
+
// sass 和 scss 都需要配置
|
|
38
|
+
api: 'modern-compiler'
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
postcss: {
|
|
42
|
+
plugins: [
|
|
43
|
+
autoprefixer,
|
|
44
|
+
postcsspxtoviewport
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
// ...其他配置项
|
|
50
|
+
resolve: {
|
|
51
|
+
alias: {
|
|
52
|
+
'@': path.resolve(__dirname, 'src'),
|
|
53
|
+
'@components': path.resolve(__dirname, 'src/components'),
|
|
54
|
+
'@utils': path.resolve(__dirname, 'src/utils'),
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
})
|