Merge branch 'rocboss:main' into main

pull/38/head
1005281342 3 years ago committed by GitHub
commit cadde4ae89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

6
.gitignore vendored

@ -1,5 +1,7 @@
.idea
.vscode
__debug_bin
!*.example
dist/
config.yaml
*.log
paopao-api
paopao-ce*

@ -15,7 +15,7 @@ ENV TZ=Asia/Shanghai
RUN apk update && apk add --no-cache ca-certificates && update-ca-certificates
COPY --from=build-env /paopao-ce/paopao-ce /usr/bin/paopao-ce
COPY --from=build-env /paopao-ce/comic.ttf /comic.ttf
COPY --from=build-env /paopao-ce/assets/comic.ttf /assets/comic.ttf
COPY --from=build-env /paopao-ce/configs /configs
EXPOSE 8000

@ -0,0 +1,26 @@
.PHONY: all build clean fmt help
BUILD_VERSION := $(shell cat version)
BUILD_DATE := $(shell date +'%Y-%m-%d %H:%M:%S')
SHA_SHORT := $(shell git rev-parse --short HEAD)
all: fmt build
build:
@go mod download
@echo Build paopao-ce
bash build.sh paopao-ce
clean:
@go clean
@find ./dist -type f -exec rm -r {} +
@find ./tmp -type f -exec rm -r {} +
fmt:
@echo Formatting...
@go fmt ./global/...
@go fmt ./internal/...
@go fmt ./pkg/...
@go vet -composites=false ./global/...
@go vet -composites=false ./internal/...
@go vet -composites=false ./pkg/...
help:
@echo "make: make"
@echo "make build: build executables"
.EXPORT_ALL_VARIABLES:
GO111MODULE = on

