265 lines
7.4 KiB
QML
265 lines
7.4 KiB
QML
import QtQuick 2.15
|
|
import QtQuick.Window 2.15
|
|
import Qt.labs.settings 1.1
|
|
import DelegateUI 1.0
|
|
import "../MyGlobals" 1.0
|
|
|
|
Item {
|
|
id:loginPage
|
|
y : GlobalVars.main_Window.captionBar.height
|
|
height: GlobalVars.main_Window.height - GlobalVars.main_Window.captionBar.height
|
|
|
|
|
|
property int mode : 0
|
|
|
|
onModeChanged: {
|
|
if(mode === 0)
|
|
{
|
|
qqInput.visible = false
|
|
savecode.visible = false
|
|
}
|
|
|
|
else if(mode === 1){
|
|
savecode.visible = true
|
|
qqInput.visible = true
|
|
}
|
|
|
|
}
|
|
|
|
|
|
property string username: ""
|
|
property string password: ""
|
|
property string bindqq: ""
|
|
|
|
//自动储存上一次登录的账号
|
|
Settings{
|
|
fileName: "./setting.ini"
|
|
property alias username: loginPage.username
|
|
property alias password: loginPage.password
|
|
}
|
|
|
|
// ShaderEffect {
|
|
// id:login_shader
|
|
// anchors.fill: parent
|
|
// vertexShader: "qrc:/shaders/effect1.vert"
|
|
// fragmentShader: "qrc:/shaders/effect1.frag"
|
|
// opacity: 0.3
|
|
|
|
// property vector3d iResolution: Qt.vector3d(width, height, 0)
|
|
// property real iTime: 0
|
|
|
|
// Timer {
|
|
// id: timer
|
|
// running: true
|
|
// repeat: true
|
|
// interval: 15
|
|
// onTriggered: parent.iTime += 0.01;
|
|
// }
|
|
// }
|
|
|
|
Column {
|
|
anchors.centerIn: parent
|
|
spacing: 10
|
|
|
|
Image {
|
|
width: 60
|
|
height: 60
|
|
source: "qrc:/image/logo.png"
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
}
|
|
|
|
Text {
|
|
text: qsTr("登录您的DP-S账号")
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
font.pixelSize: 20
|
|
font.family: DelTheme.Primary.fontPrimaryFamily
|
|
color:DelTheme.Primary.colorTextBase
|
|
}
|
|
|
|
DelInput {
|
|
id: userInput
|
|
width: 280
|
|
selectByMouse:true
|
|
placeholderText: qsTr("账号")
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
text:username
|
|
onTextChanged: username = text
|
|
}
|
|
|
|
DelInput {
|
|
id: pwdInput
|
|
width: 280
|
|
text :password
|
|
selectByMouse:true
|
|
placeholderText: qsTr("密码")
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
onTextChanged: password = text
|
|
}
|
|
|
|
DelInput {
|
|
id: qqInput
|
|
visible: false
|
|
width: 280
|
|
text :bindqq
|
|
selectByMouse:true
|
|
placeholderText: qsTr("安全口令")
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
onTextChanged: bindqq = text
|
|
DelToolTip {
|
|
visible: parent.hovered
|
|
arrowVisible: true
|
|
text: qsTr("请牢记自己设置的安全口令,并注意不要泄露")
|
|
position: DelToolTip.Position_Top
|
|
}
|
|
}
|
|
|
|
Row{
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
spacing: 15
|
|
DelButton {
|
|
width:100
|
|
text: {
|
|
switch(mode){
|
|
case 0:
|
|
return qsTr("登 录");
|
|
case 1:
|
|
return qsTr("注 册");
|
|
case 2:
|
|
return qsTr("修 改 密 码");
|
|
}
|
|
}
|
|
colorBg:{
|
|
switch(mode){
|
|
case 0:
|
|
return "#2A5CFF"
|
|
case 1:
|
|
return "#00C853"
|
|
case 2:
|
|
return "#A0B4F6"
|
|
}
|
|
}
|
|
|
|
height: 35
|
|
type: DelButton.Type_Primary
|
|
onClicked: {
|
|
switch(mode){
|
|
case 0:
|
|
loginReq();
|
|
break;
|
|
case 1:
|
|
registerReq();
|
|
break;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
DelButton {
|
|
id:savecode
|
|
width:120
|
|
text: "强制更改密码"
|
|
colorBg:"#dd2c2c"
|
|
height: 35
|
|
visible: false
|
|
type: DelButton.Type_Primary
|
|
onClicked: {
|
|
|
|
}
|
|
DelToolTip {
|
|
visible: parent.hovered
|
|
arrowVisible: true
|
|
text: qsTr("可使用注册时的安全口令强制更改密码")
|
|
position: DelToolTip.Position_Right
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function loginReq(){
|
|
// 构建 JSON 参数对象
|
|
var jsonData = {
|
|
username: username,
|
|
password: password
|
|
}
|
|
GlobalVars.sendPostRequest("/login",jsonData,function(error, response) {
|
|
if (error) {
|
|
GlobalVars.error(error.message)
|
|
} else {
|
|
//储存Token
|
|
GlobalVars.token = response.token
|
|
//跳转页面
|
|
GlobalVars.main_Window.changePage(1);
|
|
GlobalVars.msg_control.success('登录成功');
|
|
}
|
|
})
|
|
}
|
|
|
|
function registerReq(){
|
|
// 构建 JSON 参数对象
|
|
var jsonData = {
|
|
username: username,
|
|
password: password,
|
|
qq:bindqq
|
|
}
|
|
GlobalVars.sendPostRequest("/register",jsonData,function(error, response) {
|
|
if (error) {
|
|
GlobalVars.msg_control.error('注册失败:' + response);
|
|
} else {
|
|
mode = 0;
|
|
GlobalVars.msg_control.success('注册成功');
|
|
}
|
|
})
|
|
}
|
|
|
|
Row{
|
|
anchors.bottom: parent.bottom // 关键:贴到父容器底部
|
|
anchors.bottomMargin: 20
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
Text{
|
|
text: {
|
|
if(mode === 0)return qsTr("您还没有账号或忘记密码?")
|
|
else if(mode ===1)return qsTr("已有账号")
|
|
}
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
font.family: DelTheme.Primary.fontPrimaryFamily
|
|
color:DelTheme.Primary.colorTextBase
|
|
}
|
|
|
|
DelButton {
|
|
text:{
|
|
if(mode === 0)return qsTr("点击注册")
|
|
else if(mode === 1)return qsTr("点击登录")
|
|
}
|
|
height: 35
|
|
type: DelButton.Type_Link
|
|
onClicked: {
|
|
if(mode === 0)mode = 1
|
|
else if(mode === 1)mode = 0
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
DelSelect {
|
|
id:network_line
|
|
anchors.bottom: parent.bottom
|
|
anchors.bottomMargin: 20
|
|
anchors.right: parent.right
|
|
anchors.rightMargin: 10
|
|
width: 180
|
|
height: 30
|
|
model: [
|
|
// { value: 'http://192.168.200.20:8651', label: '线路1' },
|
|
{ value: 'https://dpsm.senzo.online', label: '线路1' },
|
|
{ value: 'https://dpsm.senzo.online', label: '线路2' },
|
|
{ value: 'https://dps.wyyvip.asia', label: '线路3' },
|
|
]
|
|
onCurrentIndexChanged: {
|
|
GlobalVars.server_url = network_line.model[currentIndex].value
|
|
GlobalVars.getAllVersion();
|
|
}
|
|
}
|
|
}
|