Browse Source

add README.md;

roxas 4 years ago
parent
commit
9e14c34f86
3 changed files with 59 additions and 2 deletions
  1. 56
    0
      README.md
  2. 2
    1
      src/utils/game_setting/game_config.ts
  3. 1
    1
      src/utils/logic_tools/count_down.ts

+ 56
- 0
README.md View File

@@ -0,0 +1,56 @@
1
+# 小游戏开发模板
2
+基于 Umijs + Dvajs + Antd 抽取的开发模板
3
+
4
+# 代办事项
5
+- 完善部分组件
6
+- 完成 错题记录器 组件
7
+- 完成 测试相关 部分内容
8
+
9
+# 具体使用
10
+
11
+## 目录结构
12
+```
13
+.
14
++-- .umirc.ts 用于配置项目与路由
15
++-- .prettierrc 用于配置prettier
16
++-- .eslitrc 用于配置代码规范
17
++-- tsconfig.json
18
++-- tslint.yml
19
++-- typings.d.ts
20
++-- mock 
21
+|   +-- ... 用于mock接口,可查看umijs相关测试的具体文档
22
++-- src 
23
+|   +-- assets
24
+    |   +-- ... 用于存放项目引用的静态文件,如font,png图片等
25
+|   +-- layouts
26
+    |   +-- index.less 
27
+    |   +-- index.tsx 通常用于小游戏内容的容器,在这里适配整个游戏内容框与进行一些全局样式的变更
28
+|   +-- locales
29
+    |   +-- en-US.ts 负责语言文件
30
+    |   +-- zh-CN.ts 
31
+|   +-- models
32
+    |   +-- ... 用于添加store,管理数据
33
+|   +-- pages
34
+    |   +-- ... 相关页面,常用为 main、game、rank,分别代表主页、游戏页、排行榜页
35
+|   +-- services
36
+    |   +-- ... 用于保存models中会调用的异步请求或各种服务,较通用的已转移到utils中
37
+|   +-- utils
38
+    |   +-- game_setting
39
+        |   +-- api_config.ts 用于保存当前请求的地址信息等,如静态资源文件地址、api地址等。
40
+        |   +-- game_config.ts 用于保存相关游戏内容,如倒计时上限、答题正确奖励分数情况等。
41
+    |   +-- logic_tools
42
+        |   +-- GameModal 用于控制游戏弹框,目前主要负责暂停离开弹框与报错弹框。
43
+        |   +-- count_down.ts 倒计时,全局通用,目前使用game_config.ts中的两个值进行倒计时判定,暂停与开始时会自动进行计算间隔,防止停止开始动作的间隔过大或过小。
44
+        |   +-- question_reporter.ts 尚未完工,主要用于记录错题。
45
+        |   +-- voice_play.ts 主要用于管理用户音频播放。
46
+    |   +-- tools
47
+        |   +-- cookie_helper.ts 帮助获取用户cookies,主要导出ak、lnk_lang、请求头等信息。
48
+        |   +-- intl_helper.ts 帮助用户直接获取国际化内容而不需要通过umi/locales
49
+        |   +-- mobile_tool.ts 用于帮助用户获取移动端的信息
50
+        |   +-- request_helper.ts 用于帮助用户发起异步请求
51
+        |   +-- visiable_helper.ts 用于监听用户是否离开游戏(直接在model里面的subscribe中进行使用)
52
+    |   +-- types
53
+        |   +-- interface.ts 管理各种interface,方便查阅代码
54
+|   +-- app.ts
55
+|   +-- global.css
56
+```

+ 2
- 1
src/utils/game_setting/game_config.ts View File

@@ -1,4 +1,5 @@
1 1
 // 配置游戏参数
2
-// export const init_count_down = 20;
2
+export const init_count_down = 20;
3 3
 // export const init_count_down_total = 20;
4
+export const init_count_interval = 1000;
4 5
 export const game_container_id = "xxx_game_content";

+ 1
- 1
src/utils/logic_tools/count_down.ts View File

@@ -1,5 +1,5 @@
1 1
 
2
-import { init_count_down, init_count_interval } from '@/utils/game_config';
2
+import { init_count_down, init_count_interval } from '@/utils/game_setting/game_config';
3 3
 
4 4
 const delay = (timeout: any) => new Promise(resolve => setTimeout(resolve, timeout));
5 5