@ -1,6 +1,5 @@
<div id="top"></div>
<!-- PROJECT SHIELDS -->
[![Go Report Card][goreport-shield]][goreport-url]
[![Forks][forks-shield]][forks-url]
@ -28,9 +27,9 @@
</p>
</div>
---
## 1. 截图预览
## 预览
[![明色主题][product-light-screenshot]](https://www.paopao.info)
@ -40,10 +39,7 @@
<p align="right">(<a href="#top">back to top</a>)</p>
<!-- GETTING STARTED -->
## 2. 快速开始
### 2.1 技术栈
## 🛠 技术栈
PaoPao主要由以下优秀的开源项目/工具构建
@ -54,22 +50,22 @@ PaoPao主要由以下优秀的开源项目/工具构建
* [Vue.js](https://vuejs.org/)
* [Vite.js](https://vitejs.dev/)
<!-- GETTING STARTED -->
## 🏗 快速开始
### 2.2 环境要求
### 环境要求
- Go (1.17+)
- Node.js (14+)
- MySQL (5.7+)
- Redis
- Zinc
* Go (1.17+)
* Node.js (14+)
* MySQL (5.7+)
* Redis
* Zinc
\* Zinc是一款轻量级全文搜索引擎可以查阅 https://zincsearch.com/ 安装
\* Zinc是一款轻量级全文搜索引擎可以查阅 <https://zincsearch.com/> 安装
以上环境版本为PaoPao官方的开发版本仅供参考其他版本的环境未进行充分测试
<br />
### 3. 安装说明
### 安装说明
***宝塔安装***
@ -78,45 +74,62 @@ PaoPao主要由以下优秀的开源项目/工具构建
***普通安装***
克隆代码库
```sh
git clone https://github.com/rocboss/paopao-ce.git
```
#### 3.1 后端
#### 后端
1. 导入项目根目录下的 `paopao.sql` 文件至MySQL数据库
2. 拷贝项目根目录下 `config.yaml.sample` 文件至 `config.yaml`,按照注释完成配置编辑
3. 编译后端
```sh
go mod download
go build -o paopao-api .
```
4. 启动后端
```sh
chmod +x paopao-api
./paopao-api
```
#### 3.2 前端
#### 前端
1. 进入前端目录 `web`,编辑 `.env` 文件中后端服务地址,下载依赖包
```sh
cd ./web
vim .env
yarn
```
2. 编译前端
```sh
yarn build
```
build完成后可以在dist目录获取编译产出配置nginx指向至该目录即可
#### 3.3 其他
建议后端服务使用 `supervisor` 守护进程并通过nginx反向代理后提供API给前端服务调用。
### 其他说明
建议后端服务使用 `supervisor` 守护进程,并通过 `nginx` 反向代理后提供API给前端服务调用。
短信通道使用的[聚合数据](https://www.juhe.cn/),如果申请不下来,可以考虑替换其他服务商。
代码结构比较简单,很方便扩展
## 👯‍♀️ 贡献
喜欢的朋友欢迎给个Star、贡献PR。
短信通道使用的聚合数据(juhe.cn),如果申请不下来,可以考虑替换其他服务商。
## License
代码结构比较简单很方便扩展喜欢的朋友欢迎给个Star、贡献PR。
Distributed under the MIT License. See `LICENSE` for more information.
<!-- MARKDOWN LINKS & IMAGES -->
[contributors-shield]: https://img.shields.io/github/contributors/rocboss/paopao-ce?style=flat
@ -133,4 +146,4 @@ PaoPao主要由以下优秀的开源项目/工具构建
[license-url]: https://github.com/rocboss/paopao-ce/blob/master/LICENSE.txt
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=flat&logo=linkedin&colorB=555
[product-light-screenshot]: https://cdn.rocs.me/static/paopao-light.jpeg
[product-dark-screenshot]: https://cdn.rocs.me/static/paopao-dark.jpeg
[product-dark-screenshot]: https://cdn.rocs.me/static/paopao-dark.jpeg

@ -0,0 +1,35 @@
#!/usr/bin/env bash
# shellcheck disable=SC2155
set -e
DIST_PREFIX=${1}
DEBUG_MODE=${2}
TARGET_DIR="dist"
PLATFORMS="darwin/arm64 linux/amd64 windows/amd64"
rm -rf ${TARGET_DIR}
mkdir ${TARGET_DIR}
for pl in ${PLATFORMS}; do
export CGO_ENABLED=0
export GOOS=$(echo "${pl}" | cut -d'/' -f1)
export GOARCH=$(echo "${pl}" | cut -d'/' -f2)
export TARGET=${TARGET_DIR}/${DIST_PREFIX}_${GOOS}_${GOARCH}
if [ "${GOOS}" == "windows" ]; then
export TARGET=${TARGET_DIR}/${DIST_PREFIX}_${GOOS}_${GOARCH}.exe
fi
echo "build => ${TARGET}"
if [ "${DEBUG_MODE}" == "debug" ]; then
go build -trimpath -gcflags "all=-N -l" -o "${TARGET}" \
-ldflags "-X 'main.version=${BUILD_VERSION}' \
-X 'main.buildDate=${BUILD_DATE}' \
-X 'main.commitID=${SHA_SHORT}'\
-w -s"
else
go build -trimpath -o "${TARGET}" \
-ldflags "-X 'main.version=${BUILD_VERSION}' \
-X 'main.buildDate=${BUILD_DATE}' \
-X 'main.commitID=${SHA_SHORT}'\
-w -s"
fi
done

@ -9,6 +9,7 @@ require (
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/disintegration/imaging v1.6.2
github.com/ethereum/go-ethereum v1.10.16
github.com/fatih/color v1.13.0
github.com/fbsobreira/gotron-sdk v0.0.0-20211102183839-58a64f4da5f4
github.com/gin-contrib/cors v1.3.1
github.com/gin-gonic/gin v1.7.7
@ -16,7 +17,6 @@ require (
github.com/go-redis/redis/v8 v8.11.4
github.com/go-resty/resty/v2 v2.7.0
github.com/gofrs/uuid v3.3.0+incompatible
github.com/golang/protobuf v1.5.2
github.com/google/go-cmp v0.5.7 // indirect
github.com/satori/go.uuid v1.2.0 // indirect
github.com/sirupsen/logrus v1.8.1
@ -28,6 +28,7 @@ require (
golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9 // indirect
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 // indirect
google.golang.org/protobuf v1.27.1
gopkg.in/natefinch/lumberjack.v2 v2.0.0
gopkg.in/resty.v1 v1.12.0
gorm.io/driver/mysql v1.3.2

@ -201,6 +201,7 @@ github.com/ethereum/go-ethereum v1.10.16 h1:3oPrumn0bCW/idjcxMn5YYVCdK7VzJYIvwGZ
github.com/ethereum/go-ethereum v1.10.16/go.mod h1:Anj6cxczl+AHy63o4X9O8yWNHuN5wMpfb8MAnHkWn7Y=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
github.com/fbsobreira/gotron-sdk v0.0.0-20211102183839-58a64f4da5f4 h1:zlN+of+l+or/Y6CYgpX99wwaTf4zN0myVj6YAXiE3xk=
@ -485,6 +486,7 @@ github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope
github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-ieproxy v0.0.0-20190610004146-91bb50d98149/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc=
github.com/mattn/go-ieproxy v0.0.0-20190702010315-6dee0af9227d/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc=

@ -44,7 +44,7 @@ func SyncSearchIndex(c *gin.Context) {
func GetCaptcha(c *gin.Context) {
cap := captcha.New()
if err := cap.SetFont("comic.ttf"); err != nil {
if err := cap.SetFont("assets/comic.ttf"); err != nil {
panic(err.Error())
}

@ -4,9 +4,15 @@ import (
"fmt"
"net/http"
"github.com/fatih/color"
"github.com/gin-gonic/gin"
"github.com/rocboss/paopao-ce/global"
"github.com/rocboss/paopao-ce/internal/routers"
"github.com/rocboss/paopao-ce/pkg/util"
)
var (
version, buildDate, commitID string
)
func main() {
@ -21,6 +27,9 @@ func main() {
MaxHeaderBytes: 1 << 20,
}
fmt.Printf("\x1b[36m%s\x1b[0m\n", "PaoPao service listen on http://"+global.ServerSetting.HttpIp+":"+global.ServerSetting.HttpPort)
util.PrintHelloBanner(fmt.Sprintf("paopao %s (build:%s %s)", version, commitID, buildDate))
fmt.Fprintf(color.Output, "PaoPao service listen on %s\n",
color.GreenString(fmt.Sprintf("http://%s:%s", global.ServerSetting.HttpIp, global.ServerSetting.HttpPort)),
)
s.ListenAndServe()
}

@ -6,8 +6,8 @@ import (
"time"
"github.com/fbsobreira/gotron-sdk/pkg/proto/core"
"github.com/golang/protobuf/proto"
"github.com/rocboss/paopao-ce/pkg/crypto"
"google.golang.org/protobuf/proto"
)
// SignTransaction 签名交易

@ -0,0 +1,12 @@
package util
import "fmt"
func PrintHelloBanner(text string) {
fmt.Println(" ____ __ __ ____ __ __ ")
fmt.Println("( _ \\ / _\\ / \\( _ \\ / _\\ / \\ ")
fmt.Println(" ) __// \\( O )) __// \\( O )")
fmt.Println("(__) \\_/\\_/ \\__/(__) \\_/\\_/ \\__/ ")
fmt.Println(text)
}

@ -113,7 +113,7 @@ const replyAtUsername = ref('');
const replyComposeRef = ref();
const emit = defineEmits<{
(e: "reload"): void
(e: 'reload'): void
}>();
const props = withDefaults(defineProps<{
comment: Item.CommentProps

@ -170,7 +170,7 @@ import { parsePostTag } from '@/utils/content';
import type { MentionOption, UploadFileInfo, UploadInst } from 'naive-ui';
const emit = defineEmits<{
(e: "post-success"): void
(e: 'post-success'): void
}>();
const props = withDefaults(defineProps<{
lock: number,

@ -50,11 +50,11 @@ const props = withDefaults(defineProps<{
}>(), {
commentId: 0,
atUserid: 0,
atUsername: ""
atUsername: ''
});
const emit = defineEmits<{
(e: "reload"): void,
(e: "reset"): void
(e: 'reload'): void,
(e: 'reset'): void
}>();
const inputInstRef = ref<InputInst>();
const showReply = ref(false);

@ -76,8 +76,8 @@ const props = withDefaults(defineProps<{
}>(), {});
const store = useStore();
const emit = defineEmits<{
(e: "focusReply", reply: Item.ReplyProps): void,
(e: "reload"): void
(e: 'focusReply', reply: Item.ReplyProps): void,
(e: 'reload'): void
}>();
const focusReply = () => {

@ -136,7 +136,7 @@ declare module NetParams {
}
interface PostGetTags {
type: "hot" | string,
type: 'hot' | string,
num: number
}

@ -285,9 +285,9 @@ const modelData = reactive({
imgCaptcha: '',
phone: '',
phone_captcha: '',
password: "",
old_password: "",
reenteredPassword: "",
password: '',
old_password: '',
reenteredPassword: '',
});
const beforeUpload = async (data: any) => {

Loading…
Cancel
Save