# chess **Repository Path**: liu-yong-123/chess ## Basic Information - **Project Name**: chess - **Description**: 中国象棋,可局域网对战 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 3 - **Created**: 2023-04-22 - **Last Updated**: 2023-04-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 中国象棋 使用 golang + react + android 开发的跨平台中国象棋,可单机,可局域网对战 - 在线示例 http://yuncommunity.com:8048 - 源码地址 https://gitee.com/yuncommunity/chess - 视频教程 # 目录简介 - android android端,使用 gomobile 框架 - api 服务器端,使用 beego 框架 - web 前端,使用 dva 创建模板,核心代码改自 https://github.com/itlwei/chess - abuild.sh 复制服务器文件到 android 项目中,并打包生成 apk - build.sh 依次运行脚本: 打包前端,打包服务器,打包android - gobuild.sh 打包服务器脚本 - jsbuild.sh 打包前端脚本,并复制生成的文件到服务器项目中 - push.sh 上传代码到git服务器 # 使用框架 - 后台主框架 beego https://beego.me/ - 前端模板 dva https://github.com/dvajs/dva - android端 gomobile https://github.com/golang/mobile # 下载并运行 需要先配置 golang 和 npm 开发环境 - 下载源码 ```` cd $GOPATH/src git clone https://gitee.com/yuncommunity/chess.git cd chess git checkout tags/v1.0 ```` - 运行后台接口 ```` cd $GOPATH/src/chess/api go get go run main.go ```` 打开浏览器 http://localhost:8048/ 可以查看是否启动成功 - 运行前端界面 ```` cd $GOPATH/src/chess/web npm i npm start ```` 打开浏览器 http://localhost:8049/ 可以查看是否启动成功(一般需要等几十秒) - 运行android端 安装并初始化 gomobile,参考: https://github.com/golang/go/wiki/Mobile ```` go get golang.org/x/mobile/cmd/gomobile gomobile init ```` 确保手机连接到电脑,并打开调试模式 ```` # 查看手机连接是否正常 adb devices ```` ```` cd $GOPATH/src/chess # 删除之前的的服务器文件 rm -rf android/app/src/main/assets/* # 复制配置文件 cp -a api/conf android/app/src/main/assets/ # 复制静态文件,js/图片/css cp -a api/static android/app/src/main/assets/ # 复制 beego 的模板文件(*.html) cp -a api/views android/app/src/main/assets/ # 使用 gomobile 打包 aar gomobile bind -target=android chess/api/chessweb # 移动 aar 到 android 项目中 mv chessweb.aar android/app/libs cd android # 编译并安装到手机,如果只编译不安装则执行 ./gradlew assembleDebug ./gradlew installDebug # 启动 app adb shell am start -n com.yuncommunity.chess/.MainActivity ````