@qse/edu-scripts 0.0.0-beta.2 → 0.0.0-beta.4
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/babel.config.json +4 -1
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +1440 -0
- package/dist/index.d.mts +89 -0
- package/dist/index.mjs +13 -0
- package/eslint.config.mjs +1 -1
- package/package.json +16 -10
- package/src/{auto-refactor.js → auto-refactor.ts} +6 -10
- package/src/{build.js → build.ts} +15 -7
- package/src/{cli.js → cli.ts} +14 -13
- package/src/{commit-dist.js → commit-dist.ts} +24 -15
- package/src/config/{paths.js → paths.ts} +17 -2
- package/src/config/plugins/mock-server/{index.js → index.ts} +15 -17
- package/src/config/plugins/{postcss-safe-area.js → postcss-safe-area.ts} +4 -2
- package/src/config/webpackConfig.js +37 -14
- package/src/config/webpackDevServerConfig.js +2 -3
- package/src/{deploy.js → deploy.ts} +23 -15
- package/src/{generator.js → generator.ts} +2 -10
- package/src/index.ts +2 -2
- package/src/{start.js → start.ts} +11 -6
- package/src/utils/FileSizeReporter.js +2 -2
- package/src/utils/{appConfig.js → appConfig.ts} +1 -1
- package/src/utils/{beforeStart.js → beforeStart.ts} +14 -5
- package/src/utils/changeDeployVersion.js +3 -3
- package/src/utils/defineConfig.ts +4 -4
- package/src/utils/{exec.js → exec.ts} +1 -1
- package/src/utils/{getConfig.js → getConfig.ts} +6 -4
- package/src/utils/{getOverride.js → getOverride.ts} +6 -8
- package/tsconfig.json +2 -3
- package/tsdown.config.ts +5 -0
- package/docs/.vitepress/config.ts +0 -35
- package/docs/changelog.md +0 -1
- package/docs/debug.md +0 -17
- package/docs/deploy.md +0 -54
- package/docs/faq.md +0 -144
- package/docs/feat.md +0 -167
- package/docs/grayscale.md +0 -31
- package/docs/index.md +0 -15
- package/docs/install.md +0 -1
- package/docs/mode.md +0 -42
- package/docs/override.md +0 -193
- package/docs/refactor-react-16.md +0 -37
- package/docs/refactor.md +0 -67
- package/docs/static.md +0 -24
- package/es/auto-refactor.js +0 -153
- package/es/build.js +0 -58
- package/es/cli.js +0 -65
- package/es/commit-dist.js +0 -83
- package/es/config/paths.js +0 -39
- package/es/config/plugins/mock-server/defineMock.d.ts +0 -6
- package/es/config/plugins/mock-server/defineMock.js +0 -7
- package/es/config/plugins/mock-server/index.js +0 -122
- package/es/config/plugins/postcss-safe-area.js +0 -22
- package/es/config/plugins/ws-utils-createSocketURL.js +0 -98
- package/es/config/webpackConfig.js +0 -421
- package/es/config/webpackDevServerConfig.js +0 -73
- package/es/deploy.js +0 -148
- package/es/generator.js +0 -52
- package/es/index.d.ts +0 -2
- package/es/index.js +0 -7
- package/es/start.js +0 -45
- package/es/utils/FileSizeReporter.js +0 -107
- package/es/utils/appConfig.js +0 -35
- package/es/utils/beforeStart.js +0 -51
- package/es/utils/changeDeployVersion.js +0 -85
- package/es/utils/defineConfig.d.ts +0 -83
- package/es/utils/defineConfig.js +0 -7
- package/es/utils/exec.js +0 -10
- package/es/utils/getConfig.js +0 -23
- package/es/utils/getOverride.js +0 -28
- package/src/asset/dll/libcommon3-manifest.json +0 -181
- package/src/asset/template/edu-app-env.d.ts.tpl +0 -20
- package/src/asset/template/edu-scripts.override.js.tpl +0 -7
- package/src/asset/template/tailwind.config.js.tpl +0 -11
- package/src/asset/template/tsconfig.json.tpl +0 -24
- /package/{es/asset → asset}/dll/libcommon3-manifest.json +0 -0
- /package/{es/asset → asset}/template/edu-app-env.d.ts.tpl +0 -0
- /package/{es/asset → asset}/template/edu-scripts.override.js.tpl +0 -0
- /package/{es/asset → asset}/template/tailwind.config.js.tpl +0 -0
- /package/{es/asset → asset}/template/tsconfig.json.tpl +0 -0
- /package/{src/config/plugins → asset}/ws-utils-createSocketURL.js +0 -0
package/docs/feat.md
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
# 特性
|
|
2
|
-
|
|
3
|
-
## svg 模块导出
|
|
4
|
-
|
|
5
|
-
默认导出 `dataURI`,额外导出 `ReactComponent`
|
|
6
|
-
|
|
7
|
-
两种使用方式是相同的
|
|
8
|
-
|
|
9
|
-
```tsx | pure
|
|
10
|
-
import logoURI, { ReactComponent as Logo } from './logo.svg'
|
|
11
|
-
|
|
12
|
-
export default () => (
|
|
13
|
-
<>
|
|
14
|
-
<img src={logoURI} />
|
|
15
|
-
<Logo />
|
|
16
|
-
</>
|
|
17
|
-
)
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## 复制 public 文件
|
|
21
|
-
|
|
22
|
-
`edu-scripts build` 会复制 `public` 或 `public/static` 文件到 `dist` 中
|
|
23
|
-
|
|
24
|
-
教育子工程不会复制
|
|
25
|
-
|
|
26
|
-
## 支持 typescript
|
|
27
|
-
|
|
28
|
-
如果要开启 typescrit,只需要运行 `npx edu g ts`
|
|
29
|
-
|
|
30
|
-
## 生成页面模版
|
|
31
|
-
|
|
32
|
-
可以自动生成页面模版
|
|
33
|
-
|
|
34
|
-
运行 `npx edu g page -h` 查看详细信息
|
|
35
|
-
|
|
36
|
-
## 支持[自定义配置](override.md)
|
|
37
|
-
|
|
38
|
-
运行 `npx edu g override` 生成控制文件
|
|
39
|
-
|
|
40
|
-
## 自动根据 qsb 的 CDN 调整内部配置
|
|
41
|
-
|
|
42
|
-
根据 `public/*.html` 文件里的 CDN 按需自动配置 externals 与 dll
|
|
43
|
-
|
|
44
|
-
### CDN 匹配关键字
|
|
45
|
-
|
|
46
|
-
`/react16.14.*_common31?.js/`
|
|
47
|
-
|
|
48
|
-
- external: `react`, `react-dom`, `natty-fetch`, `natty-store`, `common-utils`
|
|
49
|
-
- 添加内置的 dll 文件
|
|
50
|
-
|
|
51
|
-
`/react16.14.*_axios0.21.1/`
|
|
52
|
-
|
|
53
|
-
- external: `react`, `react-dom`, `natty-fetch`, `natty-store`, `common-utils`, `axios`
|
|
54
|
-
|
|
55
|
-
`moment2.29.1.js`
|
|
56
|
-
|
|
57
|
-
- external: `moment`
|
|
58
|
-
|
|
59
|
-
`antd3.26.20.js`
|
|
60
|
-
|
|
61
|
-
- external: `react`, `react-dom`, `moment`, `antd`
|
|
62
|
-
|
|
63
|
-
如果使用 `antd3.26.20.js` 将额外执行下列规则
|
|
64
|
-
|
|
65
|
-
`qsb-antd.min.js`
|
|
66
|
-
|
|
67
|
-
- external: `@qsb/antd`, `@qse/antd`
|
|
68
|
-
|
|
69
|
-
`qsb-scheme-render.min.js`
|
|
70
|
-
|
|
71
|
-
- external: `@qsb/scheme-render` `@qse/scheme-render`
|
|
72
|
-
|
|
73
|
-
## 支持 tailwindcss
|
|
74
|
-
|
|
75
|
-
如果要开启 tailwindcss,只需要运行 `npx edu g tailwind`
|
|
76
|
-
|
|
77
|
-
## PostCSS
|
|
78
|
-
|
|
79
|
-
预处理很多样式[兼容性问题](https://preset-env.cssdb.org/features/#stage-2)
|
|
80
|
-
|
|
81
|
-
为所有 `overflow: auto/scroll` 自动增加 `-webkit-overflow-scrolling: touch`
|
|
82
|
-
|
|
83
|
-
为所有 `env(safe-area-inset-*)` 增加 fallback
|
|
84
|
-
|
|
85
|
-
## Mock
|
|
86
|
-
|
|
87
|
-
项目内建 mock 服务器,支持热更新,可以在 development 环境下使用
|
|
88
|
-
|
|
89
|
-
mock 功能会根据 mock 文件夹自动判断是否开启
|
|
90
|
-
|
|
91
|
-
可以通过 override.config.js 文件配置 mock 参数关闭该功能
|
|
92
|
-
|
|
93
|
-
### 使用步骤
|
|
94
|
-
|
|
95
|
-
根目录创建 mock 文件夹,在该文件夹下创建的所有 js、ts 文件都会被自动加载,可以创建多层级文件夹
|
|
96
|
-
|
|
97
|
-
```js
|
|
98
|
-
// path: /mock/index.js
|
|
99
|
-
// path: /mock/depth/folder/index.js 支持深层文件
|
|
100
|
-
|
|
101
|
-
import { defineMock } from '@qse/edu-scripts'
|
|
102
|
-
|
|
103
|
-
export default defineMock({
|
|
104
|
-
'GET /api/test/test': { hello: 'world' },
|
|
105
|
-
'GET /api/test/test2': [1, 2, 3],
|
|
106
|
-
'POST /api/test2/test': (req, res) => {
|
|
107
|
-
console.log(req.body, req.cookies)
|
|
108
|
-
res.json({ foo: 'bar' })
|
|
109
|
-
},
|
|
110
|
-
})
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
### mock 规则
|
|
114
|
-
|
|
115
|
-
```ts
|
|
116
|
-
import type { RequestHandler } from 'express'
|
|
117
|
-
type Method = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS' | 'CONNECT' | 'TRACE'
|
|
118
|
-
type API = string
|
|
119
|
-
|
|
120
|
-
export type MockConfig = Record<
|
|
121
|
-
`${Method} ${API}`,
|
|
122
|
-
string | number | null | undefined | boolean | Record<string, any> | RequestHandler
|
|
123
|
-
>
|
|
124
|
-
|
|
125
|
-
export function defineMock(config: MockConfig) {
|
|
126
|
-
return config
|
|
127
|
-
}
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
mock 名称是由 method 和 apiUrl 组成的,按这种规则去匹配
|
|
131
|
-
|
|
132
|
-
所有 mock 文件最终会被合并到一起,形成一个大的对象。**所以当出现同名的 mock,前面的会被后面的覆盖**
|
|
133
|
-
|
|
134
|
-
可以通过下面的方式去获取参数
|
|
135
|
-
|
|
136
|
-
- `req.body` 获取 body 参数
|
|
137
|
-
- `req.query` 获取链接上的参数
|
|
138
|
-
- `req.cookies` 获取 cookies
|
|
139
|
-
|
|
140
|
-
<Alert>mock 规则比 proxy 具有更高的优先级,如果匹配中了 mock,就会不再去 proxy 了</Alert>
|
|
141
|
-
|
|
142
|
-
```ts
|
|
143
|
-
// path: /mock/index.ts
|
|
144
|
-
import Mock from 'mockjs'
|
|
145
|
-
|
|
146
|
-
export default {
|
|
147
|
-
// method 必须是大写。可以直接返回数据
|
|
148
|
-
'GET /api/test': { hello: 'world' },
|
|
149
|
-
|
|
150
|
-
// 可以通过 express.requestHandler 处理请求。能实现自定义内容,发送文件等
|
|
151
|
-
'POST /api/test2': (req, res) => {
|
|
152
|
-
// 例如:将 body 内容返回
|
|
153
|
-
res.json(req.body)
|
|
154
|
-
},
|
|
155
|
-
|
|
156
|
-
// 可以通过第三方库生成 mock 数据
|
|
157
|
-
'POST /api/test3': Mock.mock({
|
|
158
|
-
// 属性 list 的值是一个数组,其中含有 1 到 10 个元素
|
|
159
|
-
'list|1-10': [
|
|
160
|
-
{
|
|
161
|
-
// 属性 id 是一个自增数,起始值为 1,每次增 1
|
|
162
|
-
'id|+1': 1,
|
|
163
|
-
},
|
|
164
|
-
],
|
|
165
|
-
}),
|
|
166
|
-
}
|
|
167
|
-
```
|
package/docs/grayscale.md
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# 灰度测试
|
|
2
|
-
|
|
3
|
-
## 开启灰度测试
|
|
4
|
-
|
|
5
|
-
### PC 端
|
|
6
|
-
|
|
7
|
-
前端只要在 `package.json` 文件中加入 `grayscale` 字段即可
|
|
8
|
-
|
|
9
|
-
```json
|
|
10
|
-
{
|
|
11
|
-
"name": "模块名称",
|
|
12
|
-
"edu": { "grayscale": true }
|
|
13
|
-
}
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
此时打包出来的模块就成了灰度测试用的模块,会部署到指定的目录下,主工程会处理调度问题
|
|
17
|
-
|
|
18
|
-
模块名称可与运维讨论
|
|
19
|
-
|
|
20
|
-
后端接口会由 `nginx` 处理,前端不需要关注
|
|
21
|
-
|
|
22
|
-
### H5 端
|
|
23
|
-
|
|
24
|
-
h5 与 pc 是完全不同的方案,前端是需要将代码部署到两个地方。
|
|
25
|
-
|
|
26
|
-
`/project-name` 与 `/beta_project-name`。第二个名字需要去问运维要
|
|
27
|
-
|
|
28
|
-
#### 流程
|
|
29
|
-
|
|
30
|
-
1. 访问 `/qsxxwapdev/project-name/index.html`
|
|
31
|
-
2. 网关拦截 `index.html` 请求,并根据后台灰度配置进行分流,分别进入`/qsxxwapdev/project-name/index1.html` 与 `/qsxxwapdev/beta_project-name/index1.html`
|
package/docs/index.md
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
# https://vitepress.dev/reference/default-theme-home-page
|
|
3
|
-
layout: home
|
|
4
|
-
|
|
5
|
-
hero:
|
|
6
|
-
name: '@qse/edu-scripts'
|
|
7
|
-
text: 教育工程化基础框架
|
|
8
|
-
actions:
|
|
9
|
-
- theme: brand
|
|
10
|
-
text: 快速开始
|
|
11
|
-
link: /install
|
|
12
|
-
features:
|
|
13
|
-
- title: rspack重构
|
|
14
|
-
details: 使用rspack重构,比webpack快10x以上
|
|
15
|
-
---
|
package/docs/install.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<!-- @include: ../README.md -->
|
package/docs/mode.md
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# 模式
|
|
2
|
-
|
|
3
|
-
目前有三种模式:教育主工程模式,教育子工程模式,独立模式
|
|
4
|
-
|
|
5
|
-
## 教育子工程模式
|
|
6
|
-
|
|
7
|
-
默认情况下使用**教育子工程模式**,无需配置
|
|
8
|
-
|
|
9
|
-
## 教育主工程模式
|
|
10
|
-
|
|
11
|
-
### 启用
|
|
12
|
-
|
|
13
|
-
package.json 增加 mode 字段
|
|
14
|
-
|
|
15
|
-
```json
|
|
16
|
-
{
|
|
17
|
-
"edu": { "mode": "main" }
|
|
18
|
-
}
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## 独立项目模式
|
|
22
|
-
|
|
23
|
-
### 启用
|
|
24
|
-
|
|
25
|
-
package.json 增加 mode 字段
|
|
26
|
-
|
|
27
|
-
```json
|
|
28
|
-
{
|
|
29
|
-
"edu": { "mode": "single" }
|
|
30
|
-
}
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## 共同
|
|
34
|
-
|
|
35
|
-
请查看[特性](feat.md)
|
|
36
|
-
|
|
37
|
-
## 差异
|
|
38
|
-
|
|
39
|
-
| 差异点 | 子工程 | 主工程 | 独立 |
|
|
40
|
-
| ---------------------- | ---------------------------------------- | --------------------------------------------- | --------------------------------------------------------------------------------------- |
|
|
41
|
-
| 打包 build | 不复制 `public`,不导出 `html` 文件 | 复制 `public/static` 文件夹,导出 `html` 文件 | 复制 `public` 文件夹,导出 `html` 文件,且输出的 `output.filename` 会添加 `contenthash` |
|
|
42
|
-
| [部署 deploy](deploy.md) | 只上传 `dist/js、dist/images` 两个文件夹 | 上传 `dist` | 同主工程 |
|
package/docs/override.md
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
# 自定义配置
|
|
2
|
-
|
|
3
|
-
使用 `npx edu g override` 自动生成配置文件,修改 `webpack` 配置
|
|
4
|
-
|
|
5
|
-
## 类型
|
|
6
|
-
|
|
7
|
-
```ts
|
|
8
|
-
export type Config = {
|
|
9
|
-
webpack?: (config: Configuration) => Configuration | undefined
|
|
10
|
-
devServer?: (config: DevServerConfiguration) => DevServerConfiguration | undefined
|
|
11
|
-
babel?: (config: any, type: 'src' | 'node_modules') => any | undefined
|
|
12
|
-
/**
|
|
13
|
-
* webpack alias 配置,会与内置 alias 合并
|
|
14
|
-
*
|
|
15
|
-
* @default
|
|
16
|
-
* { '@': 'src' }
|
|
17
|
-
*/
|
|
18
|
-
alias?: Record<string, string>
|
|
19
|
-
/**
|
|
20
|
-
* webpack externals 配置,会与内置 externals 合并
|
|
21
|
-
*/
|
|
22
|
-
externals?: Record<string, string>
|
|
23
|
-
/**
|
|
24
|
-
* terser pure_funcs 配置,传 [] 可以不清空 console.log
|
|
25
|
-
* @default ['console.log']
|
|
26
|
-
*/
|
|
27
|
-
pure_funcs?: string[]
|
|
28
|
-
/**
|
|
29
|
-
* 编译 node_modules 下文件
|
|
30
|
-
*
|
|
31
|
-
* 仅在 development 环境下生效。production 一定会编译 node_modules
|
|
32
|
-
* @default true
|
|
33
|
-
*/
|
|
34
|
-
transformNodeModules?: boolean
|
|
35
|
-
/**
|
|
36
|
-
* 指定压缩工具,esbuild 比 terser 快 20-40 倍,实际压缩率差 10%左右
|
|
37
|
-
*
|
|
38
|
-
* @default 'esbuild'
|
|
39
|
-
*/
|
|
40
|
-
minify?: boolean | 'terser' | 'esbuild'
|
|
41
|
-
/** 自定义全局参数 */
|
|
42
|
-
define?: Record<string, any>
|
|
43
|
-
/** webpack-dev-server proxy
|
|
44
|
-
*
|
|
45
|
-
* @default /api -> /qsxxwapdev/api
|
|
46
|
-
*/
|
|
47
|
-
proxy?: ProxyConfigArray
|
|
48
|
-
extraPostCSSPlugins?: any[]
|
|
49
|
-
/**
|
|
50
|
-
* 开启 mock 功能,会自动加载 mock 文件夹下的文件
|
|
51
|
-
*
|
|
52
|
-
* 默认情况下自动判断根目录是否存在 mock 文件夹,如果存在则开启 mock 功能。
|
|
53
|
-
* 如果设置 false,会关闭 mock 功能
|
|
54
|
-
*/
|
|
55
|
-
mock?: boolean
|
|
56
|
-
}
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## 经典用例
|
|
60
|
-
|
|
61
|
-
### 增加 alias
|
|
62
|
-
|
|
63
|
-
```js
|
|
64
|
-
const { defineConfig } = require('@qse/edu-scripts')
|
|
65
|
-
const path = require('path')
|
|
66
|
-
|
|
67
|
-
module.exports = defineConfig({
|
|
68
|
-
alias: {
|
|
69
|
-
config: path.resolve(__dirname, 'src/config'),
|
|
70
|
-
},
|
|
71
|
-
})
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
### 保留 `console.log`
|
|
75
|
-
|
|
76
|
-
```js
|
|
77
|
-
const { defineConfig } = require('@qse/edu-scripts')
|
|
78
|
-
|
|
79
|
-
module.exports = defineConfig({
|
|
80
|
-
pure_funcs: [],
|
|
81
|
-
})
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### 增加 proxy 代理
|
|
85
|
-
|
|
86
|
-
```js
|
|
87
|
-
const { defineConfig } = require('@qse/edu-scripts')
|
|
88
|
-
|
|
89
|
-
module.exports = defineConfig({
|
|
90
|
-
proxy: [
|
|
91
|
-
{
|
|
92
|
-
context: ['/api/cadre_info'],
|
|
93
|
-
target: 'http://www.zhidianbao.cn:8088/qs_ymm/standard_api_work',
|
|
94
|
-
changeOrigin: true,
|
|
95
|
-
headers: {
|
|
96
|
-
origin: 'http://www.zhidianbao.cn',
|
|
97
|
-
host: 'www.zhidianbao.cn',
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
],
|
|
101
|
-
})
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
### 为 antd-mobile 增加 pxtorem 插件
|
|
105
|
-
|
|
106
|
-
适用范围:antd-mobile@2, antd-mobile@5
|
|
107
|
-
|
|
108
|
-
安装公司内专用的 pxtorem 插件,比原版增加了 include 与 CSS 变量 编译。并且修改默认值 `1rem === 10px`
|
|
109
|
-
|
|
110
|
-
```bash
|
|
111
|
-
npm i @qse/postcss-pxtorem
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
```js
|
|
115
|
-
const { defineConfig } = require('@qse/edu-scripts')
|
|
116
|
-
const pxtorem = require('@qse/postcss-pxtorem')
|
|
117
|
-
|
|
118
|
-
module.exports = defineConfig({
|
|
119
|
-
extraPostCSSPlugins: [pxtorem({ include: ['antd-mobile'] })],
|
|
120
|
-
})
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
> 可选:添加动态计算 html rem 值
|
|
124
|
-
|
|
125
|
-
```html
|
|
126
|
-
<script>
|
|
127
|
-
;(function (designWidth, base, max) {
|
|
128
|
-
var docEl = document.documentElement
|
|
129
|
-
var metaEl = document.querySelector('meta[name="viewport"]')
|
|
130
|
-
|
|
131
|
-
var resize = function () {
|
|
132
|
-
var maxFontSize = Infinity
|
|
133
|
-
if (max) {
|
|
134
|
-
var scale = 1
|
|
135
|
-
var match = metaEl.getAttribute('content').match(/initial\-scale=([\d\.]+)/)
|
|
136
|
-
var isMobile = /iphone|ipad|ipod|Windows Phone|android/i.test(navigator.userAgent)
|
|
137
|
-
if (match && isMobile) {
|
|
138
|
-
scale = parseFloat(match[1])
|
|
139
|
-
}
|
|
140
|
-
maxFontSize = max / scale
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
var clientWidth = docEl.clientWidth ? docEl.clientWidth : docEl.getBoundingClientRect().width
|
|
144
|
-
|
|
145
|
-
docEl.style.setProperty(
|
|
146
|
-
'font-size',
|
|
147
|
-
Math.min((clientWidth / designWidth) * base, maxFontSize) + 'px',
|
|
148
|
-
'important'
|
|
149
|
-
)
|
|
150
|
-
}
|
|
151
|
-
resize()
|
|
152
|
-
window.addEventListener('resize', resize)
|
|
153
|
-
})(375, 16, 16)
|
|
154
|
-
</script>
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
### 为 antd-mobile@2 增加按需加载
|
|
158
|
-
|
|
159
|
-
只能给 antd-mobile@2 使用。antd-mobile@5 自带 tree shake 不需要配置
|
|
160
|
-
|
|
161
|
-
```js
|
|
162
|
-
const { defineConfig } = require('@qse/edu-scripts')
|
|
163
|
-
|
|
164
|
-
module.exports = defineConfig({
|
|
165
|
-
babel(config) {
|
|
166
|
-
config.plugins.push(['import', { libraryName: 'antd-mobile', style: true }, 'antd-mobile'])
|
|
167
|
-
},
|
|
168
|
-
})
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
### 兼容 antd-mobile@1
|
|
172
|
-
|
|
173
|
-
安装 `svg-sprite-loader` 模块,复制下面的代码
|
|
174
|
-
|
|
175
|
-
```shell
|
|
176
|
-
npm i svg-sprite-loader
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
```js
|
|
180
|
-
const { defineConfig } = require('@qse/edu-scripts')
|
|
181
|
-
module.exports = defineConfig({
|
|
182
|
-
webpack(config) {
|
|
183
|
-
config.module.rules[0].oneOf.unshift({
|
|
184
|
-
test: /\.svg$/,
|
|
185
|
-
loader: 'svg-sprite-loader',
|
|
186
|
-
options: {
|
|
187
|
-
esModule: false,
|
|
188
|
-
runtimeCompat: true,
|
|
189
|
-
},
|
|
190
|
-
})
|
|
191
|
-
},
|
|
192
|
-
})
|
|
193
|
-
```
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# 升级 react16
|
|
2
|
-
|
|
3
|
-
frame 项目 react15 升级 react16 指南
|
|
4
|
-
|
|
5
|
-
## 事前准备
|
|
6
|
-
|
|
7
|
-
准备适配 common3 的 frame 与 utils
|
|
8
|
-
|
|
9
|
-
- pc: [pc-frame-utils.zip](http://www.zhidianbao.cn:8088/qsxxwapdev/edu-scripts/pc-frame-utils.zip)
|
|
10
|
-
- h5: [h5-frame-utils.zip](http://www.zhidianbao.cn:8088/qsxxwapdev/edu-scripts/h5-frame-utils.zip)
|
|
11
|
-
|
|
12
|
-
## 开始升级
|
|
13
|
-
|
|
14
|
-
1. 先提交所有内容至svn,方便回退
|
|
15
|
-
2. 解压下载的文件,将 frame 与 utils 放到对应目录
|
|
16
|
-
3. 修改 html 文件中 frame 与 utils 的版本号,引入正确的资源
|
|
17
|
-
4. 替换 CDN 资源
|
|
18
|
-
|
|
19
|
-
```html
|
|
20
|
-
<script src="//static.qsepay.net/lib/react15.4.1_fastclick1.0.6_natty-storage2.0.2-fetch2.4.2_common2.js"></script>
|
|
21
|
-
|
|
22
|
-
将上面这条 CDN 替换成下面这条
|
|
23
|
-
|
|
24
|
-
<script src="//static.qsepay.net/lib/react16.14_fastclick1.0.6_natty-storage2.0.2-fetch2.4.2_axios0.21.1_common31.js"></script>
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
5. 运行项目看看效果
|
|
28
|
-
|
|
29
|
-
## 错误处理
|
|
30
|
-
|
|
31
|
-
### refast LogicRender 缺失
|
|
32
|
-
|
|
33
|
-
删除全部的 `LogicRender`,使用*三元表达式*处理
|
|
34
|
-
|
|
35
|
-
### prop-types 缺失
|
|
36
|
-
|
|
37
|
-
react16 将 prop-types 独立了出去,请下载 prop-types 包,修改导入
|
package/docs/refactor.md
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
# 老项目接入流程
|
|
2
|
-
|
|
3
|
-
## 事前约定
|
|
4
|
-
|
|
5
|
-
`package.json` 中约定了 `name` 和 `version` 的含义
|
|
6
|
-
|
|
7
|
-
```json
|
|
8
|
-
{
|
|
9
|
-
"name": "项目名称,打包部署后都是这个名字",
|
|
10
|
-
"version": "版本号"
|
|
11
|
-
}
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
## 重构
|
|
15
|
-
|
|
16
|
-
运行 `npx @qse/edu-scripts auto-refactor` 自动重构项目,按终端提示进行操作
|
|
17
|
-
|
|
18
|
-
运行完毕后接着按下面的步骤修改代码
|
|
19
|
-
|
|
20
|
-
1. `index1.html` 增加 CDN
|
|
21
|
-
|
|
22
|
-
```html
|
|
23
|
-
<% if(process.env.NODE_ENV === 'development') { %>
|
|
24
|
-
<script src="https://www.zhidianbao.cn:8443/qsxxwapdev/edu-scripts/react-dev-preset.js"></script>
|
|
25
|
-
<script src="https://www.zhidianbao.cn:8443/qsxxwapdev/edu-scripts/moment2.29.1.js"></script>
|
|
26
|
-
<script src="https://www.zhidianbao.cn:8443/qsxxwapdev/edu-scripts/antd3.26.20.js"></script>
|
|
27
|
-
<script src="https://registry.npmmirror.com/@qse/antd/latest/files/dist/qsb-antd.min.js"></script>
|
|
28
|
-
<script src="https://registry.npmmirror.com/@qse/scheme-render/latest/files/dist/qsb-scheme-render.min.js"></script>
|
|
29
|
-
<% } else { %>
|
|
30
|
-
<script src="//static.qsepay.net/lib/react16.14_fastclick1.0.6_natty-storage2.0.2-fetch2.4.2_axios0.21.1_common31.js"></script>
|
|
31
|
-
<script src="//static.qsepay.net/lib/moment2.29.1.js"></script>
|
|
32
|
-
<script src="//static.qsepay.net/lib/antd3.26.20.js"></script>
|
|
33
|
-
|
|
34
|
-
<!-- 如果你是主工程,需要下面这两个文件 -->
|
|
35
|
-
<script src="static/lib/qsb-antd.min.js"></script>
|
|
36
|
-
<script src="static/lib/qsb-scheme-render.min.js"></script>
|
|
37
|
-
<% } %>
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
如果你的钉钉容器打不开应用,可以添加动态的 `polyfill` 解决问题
|
|
41
|
-
|
|
42
|
-
```html
|
|
43
|
-
<!-- polyfill 官网 -->
|
|
44
|
-
<script src="https://polyfill.io/v3/polyfill.min.js?features=default,es2015,es2016,es2017" crossorigin="anonymous"></script>
|
|
45
|
-
|
|
46
|
-
<!-- 阿里云镜像 -->
|
|
47
|
-
<script src="https://polyfill.alicdn.com/v3/polyfill.min.js?features=default,es2015,es2016,es2017" crossorigin="anonymous"></script>
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
2. `index1.html` 修改主文件
|
|
51
|
-
|
|
52
|
-
```html
|
|
53
|
-
<!-- 可选,动态主文件 -->
|
|
54
|
-
<script src="<%= htmlWebpackPlugin.files.js %>"></script>
|
|
55
|
-
|
|
56
|
-
<!-- 示例 -->
|
|
57
|
-
<script src="js/utils_2.0.0.js"></script>
|
|
58
|
-
<script src="<%= htmlWebpackPlugin.files.js %>"></script>
|
|
59
|
-
<script src="js/frame/frame_2.10.0.js"></script>
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
3. 运行 `npm i` 安装依赖
|
|
63
|
-
4. 运行项目 `npm run start` 参照下方排除错误
|
|
64
|
-
|
|
65
|
-
## 报错处理
|
|
66
|
-
|
|
67
|
-
请看[错误处理](faq.md)
|
package/docs/static.md
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# 静态资源
|
|
2
|
-
|
|
3
|
-
## 开发环境使用的静态资源
|
|
4
|
-
|
|
5
|
-
```html
|
|
6
|
-
<script src="https://www.zhidianbao.cn:8443/qsxxwapdev/edu-scripts/react-dev-preset.js"></script>
|
|
7
|
-
<script src="https://www.zhidianbao.cn:8443/qsxxwapdev/edu-scripts/moment2.29.1.js"></script>
|
|
8
|
-
<script src="https://www.zhidianbao.cn:8443/qsxxwapdev/edu-scripts/antd3.26.20.js"></script>
|
|
9
|
-
<script src="https://registry.npmmirror.com/@qse/antd/latest/files/dist/qsb-antd.min.js"></script>
|
|
10
|
-
<script src="https://registry.npmmirror.com/@qse/scheme-render/latest/files/dist/qsb-scheme-render.min.js"></script>
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## 生产环境使用的静态资源
|
|
14
|
-
|
|
15
|
-
```html
|
|
16
|
-
<!-- 包含 react react-dom natty-fetch common-utils dll(refast react-keeper) -->
|
|
17
|
-
<script src="//static.qsepay.net/lib/react16.14_fastclick1.0.6_natty-storage2.0.2-fetch2.4.2_common31.js"></script>
|
|
18
|
-
<!-- 额外包含 axios @0.21.1 -->
|
|
19
|
-
<script src="//static.qsepay.net/lib/react16.14_fastclick1.0.6_natty-storage2.0.2-fetch2.4.2_axios0.21.1_common31.js"></script>
|
|
20
|
-
|
|
21
|
-
<!-- 包含 moment 与 moment-locale-zh-cn -->
|
|
22
|
-
<script src="//static.qsepay.net/lib/moment2.29.1.js"></script>
|
|
23
|
-
<script src="//static.qsepay.net/lib/antd3.26.20.js"></script>
|
|
24
|
-
```
|