Skip to content

Commit 0137b60

Browse files
committed
feat: cors for apk
1 parent 3e5718a commit 0137b60

8 files changed

Lines changed: 292 additions & 102 deletions

File tree

AGENTS.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# 协作规则
2+
3+
## 通用
4+
5+
- always 使用中文回答
6+
- 代码必须清晰简洁
7+
- 高内聚、低耦合,不写面条代码
8+
- 保证可维护性、可测试性
9+
- 必要处补充逻辑注释
10+
- 不做兼容存量数据逻辑
11+
- 不做冗余兜底
12+
- 单一数据源,不重复实现同一功能
13+
- 优先复用现有技术栈
14+
- 不做降级实现,不做模拟实现,代码必须可直接用于生产
15+
- 可复用能力优先抽成通用组件
16+
- 不把开发心智暴露到用户界面
17+
18+
## Android 发包
19+
20+
- 发包单一版本源:`/Users/anhaohui/twomoons/.env.local` 中的 `NEXT_PUBLIC_VERSION`
21+
- 应用内更新检测读取 `NEXT_PUBLIC_VERSION`
22+
- 远端版本源:`/Users/anhaohui/Documents/stocks/config/db.json``presets[id=version].latest`
23+
- 上面两处版本号必须一致
24+
- Android 发包时,APK 内 API 地址必须使用生产域名 `https://two-moons.site`
25+
- 本地开发地址 `https://two-moons:3000` 不能打进发布包
26+
27+
- `android/app/build.gradle` 中:
28+
- `versionName` 必须等于 `NEXT_PUBLIC_VERSION`
29+
- `versionCode` 规则:`major * 10000 + minor * 100 + patch`
30+
31+
- 发布新版本时,禁止只改 Android 原生版本号
32+
- 发布新版本时,禁止只改 `.env.local` 不改远端 `latest`
33+
34+
## 发包命令
35+
36+
- 统一使用:
37+
38+
```bash
39+
./scripts/build_apk.sh <version>
40+
```
41+
42+
- 示例:
43+
44+
```bash
45+
./scripts/build_apk.sh 1.4.0
46+
```
47+
48+
- 该命令必须完成:
49+
- 更新 `.env.local`
50+
- 更新 `android/app/build.gradle`
51+
- 更新 `/Users/anhaohui/Documents/stocks/config/db.json`
52+
- 执行 `yarn export`
53+
- 执行 `npx cap sync android`
54+
- 执行 `./gradlew assembleRelease`
55+
- 覆盖 `/Users/anhaohui/Documents/stocks/two-moons-release/moonbox-latest.apk`
56+
- 提交并推送 `/Users/anhaohui/Documents/stocks/config`
57+
- 提交并推送 `/Users/anhaohui/Documents/stocks/two-moons-release`
58+
59+
## 产物路径
60+
61+
- 构建产物:
62+
`/Users/anhaohui/twomoons/android/app/build/outputs/apk/release/app-release.apk`
63+
- 发布产物:
64+
`/Users/anhaohui/Documents/stocks/two-moons-release/moonbox-latest.apk`
65+
66+
## 发布后校验
67+
68+
- 校验 APK 路径、大小、修改时间、SHA-256
69+
- 校验 `NEXT_PUBLIC_VERSION``versionName``versionCode`、远端 `latest` 全部一致
70+
- 校验 `config``two-moons-release` 两个仓库都已推送且工作区干净

