Skip to content

Commit 5c77d1a

Browse files
committed
chore: code style
1 parent 2306c30 commit 5c77d1a

File tree

7 files changed

+133
-136
lines changed

7 files changed

+133
-136
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,49 +9,52 @@ jobs:
99
install-and-test:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v2
13-
- name: Install dependencies
12+
-
13+
uses: actions/checkout@v2
14+
-
15+
name: Install dependencies
1416
run: |
1517
yarn
18+
yarn lint
1619
build-android:
1720
needs: install-and-test
1821
runs-on: ubuntu-latest
1922
steps:
20-
- uses: actions/checkout@v2
21-
22-
- name: Use Node.js
23+
-
24+
uses: actions/checkout@v2
25+
-
26+
name: Use Node.js
2327
uses: actions/setup-node@v2
2428
with:
2529
node-version: "16.16.0"
26-
27-
- name: Get yarn cache directory path
30+
-
31+
name: Get yarn cache directory path
2832
id: yarn-cache-dir-path
2933
run: echo "::set-output name=dir::$(yarn cache dir)"
30-
3134
- uses: actions/cache@v1
3235
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
3336
with:
3437
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
3538
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
3639
restore-keys: |
3740
${{ runner.os }}-yarn-
38-
39-
- name: Install dependencies
41+
-
42+
name: Install dependencies
4043
run: |
4144
yarn
42-
43-
- name: Build Android Release
45+
-
46+
name: Build Android Release
4447
run: |
4548
cd android && ./gradlew assembleRelease
46-
47-
- name: Get the version
49+
-
50+
name: Get the version
4851
id: get_version
4952
run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3)
50-
51-
- name: Rename Apk Name
53+
-
54+
name: Rename Apk Name
5255
run: cp android/app/build/outputs/apk/release/app-release.apk android/app/build/outputs/apk/release/v2hub-${{ steps.get_version.outputs.VERSION }}.apk
53-
54-
- name: build changelog
56+
-
57+
name: build changelog
5558
id: build_changelog
5659
if: startsWith(github.ref, 'refs/tags/')
5760
uses: mikepenz/[email protected]
@@ -60,8 +63,8 @@ jobs:
6063
with:
6164
configuration: ".config/changelog_configuration.json"
6265
ignorePreReleases: "false"
63-
64-
- name: Create Release
66+
-
67+
name: Create Release
6568
uses: softprops/action-gh-release@v1
6669
if: startsWith(github.ref, 'refs/tags/')
6770
with:
@@ -71,21 +74,18 @@ jobs:
7174
env:
7275
GITHUB_TOKEN: ${{ secrets.github_token }}
7376

74-
# - name: Upload Artifact
75-
# uses: actions/upload-artifact@v1
76-
# with:
77-
# name: app-release.apk
78-
# path: android/app/build/outputs/apk/release/
79-
80-
81-
jishida-push:
77+
push:
8278
runs-on: ubuntu-latest
8379
needs: [build-android]
8480
if: startsWith(github.ref, 'refs/tags/')
8581
steps:
86-
- name: JiShiDa Push
87-
uses: funnyzak/jishida-action@master
82+
-
83+
name: V2Hub Release Push
84+
uses: funnyzak/pushoo-action@main
8885
with:
89-
key: ${{secrets.JPUSH_KEY}}
90-
head: ${{github.repository}}已完成打包发布
91-
body: 来自GithubAction:${{github.repository}} 发布已完成,下载地址:https://github.com/funnyzak/react-native-v2ex/releases。
86+
platforms: ifttt, bark
87+
tokens: ${{ secrets.PUSH_KEY }}
88+
content: |
89+
# ${{github.repository}} Released
90+
options: '{"bark": { "url": "https://github.com/funnyzak" }}'
91+
debug: false

.github/workflows/test.yml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@ name: test
22

