Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2aefc6d

Browse files
committed
init
0 parents  commit 2aefc6d

48 files changed

Lines changed: 5347 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.aicode.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"activeGroup" : "build",
3+
"groups" : {
4+
"Default" : [
5+
"package.json",
6+
"src/app/App.tsx",
7+
"src/features/chat/components/ChatHeader.tsx",
8+
"src/features/chat/components/ChatMain.tsx",
9+
"src/features/chat/components/InputIsland.tsx",
10+
"src/features/chat/components/MessageList.tsx",
11+
"src/features/chat/components/ShareModal.tsx",
12+
"src/features/chat/hooks.ts",
13+
"src/features/chat/store.ts",
14+
"src/features/chat/types.ts",
15+
"src/features/chat/utils.ts",
16+
"src/features/contacts/components/ProfileCard.tsx",
17+
"src/features/contacts/components/Sidebar.tsx",
18+
"src/features/contacts/components/UserList.tsx",
19+
"src/features/contacts/hooks.ts",
20+
"src/features/contacts/store.ts",
21+
"src/features/contacts/types.ts",
22+
"src/features/network/hooks.ts",
23+
"src/features/network/notify.ts",
24+
"src/features/network/socket.ts",
25+
"src/features/network/types.ts",
26+
"src/features/theme/hooks.ts",
27+
"src/features/theme/store.ts",
28+
"src/features/theme/types.ts",
29+
"src/main.tsx",
30+
"src/styles/index.css"
31+
],
32+
"build" : [
33+
"build-all.sh",
34+
"build.sh",
35+
"package.json",
36+
"scripts/build-all.mjs",
37+
"scripts/copy-static.mjs"
38+
],
39+
"server" : [
40+
"server/README.md",
41+
"server/client.go",
42+
"server/go.mod",
43+
"server/go.sum",
44+
"server/hub.go",
45+
"server/main.go",
46+
"server/message.go",
47+
"server/static/index.html"
48+
]
49+
}
50+
}

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
dist
3+
.DS_Store
4+
server/static/*
5+
*.tsbuildinfo
6+
lantalk-server
7+
dist-bin

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"files.exclude": {
3+
"**/*.tsbuildinfo": true,
4+
}
5+
}

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# LanTalk
2+
3+
局域网聊天工具

build-all.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
# build-all.sh — cross-compile LanTalk server for all major platforms
3+
# Run AFTER build.sh has already copied dist/ to server/static/
4+
set -e
5+
6+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
cd "$SCRIPT_DIR/server"
8+
9+
go mod download
10+
11+
targets=(
12+
"linux amd64 lantalk-server-linux-amd64"
13+
"linux arm64 lantalk-server-linux-arm64"
14+
"darwin amd64 lantalk-server-macos-amd64"
15+
"darwin arm64 lantalk-server-macos-arm64"
16+
"windows amd64 lantalk-server-windows-amd64.exe"
17+
)
18+
19+
mkdir -p ../dist-bin
20+
21+
for t in "${targets[@]}"; do
22+
read -r goos goarch outname <<< "$t"
23+
echo " Building $outname ..."
24+
GOOS=$goos GOARCH=$goarch go build -ldflags="-s -w" -o "../dist-bin/$outname" .
25+
done
26+
27+
echo ""
28+
echo "✅ All binaries in dist-bin/:"
29+
ls -lh ../dist-bin/

