Skip to content

作者

novlan1

和平赛事开发须知

和平赛事,又称和平赛场。

1. 地址

描述

地址
竖版 Githttps://git.aow.com/pmd-mobile/match/gp-next/
竖版研发平台https://mobile.aow.com/rd-platform-web/#/project/detail/f8360bc3-816f-4457-88e8-86ae6647406e/
横版 Githttps://git.aow.com/pmd-mobile/match/gp-hor/
横版研发平台https://mobile.aow.com/rd-platform-web/#/project/detail/cda4ad74-b8cf-4f35-82ae-0f5cd0e4fe97/

2. 发布权限

Press Next 组件库

  • release 分支发 patch,其他发 beta
  • 开发人员可发任意分支,有审核,长时间未通过可以艾特 novlan1

业务

  • release 分支 novlan1 来发
  • 其他分支任意开发人员可根据需求发布

3. 前端规范

  1. 页面自行引入 global-componentDialog 等,不学赛宝由插件引入,所见即所得
  2. 小程序下不要用 H5 才有的语法,如 location.href,其他语法同理!不要指望插件兜底,用条件编译,以及 uni-app 原生语法
  3. 路由用原生语法,即 uni.navigateTo 等,不要用 this.$router 等需要其他插件的语法
  4. 迁移 Vue3 后,新的需求、新的页面都用 Vue3 的 Composition API + Typescript,之前的页面可以不改
  5. 宏定义不需要引入

4. 重构相关

  1. 不要用标签选择器,用 class。标签选择器的样式在 Vue3 小程序下不会被转换,和平赛事目前是自己写的 postcss 插件,不要依赖这个!
  2. 新需求中改动结构、新增DOM等,必须明确标注注释,或者 v-if=“false”防止开发不知情的情况下发布现网
  3. 不要加全局样式(即在 App.vue 中直接或间接引入的样式),如一定要加,找 novlan1 评估
  4. tailwindcss 命名一行一个

5. 提测须知

  1. 提测分支需以 feature/story- 开头,自动加保护分支
  2. 提测前需提MR,让 novlan1 看看

6. 提交规范

  1. 符合 angular 提交规范
  2. 提交信息要具体、简洁,下面是不正确的示例

7. 业务细节

7.1. 类型导入要声明关键词 type

类型导入时要显式声明关键词 type,否则可能会导致编译出错。

The requested module '/xxx3.ts' does not provide an export named 'Abc'
ts
// 正确
import type { Abc } from './xxx';

// 错误
import { Abc } from './xxx';

7.2. Header 组件

不需要自定义导航栏的页面,pages.json 设置如下:

json
"style": {
  "navigationBarTitleText": "队伍"
}

需要自定义头部的页面:

json
"style": {
  "navigationStyle": "custom"
}

导航栏组件:

ts
import PressCustomHeader from 'press-next/press-custom-header/press-custom-header.vue';
import { useStatusBarHeight } from 'press-next/hooks/status-bar-height';

const {
  statusBarHeight,
  headerHeight,
} = useStatusBarHeight();

7.3. 返回

返回方法统一用 press-next 中的方法:

ts
import { goBack } from 'press-next/common/utils/go-back/index';

goBack({
  home: '/views/index/index',
});

7.4. 二维码组件

ts
import PressGpPopupImage from 'press-next/press-gp-popup-image/press-gp-popup-image';

7.5. 隐藏滚动条

less
@layer utilities {
  /* 隐藏 Chrome, Safari 和 Opera 的滚动条 */
  .no-scrollbar::-webkit-scrollbar {
    display: none;
  }
  /* 隐藏 IE, Edge 和 Firefox 的滚动条 */
  .no-scrollbar {
    -ms-overflow-style: none;  /* IE 和 Edge */
    scrollbar-width: none;  /* Firefox */
  }
}
html
<div class="no-scrollbar"></div>

7.6. typescript-eslint

vue-tsc 需要 typescript 较高版本。

最新版的的 eslint-config-light-vue3 不内置 @typescript-eslint/parser@typescript-eslint/eslint-plugin,由业务自己安装,来适配业务自己的 typescript 版本。

7.7. 分享

分两步:

  1. 初始化
  2. openShareUI
ts
import { initShare, openShareUI } from 'src/local-logic/tip-match/share/share-init';

// 在合适的时机初始化
initShare(shareParams);

// 用户触发
openShareUI();

具体代码要结合业务实际。

7.8. Toast

使用 press-next 中的 toast,而不是 pmd 中的,有更丰富的类型提示。

ts
import { Toast } from 'press-next/common/toast';

Toast.showLoading('加载中...');
Toast.show(text);
Toast.showSuccess(text);
Toast.showFail(text);

7.9. 拉起赛事房间

7.9.1. 核心

赛事页面 H5 (或小程序等)向游戏传递参数房间信息,比如 RoomIdRoomPwd

房间信息,由赛事后台向游戏后台请求生成,不赘述。

7.9.2. 示例

拉起示例:

bash
xxx://?rmid:${roomId},rmpw:${roomPwd},t:${time}

xxxscheme 关键词,rmid 是房间 Id, rmpw 是房间密码

只要游戏能正确解析到 H5 页面传过来的参数即可,格式不限。

8. TailwindCSS

8.1. vscode 插件

提效工具:Tailwind CSS IntelliSense

8.2. pr-[.28rem]

小程序中不能使用 pr-[.28rem] 这种,可以使用 pr-1.12,同时在tailwind.config.js 中配置下 theme.extend.padding = {1.12: '.28rem'}

原因是uni-app会把class中的[.解析成\[\放到wxss中,导致编译错误。

8.3. bg-url

background-imagehtml 中书写的时候不能带引号。下面是错误的

html
class="
  bg-[url('https://image-1251917893.file.myqcloud.com/tip-project/pubg/pubg-match/manager-business-card/manager-card-select.png')]
"

下面是正确的

html
class="
  bg-[url(https://image-1251917893.file.myqcloud.com/tip-project/pubg/pubg-match/manager-business-card/manager-card-select.png)]
"

带引号的类名,如果同时存在动态类名,在小程序下会编译不通过。

8.4. 动态类名

以下动态类名会丢失小数点:

html
:class="[index === active ? 'w-11.2 h-6.4' : 'w-9.6 h-5.44']"

可以改成对象形式,而不是数组:

html
:class="{'w-11.2 h-6.4': index === active, 'w-9.6 h-5.44': index !== active}"

8.5. box-shadow

rgba 的颜色值中间不能加空格,不能用小数点的 rem,下面是错误的:

html
:class="{ 'shadow-[0_0.08rem_0.08rem_rgba(0, 0, 0, 0.16)]': index === active }"

下面是正确的

html
:class="{ 'shadow-[0_4px_4px_rgba(0,0,0,0.16)]': index === active }"

8.6. border

设置 border-bottom:

css
a {
  border-bottom: .02rem solid rgba(255, 255, 255, .10);
}

设置如下:

html
<div class="
  border-0
  border-solid
  border-b-[rgba(255,255,255,.10)]
  border-b-0.08
">
</div>

需要设置一个 border-0,否则其他方向的边框也会有,不符合预期。另外,tailwindcss 中没有 border-b-solid

8.7. 安全区

html
pb-[calc(env(safe-area-inset-bottom)+70px)]

8.8. icon

涉及icon图标大小等会有权重问题,可以加!

8.9. 剪裁

html
[clip-path:polygon(0_0,100%_0,100%_100%,20%_100%)]