提交 2600cf5d 编写于 作者: P peterq

feature: 关于页面

上级 7441f9f9
// +build !product
package dep
var Env = tEnv{
Dev: true,
Platform: "",
ApiBase: "http://127.0.0.1:8081",
InternalServerUrl: "",
VersionString: "v0.0.0-development",
DataPath: "",
Version: 20190620001,
ClientUA: "pan-light/v0.0.0-development;",
}
// +build product
package dep
var Env = tEnv{
Dev: false,
Platform: "",
ApiBase: "https://pan-light.peterq.cn",
InternalServerUrl: "",
VersionString: "v0.0.0-preview",
DataPath: "",
Version: 20190620001,
ClientUA: "pan-light/v0.0.0-preview;build 20190620;",
}
......@@ -10,27 +10,12 @@ import (
type tEnv struct {
Dev bool // 是否为开发环境
Platform string // 运行平台, darwin, windows, linux
ApiHost string
ApiBase string // api调用前缀
InternalServerUrl string
VersionString string
DataPath string
Version int
ClientUA string
ElectronSecretUA string
ListenPort int
}
var Env = tEnv{
Dev: true,
Platform: "",
ApiHost: "http://127.0.0.1:9050",
InternalServerUrl: "",
VersionString: "v1.0.0",
DataPath: "",
Version: 20181113001,
ClientUA: "pan-light/v1.0.0;build 20181113001;",
ElectronSecretUA: "secret",
ListenPort: 5678,
}
func init() {
......
......@@ -17,6 +17,10 @@ var baseSyncRoutes = map[string]syncHandler{
"env.internal_server_url": func(p map[string]interface{}) interface{} {
return dep.Env.InternalServerUrl
},
// 版本
"env.version": func(p map[string]interface{}) interface{} {
return dep.Env.VersionString
},
// 存数据
"storage.set": func(p map[string]interface{}) (result interface{}) {
storage.UserStorageSet(p["k"].(string), p["v"].(string))
......
......@@ -422,3 +422,14 @@ var openSetting = (function () {
return ins
}
})()
var openAbout = (function () {
var comp = loadComponent(function(){},'../pages/about-window.qml')
var ins
return function(){
if (!ins || !ins.visible) {
ins = comp.createObject(G.root)
}
return ins
}
})()
import QtQuick 2.0
import QtQuick.Window 2.2
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import "../js/app.js" as App
import "../js/util.js" as Util
Window {
id: window
flags: Qt.Dialog | Qt.WindowModal | Qt.WindowCloseButtonHint
modality: Qt.ApplicationModal
title: '关于'
minimumHeight: height
minimumWidth: width
maximumHeight: height
maximumWidth: width
visible: true
width: 600
height: 400
property string version: 'v0.0.1-preview'
property string userAgreementLink: 'https://pan-light.peterq.cn/user-agreement'
property string gitRepoUrl: 'https://github.com/peterq/pan-light'
property string email: 'me@peterq.cn'
Component.onCompleted: {
visible = true
requestActivate()
version = Util.callGoSync('env.version')
}
onVisibleChanged: {
if (!visible) {
window.destroy()
}
}
Item {
anchors.fill: parent
Rectangle {
id: logoCon
width: parent.width
height: parent.height * 0.7
Image {
source: '../assets/images/pan-light-1.png'
height: parent.height * 0.8
width: height
anchors.centerIn: parent
}
}
Rectangle {
width: parent.width
height: parent.height - logoCon.height
anchors.top: logoCon.bottom
color: '#eee'
Text {
text: ['<b>pan-light&nbsp;&nbsp;&nbsp;' + window.version + '</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="'
+ window.userAgreementLink + '" >查看用户协议</a>',
'作&nbsp;&nbsp;&nbsp;&nbsp;者&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PeterQ&lt;<a href="mailto://' + window.email
+ '" >' + window.email
+ '</a>&gt;', 'Git Repo&nbsp;&nbsp;' + '<a href="' + window.gitRepoUrl
+ '" >' + window.gitRepoUrl + '</a>'].join(
'<br>')
textFormat: Text.RichText
x: 30
anchors.verticalCenter: parent.verticalCenter
wrapMode: Text.Wrap
onLinkActivated: {
Qt.openUrlExternally(link)
}
}
}
}
}
......@@ -165,5 +165,6 @@
<file>widget/Resize.qml</file>
<file>assets/images/icons/baidu-cloud.svg</file>
<file>pages/setting-window.qml</file>
<file>pages/about-window.qml</file>
</qresource>
</RCC>
......@@ -72,7 +72,7 @@ Item {
MenuItem {
text: '关于'
onTriggered: {
Util.openAbout()
}
}
MenuItem {
......
......@@ -3,10 +3,11 @@ package pan_api
import (
"fmt"
"github.com/peterq/pan-light/pc/dep"
"github.com/peterq/pan-light/pc/storage"
"io"
"log"
"net"
"net/http"
"strings"
"time"
)
......@@ -21,12 +22,6 @@ type headChecker struct {
}
func (c headChecker) ServeHTTP(w http.ResponseWriter, r *http.Request) {
ua := r.Header.Get("User-Agent")
if strings.Index(ua, dep.Env.ElectronSecretUA) < 0 && false {
w.WriteHeader(404)
w.Write([]byte("hello, pan-light " + dep.Env.VersionString))
return
}
c.real.ServeHTTP(w, r)
}
......@@ -46,16 +41,22 @@ func startAgentServer() {
dep.Fatal("exit by api")
})
if dep.Env.Dev {
_, err := http.Get("http://127.0.0.1:" + fmt.Sprint(dep.Env.ListenPort) + "/exit")
if dep.Env.Dev && storage.Global.InternalServerPort > 0 {
_, err := http.Get("http://127.0.0.1:" + fmt.Sprint(storage.Global.InternalServerPort) + "/exit")
if err != nil {
time.Sleep(time.Second)
}
}
log.Println("Listening...")
dep.Env.InternalServerUrl = "http://127.0.0.1:" + fmt.Sprint(dep.Env.ListenPort)
err := http.ListenAndServe(fmt.Sprintf(":%d", dep.Env.ListenPort), headChecker{real: mux})
listener, err := net.Listen("tcp", ":0")
if err != nil {
dep.Fatal(err.Error())
}
storage.Global.InternalServerPort = int64(listener.Addr().(*net.TCPAddr).Port)
log.Println("Using port:", storage.Global.InternalServerPort)
dep.Env.InternalServerUrl = "http://127.0.0.1:" + fmt.Sprint(storage.Global.InternalServerPort)
err = http.Serve(listener, headChecker{real: mux})
if err != nil {
dep.Fatal(err.Error())
}
......
......@@ -23,6 +23,7 @@ const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
type GlobalData struct {
UserStateMap map[string]*State `protobuf:"bytes,1,rep,name=userStateMap,proto3" json:"userStateMap,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
CurrentUser string `protobuf:"bytes,2,opt,name=currentUser,proto3" json:"currentUser,omitempty"`
InternalServerPort int64 `protobuf:"varint,3,opt,name=internalServerPort,proto3" json:"internalServerPort,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
......@@ -67,6 +68,13 @@ func (m *GlobalData) GetCurrentUser() string {
return ""
}
func (m *GlobalData) GetInternalServerPort() int64 {
if m != nil {
return m.InternalServerPort
}
return 0
}
type State struct {
Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"`
Settings *StateSetting `protobuf:"bytes,2,opt,name=settings,proto3" json:"settings,omitempty"`
......@@ -260,29 +268,30 @@ func init() {
func init() { proto.RegisterFile("storage/types.proto", fileDescriptor_7311ad31e6b1ce7e) }
var fileDescriptor_7311ad31e6b1ce7e = []byte{
// 373 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0xc1, 0x6e, 0xda, 0x40,
0x14, 0x94, 0x31, 0xc6, 0xf0, 0x5c, 0xb5, 0xb0, 0x45, 0x68, 0xe5, 0x4b, 0x11, 0x6a, 0x25, 0x0e,
0x95, 0x2b, 0xd1, 0x4b, 0xd5, 0x43, 0xa4, 0x88, 0xe4, 0x90, 0x43, 0x14, 0xc9, 0x88, 0x0f, 0x58,
0xe0, 0xc9, 0xb2, 0x30, 0xbb, 0xd6, 0xee, 0x3a, 0x09, 0xb9, 0xe6, 0xef, 0xf2, 0x55, 0x91, 0xd7,
0x8b, 0x31, 0x90, 0x43, 0x6e, 0x7e, 0xf3, 0x66, 0xc6, 0xe3, 0x79, 0x86, 0xef, 0x4a, 0x0b, 0xc9,
0x12, 0xfc, 0xa3, 0xf7, 0x39, 0xaa, 0x28, 0x97, 0x42, 0x0b, 0xe2, 0x5b, 0x70, 0xf2, 0xe6, 0x00,
0x24, 0x99, 0x58, 0xb1, 0xec, 0x86, 0x69, 0x46, 0xee, 0xe0, 0x4b, 0xa1, 0x50, 0x2e, 0x34, 0xd3,
0x78, 0xcf, 0x72, 0xea, 0x8c, 0xdd, 0x69, 0x30, 0xfb, 0x15, 0x59, 0x7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0xdd, 0xf8, 0x72, 0x11, 0x5e, 0x41, 0xff, 0x3c, 0xdf, 0x07, 0x57, 0x19, 0x36,
0xaf, 0xd2, 0x6b, 0x5e, 0x61, 0x0d, 0xbe, 0xed, 0xe5, 0xb3, 0x32, 0x32, 0x82, 0xce, 0x46, 0xec,
0x58, 0xca, 0xa9, 0x6b, 0x60, 0x3b, 0x11, 0x0a, 0x3e, 0x3e, 0xe7, 0xa9, 0x44, 0x45, 0xdb, 0x26,
0xee, 0x61, 0x5c, 0x75, 0xcc, 0x7f, 0xfc, 0xf7, 0x3d, 0x00, 0x00, 0xff, 0xff, 0x32, 0x32, 0xfe,
0xfd, 0xde, 0x02, 0x00, 0x00,
// 397 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0xc1, 0x6e, 0xd4, 0x30,
0x10, 0x55, 0xea, 0x6e, 0xb7, 0x99, 0x20, 0xd8, 0x0e, 0x55, 0x65, 0xe5, 0x42, 0x54, 0x81, 0x94,
0x03, 0x0a, 0xd2, 0x72, 0x41, 0x1c, 0x90, 0x50, 0xe1, 0xc0, 0x01, 0x81, 0x1c, 0xf5, 0x03, 0xdc,
0xdd, 0x51, 0x14, 0x6d, 0x6a, 0x47, 0xb6, 0x53, 0x58, 0xae, 0xfc, 0x35, 0x27, 0x14, 0xc7, 0xcd,
0xa6, 0xdb, 0x3d, 0xf4, 0x96, 0x79, 0xf3, 0xde, 0xcc, 0xcb, 0x1b, 0xc3, 0x4b, 0xeb, 0xb4, 0x91,
0x15, 0xbd, 0x73, 0xdb, 0x96, 0x6c, 0xd1, 0x1a, 0xed, 0x34, 0xce, 0x03, 0x78, 0xf9, 0x2f, 0x02,
0xa8, 0x1a, 0x7d, 0x23, 0x9b, 0x2f, 0xd2, 0x49, 0xfc, 0x06, 0xcf, 0x3a, 0x4b, 0xa6, 0x74, 0xd2,
0xd1, 0x77, 0xd9, 0xf2, 0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 0xac, 0xf5, 0x2f, 0xd5,
0x68, 0xb9, 0x2e, 0xa9, 0x2a, 0xeb, 0x3f, 0xe4, 0xff, 0x96, 0x89, 0x7d, 0x18, 0xdf, 0xc2, 0xd9,
0x3d, 0x74, 0xa5, 0x8d, 0xee, 0x5c, 0xad, 0x86, 0x34, 0x99, 0x78, 0xdc, 0x48, 0x3f, 0xc1, 0x62,
0xdf, 0xdf, 0x81, 0xab, 0x9c, 0x4f, 0xaf, 0x12, 0x4f, 0xaf, 0xb0, 0x82, 0x79, 0xc8, 0xe5, 0xa9,
0x32, 0xbc, 0x80, 0x93, 0xb5, 0xbe, 0x95, 0xb5, 0xf2, 0xaf, 0x25, 0x16, 0xa1, 0x42, 0x0e, 0x73,
0xfa, 0xdd, 0xd6, 0x86, 0x2c, 0x3f, 0xf6, 0x76, 0xef, 0xcb, 0x9b, 0x13, 0xff, 0xee, 0xdf, 0xff,
0x0f, 0x00, 0x00, 0xff, 0xff, 0x78, 0x36, 0x24, 0x2c, 0x0e, 0x03, 0x00, 0x00,
}
......@@ -5,6 +5,7 @@ package storage;
message globalData {
map<string, state> userStateMap = 1;
string currentUser = 2;
int64 internalServerPort = 3;
}
message state {
......
......@@ -12,5 +12,5 @@ func main() {
app.Get("/", func(ctx context.Context) {
ctx.Write([]byte("Hello pan-light"))
})
app.Run(iris.Addr(":8081"))
app.Run(iris.Addr("127.0.0.1:8081"))
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册