File tree 3 files changed +142
-5
lines changed
3 files changed +142
-5
lines changed Original file line number Diff line number Diff line change @@ -135,13 +135,40 @@ GitHub Pages: <https://realkai42.github.io/qwerty-learner/>
135
135
136
136
本项目是基于` React ` 开发的,需要 node 环境来运行。
137
137
138
+ ### 环境准备
139
+
140
+ 1 . NodeJS
141
+ 2 . Git
142
+ 3 . Yarn
143
+
144
+ > ** 验证是否已经拥有相关环境**
145
+ >
146
+ > 1 . 手动验证
147
+ > 请在命令行下执行以下命令,查看是否有对应版本输出
148
+ >
149
+ > ``` sh
150
+ > node --version
151
+ > git --version
152
+ > yarn --version
153
+ > ` ` `
154
+ >
155
+ > 2. 脚本验证
156
+ > 使用我们提供的脚本对所需环境进行验证,如果确实依赖项会自动安装
157
+ > - Windows 用户可以直接执行 [pre-check.ps1](scripts/pre-check.ps1) 脚本
158
+ > - MacOS 用户可以直接执行 [pre-check.sh](scripts/pre-check.sh) 脚本
159
+
160
+ 如果有对应环境缺失,我们可以参考下列官方文档进行安装
161
+
162
+ > - [NodeJS](https://nodejs.org/en/download)
163
+ > - [Git](https://git-scm.com/downloads)
164
+ > - [yarn](https://classic.yarnpkg.com/lang/en/docs/install)
165
+
138
166
# ## 手动安装
139
167
140
- 1 . 安装 NodeJS,参考[ 官方文档] ( https://nodejs.org/en/download )
141
- 2 . 使用 ` git clone ` 下载项目到本地, 不使用 git 可能因为缺少依赖而无法运行
142
- 3 . 打开命令行,在项目根目录下,运行` yarn install ` 来下载依赖。
143
- 4 . 执行` yarn start ` 来启动项目,项目默认地址为` http://localhost:5173/ `
144
- 5 . 在浏览器中打开` http://localhost:5173/ ` 来访问项目。
168
+ 1. 在命令行中执行 ` git clone https://github.com/RealKai42/qwerty-learner.git` 将项目拉取到本地, 如果不使用 git 可能因为缺少依赖而无法运行
169
+ 2. 在命令行中执行 ` cd qwerty-learner` ,进入项目根目录,执行` yarn install` 来下载依赖。
170
+ 3. 执行` yarn start` 来启动项目,项目默认地址为` http://localhost:5173/`
171
+ 4. 在浏览器中打开` http://localhost:5173/` 来访问项目。
145
172
146
173
# ## 脚本执行
147
174
Original file line number Diff line number Diff line change
1
+ # 定义函数
2
+ function Test-CommandInstalled ([string ]$CommandName ) {
3
+ $command = Get-Command $CommandName - ErrorAction SilentlyContinue
4
+ if ($command ) {
5
+ return $true
6
+ }
7
+ else {
8
+ return $false
9
+ }
10
+ }
11
+
12
+ $location = Get-Location
13
+
14
+ # 检测Node命令是否存在
15
+ if (! (Test-CommandInstalled node)) {
16
+ Write-Host " 未检测到nodejs环境,尝试使用winget安装..."
17
+ # 检测winget是否存在
18
+ if (! (Test-CommandInstalled winget)) {
19
+ Write-Host " 未检测到 winget,无法完成安装,请检测系统版本,或尝试安装 winget:https://www.microsoft.com/p/app-installer/9nblggh4nns1#activetab=pivot:overviewtab"
20
+ }
21
+ else {
22
+ winget install OpenJS.Nodejs -- silent
23
+ Write-Host " nodejs 安装完成,版本为:"
24
+ node -- version
25
+ }
26
+ }else {
27
+ Write-Host " 检测到 nodejs 环境,版本为:"
28
+ node -- version
29
+ }
30
+
31
+ # 检测Git命令是否存在
32
+ if (! (Test-CommandInstalled git)) {
33
+ Write-Host " 未检测到 git 环境,尝试使用winget安装..."
34
+ # 检测winget是否存在
35
+ if (! (Test-CommandInstalled winget)) {
36
+ Write-Host " 未检测到 winget,无法完成安装,请检测系统版本,或尝试安装 winget:https://www.microsoft.com/p/app-installer/9nblggh4nns1#activetab=pivot:overviewtab"
37
+ }
38
+ else {
39
+ winget install -- id Git.Git - e -- source winget
40
+ Write-Host " git 安装完成,版本为:"
41
+ git -- version
42
+ }
43
+ }else {
44
+ Write-Host " 检测到 git 环境,版本为:"
45
+ git -- version
46
+ }
47
+
48
+ # 检测Yarn命令是否存在
49
+ if (! (Test-CommandInstalled yarn)) {
50
+ Write-Host " 未检测到 yarn 环境,尝试使用winget安装..."
51
+ # 检测winget是否存在
52
+ if (! (Test-CommandInstalled npm)) {
53
+ Write-Host " 未检测到 npm,请尝试手动下载 NodeJS (https://nodejs.org/en/download)"
54
+ }
55
+ else {
56
+ npm install -- global yarn
57
+ Write-Host " yarn 安装完成,版本为:"
58
+ yarn -- version
59
+ }
60
+ }else {
61
+ Write-Host " 检测到 yarn 环境,版本为:"
62
+ yarn -- version
63
+ }
Original file line number Diff line number Diff line change
1
+ cd " $( dirname " $0 " ) " || exit
2
+
3
+ # 判断是否安装了 Node
4
+ if ! type node > /dev/null 2>&1 ; then
5
+ echo " 未检测到 nodejs 环境,尝试使用homebrew安装..."
6
+ # 检测homebrew是否存在
7
+ if ! type brew > /dev/null 2>&1 ; then
8
+ echo " 未检测到 homebrew,无法完成安装,请安装 homebrew 后进行尝试 (https://brew.sh/)"
9
+ else
10
+ brew install node
11
+ echo " node 安装完成,版本为: "
12
+ node --version
13
+ fi
14
+ else
15
+ echo " 检测到 NodeJS 环境,版本为:"
16
+ node -v
17
+ fi
18
+
19
+ if ! type git > /dev/null 2>&1 ; then
20
+ echo " 未检测到 git 环境,尝试使用 homebrew 安装..."
21
+ # 检测 homebrew 是否存在
22
+ if ! type brew > /dev/null 2>&1 ; then
23
+ echo " 未检测到 homebrew,请手动安装 homebrew 后进行尝试 (https://brew.sh/)"
24
+ else
25
+ brew install git
26
+ echo " git 安装完成,版本为: "
27
+ git --version
28
+ fi
29
+ else
30
+ echo " 检测到 git 环境,版本为:"
31
+ git --version
32
+ fi
33
+
34
+ if ! type yarn > /dev/null 2>&1 ; then
35
+ echo " 未检测到 yarn 环境,尝试使用 homebrew 进行安装"
36
+ # 检测 homebrew 是否存在
37
+ if ! type brew > /dev/null 2>&1 ; then
38
+ echo " 未检测到 homebrew ,请手动安装 homebrew 后进行尝试 (https://brew.sh/)"
39
+ else
40
+ brew install yarn
41
+ echo " yarn 安装完成,版本为: "
42
+ yarn --version
43
+ fi
44
+ else
45
+ echo " 检测到 yarn 环境,版本为:"
46
+ yarn -v
47
+ fi
You can’t perform that action at this time.
0 commit comments