Skip to content

Commit

Permalink
修正在某些低版本的情况下,弹框无法正确开启
Browse files Browse the repository at this point in the history
  • Loading branch information
CYL96 committed Aug 22, 2024
1 parent a864f52 commit a278d92
Show file tree
Hide file tree
Showing 25 changed files with 163 additions and 19 deletions.
4 changes: 2 additions & 2 deletions server/build-win.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ chcp 65001 > nul
echo 当前时间:%time:~0,8%

echo 开始编译 control-server.exe
go build -ldflags -H=windowsgui -o control-server.exe main.go
go build -ldflags -H=windowsgui -o control-server.exe

if %errorlevel%==0 (
echo 编译成功
Expand All @@ -13,7 +13,7 @@ if %errorlevel%==0 (
)

echo 开始编译 control-server-cli.exe
go build -o control-server-cli.exe main.go
go build -o control-server-cli.exe

if %errorlevel%==0 (
echo 编译成功
Expand Down
Binary file added server/config/icon.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion server/config/system.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"sound_open":true,"run_ip":"0.0.0.0","run_port":55001,"is_scale":true}
{"sound_open":true,"run_ip":"0.0.0.0","run_port":55003,"is_scale":true}
4 changes: 4 additions & 0 deletions server/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,10 @@ const docTemplate = `{
],
"example": 0
},
"mouse_back_to_origin": {
"description": "在脚本中,如果鼠标移动,是否返回原点",
"type": "boolean"
},
"path": {
"description": "目录或网页",
"type": "string",
Expand Down
4 changes: 4 additions & 0 deletions server/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,10 @@
],
"example": 0
},
"mouse_back_to_origin": {
"description": "在脚本中,如果鼠标移动,是否返回原点",
"type": "boolean"
},
"path": {
"description": "目录或网页",
"type": "string",
Expand Down
3 changes: 3 additions & 0 deletions server/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ definitions:
default: 0
description: 1:color 2:图片
example: 0
mouse_back_to_origin:
description: 在脚本中,如果鼠标移动,是否返回原点
type: boolean
path:
description: 目录或网页
example: ""
Expand Down
Binary file removed server/go_build_server.exe
Binary file not shown.
10 changes: 10 additions & 0 deletions server/nac.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
Binary file added server/nac.syso
Binary file not shown.
26 changes: 26 additions & 0 deletions server/src/common/ip.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**************************************************
*文件名:ip.go
*内容简述:*
*文件历史:
author CYL96 创建 2024/6/21
**************************************************/

package common

import "net"

func GetAllIp() []string {
var ipList []string
addrs, err := net.InterfaceAddrs()
if err != nil {
return ipList
}
for _, address := range addrs {
if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
if ipnet.IP.To4() != nil {
ipList = append(ipList, ipnet.IP.String())
}
}
}
return ipList
}
31 changes: 31 additions & 0 deletions server/src/common/ip_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**************************************************
*文件名:ip_test.go
*内容简述:*
*文件历史:
author CYL96 创建 2024/6/21
**************************************************/

package common

import (
"fmt"
"log"
"net"
"testing"
)

func TestGetAllIp(t *testing.T) {
interfaces, err := net.Interfaces()
if err != nil {
log.Println(err)
return
}
for _, inte := range interfaces {
fmt.Println("Name:", inte.Name)
fmt.Println("HardwareAddr:", inte.HardwareAddr)
fmt.Println("flag:", inte.Flags)
addrs, err := inte.Addrs()
fmt.Println("ip:", addrs, err)
fmt.Println("-----------------------")
}
}
17 changes: 17 additions & 0 deletions server/src/common/url.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**************************************************
*文件名:url.go
*内容简述:*
*文件历史:
author CYL96 创建 2024/6/21
**************************************************/

package common

import "os/exec"

func OpenUrl(url string) {
if url == "" {
return
}
exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
}
5 changes: 3 additions & 2 deletions server/src/config/ctrl.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ const (
ControlTypeRunExe ControlType = 5 // 4:打开exe
ControlTypeRunCmd ControlType = 6 // 4:打开cmd

KeyTypeDefault KeyType = 1 // 单键
KeyTypeText KeyType = 2 // 文本
KeyTypeDefault KeyType = 1 // 单键
KeyTypeText KeyType = 2 // 文本

KeyTypeShortcutKey KeyType = 3 // 快捷键
KeyTypeMouse KeyType = 4 // 鼠标点击
KeyTypeMouseMove KeyType = 5 // 鼠标移动
Expand Down
4 changes: 3 additions & 1 deletion server/src/config/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ func readSystemConfig(ctx *runCtx.RunCtx) (err error) {
if err != nil {
return
}

if len(SystemConfig.RunIp) == 0 {
SystemConfig.RunIp = "0.0.0.0"
}
return nil
}

Expand Down
27 changes: 27 additions & 0 deletions server/src/systray/systray.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ package systray

import (
"encoding/base64"
"fmt"
"log"

"github.com/getlantern/systray"
"server/src/common"
"server/src/config"
"server/src/runCtx"
)

func RunSystray() {
Expand All @@ -25,11 +29,34 @@ func onReady() {
log.Println(err)
}
systray.SetTitle("Control My Windows")

cfg := config.GetSystemConfig(runCtx.DefaultContext())
var urlOpen = func(url string) {
ch := systray.AddMenuItem(url, url)
go func() {
<-ch.ClickedCh
common.OpenUrl(url)
}()
}

if cfg.RunIp == "0.0.0.0" {
ips := common.GetAllIp()
for _, ip := range ips {
url := fmt.Sprintf("http://%s:%d", ip, cfg.RunPort)
urlOpen(url)
}
} else {
url := fmt.Sprintf("http://%s:%d", cfg.RunIp, cfg.RunPort)
urlOpen(url)
}

systray.AddSeparator()
mQuit := systray.AddMenuItem("Quit", "Quit the whole app")
go func() {
<-mQuit.ClickedCh
systray.Quit()
}()

}

func onExit() {
Expand Down
16 changes: 16 additions & 0 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@element-plus/icons-vue": "^2.3.1",
"@icon-park/vue-next": "^1.4.2",
"axios": "^1.6.8",
"core-js": "^3.38.1",
"element-plus": "^2.6.2",
"vue": "^3.4.15",
"vue-draggable-plus": "^0.4.0",
Expand Down
2 changes: 1 addition & 1 deletion ui/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script setup>
import {onMounted} from "vue";
onMounted(() => {
var bd = document.getElementById("my-body")
bd.style.width = window.innerWidth + 'px'
Expand All @@ -11,6 +10,7 @@ onMounted(() => {

<template>
<div id="my-body">
<!-- 123123-->
<router-view/>
</div>
</template>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/assets/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
}

body {
min-height: 100vh;
min-height: 100%;
color: var(--color-text);
background: var(--color-background);
transition:
Expand Down
6 changes: 3 additions & 3 deletions ui/src/components/control/control.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</div>

<div @click="ClickControlDetail(item)"
style="display: flex;flex-grow: 1;margin-left: 1vw;text-align: center;justify-content: center;height: 100%">
style="display: flex;flex-grow: 1;margin-left: 1%;text-align: center;justify-content: center;height: 100%">
<el-text style="width: 100%;">{{ item.control_name }}</el-text>
</div>
<div style="display: flex;flex-direction: column; justify-content: space-around;align-items: flex-end;padding-right: 1%;height: 100%">
Expand Down Expand Up @@ -118,7 +118,7 @@
<el-dialog
v-model="exitDialogVisible"
align-center
width="40vh">
width="40%">
<el-text>退出程序?</el-text>
<template #footer>
<div class="works-dialog-footer">
Expand All @@ -134,7 +134,7 @@
<!-- 系统设置 弹框 -->
<el-dialog align-center
v-model="editSystemDialogVisible"
width="80vw">
width="80%">
<el-form label-width="auto">
<el-form-item label="端口">
<el-input-number v-model="editSystemItem.run_port"></el-input-number>
Expand Down
4 changes: 2 additions & 2 deletions ui/src/components/detail/detail.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
/*margin-right: 6px;*/
}
.detail-color-picker{
height: 200vh;
height: 200%;
}

.detail-list-scrollbar-view {
Expand All @@ -60,7 +60,7 @@

.detail-list-script-view {
height: 90%;
max-width: 95vw;
max-width: 95%;
display: flex;
align-items: flex-start;
justify-content: flex-start;
Expand Down
8 changes: 4 additions & 4 deletions ui/src/components/detail/detail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
<div style="display: flex;flex-direction: column;height: 100%;width: 100%">
<header style="height: 5%;padding: 1% 0 1% 0;min-height: 30px;width: 100%">
<div style="display: flex;align-items: center;justify-content: center;height: 100%">
<el-button @click="GotoHome" style="width: 10vw">
<el-button @click="GotoHome" style="width: 10%">
<el-icon>
<Back/>
</el-icon>
</el-button>


<el-button @click="GetDetailList" style="width: 30vw">
<el-button @click="GetDetailList" style="width: 30%">
<el-icon>
<Refresh/>
</el-icon>
</el-button>

<div style="width: 45vw;margin-left: 12px;display: flex;align-items: center;justify-content: center">
<div style="width: 45%;margin-left: 12px;display: flex;align-items: center;justify-content: center">
<el-button v-show="!isEditMod" @click="isEditMod= true" style="width: 100%">
<el-icon>
<Edit/>
Expand Down Expand Up @@ -225,7 +225,7 @@
<el-dialog align-center
v-model="editDialogVisible"
:fullscreen="true"
width="90vw">
width="90%">
<div
style="width: 100%;display: flex;flex-direction: column;align-items: center;justify-content: center;margin-top: 30px;">
<el-form label-position="right" label-width="auto" style="width: 100%;">
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/detail/detailEdit.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div >
<div style="display: flex;height: 90%;max-width: 90vw;align-items: center;justify-content: center;">
<div style="display: flex;height: 90%;max-width: 90%;align-items: center;justify-content: center;">
<VueDraggable
v-model="showList"
:animation="150"
Expand Down
1 change: 1 addition & 0 deletions ui/src/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'core-js/actual/array/flat-map'
import {createApp} from "vue";
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
Expand Down
3 changes: 2 additions & 1 deletion ui/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export default defineConfig({
vue(),
],
build:{
target:['edge90','chrome90','firefox90','safari14','safari15','es2015'],
cssTarget: 'chrome83',
target:['edge83','chrome83','firefox83','safari14','safari15','es2015'],
},
resolve: {
alias: {
Expand Down

0 comments on commit a278d92

Please sign in to comment.