build.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
cd "$SCRIPT_DIR"
6+
7+
echo "==> [1/4] Installing frontend dependencies..."
8+
npm install
9+
10+
echo "==> [2/4] Building frontend..."
11+
npm run build
12+
13+
echo "==> [3/4] Copying dist to server/static..."
14+
rm -rf server/static/*
15+
cp -r dist/* server/static/
16+
17+
echo "==> [4/4] Building Go binary..."
18+
cd server
19+
20+
go mod download
21+
22+
mkdir -p ../dist-bin
23+
go build -ldflags="-s -w" -o ../dist-bin/lantalk .
24+
25+
cd ..
26+
27+
echo ""
28+
echo "✅ Build complete! Run with:"
29+
echo " ./dist-bin/lantalk"
30+
echo ""
31+
echo " Optional: set PORT env var to change port (default 3000)"
32+
echo " PORT=8080 ./dist-bin/lantalk"

index.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!doctype html>
2+
<html lang="zh-CN">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover" />
6+
<meta name="mobile-web-app-capable" content="yes" />
7+
<meta name="apple-mobile-web-app-capable" content="yes" />
8+
<meta name="apple-mobile-web-app-status-bar-style" content="default" />
9+
<title>LanTalk</title>
10+
</head>
11+
<body>
12+
<div id="root"></div>
13+
<script type="module" src="/src/main.tsx"></script>
14+
</body>
15+
</html>

package.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "@hyxf/lantalk",
3+
"private": true,
4+
"version": "0.0.1",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"server": "cd server && go run .",
9+
"build": "tsc -b && vite build",
10+
"build:go": "npm run build && node scripts/copy-static.mjs && cd server && go mod download && mkdir -p ../dist-bin && go build -ldflags=\"-s -w\" -o ../dist-bin/lantalk .",
11+
"build:go:win": "npm run build && node scripts/copy-static.mjs && cd server && go mod download && mkdir -p ../dist-bin && go build -ldflags=\"-s -w\" -o ../dist-bin/lantalk.exe .",
12+
"build:all": "npm run build && node scripts/copy-static.mjs && node scripts/build-all.mjs",
13+
"lint": "eslint .",
14+
"preview": "vite preview"
15+
},
16+
"dependencies": {
17+
"react": "^19.0.0",
18+
"react-dom": "^19.0.0",
19+
"zustand": "^5.0.0",
20+
"clsx": "^2.1.0",
21+
"tailwind-merge": "^2.2.0",
22+
"ws": "^8.18.0",
23+
"lucide-react": "^0.460.0",
24+
"qrcode": "^1.5.4"
25+
},
26+
"devDependencies": {
27+
"@types/react": "^19.0.0",
28+
"@types/react-dom": "^19.0.0",
29+
"@vitejs/plugin-react": "^4.2.1",
30+
"typescript": "^5.3.3",
31+
"vite": "^5.1.0",
32+
"tailwindcss": "^4.0.0",
33+
"@tailwindcss/vite": "^4.0.0",
34+
"@types/ws": "^8.5.10",
35+
"@types/qrcode": "^1.5.5"
36+
}
37+
}

scripts/build-all.mjs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* Cross-compile lantalk-server for all platforms.
3+
* Run after `npm run build` and copy-static.mjs have completed.
4+
*/
5+
import { execSync } from 'child_process';
6+
import { mkdirSync } from 'fs';
7+
import { resolve, dirname } from 'path';
8+
import { fileURLToPath } from 'url';
9+
10+
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
11+
const serverDir = resolve(root, 'server');
12+
const outDir = resolve(root, 'dist-bin');
13+
14+
mkdirSync(outDir, { recursive: true });
15+
16+
const targets = [
17+
{ GOOS: 'linux', GOARCH: 'amd64', out: 'lantalk-linux-amd64' },
18+
{ GOOS: 'linux', GOARCH: 'arm64', out: 'lantalk-linux-arm64' },
19+
{ GOOS: 'darwin', GOARCH: 'amd64', out: 'lantalk-macos-amd64' },
20+
{ GOOS: 'darwin', GOARCH: 'arm64', out: 'lantalk-macos-arm64' },
21+
{ GOOS: 'windows', GOARCH: 'amd64', out: 'lantalk-windows-amd64.exe' },
22+
];
23+
24+
for (const { GOOS, GOARCH, out } of targets) {
25+
const outPath = resolve(outDir, out);
26+
console.log(`Building ${out}...`);
27+
execSync(
28+
`go build -ldflags="-s -w" -o "${outPath}" .`,
29+
{
30+
cwd: serverDir,
31+
env: { ...process.env, GOOS, GOARCH, CGO_ENABLED: '0' },
32+
stdio: 'inherit',
33+
}
34+
);
35+
}
36+
37+
console.log('\n✅ All binaries written to dist-bin/');

scripts/copy-static.mjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { rmSync, mkdirSync, cpSync } from 'fs';
2+
import { resolve, dirname } from 'path';
3+
import { fileURLToPath } from 'url';
4+
5+
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
6+
const dist = resolve(root, 'dist');
7+
const target = resolve(root, 'server', 'static');
8+
9+
rmSync(target, { recursive: true, force: true });
10+
mkdirSync(target, { recursive: true });
11+
cpSync(dist, target, { recursive: true });
12+
console.log('✅ Copied dist → server/static');

0 commit comments

Comments
 (0)