33
on:
44
push:
5-
branches:
6-
- 'main'
7-
- 'dev'
5+
branches: [ dev, main ]
86
pull_request:
9-
branches:
10-
- 'main'
11-
- 'dev'
7+
branches: [ dev, main ]
128
jobs:
139
lint:
1410
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
node-version: [16.x]
1514
steps:
1615
-
1716
name: Checkout
@@ -20,13 +19,11 @@ jobs:
2019
name: Use Node.js
2120
uses: actions/setup-node@v2
2221
with:
23-
node-version: "16.16.0"
24-
22+
node-version: ${{ matrix.node-version }}
2523
-
2624
name: Get yarn cache directory path
2725
id: yarn-cache-dir-path
2826
run: echo "::set-output name=dir::$(yarn cache dir)"
29-
3027
-
3128
uses: actions/cache@v1
3229
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
@@ -35,11 +32,8 @@ jobs:
3532
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
3633
restore-keys: |
3734
${{ runner.os }}-yarn-
38-
-
39-
name: Install dependencies
40-
run: |
41-
yarn
4235
-
4336
name: Lint
4437
run: |
38+
yarn
4539
yarn lint

android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ android {
138138
applicationId "github.funnyzak.v2ex"
139139
minSdkVersion rootProject.ext.minSdkVersion
140140
targetSdkVersion rootProject.ext.targetSdkVersion
141-
versionCode 32
141+
versionCode 33
142142
versionName "0.7.1"
143143
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
144144

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
"start": "react-native start",
1212
"test": "jest",
1313
"pod": "pod-install",
14-
"lint:fix": "eslint --max-warnings 0 . --ext .js,.jsx,.ts,.tsx --fix",
15-
"lint:code": "eslint --max-warnings 0 . --ext .js,.jsx,.ts,.tsx",
14+
"lint:code": "eslint --max-warnings 100 . --ext .js,.jsx,.ts,.tsx",
1615
"lint:style": "prettier --check '**/*.{ts,js,jsx,tsx}'",
16+
"lint:style:fix": "prettier --write '**/*.{ts,js,jsx,tsx}'",
1717
"lint": "yarn lint:code && yarn lint:style",
18+
"lint:fix": "yarn lint:style:fix && yarn lint:code --fix",
1819
"prepare": "if [[ $NODE_ENV != \"production\" ]]; then husky install; fi && patch-package",
1920
"upgrade": "react-native upgrade",
2021
"check-dependencies": "rnx-dep-check",
@@ -31,6 +32,8 @@
3132
"keywords": [
3233
"react",
3334
"react-native",
35+
"v2ex",
36+
"react-native-v2ex",
3437
"javascript",
3538
"js",
3639
"redux",

src/components/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
export { default as Header } from './header'
2-
export { default as LoadingModal } from './loading-modal'
3-
export { default as loading } from './loading'
4-
export * from './atoms'
5-
export * from './common'
6-
export { default as Avatar } from './avatar'
7-
8-
export * from './toast'
1+
export { default as Header } from './header'
2+
export { default as LoadingModal } from './loading-modal'
3+
export { default as loading } from './loading'
4+
export * from './atoms'
5+
export * from './common'
6+
export { default as Avatar } from './avatar'
7+
8+
export * from './toast'

src/utils/adapter.ts

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,52 @@
1-
import { Dimensions, Platform, StatusBar, PixelRatio } from 'react-native'
2-
3-
/**
4-
* 判断是否为 iPhone X
5-
* @returns {boolean}
6-
*/
7-
export function isIphoneX() {
8-
const X_WIDTH = 375
9-
const X_HEIGHT = 812
10-
return Platform.OS === IOS && screenHeight === X_HEIGHT && screenWidth === X_WIDTH
11-
}
12-
13-
/**
14-
* 返回状态栏的高度
15-
* @returns {number}
16-
*/
17-
export function getStatusBarHeight() {
18-
let statusBarHeight = 20
19-
20-
if (Platform.OS === ANDROID) {
21-
statusBarHeight = StatusBar.currentHeight || 20
22-
}
23-
24-
if (isIphoneX()) {
25-
statusBarHeight = 44
26-
}
27-
28-
return statusBarHeight
29-
}
30-
31-
// 设计稿的宽度和高度
32-
const designWidth = 375
33-
const designHeight = 667
34-
35-
export const screenWidth = Dimensions.get('window').width
36-
export const screenHeight = Dimensions.get('window').height
37-
38-
export const unitWidth = screenWidth / designWidth
39-
export const unitHeight = screenHeight / designHeight
40-
41-
export const statusBarHeight = getStatusBarHeight()
42-
export const safeAreaViewHeight = isIphoneX() ? 34 : 0
43-
44-
// 标题栏的高度
45-
export const titleHeight = unitWidth * 100 + statusBarHeight
46-
47-
// 字体缩放比例,一般情况下不用考虑。
48-
// 当应用中的字体需要根据手机设置中字体大小改变的话需要用到缩放比例
49-
export const fontscale = PixelRatio.getFontScale()
50-
51-
export const ANDROID = 'android'
52-
export const IOS = 'ios'
1+
import { Dimensions, Platform, StatusBar, PixelRatio } from 'react-native'
2+
3+
/**
4+
* 判断是否为 iPhone X
5+
* @returns {boolean}
6+
*/
7+
export function isIphoneX() {
8+
const X_WIDTH = 375
9+
const X_HEIGHT = 812
10+
return Platform.OS === IOS && screenHeight === X_HEIGHT && screenWidth === X_WIDTH
11+
}
12+
13+
/**
14+
* 返回状态栏的高度
15+
* @returns {number}
16+
*/
17+
export function getStatusBarHeight() {
18+
let statusBarHeight = 20
19+
20+
if (Platform.OS === ANDROID) {
21+
statusBarHeight = StatusBar.currentHeight || 20
22+
}
23+
24+
if (isIphoneX()) {
25+
statusBarHeight = 44
26+
}
27+
28+
return statusBarHeight
29+
}
30+
31+
// 设计稿的宽度和高度
32+
const designWidth = 375
33+
const designHeight = 667
34+
35+
export const screenWidth = Dimensions.get('window').width
36+
export const screenHeight = Dimensions.get('window').height
37+
38+
export const unitWidth = screenWidth / designWidth
39+
export const unitHeight = screenHeight / designHeight
40+
41+
export const statusBarHeight = getStatusBarHeight()
42+
export const safeAreaViewHeight = isIphoneX() ? 34 : 0
43+
44+
// 标题栏的高度
45+
export const titleHeight = unitWidth * 100 + statusBarHeight
46+
47+
// 字体缩放比例,一般情况下不用考虑。
48+
// 当应用中的字体需要根据手机设置中字体大小改变的话需要用到缩放比例
49+
export const fontscale = PixelRatio.getFontScale()
50+
51+
export const ANDROID = 'android'
52+
export const IOS = 'ios'

src/utils/alert.ts

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
import { Alert } from 'react-native'
2-
import { translate } from '@src/i18n'
3-
interface IBaseAlert {
4-
title?: string
5-
message: string
6-
}
7-
interface IAlert extends IBaseAlert {
8-
title?: string
9-
message: string
10-
onPress?: (value?: string | undefined) => void
11-
}
12-
13-
interface IConfirm extends IBaseAlert {
14-
onOk?: (value?: string | undefined) => void
15-
onCancel?: (value?: string | undefined) => void
16-
}
17-
18-
export const alert = ({ title = translate('common.tip'), message, onPress }: IAlert) => {
19-
Alert.alert(title, message, [{ text: translate('common.ok'), onPress: onPress }])
20-
}
21-
22-
export const confirm = ({ title = translate('common.tip'), message, onOk: onOK, onCancel }: IConfirm) => {
23-
Alert.alert(title, message, [
24-
{ text: translate('common.ok'), onPress: onOK, style: 'default' },
25-
{ text: translate('common.cancel'), onPress: onCancel, style: 'cancel' }
26-
])
27-
}
1+
import { Alert } from 'react-native'
2+
import { translate } from '@src/i18n'
3+
interface IBaseAlert {
4+
title?: string
5+
message: string
6+
}
7+
interface IAlert extends IBaseAlert {
8+
title?: string
9+
message: string
10+
onPress?: (value?: string | undefined) => void
11+
}
12+
13+
interface IConfirm extends IBaseAlert {
14+
onOk?: (value?: string | undefined) => void
15+
onCancel?: (value?: string | undefined) => void
16+
}
17+
18+
export const alert = ({ title = translate('common.tip'), message, onPress }: IAlert) => {
19+
Alert.alert(title, message, [{ text: translate('common.ok'), onPress: onPress }])
20+
}
21+
22+
export const confirm = ({ title = translate('common.tip'), message, onOk: onOK, onCancel }: IConfirm) => {
23+
Alert.alert(title, message, [
24+
{ text: translate('common.ok'), onPress: onOK, style: 'default' },
25+
{ text: translate('common.cancel'), onPress: onCancel, style: 'cancel' }
26+
])
27+
}

0 commit comments

Comments
 (0)