Skip to content

Commit 1cf3733

Browse files
committed
refactor(config): clean up and standardize code formatting in configuration files
1 parent 108c20c commit 1cf3733

7 files changed

Lines changed: 102 additions & 182 deletions

File tree

.github/workflows/build-apk.yml

Lines changed: 9 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ permissions:
77
contents: write
88

99
jobs:
10-
build_tv:
10+
direct_build:
1111
name: Build Android TV APK
1212
runs-on: ubuntu-latest
1313
steps:
@@ -34,97 +34,24 @@ jobs:
3434
java-version: "17"
3535

3636
- name: Prebuild TV App
37-
run: yarn prebuild
37+
run: yarn prebuild-tv
3838

3939
- name: Build TV APK
40-
run: yarn build-tv
40+
run: yarn build-local
4141

42-
- name: Upload TV APK
43-
uses: actions/upload-artifact@v4
44-
with:
45-
name: orion-tv-apk
46-
path: android/app/build/outputs/apk/release/app-release.apk
47-
48-
build_mobile:
49-
name: Build Android Mobile APK
50-
runs-on: ubuntu-latest
51-
steps:
52-
- name: Check out repository
53-
uses: actions/checkout@v3
54-
55-
- name: Set up Node.js
56-
uses: actions/setup-node@v3
57-
with:
58-
node-version: 18
59-
cache: "yarn"
60-
61-
- name: Install dependencies
62-
run: yarn install --frozen-lockfile
63-
64-
- name: Get version from package.json
65-
id: package-version
66-
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
67-
68-
- name: Setup JDK
69-
uses: actions/setup-java@v3
70-
with:
71-
distribution: "zulu"
72-
java-version: "17"
73-
74-
- name: Prebuild Mobile App
75-
run: yarn prebuild
76-
77-
- name: Build Mobile APK
78-
run: yarn build-mobile
79-
80-
- name: Upload Mobile APK
81-
uses: actions/upload-artifact@v4
82-
with:
83-
name: orion-mobile-apk
84-
path: android/app/build/outputs/apk/release/app-release.apk
85-
86-
release:
87-
name: Create Release
88-
needs: [build_tv, build_mobile]
89-
runs-on: ubuntu-latest
90-
steps:
91-
- name: Check out repository
92-
uses: actions/checkout@v3
93-
94-
- name: Get version from package.json
95-
id: package-version
96-
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
97-
98-
- name: Download TV APK
99-
uses: actions/download-artifact@v4
100-
with:
101-
name: orion-tv-apk
102-
path: artifacts/tv
103-
104-
- name: Download Mobile APK
105-
uses: actions/download-artifact@v4
106-
with:
107-
name: orion-mobile-apk
108-
path: artifacts/mobile
109-
110-
- name: Rename APK files
42+
- name: Rename APK file
11143
run: |
112-
mv artifacts/tv/app-release.apk artifacts/orionTV-tv.${{ steps.package-version.outputs.version }}.apk
113-
mv artifacts/mobile/app-release.apk artifacts/orionTV-mobile.${{ steps.package-version.outputs.version }}.apk
44+
mkdir -p artifacts
45+
cp android/app/build/outputs/apk/release/app-release.apk artifacts/orionTV.${{ steps.package-version.outputs.version }}.apk
11446
115-
- name: Create Release and Upload APKs
47+
- name: Create Release and Upload APK
11648
uses: softprops/action-gh-release@v2
11749
with:
11850
tag_name: v${{ steps.package-version.outputs.version }}
11951
name: Release v${{ steps.package-version.outputs.version }}
120-
body: |
121-
Automated release for version v${{ steps.package-version.outputs.version }}.
122-
- orionTV-tv.${{ steps.package-version.outputs.version }}.apk - Android TV版本
123-
- orionTV-mobile.${{ steps.package-version.outputs.version }}.apk - 手机/平板版本
52+
body: Automated release for version v${{ steps.package-version.outputs.version }}.
12453
draft: false
12554
prerelease: false
126-
files: |
127-
artifacts/orionTV-tv.${{ steps.package-version.outputs.version }}.apk
128-
artifacts/orionTV-mobile.${{ steps.package-version.outputs.version }}.apk
55+
files: artifacts/orionTV.${{ steps.package-version.outputs.version }}.apk
12956
env:
13057
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

