Skip to content

Commit 1bbdaa9

Browse files
committed
initial commit
0 parents  commit 1bbdaa9

File tree

11 files changed

+135
-0
lines changed

11 files changed

+135
-0
lines changed

Diff for: .github/workflows/update-words.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Build feeds-json.json
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- 'words.csv'
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: oven-sh/setup-bun@v1
20+
with:
21+
bun-version: latest
22+
23+
- name: Install deps && Gen file
24+
run: |
25+
bun install
26+
bun run scripts/genjson.js
27+
28+
- name: Commit files
29+
run: |
30+
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
31+
git config --local user.name "github-actions[bot]"
32+
git commit -m "Build words.json" -a || true
33+
34+
- name: Push changes
35+
uses: tianheg/github-actions@push
36+
with:
37+
github_token: ${{ secrets.GITHUB_TOKEN }}
38+
branch: ${{ github.ref }}

Diff for: .gitignore

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Nuxt dev/build outputs
2+
.output
3+
.data
4+
.nuxt
5+
.nitro
6+
.cache
7+
dist
8+
9+
# Node dependencies
10+
node_modules
11+
12+
# Logs
13+
logs
14+
*.log
15+
16+
# Misc
17+
.DS_Store
18+
.fleet
19+
.idea
20+
21+
# Local env files
22+
.env
23+
.env.*
24+
!.env.example

Diff for: bun.lockb

317 KB
Binary file not shown.

Diff for: data/words.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[
2+
{
3+
"id": "2",
4+
"content": "你的野心是什么?"
5+
},
6+
{
7+
"id": "1",
8+
"content": "野心很脆弱,容易被各种困难摧毁"
9+
}
10+
]

Diff for: nuxt.config.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// https://nuxt.com/docs/api/configuration/nuxt-config
2+
export default defineNuxtConfig({});

Diff for: package.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "mood-boost",
3+
"private": true,
4+
"type": "module",
5+
"scripts": {
6+
"build": "nuxt build",
7+
"dev": "nuxt dev",
8+
"generate": "nuxt generate",
9+
"preview": "nuxt preview"
10+
},
11+
"devDependencies": {
12+
"nuxt": "^3.11.1",
13+
"vue": "^3.4.21"
14+
}
15+
}

Diff for: scripts/genjson.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const fs = require('fs')
2+
const csv = require('csv-parser')
3+
4+
// Read the CSV file and convert it to JSON
5+
const jsonData = []
6+
7+
fs.createReadStream('words.csv')
8+
.pipe(csv())
9+
.on('data', (row) => {
10+
const updatedRow = {}
11+
Object.keys(row).forEach((key) => {
12+
updatedRow[key.trim()] = row[key].trim()
13+
})
14+
jsonData.push(updatedRow)
15+
})
16+
.on('end', () => {
17+
fs.writeFile('./data/words.json', JSON.stringify(jsonData, null, 2), (err) => {
18+
if (err) throw err
19+
console.log('CSV to JSON conversion complete')
20+
})
21+
})

Diff for: server/api/words.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default defineEventHandler(async () => {
2+
const data = await import("~/data/words.json");
3+
return data.default;
4+
});

Diff for: tsconfig.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
// https://nuxt.com/docs/guide/concepts/typescript
3+
"extends": "./.nuxt/tsconfig.json"
4+
}
5+

Diff for: vercel.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"headers": [
3+
{
4+
"source": "/api/(.*)",
5+
"headers": [
6+
{
7+
"key": "Content-Security-Policy",
8+
"value": "frame-ancestors 'self' https://tianheg.org"
9+
}
10+
]
11+
}
12+
]
13+
}

Diff for: words.csv

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
id, content
2+
2, 你的野心是什么?
3+
1, 野心很脆弱,容易被各种困难摧毁

0 commit comments

Comments
 (0)