android/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ android {
77
applicationId "com.rinko.moonbox"
88
minSdkVersion rootProject.ext.minSdkVersion
99
targetSdkVersion rootProject.ext.targetSdkVersion
10-
versionCode 4
11-
versionName "1.3"
10+
versionCode 10403
11+
versionName "1.4.3"
1212
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1313
aaptOptions {
1414
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.

components/Header.tsx

Lines changed: 54 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -204,62 +204,69 @@ export const Header: React.FC = () => {
204204

205205
return (
206206
<header
207-
className="w-full border-0 border-b border-solid border-b-stone-100 h-12 flex items-center justify-between text-sm px-4 fixed top-0 z-30"
207+
className="fixed top-0 z-30 w-full overflow-hidden border-0 border-b border-solid border-b-stone-100"
208208
style={{
209+
height: "var(--app-header-offset)",
209210
background: "rgba(255,255,255,.5)",
210211
backdropFilter: "blur(8px)",
211-
paddingTop: "var(--safe-area-inset-top)",
212+
paddingTop: "var(--safe-area-inset-top, 0px)",
212213
}}
213214
>
214-
<a
215-
href="https://github.com/moayuisuda"
216-
target="_blank"
217-
rel="noopener noreferrer"
218-
className="font-thin font-mono text-inherit hidden md:block"
215+
<div
216+
className="relative flex items-center justify-between px-4 text-sm"
217+
style={{
218+
height: "var(--app-header-height)",
219+
}}
219220
>
220-
BY MOAYUISUDA
221-
</a>
221+
<a
222+
href="https://github.com/moayuisuda"
223+
target="_blank"
224+
rel="noopener noreferrer"
225+
className="hidden font-mono font-thin text-inherit md:block"
226+
>
227+
BY MOAYUISUDA
228+
</a>
222229

223-
<Link legacyBehavior href="/">
224-
<img
225-
className="block cursor-pointer static md:absolute"
226-
src="/pics/logo.svg"
227-
alt=""
228-
style={{
229-
left: "calc(50% - 70px)",
230-
}}
231-
height={36}
232-
/>
233-
</Link>
230+
<Link legacyBehavior href="/">
231+
<img
232+
className="static block h-9 w-auto cursor-pointer md:absolute"
233+
src="/pics/logo.svg"
234+
alt=""
235+
style={{
236+
left: "calc(50% - 70px)",
237+
}}
238+
/>
239+
</Link>
234240

235-
<Space>
236-
<Menu
237-
overflowedIndicator={<UnorderedListOutlined />}
238-
className="flex items-center w-28 lg:w-auto justify-end"
239-
style={{
240-
lineHeight: "36px",
241-
minWidth: 0,
242-
flex: "auto",
243-
}}
244-
mode="horizontal"
245-
items={menuItemsMap[locale]}
246-
/>
247-
{isLoggedIn && (
248-
<div className="flex items-center mr-2">
249-
<div
250-
style={{
251-
marginRight: -2,
252-
marginTop: -8,
253-
}}
254-
className={getStatusDotStyle()}
255-
title={getStatusTitle()}
256-
></div>
257-
<CloudSyncOutlined style={{ fontSize: 16, marginTop: 2 }} />
241+
<Space align="center">
242+
<Menu
243+
overflowedIndicator={<UnorderedListOutlined />}
244+
className="flex items-center justify-end w-28 lg:w-auto"
245+
style={{
246+
lineHeight: "36px",
247+
minWidth: 0,
248+
flex: "auto",
249+
}}
250+
mode="horizontal"
251+
items={menuItemsMap[locale]}
252+
/>
253+
{isLoggedIn && (
254+
<div className="mr-2 flex items-center">
255+
<div
256+
style={{
257+
marginRight: -2,
258+
marginTop: -8,
259+
}}
260+
className={getStatusDotStyle()}
261+
title={getStatusTitle()}
262+
></div>
263+
<CloudSyncOutlined style={{ fontSize: 16, marginTop: 2 }} />
258264

259-
{/* <span className="text-xs text-gray-600">{user.name}</span> */}
260-
</div>
261-
)}
262-
</Space>
265+
{/* <span className="text-xs text-gray-600">{user.name}</span> */}
266+
</div>
267+
)}
268+
</Space>
269+
</div>
263270
</header>
264271
);
265272
};

components/OneSong/index.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ export const OneSong = () => {
3636
<div
3737
className="fixed z-10 w-full transition-all duration-700"
3838
style={{
39-
top: collapse
40-
? "calc(48px + var(--safe-area-inset-top))"
41-
: "calc(100vh - 40px)",
39+
top: collapse ? "var(--app-header-offset)" : "calc(100vh - 40px)",
4240
}}
4341
>
4442
<header
@@ -54,7 +52,7 @@ export const OneSong = () => {
5452
<div
5553
className="p-4 bg-white"
5654
style={{
57-
height: "calc(100vh - 48px - 36px - var(--safe-area-inset-top))",
55+
height: "calc(100vh - var(--app-header-offset) - 36px)",
5856
overflow: "auto",
5957
}}
6058
>

pages/_app.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -438,16 +438,18 @@ function MyApp({ Component, pageProps, router }: AppPropsWithLayout) {
438438
</div>
439439
<div
440440
className="root"
441-
style={{
442-
// height: checkPWA() ? "100vh" : "",
443-
// overflowY: "auto",
444-
// overscrollBehavior: "none",
445-
}}
441+
style={
442+
{
443+
// height: checkPWA() ? "100vh" : "",
444+
// overflowY: "auto",
445+
// overscrollBehavior: "none",
446+
}
447+
}
446448
>
447449
<Header />
448450
<div
449451
style={{
450-
height: `calc(2.25rem + var(--safe-area-inset-top))`,
452+
height: "var(--app-header-offset)",
451453
}}
452454
></div>
453455
{Component.getLayout ? (

pages/phrase/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,10 @@ const PhraseNotebook = () => {
203203

204204
<div className="max-w-4xl mx-auto p-4 md:p-8">
205205
{/* 顶部控制栏 */}
206-
<div className="sticky top-12 z-20 mb-4">
206+
<div
207+
className="sticky z-20 mb-4"
208+
style={{ top: "var(--app-header-offset)" }}
209+
>
207210
<div className="flex items-center justify-between gap-4 mb-4">
208211
{/* 搜索框 */}
209212
<div className="flex-1 max-w-md mx-auto">

0 commit comments

Comments
 (0)