components/settings/UpdateSection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { View, StyleSheet, Platform, ActivityIndicator } from "react-native";
33
import { ThemedText } from "../ThemedText";
44
import { StyledButton } from "../StyledButton";
55
import { useUpdateStore } from "@/stores/updateStore";
6-
import { UPDATE_CONFIG } from "@/constants/UpdateConfig";
6+
// import { UPDATE_CONFIG } from "@/constants/UpdateConfig";
77

88
export function UpdateSection() {
99
const { currentVersion, remoteVersion, updateAvailable, downloading, downloadProgress, checkForUpdate } =

constants/UpdateConfig.ts

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,36 @@
1-
import { DeviceUtils } from '@/utils/DeviceUtils';
2-
31
export const UPDATE_CONFIG = {
42
// 自动检查更新
53
AUTO_CHECK: true,
6-
4+
75
// 检查更新间隔(毫秒)
86
CHECK_INTERVAL: 12 * 60 * 60 * 1000, // 12小时
9-
7+
108
// GitHub相关URL
11-
GITHUB_RAW_URL: 'https://ghfast.top/https://raw.githubusercontent.com/zimplexing/OrionTV/refs/heads/master/package.json',
12-
9+
GITHUB_RAW_URL:
10+
"https://ghfast.top/https://raw.githubusercontent.com/zimplexing/OrionTV/refs/heads/master/package.json",
11+
1312
// 获取平台特定的下载URL
1413
getDownloadUrl(version: string): string {
15-
const isTV = DeviceUtils.isTV();
16-
const platform = isTV ? 'tv' : 'mobile';
17-
return `https://ghfast.top/https://github.com/zimplexing/OrionTV/releases/download/v${version}/orionTV-${platform}.${version}.apk`;
14+
return `https://ghfast.top/https://github.com/zimplexing/OrionTV/releases/download/v${version}/orionTV.${version}.apk`;
1815
},
19-
16+
2017
// 是否显示更新日志
2118
SHOW_RELEASE_NOTES: true,
22-
19+
2320
// 是否允许跳过版本
2421
ALLOW_SKIP_VERSION: true,
25-
22+
2623
// 下载超时时间(毫秒)
2724
DOWNLOAD_TIMEOUT: 10 * 60 * 1000, // 10分钟
28-
25+
2926
// 是否在WIFI下自动下载
3027
AUTO_DOWNLOAD_ON_WIFI: false,
31-
28+
3229
// 更新通知设置
3330
NOTIFICATION: {
3431
ENABLED: true,
35-
TITLE: 'OrionTV 更新',
36-
DOWNLOADING_TEXT: '正在下载新版本...',
37-
DOWNLOAD_COMPLETE_TEXT: '下载完成,点击安装',
32+
TITLE: "OrionTV 更新",
33+
DOWNLOADING_TEXT: "正在下载新版本...",
34+
DOWNLOAD_COMPLETE_TEXT: "下载完成,点击安装",
3835
},
39-
};
36+
};

hooks/useResponsiveLayout.ts

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { useState, useEffect } from 'react';
2-
import { Dimensions, Platform } from 'react-native';
1+
import { useState, useEffect } from "react";
2+
import { Dimensions, Platform } from "react-native";
33

4-
export type DeviceType = 'mobile' | 'tablet' | 'tv';
4+
export type DeviceType = "mobile" | "tablet" | "tv";
55

