Skip to content

Commit cc14000

Browse files
author
kaiyu.kong
committed
feat: 精简代码
1 parent a1d383e commit cc14000

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+382
-1403
lines changed

.dumirc.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ const logo =
44
'https://imagev2.xmcdn.com/storages/f8d2-audiofreehighqps/81/43/GMCoOSYIO18uAAAvaAIdYbXD.png';
55

66
const publicPath =
7-
process.env.NODE_ENV === 'production' ? `/cli/create-project/` : '/';
7+
process.env.NODE_ENV === 'production'
8+
? `/create-project/refs/heads/master/`
9+
: '/';
810

911
export default defineConfig({
12+
outputPath: 'site',
1013
themeConfig: {
1114
name: 'create-project',
1215
logo,
@@ -20,7 +23,4 @@ export default defineConfig({
2023
alias: {
2124
images: '/docs/images',
2225
},
23-
resolve: {
24-
docDirs: ['docs'],
25-
},
2626
});

.github/workflows/ci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: GitHub Actions Build and Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- v*
8+
paths:
9+
- docs/**
10+
- typings/**
11+
- .umirc.js
12+
- tsconfig.json
13+
- package.json
14+
- .github/workflows/*
15+
16+
jobs:
17+
build-and-deploy:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/[email protected] # If you're using actions/checkout@v2 you must set persist-credentials to false in most cases for the deployment to work correctly.
22+
- name: Use Node.js 16.x
23+
uses: actions/setup-node@v2
24+
with:
25+
node-version: 16
26+
- name: Install
27+
run: npm install
28+
- name: Build docs
29+
run: npm run build
30+
- name: Deploy docs
31+
uses: JamesIves/[email protected]
32+
with:
33+
branch: gh-pages
34+
folder: site
35+
target-folder: ${{github.ref}}

.gitlab-ci.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
18

.yarnrc

Lines changed: 0 additions & 2 deletions
This file was deleted.

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
## Getting Started
22

33
```bash
4-
npx -p @xmly/create-project create-project
4+
npx -p @ecode/create-project create-project
55
```
66

77
## 下载自定义模版
88

99
```bash
10-
npx -p @xmly/create-project create-project download [模板名称]
10+
npx -p @ecode/create-project create-project download [模板名称]
1111
```
1212

1313
## 将项目转换为模版
1414

1515
先进入项目目录,再执行以下命令:
1616

1717
```bash
18-
npx -p @xmly/create-project create-project transform [模板名]
18+
npx -p @ecode/create-project create-project transform [模板名]
1919

2020
```
2121

2222
模版存放目录(可选):
2323

2424
```bash
25-
npx -p @xmly/create-project create-project transform [模板名] <模版存放目录>
25+
npx -p @ecode/create-project create-project transform [模板名] <模版存放目录>
2626
```
2727

28-
[文档](http://react-library.pages.xmly.work/cli/create-project)
28+
[文档](https://yicoding.github.io/create-project)

docs/download.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ nav:
1414
下载模版:
1515

1616
```bash
17-
npx -p @xmly/create-project create-project download [模板名称]
17+
npx -p @ecode/create-project create-project download [模板名称]
1818
```
1919

2020
`or`
2121

2222
支持输入项目名称:
2323

2424
```bash
25-
npx -p @xmly/create-project create-project download [模板名称] [项目名称]
25+
npx -p @ecode/create-project create-project download [模板名称] [项目名称]
2626
```
2727

2828
支持下载模版后替换内容:
2929

3030
```bash
31-
npx -p @xmly/create-project create-project download [模板名称] -r [旧内容] [新内容]
31+
npx -p @ecode/create-project create-project download [模板名称] -r [旧内容] [新内容]
3232
```
3333

3434
## 要求的模版目录文件

docs/guide/apm.md

Lines changed: 0 additions & 60 deletions
This file was deleted.

docs/guide/config.md

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ nav:
4747
```js
4848
proxy: {
4949
'/proxy_url': {
50-
target: 'https://m.test.ximalaya.com',
50+
target: 'https://m.test.xxx.com',
5151
changeOrigin: true,
5252
rewrite: (path) => path.replace(/^\/proxy_url/, '')
5353
}
@@ -121,14 +121,14 @@ export default defineConfig({
121121
```ts | pure
122122
import { defineConfig, loadEnv } from 'vite';
123123
import type { ConfigEnv } from 'vite';
124-
import react from '@vitejs/plugin-react-swc';
124+
import react from '@vitejs/plugin-react';
125125
import legacy from '@vitejs/plugin-legacy';
126126
import autoprefixer from 'autoprefixer';
127-
import { minify } from 'terser'; // 引入手动安装的Terser
128127
import { visualizer } from 'rollup-plugin-visualizer';
129128
import { viteMockServe } from 'vite-plugin-mock';
130129
import { manualChunksPlugin } from 'vite-plugin-webpackchunkname';
131130
import checker from 'vite-plugin-checker';
131+
import { moveScriptsToBody } from './plugins/moveScriptsToBody';
132132

133133
// 引入 path 包注意两点:
134134
// 1. 为避免类型报错,你需要通过 `pnpm i @types/node -D` 安装类型
@@ -163,42 +163,29 @@ export default defineConfig(({ mode, command }: ConfigEnv): any => {
163163
// 本地开发配置
164164
server: {
165165
host: true,
166-
// host: 'dev.test.ximalaya.com',
166+
// host: 'dev.test.xxx.com',
167167
port: 8080,
168168
open: true,
169169
// 配置代理,处理本地开发跨域问题
170170
proxy: {
171171
'/proxy_url': {
172-
target: 'https://m.test.ximalaya.com',
172+
target: 'https://m.test.xxx.com',
173173
changeOrigin: true,
174174
rewrite: (path) => path.replace(/^\/proxy_url/, '')
175175
}
176176
}
177177
},
178178
// 构建配置
179179
build: {
180-
// rollup配置
181-
rollupOptions: {
182-
// 输出配置
183-
output: {
184-
plugins: [
185-
{
186-
name: 'terser',
187-
async renderChunk(code) {
188-
const minified = await minify(code, {
189-
compress: {
190-
// 生产环境删除console
191-
drop_console: mode === 'production'
192-
},
193-
});
194-
return {
195-
code: minified.code,
196-
};
197-
}
198-
}
199-
]
180+
// 生成sourcemap文件
181+
sourcemap: true,
182+
minify: 'terser',
183+
terserOptions: {
184+
compress: {
185+
// 生产环境删除console.log
186+
pure_funcs: mode === 'production' ? ['console.log'] : []
200187
}
201-
}
188+
},
202189
},
203190
plugins: [
204191
checker({
@@ -220,6 +207,8 @@ export default defineConfig(({ mode, command }: ConfigEnv): any => {
220207
'not dead'
221208
],
222209
}),
210+
// 自定义插件,将脚本移动到body底部
211+
moveScriptsToBody(),
223212
// mock服务
224213
mode === 'mock' &&
225214
viteMockServe({
@@ -233,7 +222,7 @@ export default defineConfig(({ mode, command }: ConfigEnv): any => {
233222
open: true,
234223
gzipSize: true,
235224
brotliSize: true
236-
})
225+
}),
237226
]
238227
};
239228
});

docs/guide/constants.md

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,19 @@ nav:
1515
`src/utils/constants` 文件中
1616

1717
```ts
18+
/** constants */
1819
import { isProd } from '@/utils/env';
1920
import { UserInfo } from '@/utils/types';
2021

2122
const env = isProd ? '.' : '.test.';
2223

23-
/**喜马jssdk */
24-
export const XIMA_JSSDK_SCRIPT = '//s1.xmcdn.com/yx/jssdk/1.1.1/build/ly.js';
25-
// xima-jssdk-appid
26-
// 需自行申请(申请地址:https://ops.ximalaya.com/gatekeeper/lego/page/5fd730ffefec5c41c33f59fe/5fd73182132c4ec5392fe16e)
24+
/**xxx-jssdk */
25+
export const XXX_JSSDK_SCRIPT = '//xxx.xcdn.com/jssdk/sdk.js';
26+
// xxx-jssdk-appid
2727
export const XIMA_JSSDK_APPID = 'xxx';
28-
// xima-sdk-api列表
29-
export const XIMA_JSSDK_APIS = [
30-
'account.getUserInfo',
31-
'account.login',
32-
'util.openUrl',
33-
'util.share',
34-
'nav.setMenu',
35-
];
36-
/**喜马sdk */
28+
// xxx-sdk-api列表
29+
export const XXX_JSSDK_APIS = [];
30+
/**xxx-sdk */
3731

3832
/** 微信jssdk */
3933
export const WECHAT_JSSDK_SCRIPT = '//res.wx.qq.com/open/js/jweixin-1.6.0.js';
@@ -45,15 +39,15 @@ export const WECHAT_JSSDK_APIS = [
4539
export const WECHAT_OPENTAGLIST = ['wx-open-launch-app'];
4640
// 站外唤端CID(需自行申请)
4741
export const CID = 'xxx';
48-
// 微信开放标签appid
49-
export const appid = 'wxb9371ecb5f0f05b1';
42+
// 需要唤端的appid
43+
export const appid = 'xxxxxxxxxxxx';
5044
/** 微信jssdk */
5145

5246
/** 用户信息相关 */
5347
const userExtraInfo = {
5448
nickName: '',
5549
imgUrl:
56-
'https://imagev2.xmcdn.com/group63/M06/94/66/wKgMcl0lkjvDyDg-AAAAdAw-8b8622.png!op_type=9&strip=1&quality=0&unlimited=1'
50+
'https://imagev2.xxcdn.com/group63/M06/94/66/wKgMcl0lkjvDyDg-AAAAdAw-8b8622.png!op_type=9&strip=1&quality=0&unlimited=1'
5751
}
5852

5953
// 未调用登录接口前的默认用户信息
@@ -73,11 +67,8 @@ export const UNLOGIN_USER = {
7367
};
7468
/** 用户信息相关 */
7569

76-
// 主站域名
77-
export const M_ORIGIN = `https://m${env}ximalaya.com`;
7870
// h5登录页域名
79-
export const PASSPORT_ORIGIN = `https://passport${env}ximalaya.com`;
80-
71+
export const PASSPORT_ORIGIN = `https://passport${env}xxx.com`;
8172

8273
// 接口失败提示语
8374
export const FAIL_MESSAGE = '你们太热情了';

0 commit comments

Comments
 (0)