Skip to content

Commit ca84818

Browse files
committed
update
1 parent 7af5a14 commit ca84818

10 files changed

Lines changed: 52 additions & 180 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: false
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
- name: Setup Node
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: "20"
27+
cache: 'npm'
28+
- name: Install dependencies
29+
run: npm ci
30+
- name: Build
31+
run: npm run build
32+
- name: Upload artifact
33+
uses: actions/upload-pages-artifact@v3
34+
with:
35+
path: ./out
36+
37+
deploy:
38+
environment:
39+
name: github-pages
40+
url: ${{ steps.deployment.outputs.page_url }}
41+
runs-on: ubuntu-latest
42+
needs: build
43+
steps:
44+
- name: Deploy to GitHub Pages
45+
id: deployment
46+
uses: actions/deploy-pages@v4

.vscode/tasks.json

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,6 @@
4444
},
4545
"group": "build",
4646
"problemMatcher": []
47-
},
48-
{
49-
"label": "部署到Netlify",
50-
"type": "shell",
51-
"command": "cd ${workspaceFolder} && npm run deploy-netlify",
52-
"presentation": {
53-
"reveal": "always",
54-
"panel": "new"
55-
},
56-
"group": "build",
57-
"problemMatcher": []
5847
}
5948
]
6049
}

app/page.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,8 @@ const RandomNamePickerContent = () => {
9090
);
9191

9292
const handleShareList = () => {
93-
// 获取basePath,确保URL中包含正确的路径前缀
94-
const basePath = process.env.NODE_ENV === 'production' ? '/randomchoice' : '';
95-
const url = `${window.location.origin}${basePath}/?list=${encodeURIComponent(names.join(','))}`;
93+
// 由于移除了 basePath 配置,不再需要添加路径前缀
94+
const url = `${window.location.origin}/?list=${encodeURIComponent(names.join(','))}`;
9695
navigator.clipboard.writeText(url);
9796
alert('分享链接已复制到剪贴板!');
9897
};

next.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ module.exports = withPWA({
88
reactStrictMode: true,
99
output: 'export',
1010
distDir: 'out',
11-
basePath: '/randomchoice',
11+
// basePath 已移除,使应用部署在根目录
1212
});

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"build": "next build",
88
"start": "next start",
99
"lint": "next lint",
10-
"deploy-netlify": "next build && cp -r out/randomchoice/* out/ && npx netlify-cli deploy --dir=out"
10+
"deploy-netlify": "next build && npx netlify-cli deploy --dir=out",
11+
"deploy-gh-pages": "next build && touch out/.nojekyll"
1112
},
1213
"dependencies": {
1314
"next": "15.3.1",

public/sw.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/favicon.ico

-25.3 KB
Binary file not shown.

src/app/globals.css

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/app/layout.tsx

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/app/page.tsx

Lines changed: 0 additions & 103 deletions
This file was deleted.

0 commit comments

Comments
 (0)