提交 36c7f910 编写于 作者: P peterq

add: 问题反馈页面

上级 bb54ee5c
......@@ -104,12 +104,28 @@ var baseAsyncRoutes = map[string]asyncHandler{
"secret": secret,
"token": token,
})
storage.UserState.Token = jwt.(string)
if err != nil {
reject(err)
return
}
storage.UserState.Token = jwt.(string)
log.Println(jwt)
resolve(jwt)
},
"api.call": func(p map[string]interface{}, resolve func(interface{}), reject func(interface{}), progress func(interface{}), qmlMsg chan interface{}) {
data, err := server_api.Call(p["name"].(string), p["param"].(gson))
if err != nil {
if data == nil {
data = gson{
"success": false,
"message": err.Error(),
"code": -1,
}
}
reject(data)
return
}
resolve(data)
},
}
......@@ -433,3 +433,18 @@ var openAbout = (function () {
return ins
}
})()
var openFeedback = (function () {
var comp = loadComponent(function(){},'../pages/feedback-window.qml')
var ins
return function(){
if (!ins || !ins.visible) {
ins = comp.createObject(G.root)
}
return ins
}
})()
function api(name, param) {
return callGoAsync('api.call', {name: name, param: param})
}
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
import "../widget"
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: 550
height: 300
Component.onCompleted: {
visible = true
requestActivate()
}
onVisibleChanged: {
if (!visible) {
window.destroy()
}
}
TopIndicator {
id: topIndicator
z: 2
}
Column {
y: 10
width: parent.width * 0.8
anchors.horizontalCenter: parent.horizontalCenter
spacing: 10
TextArea {
id: input
width: parent.width
height: 200
placeholderText: '请输入反馈内容'
focus: true
background: Rectangle {
color: '#eee'
}
}
Button {
text: '提交'
onClicked: {
var content = input.text.trim()
if (!content) return
enabled = false
text = '提交中'
Util.api('feedback', {
content: content
})
.then(function() {
topIndicator.success('提交成功')
return Util.sleep(1000)
})
.then(function () {
window.visible = false
})
.catch(function(error) {
topIndicator.fail(error.message)
text = '提交'
enabled = true
})
}
}
}
}
......@@ -166,5 +166,7 @@
<file>assets/images/icons/baidu-cloud.svg</file>
<file>pages/setting-window.qml</file>
<file>pages/about-window.qml</file>
<file>pages/feedback-window.qml</file>
<file>widget/TopIndicator.qml</file>
</qresource>
</RCC>
import QtQuick 2.0
Rectangle {
id: root
property color successColor: 'green'
property color failColor: 'red'
property color warningColor: 'orange'
property alias duration: hideTimer.interval
width: parent.width
height: 40
y: -height
Text {
id: msgText
text: ''
color: 'white'
anchors.centerIn: parent
}
MouseArea {
id: ma
anchors.fill: parent
hoverEnabled: true
}
Timer {
id: hideTimer
interval: 2500
running: false
onTriggered: {
if (ma.containsMouse) {
restart()
return
}
y = -height
}
}
Behavior on y {
PropertyAnimation {
duration: 200
}
}
function success(msg) {
color = successColor
show(msg)
}
function fail(msg) {
color = failColor
show(msg)
}
function warn(msg) {
color = warningColor
show(msg)
}
function show(msg) {
y = 0
msgText.text = msg
hideTimer.restart()
}
}
......@@ -63,6 +63,25 @@ Item {
App.appState.floatWindow.visible = !App.appState.floatWindow.visible
}
}
MenuItem {
text: '设置'
onTriggered: {
Util.openSetting()
}
}
MenuItem {
text: '关于'
onTriggered: {
Util.openAbout()
}
}
MenuItem {
text: '问题反馈'
onTriggered: {
Util.openFeedback()
}
}
MenuItem {
text: '登出账号'
onTriggered: {
......@@ -101,25 +120,7 @@ Item {
}
}
MenuItem {
text: '设置'
onTriggered: {
Util.openSetting()
}
}
MenuItem {
text: '关于'
onTriggered: {
Util.openAbout()
}
}
MenuItem {
text: '问题反馈'
onTriggered: {
}
}
MenuItem {
text: '重启'
text: '重启程序'
onTriggered: Util.callGoSync("reboot")
}
MenuItem {
......
......@@ -3,10 +3,10 @@ package server_api
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"github.com/peterq/pan-light/pc/dep"
"github.com/peterq/pan-light/pc/storage"
"github.com/pkg/errors"
"io/ioutil"
"net/http"
)
......@@ -16,6 +16,7 @@ type gson = map[string]interface{}
var urlMap = map[string]string{
"login-token": "/api/pc/login-token",
"login": "/api/pc/login",
"feedback": "/api/pc/feedback",
}
var httpClient = http.Client{
//Timeout: 15 * time.Second,
......@@ -46,6 +47,8 @@ func Call(name string, param map[string]interface{}) (result interface{}, err er
return ret, errors.New(fmt.Sprint("api error(", ret["code"], "): ", ret["message"]))
}
result = ret["result"]
} else {
err = errors.Wrap(err, "json resp invalid")
}
return
}
......@@ -51,9 +51,10 @@ func ApiRecover(ctx context.Context) {
}
// 转换为 app error
if appErr, ok = e.(AppError); !ok {
if appErr, ok = err.(AppError); !ok {
ctx.StatusCode(iris.StatusInternalServerError)
appErr = NewError("internal server error", 500, err)
ctx.Application().Logger().Error(err)
}
ctx.JSON(map[string]interface{}{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册