Skip to content

Commit

Permalink
v1.0.4
Browse files Browse the repository at this point in the history
- 修复Android客户端可能推送部分文本的问题
- 修复部分Windows系统二维码生成时乱码问题
- 电脑端支持关闭自动使用默认浏览器打开链接(默认值为自动打开链接),配置文件lemon.conf使用auto_open_url=close关闭,auto_open_url=open自动打开链接
- 电脑端提供上传和下载接口,iOS支持上传和下载快捷指令 by @bestK
  • Loading branch information
ishare20 committed Dec 14, 2023
1 parent e1bb10a commit 1efe010
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 28 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "net.lemontree.push"
minSdkVersion 21
targetSdkVersion 32
versionCode 4
versionName "1.0.3"
versionCode 5
versionName "1.0.4"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="net.lemontree.push">

<uses-feature
android:name="android.hardware.camera"
android:required="false" />
Expand All @@ -13,6 +12,7 @@
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_CLIPBOARD" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />

<application

Expand Down
12 changes: 7 additions & 5 deletions android/app/src/main/java/net/lemontree/push/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@

import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Type;
import java.net.Socket;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -250,12 +252,12 @@ public void onWindowFocusChanged(boolean hasFocus) {
}

public static boolean sendToPC(String url, String content) {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(url + "?text=" + content)
.build();
Call call = client.newCall(request);
try {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(url + "?text=" + URLEncoder.encode(content, "UTF-8"))
.build();
Call call = client.newCall(request);
Response response = call.execute();
if (response.isSuccessful()) {
return true;
Expand Down
4 changes: 4 additions & 0 deletions desktop/src/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ module net.blt/lemon_push
go 1.20

require (
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f // indirect
github.com/Han-Ya-Jun/qrcode2console v0.0.0-20190430081741-6890f5f0fdf5 // indirect
github.com/atotto/clipboard v0.1.4 // indirect
github.com/disintegration/imaging v1.6.2 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mdp/qrterminal/v3 v3.1.1 // indirect
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect
golang.org/x/image v0.13.0 // indirect
golang.org/x/sys v0.8.0 // indirect
rsc.io/qr v0.2.0 // indirect
)
11 changes: 11 additions & 0 deletions desktop/src/go.sum
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f h1:2dk3eOnYllh+wUOuDhOoC2vUVoJF/5z478ryJ+wzEII=
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f/go.mod h1:4a58ifQTEe2uwwsaqbh3i2un5/CBPg+At/qHpt18Tmk=
github.com/Han-Ya-Jun/qrcode2console v0.0.0-20190430081741-6890f5f0fdf5 h1:EMggICCq0/d9uNIJzwj3UHntcH6cPVT4kfWbyzut8GQ=
github.com/Han-Ya-Jun/qrcode2console v0.0.0-20190430081741-6890f5f0fdf5/go.mod h1:onbao3S7v7VTWE5sGfmiYgOt1MqzSd2dMp/+o6rk1Wk=
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c=
github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mdp/qrterminal/v3 v3.1.1 h1:cIPwg3QU0OIm9+ce/lRfWXhPwEjOSKwk3HBwL3HBTyc=
github.com/mdp/qrterminal/v3 v3.1.1/go.mod h1:5lJlXe7Jdr8wlPDdcsJttv1/knsRgzXASyr4dcGZqNU=
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.13.0 h1:3cge/F/QTkNLauhf2QoE9zp+7sr+ZcL4HnoZmdwg9sg=
golang.org/x/image v0.13.0/go.mod h1:6mmbMOeV28HuMTgA6OSRkdXKYw/t5W9Uwn2Yv1r3Yxk=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
rsc.io/qr v0.2.0 h1:6vBLea5/NRMVTz8V66gipeLycZMl/+UlFmk8DvqQ6WY=
rsc.io/qr v0.2.0/go.mod h1:IF+uZjkb9fqyeF/4tlBoynqmQxUoPfWEKh921coOuXs=
1 change: 1 addition & 0 deletions desktop/src/lemon_push.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ip=
port=14756
folder=./_lemon_
auto_open_url=open
41 changes: 22 additions & 19 deletions desktop/src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ import (
"strings"
"time"

qrcodeTerminal "github.com/Baozisoftware/qrcode-terminal-go"
"github.com/atotto/clipboard"
"github.com/mdp/qrterminal/v3"
)

var dt = time.Now()
var folder = "./_lemon_"
var auto_open_url = "open"

func main() {
http.HandleFunc("/set_clipboard", setClipboard)
Expand All @@ -33,12 +34,16 @@ func main() {
fmt.Println("加载配置lemon_push.conf失败:", lerr)
return
}
port := ":" + config["port"] // 监听端口
selectedIP := config["ip"] // ip地址
folder = config["folder"] // 文件夹
port := ":" + config["port"] // 监听端口
selectedIP := config["ip"] // ip地址
folder = config["folder"] // 文件夹
auto_open_url = config["auto_open_url"] // 自动使用默认浏览器打开url
if folder != "" {
createFolderIfNotExists(folder)
}
if auto_open_url == "" { //存在配置但没有字段值时
auto_open_url = "open"
}

fmt.Println(dt.Format("2006-01-02 15:04:05"), " 服务端监听端口:", config["port"])

Expand All @@ -64,7 +69,7 @@ func main() {

fmt.Println(dt.Format("2006-01-02 15:04:05"), " 选择的IP地址:", selectedIP, " 请使用App扫码连接")
url := selectedIP + port
qRCode2ConsoleWithUrl(url)
qRCode2ConsoleWithUrlNew(url)
fmt.Println(dt.Format("2006-01-02 15:04:05"), " 服务端已启动")
err := http.ListenAndServe(port, nil)
if err != nil {
Expand All @@ -73,14 +78,9 @@ func main() {

}

func qRCode2ConsoleWithUrl(url string) {
config := qrterminal.Config{
Level: qrterminal.L,
BlackChar: qrterminal.BLACK,
WhiteChar: qrterminal.WHITE,
Writer: os.Stdout,
}
qrterminal.GenerateWithConfig(url, config)
func qRCode2ConsoleWithUrlNew(url string) {
obj := qrcodeTerminal.New()
obj.Get(url).Print()
}

func getLocalIP() []string {
Expand Down Expand Up @@ -121,12 +121,14 @@ func setClipboard(w http.ResponseWriter, r *http.Request) {
code := values.Get("text")
clipboard.WriteAll(code)
fmt.Println("客户端 " + r.RemoteAddr + " 设置剪切板:" + code)
p := regexp.MustCompile(`https?://[^\s]+/[^/]+`)
if p.MatchString(code) {
matches := p.FindAllString(code, -1)
for _, match := range matches {
fmt.Printf("%s 启动浏览器打开链接:%s\n", dt.Format("2006-01-02 15:04:05"), match)
openBrowser(match)
if auto_open_url == "open" {
p := regexp.MustCompile(`https?://[^\s]+/[^/]+`)
if p.MatchString(code) {
matches := p.FindAllString(code, -1)
for _, match := range matches {
fmt.Printf("%s 启动浏览器打开链接:%s\n", dt.Format("2006-01-02 15:04:05"), match)
openBrowser(match)
}
}
}

Expand Down Expand Up @@ -259,6 +261,7 @@ func loadConfigFile(filename string) (map[string]string, error) {
config["port"] = "14756"
config["folder"] = "./_lemon_"
config["ip"] = ""
config["auto_open_url"] = "open"

// 创建文件并写入默认配置
file, err = os.OpenFile(filePath, os.O_RDWR|os.O_CREATE, 0644)
Expand Down
8 changes: 7 additions & 1 deletion docs/docs/download.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ sidebar_position: 2

## 123 云盘汇总下载链接

### v1.0.4

*2023.12.14*

[https://www.123pan.com/s/y4HrVv-fYUlA.html](https://www.123pan.com/s/y4HrVv-fYUlA.html)

### v1.0.3

[https://www.123pan.com/s/y4HrVv-xtulA.html](https://www.123pan.com/s/y4HrVv-xtulA.html)
Expand All @@ -26,7 +32,7 @@ sidebar_position: 2

获取快捷指令后修改 IP 地址为电脑的 IP 地址即可

### [推送剪切板](https://www.icloud.com/shortcuts/8a70ba1051cc4b9192a2e966d10fbf85)
### [推送剪切板](https://www.icloud.com/shortcuts/e4c0de6a7a7d4a52a8e82f108e509475)

### [获取剪切板](https://www.icloud.com/shortcuts/3dc68dccca8c4818982cfbbd5ae89c44)

Expand Down
8 changes: 8 additions & 0 deletions docs/docs/version.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# 版本更新日志
## v1.0.4
*2023.12.14*

- 修复Android客户端可能推送部分文本的问题
- 修复部分Windows系统二维码生成时乱码问题
- 电脑端支持关闭自动使用默认浏览器打开链接(默认值为自动打开链接),配置文件lemon.conf使用auto_open_url=close关闭,auto_open_url=open自动打开链接
- 电脑端提供上传和下载接口,iOS支持上传和下载快捷指令 by @bestK

## v1.0.3
- App支持扫码连接,无需手动输入

Expand Down

0 comments on commit 1efe010

Please sign in to comment.