66
export interface ResponsiveConfig {
77
deviceType: DeviceType;
@@ -17,40 +17,44 @@ export interface ResponsiveConfig {
1717
const BREAKPOINTS = {
1818
mobile: { min: 0, max: 767 },
1919
tablet: { min: 768, max: 1023 },
20-
tv: { min: 1024, max: Infinity }
20+
tv: { min: 1024, max: Infinity },
2121
};
2222

2323
const getDeviceType = (width: number): DeviceType => {
24-
const isTV = process.env.EXPO_TV === '1' || Platform.isTV;
25-
if (isTV) return 'tv';
26-
27-
if (width >= BREAKPOINTS.tv.min) return 'tv';
28-
if (width >= BREAKPOINTS.tablet.min) return 'tablet';
29-
return 'mobile';
24+
if (Platform.isTV) return "tv";
25+
26+
if (width >= BREAKPOINTS.tv.min) return "tv";
27+
if (width >= BREAKPOINTS.tablet.min) return "tablet";
28+
return "mobile";
3029
};
3130

32-
const getLayoutConfig = (deviceType: DeviceType, width: number, height: number, isPortrait: boolean): ResponsiveConfig => {
33-
const spacing = deviceType === 'mobile' ? 8 : deviceType === 'tablet' ? 12 : 16;
34-
31+
const getLayoutConfig = (
32+
deviceType: DeviceType,
33+
width: number,
34+
height: number,
35+
isPortrait: boolean
36+
): ResponsiveConfig => {
37+
const spacing = deviceType === "mobile" ? 8 : deviceType === "tablet" ? 12 : 16;
38+
3539
let columns: number;
3640
let cardWidth: number;
3741
let cardHeight: number;
3842

3943
switch (deviceType) {
40-
case 'mobile':
44+
case "mobile":
4145
columns = isPortrait ? 3 : 4;
4246
// 使用flex布局,卡片可以更大一些来填充空间
43-
cardWidth = (width - spacing) / columns * 0.85; // 增大到85%
47+
cardWidth = ((width - spacing) / columns) * 0.85; // 增大到85%
4448
cardHeight = cardWidth * 1.2; // 5:6 aspect ratio (reduced from 2:3)
4549
break;
46-
47-
case 'tablet':
50+
51+
case "tablet":
4852
columns = isPortrait ? 3 : 4;
49-
cardWidth = (width - spacing) / columns * 0.85; // 增大到85%
53+
cardWidth = ((width - spacing) / columns) * 0.85; // 增大到85%
5054
cardHeight = cardWidth * 1.4; // slightly less tall ratio
5155
break;
52-
53-
case 'tv':
56+
57+
case "tv":
5458
default:
5559
columns = 5;
5660
cardWidth = 160; // Fixed width for TV
@@ -72,12 +76,12 @@ const getLayoutConfig = (deviceType: DeviceType, width: number, height: number,
7276

7377
export const useResponsiveLayout = (): ResponsiveConfig => {
7478
const [dimensions, setDimensions] = useState(() => {
75-
const { width, height } = Dimensions.get('window');
79+
const { width, height } = Dimensions.get("window");
7680
return { width, height };
7781
});
7882

7983
useEffect(() => {
80-
const subscription = Dimensions.addEventListener('change', ({ window }) => {
84+
const subscription = Dimensions.addEventListener("change", ({ window }) => {
8185
setDimensions({ width: window.width, height: window.height });
8286
});
8387

@@ -87,7 +91,7 @@ export const useResponsiveLayout = (): ResponsiveConfig => {
8791
const { width, height } = dimensions;
8892
const isPortrait = height > width;
8993
const deviceType = getDeviceType(width);
90-
94+
9195
return getLayoutConfig(deviceType, width, height, isPortrait);
9296
};
9397

@@ -100,31 +104,31 @@ export const useResponsiveValue = <T>(values: { mobile: T; tablet: T; tv: T }):
100104
// Utility hook for responsive styles
101105
export const useResponsiveStyles = () => {
102106
const config = useResponsiveLayout();
103-
107+
104108
return {
105109
// Common responsive styles
106110
container: {
107111
paddingHorizontal: config.spacing,
108112
},
109-
113+
110114
// Card styles
111115
cardContainer: {
112116
width: config.cardWidth,
113117
height: config.cardHeight,
114118
marginBottom: config.spacing,
115119
},
116-
120+
117121
// Grid styles
118122
gridContainer: {
119123
paddingHorizontal: config.spacing / 2,
120124
},
121-
125+
122126
// Typography
123-
titleFontSize: config.deviceType === 'mobile' ? 18 : config.deviceType === 'tablet' ? 22 : 28,
124-
bodyFontSize: config.deviceType === 'mobile' ? 14 : config.deviceType === 'tablet' ? 16 : 18,
125-
127+
titleFontSize: config.deviceType === "mobile" ? 18 : config.deviceType === "tablet" ? 22 : 28,
128+
bodyFontSize: config.deviceType === "mobile" ? 14 : config.deviceType === "tablet" ? 16 : 18,
129+
126130
// Spacing
127-
sectionSpacing: config.deviceType === 'mobile' ? 16 : config.deviceType === 'tablet' ? 20 : 24,
131+
sectionSpacing: config.deviceType === "mobile" ? 16 : config.deviceType === "tablet" ? 20 : 24,
128132
itemSpacing: config.spacing,
129133
};
130-
};
134+
};

metro.config.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Learn more https://docs.expo.io/guides/customizing-metro
2-
const {getDefaultConfig} = require('expo/metro-config');
3-
const path = require('path');
2+
const { getDefaultConfig } = require("expo/metro-config");
3+
const path = require("path");
44

55
// Find the project and workspace directories
66
// eslint-disable-next-line no-undef
@@ -16,24 +16,24 @@ const config = getDefaultConfig(projectRoot);
1616
// Metro will still resolve source files with standard extensions
1717
// as usual if TV-specific files are not found for a module.
1818
//
19-
if (process.env?.EXPO_TV === '1') {
20-
const originalSourceExts = config.resolver.sourceExts;
21-
const tvSourceExts = [
22-
...originalSourceExts.map((e) => `tv.${e}`),
23-
...originalSourceExts,
24-
];
25-
config.resolver.sourceExts = tvSourceExts;
26-
}
19+
// if (process.env?.EXPO_TV === '1') {
20+
// const originalSourceExts = config.resolver.sourceExts;
21+
// const tvSourceExts = [
22+
// ...originalSourceExts.map((e) => `tv.${e}`),
23+
// ...originalSourceExts,
24+
// ];
25+
// config.resolver.sourceExts = tvSourceExts;
26+
// }
2727

2828
// This can be replaced with `find-yarn-workspace-root`
29-
const monorepoRoot = path.resolve(projectRoot, '../..');
29+
const monorepoRoot = path.resolve(projectRoot, "../..");
3030

3131
// 1. Watch all files within the monorepo
3232
config.watchFolders = [monorepoRoot];
3333
// 2. Let Metro know where to resolve packages and in what order
3434
config.resolver.nodeModulesPaths = [
35-
path.resolve(projectRoot, 'node_modules'),
36-
path.resolve(monorepoRoot, 'node_modules'),
35+
path.resolve(projectRoot, "node_modules"),
36+
path.resolve(monorepoRoot, "node_modules"),
3737
];
3838
config.resolver.disableHierarchicalLookup = true;
3939

package.json

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,12 @@
44
"main": "expo-router/entry",
55
"version": "1.3.0",
66
"scripts": {
7-
"start": "EXPO_USE_METRO_WORKSPACE_ROOT=1 expo start",
8-
"start-tv": "EXPO_TV=1 EXPO_USE_METRO_WORKSPACE_ROOT=1 expo start",
9-
"start-mobile": "EXPO_USE_METRO_WORKSPACE_ROOT=1 expo start --tunnel",
10-
"android": "EXPO_USE_METRO_WORKSPACE_ROOT=1 expo run:android",
11-
"android-tv": "EXPO_TV=1 EXPO_USE_METRO_WORKSPACE_ROOT=1 expo run:android",
12-
"android-mobile": "EXPO_USE_METRO_WORKSPACE_ROOT=1 expo run:android --device",
13-
"ios": "EXPO_USE_METRO_WORKSPACE_ROOT=1 expo run:ios",
14-
"ios-tv": "EXPO_TV=1 EXPO_USE_METRO_WORKSPACE_ROOT=1 expo run:ios",
15-
"ios-mobile": "EXPO_USE_METRO_WORKSPACE_ROOT=1 expo run:ios --device",
16-
"prebuild": "EXPO_USE_METRO_WORKSPACE_ROOT=1 expo prebuild --clean && yarn copy-config",
7+
"start": "EXPO_TV=1 EXPO_USE_METRO_WORKSPACE_ROOT=1 expo start",
8+
"android": "EXPO_TV=1 EXPO_USE_METRO_WORKSPACE_ROOT=1 expo run:android",
9+
"ios": "EXPO_TV=1 EXPO_USE_METRO_WORKSPACE_ROOT=1 expo run:ios",
10+
"prebuild": "EXPO_TV=1 EXPO_USE_METRO_WORKSPACE_ROOT=1 expo prebuild --clean && yarn copy-config",
1711
"copy-config": "cp -r xml/* android/app/src/*",
18-
"build": "cd android && ./gradlew assembleRelease",
19-
"build-tv": "EXPO_TV=1 yarn prebuild && cd android && ./gradlew assembleRelease",
20-
"build-mobile": "yarn prebuild && cd android && ./gradlew assembleRelease",
12+
"build": "EXPO_TV=1 yarn prebuild && cd android && ./gradlew assembleRelease",
2113
"build-debug": "cd android && ./gradlew assembleDebug",
2214
"test": "jest --watchAll",
2315
"test-ci": "jest --ci --coverage --no-cache",
@@ -90,4 +82,4 @@
9082
}
9183
},
9284
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
93-
}
85+
}

0 commit comments

Comments
 (0)