Compare commits

...

10 Commits

Author SHA1 Message Date
Mike Solar c0f45de00b 完成下载功能 2023-09-18 21:35:41 +08:00
Mike Solar 7493ac4d2e 导航栏按钮 2023-09-09 16:11:02 +08:00
Mike Solar ede78c640b 修复打不开自行添加的应用 2023-09-06 21:22:06 +08:00
Mike Solar a96f802b85 修复全名重复 2023-08-29 11:45:11 +08:00
Mike Solar fd525fb8d1 阶段性完成,还差独立浏览器和几个别的需求。 2023-08-26 22:13:39 +08:00
Mike Solar 9ee232cead 解决兼容性问题 2023-08-21 15:10:19 +08:00
Mike Solar 5ec58b3bfb 除了win7的问题外全修复了 2023-08-18 20:51:05 +08:00
Mike Solar b728e697fb 几乎完成 2023-08-18 19:09:55 +08:00
Mike Solar bc3b3f69a7 准备整理代码 2023-08-17 01:10:27 +08:00
Mike Solar 94017995bc 关了VS,重新提交 2023-08-15 20:13:27 +08:00
46 changed files with 1912 additions and 1566 deletions

View File

@ -1,4 +1,4 @@
//
//
// Created by HW on 2023/07/26.
//
#include "MyButton.h"
@ -10,6 +10,7 @@ MyButton::MyButton(ButtonStruct &buttonStruct,int width,int height,QList<MyButto
this->height2=height;
this->text=buttonStruct.text;
this->op = buttonStruct.op;
this->orig_name = buttonStruct.orig_name;
this->func = buttonStruct.func;
this->url = buttonStruct.url;
this->path = buttonStruct.path;
@ -43,7 +44,7 @@ void MyButton::paintEvent(QPaintEvent *e) {
setContentsMargins(0,0,0,0);
QFont ft;
ft.setPixelSize(TEXT_SIZE);
//别问我为啥乘3我也不知道
//别问我为啥乘3我也不知道
int text_x=(width()-TEXT_SIZE*text.length()*scale*3)/2;
int text_y=(logo_width+logo_y+10);
QRectF logo_rect(logo_x, logo_y, logo_width, logo_width);
@ -91,6 +92,6 @@ void MyButton::mouseReleaseEvent(QMouseEvent *event) {
checked=false;
else
checked=true;
emit clicked1(op, func, url, path, initial_position);
emit clicked1(orig_name,op, func, url, path, initial_position);
}

View File

@ -1,4 +1,4 @@
//
//
// Created by HW on 2023/07/26.
//
@ -16,7 +16,7 @@
class MyButton: public QPushButton{
Q_OBJECT
signals:
void clicked1(QString op, QString func, QString url, QString path, QString initial_position);
void clicked1(QString orig_name,QString op, QString func, QString url, QString path, QString initial_position);
public:
MyButton(ButtonStruct &buttonStruct,int width,int height,QList<MyButton *> *buttons,QWidget *parent=nullptr);
~MyButton() override;
@ -57,6 +57,7 @@ private:
QImage *logo_cover;
QVBoxLayout *layout;
QString text;
QString orig_name;
QString url;
QString op;
QString path;

View File

@ -102,6 +102,7 @@
<QtRcc Include="OfficeAssistant_msvc.qrc" />
</ItemGroup>
<ItemGroup>
<QtMoc Include="userimprove.h" />
<QtMoc Include="applicationmanager.h" />
<QtMoc Include="addapp.h" />
<QtMoc Include="addcategory.h" />
@ -139,6 +140,7 @@
<ClCompile Include="netio.cpp" />
<ClCompile Include="qminiblink.cpp" />
<ClCompile Include="sqlitehelper.cpp" />
<ClCompile Include="userimprove.cpp" />
</ItemGroup>
<ItemGroup>
<QtUic Include="addapp.ui" />
@ -152,6 +154,7 @@
<QtUic Include="mysettingsdialog.ui" />
<QtUic Include="navbar.ui" />
<QtUic Include="qminiblink.ui" />
<QtUic Include="userimprove.ui" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="logo.rc" />

View File

@ -85,6 +85,9 @@
<QtMoc Include="applicationmanagerpage.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="userimprove.h">
<Filter>Header Files</Filter>
</QtMoc>
</ItemGroup>
<ItemGroup>
<ClCompile Include="mainscreen.cpp">
@ -123,15 +126,18 @@
<ClCompile Include="minibutton.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="addapp.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="addcategory.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="applicationmanagerpage.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="userimprove.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="addapp.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<QtUic Include="navbar.ui">
@ -167,6 +173,9 @@
<QtUic Include="applicationmanagerpage.ui">
<Filter>Form Files</Filter>
</QtUic>
<QtUic Include="userimprove.ui">
<Filter>Form Files</Filter>
</QtUic>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="logo.rc">

View File

@ -1,13 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerCommandArguments>79c86fb12b36dfa33d1a537c9af100b4c7928a9c</LocalDebuggerCommandArguments>
<LocalDebuggerCommandArguments>autostart</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LocalDebuggerCommandArguments>$(QmlDebug)</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<QtLastBackgroundBuild>2023-08-12T03:22:21.9071424Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2023-09-18T12:55:53.6703998Z</QtLastBackgroundBuild>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<QtLastBackgroundBuild>2023-08-12T03:22:23.0360904Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2023-09-18T12:55:55.7491129Z</QtLastBackgroundBuild>
</PropertyGroup>
</Project>

View File

@ -1,4 +1,4 @@
#include "addapp.h"
#include "addapp.h"
#include <QFileDialog>
#include <QProcessEnvironment>
#include <QMessageBox>
@ -18,19 +18,26 @@ AddApp::AddApp(bool isEdit, Record2 *row , QWidget* parent)
ui.setupUi(this);
this->row=row;
SQLiteHelper sqlite_helper;
setFixedSize(450, 450);
setFixedSize(450, 600);
Record2 record;
sqlite_helper.get_a_software(row->orig_name, &record);
setWindowFlags(Qt::WindowCloseButtonHint);
form = new QFormLayout;
name = new QLineEdit;
form->addRow(QString::fromLocal8Bit("名称"), name);
if(isEdit)
{
record=*row;//最初为啥这么写我也忘了
}
if (record.orig_name.isEmpty())
{
path = new QPushButton(QString::fromLocal8Bit("浏览"));
connect(path, &QPushButton::clicked, this, &AddApp::broswer_exe);
form->addRow(QString::fromLocal8Bit("路径"), path);
if (isEdit)
{
sqlite_helper.get_a_software(row->orig_name, &record);
name_label = new QLabel(orig_name_str);
form->addRow(QString::fromLocal8Bit("全名"), name_label);
form->addRow(QString::fromLocal8Bit("全名"), name_label);
if (!record.orig_name.isEmpty())
{
name_label->setText(record.orig_name);
@ -40,17 +47,14 @@ AddApp::AddApp(bool isEdit, Record2 *row , QWidget* parent)
else
{
orig_name = new QLineEdit;
form->addRow(QString::fromLocal8Bit("全名"), orig_name);
form->addRow(QString::fromLocal8Bit("全名"), orig_name);
}
form->addRow(QString::fromLocal8Bit("名称"), name);
if (record.orig_name.isEmpty())
{
path = new QPushButton(QString::fromLocal8Bit("浏览"));
connect(path, &QPushButton::clicked, this, &AddApp::broswer_exe);
form->addRow(QString::fromLocal8Bit("路径"), path);
sort = new QLineEdit;
sort->setValidator(new QIntValidator(10, 100));
form->addRow(QString::fromLocal8Bit("排序"), sort);
sort->setText("50");
form->addRow(QString::fromLocal8Bit("排序"), sort);
QList<Categrory> categrories;
layout_inner = new QVBoxLayout;
sqlite_helper.get_category(categrories, true);
@ -62,8 +66,8 @@ AddApp::AddApp(bool isEdit, Record2 *row , QWidget* parent)
layout_inner->addWidget(check_box);
categories_list.insert(category.id, check_box);
}
form->addRow(QString::fromLocal8Bit("类别"), layout_inner);
submit_btn = new QPushButton(QString::fromLocal8Bit("提交"));
form->addRow(QString::fromLocal8Bit("类别"), layout_inner);
submit_btn = new QPushButton(QString::fromLocal8Bit("提交"));
form->addWidget(submit_btn);
this->setLayout(form);
connect(path, &QPushButton::click, this, &AddApp::broswer_exe);
@ -75,15 +79,36 @@ AddApp::AddApp(bool isEdit, Record2 *row , QWidget* parent)
name->setText(record.name);
name_str = record.name;
sort_str = QString::number(record.sort);
path = new QPushButton(QString::fromLocal8Bit("浏览"));
path = new QPushButton(QString::fromLocal8Bit("浏览"));
path_str = record.exe_file;
path->setText(QString::fromWCharArray(fs::path(path_str.toStdWString()).filename().c_str()));
connect(path, &QPushButton::clicked, this, &AddApp::broswer_exe);
form->addRow(QString::fromLocal8Bit("路径"), path);
if (record.op == "soft")
{
form->addRow(QString::fromLocal8Bit("路径"), path);
}
if (isEdit)
{
sqlite_helper.get_a_software(row->orig_name, &record);
name_label = new QLabel(orig_name_str);
form->addRow(QString::fromLocal8Bit("全名"), name_label);
if (!record.orig_name.isEmpty())
{
name_label->setText(record.orig_name);
}
orig_name_str = record.orig_name;
}
else
{
orig_name = new QLineEdit;
form->addRow(QString::fromLocal8Bit("全名"), orig_name);
}
form->addRow(QString::fromLocal8Bit("名称"), name);
sort = new QLineEdit;
sort->setText(QString::number(record.sort));
sort->setValidator(new QIntValidator(10, 100));
form->addRow(QString::fromLocal8Bit("排序"), sort);
form->addRow(QString::fromLocal8Bit("排序"), sort);
QList<Categrory> categrories;
layout_inner = new QVBoxLayout;
sqlite_helper.get_category(categrories, true);
@ -98,15 +123,14 @@ AddApp::AddApp(bool isEdit, Record2 *row , QWidget* parent)
layout_inner->addWidget(check_box);
categories_list.insert(category.id, check_box);
}
form->addRow(QString::fromLocal8Bit("类别"), layout_inner);
submit_btn = new QPushButton(QString::fromLocal8Bit("提交"));
form->addRow(QString::fromLocal8Bit("类别"), layout_inner);
submit_btn = new QPushButton(QString::fromLocal8Bit("提交"));
form->addWidget(submit_btn);
this->setLayout(form);
connect(path, &QPushButton::click, this, &AddApp::broswer_exe);
connect(submit_btn, &QPushButton::clicked, this, &AddApp::submit);
this->isEdit = isEdit;
}
}
AddApp::~AddApp()
@ -130,26 +154,32 @@ void AddApp::broswer_exe(){
QString path_str_old = path_str;
if(path_str.isEmpty())
{
path_str = QFileDialog::getOpenFileName(this, QString::fromLocal8Bit("选择程序"),
QApplication::applicationDirPath(), QString::fromLocal8Bit("应用程序 (*.exe)"));
path_str = QFileDialog::getOpenFileName(this, QString::fromLocal8Bit("选择程序"),
QApplication::applicationDirPath(), QString::fromLocal8Bit("应用程序 (*.exe)"));
}
else
{
path_str = QFileDialog::getOpenFileName(this, QString::fromLocal8Bit("选择程序"),
path_str, QString::fromLocal8Bit("应用程序 (*.exe)"));
path_str = QFileDialog::getOpenFileName(this, QString::fromLocal8Bit("选择程序"),
path_str, QString::fromLocal8Bit("应用程序 (*.exe)"));
}
if (path_str.isEmpty()) {
path_str = path_str_old;
}
fs::path file(path_str.toStdWString());
path->setText(QString::fromStdWString(file.filename().c_str()));
if(!isEdit)
{
orig_name->setText(QString::fromStdWString(file.filename().c_str()));
}
}
void AddApp::submit() {
if(isEdit)
if(sort->text().toInt()<10||sort->text().toInt()>100)
{
if (!path->text().isEmpty())
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("排序必须在10-100之间"));
return;
}
if (isEdit)
{
QString name_str_old = name_str;
QString sort_str_old = sort_str;
@ -163,12 +193,6 @@ void AddApp::submit() {
}
}
else
{
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("未填写路径"));
return;
}
}
else
{
if ((!orig_name->text().isEmpty()) && (!path->text().isEmpty()))
{
@ -184,27 +208,21 @@ void AddApp::submit() {
}
else
{
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("未填写全名或路径"));
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("未填写全名或路径"));
return;
}
}
categories = new bool[8];
for (int i = 0; i < 8; i++) {
for (int i = 0; i < CATEGORIES_NUM; i++) {
categories[i] = false;
}
categories[ALL-1] = true;
if (row->op == "soft") {
categories[SOFT-1] = true;
}
else if (row->op == "app") {
categories[INNER-1] = true;
}
for(auto key:categories_list.keys())
{
categories[key - 1] = categories_list[key]->checkState();
}
for (int i = 0; i < 8; i++) {
for (int i = 0; i < CATEGORIES_NUM; i++) {
qDebug() << categories[i];
}

View File

@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <QDialog>
#include <QLineEdit>
@ -16,7 +16,7 @@ class AddApp : public QDialog
Q_OBJECT
public:
AddApp(bool isEdit = false, Record2 *orig_name_str=nullptr,QWidget* parent = nullptr);
AddApp(bool isEdit = false, Record2 *row=nullptr,QWidget* parent = nullptr);
~AddApp();
QString get_exe_path()
{

View File

@ -1,5 +1,8 @@
#include "addcategory.h"
#include "addcategory.h"
#include <QString>
#include "config.h"
AddCategory::AddCategory(QWidget* parent)
: QDialog(parent)
{
@ -9,21 +12,21 @@ AddCategory::AddCategory(QWidget* parent)
//connect(ui.submit, &QPushButton::click, this, &AddCategory::submit);
QStringList title;
ui.tableWidget->setColumnCount(3);
title << QString::fromLocal8Bit("名称") << QString::fromLocal8Bit("显示") << QString::fromLocal8Bit("排序");
title << QString::fromLocal8Bit("名称") << QString::fromLocal8Bit("显示") << QString::fromLocal8Bit("排序");
ui.tableWidget->setHorizontalHeaderLabels(title);
sqlite_helper.get_category(categrories,false);
sqlite_helper.get_category(categrories,true);
ui.tableWidget->setRowCount(categrories.count());
int i = 0;
for(auto category : categrories)
{
ui.tableWidget->setItem(i, 0, new QTableWidgetItem(category.name));
if(category.id==1&&category.id==8)
if(category.id==ALL||category.id==OTHERS||category.id==ELITE)
{
ui.tableWidget->item(i, 0)->setFlags(ui.tableWidget->item(i, 0)->flags() & (~Qt::ItemIsEditable));
}
QComboBox* combo_box = new QComboBox;
combo_box->addItem(QString::fromLocal8Bit("显示"), true);
combo_box->addItem(QString::fromLocal8Bit("不显示"), false);
combo_box->addItem(QString::fromLocal8Bit("显示"), true);
combo_box->addItem(QString::fromLocal8Bit("不显示"), false);
if(category.display==true)
{
combo_box->setCurrentIndex(0);
@ -36,7 +39,7 @@ AddCategory::AddCategory(QWidget* parent)
combo_boxes << combo_box;
i++;
}
//submit_btn = new QPushButton(QString::fromLocal8Bit("提交"));
//submit_btn = new QPushButton(QString::fromLocal8Bit("提交"));
connect(ui.submit, &QPushButton::clicked, this, &AddCategory::submit);
}
AddCategory::~AddCategory()
@ -60,7 +63,7 @@ void AddCategory::submit()
categrory.sort = ui.tableWidget->item(i, 2)->text().toInt(&ok, 10);
if(!ok)
{
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("排序列中有一行不是数字"));
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("排序列中有一行不是数字"));
return;
}
categrories_new << categrory;

View File

@ -1,30 +1,36 @@
#include "applicationmanager.h"
#include "applicationmanager.h"
#include "applicationmanagerpage.h"
#include "config.h"
#include "addapp.h"
#include "addcategory.h"
#include "sqlitehelper.h"
#include "userimprove.h"
#include "globalvariables.h"
#include "netio.h"
#include <ctime>
#include "globalvariables.h"
#include "mainwindowlayout.h"
#include "MyButton.h"
ApplicationManager::ApplicationManager(QWidget *parent)
: QWidget(parent)
{
application_manager = this;
ui.setupUi(this);
connect(this, &ApplicationManager::clickButton, mainWindowLayout, &MainWindowLayout::clickButton);
resize(parent->width(), parent->height());
this->parent = parent;
miniblink = new QMiniBlink(this);
miniblink->init();
miniblink->show();
connect(this, &ApplicationManager::changeUrl, miniblink, &QMiniBlink::switchUrl);
layout = new QVBoxLayout(this);
layout_top = new QHBoxLayout(this);
layout_top->setAlignment(Qt::AlignRight);
layout_top->setMargin(5);
layout_top_right = new QHBoxLayout(this);
layout_top_right->setAlignment(Qt::AlignRight);
layout_top_right->setMargin(5);
layout_top= new QHBoxLayout(this);
layout_top_left = new QHBoxLayout(this);
layout_top_left->setMargin(0);
layout_top_left->setAlignment(Qt::AlignLeft);
layout_bottom = new QHBoxLayout(this);
QList<Categrory> categrories;
sqlite_helper.get_category(categrories,false,true);
sqlite_helper.get_category(categrories,false);
sqlite_helper.get_buttons(button_structs);
for (auto button_struct : button_structs)
{
@ -36,8 +42,8 @@ ApplicationManager::ApplicationManager(QWidget *parent)
button->setMaximumHeight(TEXT_SIZE * scale * 3 + 20);
//button->resize(TEXT_SIZE * button->text().length() * scale * 3 + 20, TEXT_SIZE * scale * 3 + 10);
buttons << button;
layout_top->addWidget(button, 1);
connect(button, &MiniButton::click0, button, &MiniButton::onclick1);
layout_top_right->addWidget(button, 1);
connect(button, &MiniButton::clicked, button, &MiniButton::onclick1);
connect(button, &MiniButton::click1, this, &ApplicationManager::onclick1);
}
//ui.tabWidget->setStyleSheet("border:none;");
@ -49,24 +55,29 @@ ApplicationManager::ApplicationManager(QWidget *parent)
tab_bar = new QTabBar(this);
layout_bottom_top = new QVBoxLayout;
for(int i=1;i<=8;i++)
for(int i=0;i<categrories.length();i++)
{
tab_bar->addTab(categrories[i - 1].name + "(" + QString::number(categrories[i - 1].total) + ")");
tab_bar->addTab(categrories[i].name + "(" + QString::number(categrories[i].total) + ")");
map2.insert(i, categrories[i].id);
}
layout_bottom_top->addWidget(tab_bar, 1);
layout_top_left->addWidget(tab_bar, 1);
layout_top->addLayout(layout_top_left, 7);
layout_top->addLayout(layout_top_right, 3);
application_manager_page_all = new ApplicationManagerPage(ALL, this, this);
connect(this, &ApplicationManager::refresh, application_manager_page_all, &ApplicationManagerPage::refresh);
layout_bottom_top->addWidget(application_manager_page_all, 19);
map.insert(1, application_manager_page_all);
for(int i=2;i<=8;i++)
map.insert(ALL, application_manager_page_all);
for(int i=2;i<=CATEGORIES_NUM;i++)
{
ApplicationManagerPage* application_manager_page = new ApplicationManagerPage(i, this, this);
connect(this, &ApplicationManager::refresh, application_manager_page, &ApplicationManagerPage::refresh);
layout_bottom_top->addWidget(application_manager_page, 19);
layout_bottom_top->addWidget(application_manager_page, 1);
application_manager_page->setHidden(true);
map.insert(i, application_manager_page);
}
connect(this,&ApplicationManager::refresh,this,&ApplicationManager::onNumChange);
//先不刷新创建完navbar再刷新
//emit refresh();
connect(this,&ApplicationManager::refresh_tab,this,&ApplicationManager::onNumChange);
tab_bar->setCurrentIndex(0);
connect(tab_bar, &QTabBar::currentChanged, this, &ApplicationManager::tabChange);
QString style = "QTabBar::tab{height:80;width:150; border:2px} QTabBar::tab:hover{ border:2px;height:80;width:150;color:";
@ -76,63 +87,7 @@ ApplicationManager::ApplicationManager(QWidget *parent)
style += ";}";
tab_bar->setStyleSheet(style);
tab_bar->setDrawBase(false);
/*ApplicationManagerPage* application_manager_page_all = new ApplicationManagerPage(ALL,this);
QHBoxLayout *application_manager_page_all_layout = new QHBoxLayout;
application_manager_page_all_layout->addWidget(application_manager_page_all);
pages.insert(application_manager_page_all_layout, application_manager_page_all);
ui.tab_1->setLayout(application_manager_page_all_layout);
ui.tabWidget->setTabText(0,QString::fromLocal8Bit("全部"));
ApplicationManagerPage* application_manager_page_elite = new ApplicationManagerPage(ELITE,this);
QHBoxLayout* application_manager_page_elite_layout = new QHBoxLayout;
application_manager_page_elite_layout->addWidget(application_manager_page_elite);
ui.tab_2->setLayout(application_manager_page_elite_layout);
pages.insert(application_manager_page_elite_layout, application_manager_page_elite);
ui.tabWidget->setTabText(1, categrories[0].name);
ApplicationManagerPage* application_manager_page_soft = new ApplicationManagerPage(SOFT,this);
QHBoxLayout* application_manager_page_soft_layout = new QHBoxLayout;
application_manager_page_soft_layout->addWidget(application_manager_page_soft);
pages.insert(application_manager_page_soft_layout, application_manager_page_soft);
ui.tab_3->setLayout(application_manager_page_soft_layout);
ui.tabWidget->setTabText(2, categrories[1].name);
ApplicationManagerPage* application_manager_page_system = new ApplicationManagerPage(SYSTEM,this);
QHBoxLayout* application_manager_page_system_layout = new QHBoxLayout;
application_manager_page_system_layout->addWidget(application_manager_page_system);
pages.insert(application_manager_page_system_layout, application_manager_page_system);
ui.tab_4->setLayout(application_manager_page_system_layout);
ui.tabWidget->setTabText(3, categrories[2].name);
ApplicationManagerPage* application_manager_page_inner = new ApplicationManagerPage(INNER,this);
QHBoxLayout* application_manager_page_inner_layout = new QHBoxLayout;
application_manager_page_inner_layout->addWidget(application_manager_page_inner);
pages.insert(application_manager_page_inner_layout, application_manager_page_inner);
ui.tab_5->setLayout(application_manager_page_inner_layout);
ui.tabWidget->setTabText(4, categrories[3].name);
ApplicationManagerPage* application_manager_page_custom_1 = new ApplicationManagerPage(CUSTOM_1, this);
QHBoxLayout* application_manager_page_custom_1_layout = new QHBoxLayout;
application_manager_page_custom_1_layout->addWidget(application_manager_page_custom_1);
pages.insert(application_manager_page_custom_1_layout, application_manager_page_custom_1);
ui.tab_6->setLayout(application_manager_page_custom_1_layout);
ui.tabWidget->setTabText(5, categrories[4].name);
ApplicationManagerPage* application_manager_page_custom_2 = new ApplicationManagerPage(CUSTOM_2, this);
QHBoxLayout* application_manager_page_custom_2_layout = new QHBoxLayout;
application_manager_page_custom_2_layout->addWidget(application_manager_page_custom_2);
pages.insert(application_manager_page_custom_2_layout, application_manager_page_custom_2);
ui.tab_7->setLayout(application_manager_page_custom_2_layout);
ui.tabWidget->setTabText(6, categrories[5].name);
ApplicationManagerPage* application_manager_page_others = new ApplicationManagerPage(OTHERS,this);
QHBoxLayout* application_manager_page_others_layout = new QHBoxLayout;
application_manager_page_others_layout->addWidget(application_manager_page_others);
pages.insert(application_manager_page_others_layout, application_manager_page_others);
ui.tab_8->setLayout(application_manager_page_others_layout);
ui.tabWidget->setTabText(7, categrories[6].name);*/
layout_bottom->addLayout(layout_bottom_top,7);
layout_bottom->addWidget(miniblink, 3);
layout->addLayout(layout_top, 1);
layout->addLayout(layout_bottom, 9);
setLayout(layout);
@ -149,7 +104,8 @@ ApplicationManager::~ApplicationManager()
delete pages[layout];
delete layout;
}
delete miniblink;
delete layout_top_left;
delete layout_top_right;
delete layout_top;
delete layout_bottom;
delete layout;
@ -165,97 +121,115 @@ void ApplicationManager::onclick1(QString op, QString func, QString path, QStrin
add_app.exec();
if(add_app.changed)
{
bool ok = sqlite_helper.insert_software(add_app.get_name(), add_app.get_orig_name(), add_app.get_exe_path(),
int ok = sqlite_helper.insert_software(add_app.get_name(), add_app.get_orig_name(), add_app.get_exe_path(),
add_app.get_sort(), add_app.get_categories());
if (!ok)
{
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("插入失败"));
}
emit refresh();
/*table->insertRow(table->rowCount()-1);
table->setItem(table->rowCount(), 0, new QTableWidgetItem(add_app.get_name()));
table->setItem(table->rowCount(), 1, new QTableWidgetItem(add_app.get_orig_name()));
Record2 record2;
srand(time(nullptr));
int id = rand();
if(id<RAND_MAX-100000)
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("插入失败。"));
}else if(ok==FIND)
{
id += 100000;
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("已存在。"));
}
record2.settings = new MiniButton(id, "settings");
record2.settings->setText(QString::fromLocal8Bit("设置"));
connect(record2.settings, &MiniButton::click0, record2.settings, &MiniButton::onclick2);
connect(record2.settings, &MiniButton::click2, this, &ApplicationManager::onclick2);
record2.open = new MiniButton(id, "open");
record2.open->setText(QString::fromLocal8Bit("打开"));
connect(record2.open, &MiniButton::click0, record2.open, &MiniButton::onclick2);
connect(record2.open, &MiniButton::click2, this, &ApplicationManager::onclick2);
record2.exe_file = add_app.get_exe_path();
record2.orig_name = add_app.get_orig_name();
table->setCellWidget(table->rowCount(), 4, record2.settings);
table->setCellWidget(table->rowCount(), 5, record2.open);
rows.insert(id, record2);*/
emit refresh_tab();
}
}
else if (func == "app_update")
{
bool software_ok = sqlite_helper.update_software();
bool app_ok = sqlite_helper.update_app();
if(software_ok&&app_ok)
QFile file(QApplication::applicationDirPath() + DEFAULT_FILE);
if(file.open(QIODevice::ReadOnly))
{
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("更新成功"));
QByteArray ba = file.readAll();
file.close();
QJsonParseError json_error;
QJsonDocument jsonDoc(QJsonDocument::fromJson(ba, &json_error));
if (json_error.error == QJsonParseError::NoError)
{
QJsonObject rootObj = jsonDoc.object();
agree=rootObj.value("agree").toBool();
}
else
{
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("更新部分或全部失败"));
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("配置文件损坏"));
}
emit refresh();
}else
{
UserImprove user_improve;
user_improve.exec();
if(file.open(QIODevice::WriteOnly|QIODevice::Text))
{
QJsonObject rootObj;
rootObj.insert("agree", agree);
QJsonDocument jsonDoc;
jsonDoc.setObject(rootObj);
file.write(jsonDoc.toJson());
file.close();
}
}
if(agree)
{
DeviceRequest *device_request = new DeviceRequest;//构造函数里面会自动发送请求
delete device_request;
}
if (software_ok && app_ok)
{
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("更新成功"));
emit refresh_tab();
}
else
{
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("更新部分或全部失败,全名是否重名?"));
}
}else if(func=="app_category")
{
AddCategory add_category;
add_category.exec();
if(add_category.changed)
{
for(int i=0;i<7;i++)
for(int i=0;i<add_category.categrories.length();i++)
{
tab_bar->setTabText(i + 1, add_category.categrories[i].name);
}
bool ok = sqlite_helper.set_category(add_category.categrories);
if (!ok)
{
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("添加失败"));
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("添加失败,分类是否重名?"));
}
emit refresh();
emit refresh_tab();
}
}
}else if(op=="soft")
{
emit changeUrl(url);
ShellExecute(GetDesktopWindow(), L"open", path.toStdWString().c_str(), L"", L"", SW_SHOW);
emit clickButton("",op,func,url,path,"");
//ShellExecute(GetDesktopWindow(), L"open", path.toStdWString().c_str(), L"", L"", SW_SHOW);
}else if(op=="app")
{
emit changeUrl(url);
QString str = QApplication::applicationDirPath() + path;
ShellExecute(GetDesktopWindow(), L"open",str.toStdWString().c_str(), L"", L"", SW_SHOW);
emit clickButton("", op, func, url, path, "");
//QString str = QApplication::applicationDirPath() + path;
//ShellExecute(GetDesktopWindow(), L"open",str.toStdWString().c_str(), L"", L"", SW_SHOW);
}else if(op=="url")
{
emit changeUrl(url);
//emit clickButton("", op, func, url, path, "");
emit clickButton("", op, func, url, path, "");
}
}
void ApplicationManager::onclick2(QString orig_name, QString op)
{
sqlite_helper.use_software(orig_name);
if (op == "app")
{
if (application_manager_page_all->rows[orig_name].func == "openwechat") {
emit application_manager_page_all->onclick3(application_manager_page_all->rows[orig_name].op, application_manager_page_all->rows[orig_name].func, application_manager_page_all->rows[orig_name].exe_file, application_manager_page_all->rows[orig_name].url);
emit application_manager_page_all->onclick3(orig_name,application_manager_page_all->rows[orig_name].op, application_manager_page_all->rows[orig_name].func, application_manager_page_all->rows[orig_name].exe_file, application_manager_page_all->rows[orig_name].url);
}
else {
emit changeUrl(application_manager_page_all->rows[orig_name].url);
WinExec((QApplication::applicationDirPath()+application_manager_page_all->rows[orig_name].exe_file).toStdString().c_str(), SW_SHOW);
//emit changeUrl(application_manager_page_all->rows[orig_name].url);
//WinExec((QApplication::applicationDirPath()+application_manager_page_all->rows[orig_name].exe_file).toStdString().c_str(), SW_SHOW);
emit clickButton("", op, application_manager_page_all->rows[orig_name].func, application_manager_page_all->rows[orig_name].url, application_manager_page_all->rows[orig_name].exe_file, "");
}
}
else if (op == "settings")
@ -267,14 +241,14 @@ void ApplicationManager::onclick2(QString orig_name, QString op)
bool ok = sqlite_helper.edit_software(add_app.get_name(), add_app.get_orig_name(), add_app.get_exe_path(), add_app.get_sort(), add_app.get_categories());
if (!ok)
{
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("编辑失败"));
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("编辑失败"));
}
emit refresh();
emit refresh_tab();
}
}
else {
emit application_manager_page_all->onclick3(application_manager_page_all->rows[orig_name].op,
emit application_manager_page_all->onclick3(orig_name,application_manager_page_all->rows[orig_name].op,
application_manager_page_all->rows[orig_name].func,
application_manager_page_all->rows[orig_name].url,
application_manager_page_all->rows[orig_name].exe_file
@ -289,13 +263,42 @@ void ApplicationManager::tabChange(int index)
{
map[i]->setHidden(true);
}
map[index + 1]->setHidden(false);
map[map2[index]]->setHidden(false);
}
void ApplicationManager::onNumChange() {
QList<Categrory> categrories;
sqlite_helper.get_category(categrories, false, true);
for (int i = 0; i < categrories.size(); i++) {
tab_bar->setTabText(i, categrories[i].name + "(" + QString::number(categrories[i].total) + ")");
int count = tab_bar->count();
disconnect(tab_bar, &QTabBar::currentChanged, this, &ApplicationManager::tabChange);
for(int i=0;i<count;i++)
{
tab_bar->removeTab(0);
}
for(auto i:map.values())
{
delete i;
}
application_manager_page_all = new ApplicationManagerPage(ALL, this, this);
connect(this, &ApplicationManager::refresh, application_manager_page_all, &ApplicationManagerPage::refresh);
layout_bottom_top->addWidget(application_manager_page_all, 19);
map.insert(ALL, application_manager_page_all);
for (int i = 2; i <= CATEGORIES_NUM; i++)
{
ApplicationManagerPage* application_manager_page = new ApplicationManagerPage(i, this, this);
connect(this, &ApplicationManager::refresh, application_manager_page, &ApplicationManagerPage::refresh);
layout_bottom_top->addWidget(application_manager_page, 1);
application_manager_page->setHidden(true);
map.insert(i, application_manager_page);
}
QList<Categrory> categories;
map2.clear();
sqlite_helper.get_category(categories,false);
for (int i = 0; i < categories.size(); i++) {
tab_bar->addTab(categories[i].name + "(" + QString::number(categories[i].total) + ")");
map2.insert(i, categories[i].id);
}
connect(tab_bar, &QTabBar::currentChanged, this, &ApplicationManager::tabChange);
tab_bar->setCurrentIndex(0);
emit refresh();
}
ApplicationManager *application_manager;

View File

@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <QWidget>
#include "sqlitehelper.h"
@ -16,6 +16,8 @@
#include "ui_applicationmanager.h"
#include <QTabBar>
#include <QCheckBox>
#include "config.h"
class ApplicationManagerPage;
struct Record2
@ -24,7 +26,7 @@ struct Record2
QLabel *orig_name;
QLabel *dev;
QLabel *use_time;*/
QSvgWidget* icon;
QLabel* icon;
MiniButton* settings;
MiniButton * open;
QString op;
@ -33,9 +35,10 @@ struct Record2
QString orig_name;
QString exe_file;
QCheckBox *check_box;
bool is_locked;
int sort;
QString url;
bool categories[8];
bool categories[CATEGORIES_NUM];
};
struct Title
@ -50,9 +53,11 @@ class ApplicationManager : public QWidget
{
Q_OBJECT
signals:
void changeUrl(QString url);
void clickButton(QString orig_name, QString op, QString func, QString url, QString path, QString initial_position);
void refresh();
void refresh_tab();
public:
QList<MiniButton*> buttons;
ApplicationManager(QWidget *parent = nullptr);
~ApplicationManager();
QWidget* parent;
@ -61,14 +66,16 @@ private:
QVBoxLayout* layout;
QTabBar *tab_bar;
QMap<int, ApplicationManagerPage*> map;
QMap<int,int> map2;
QHBoxLayout* layout_top;
QHBoxLayout* layout_bottom;
QMiniBlink* miniblink;
QList<MiniButton*> buttons;
QList<Record> softwares;
QList<ButtonStruct> button_structs;
ApplicationManagerPage* application_manager_page_all;
Ui::ApplicationManagerClass ui;
QHBoxLayout* layout_top_left;
QHBoxLayout* layout_top_right;
SQLiteHelper sqlite_helper;
QVBoxLayout *layout_bottom_top;
QTableWidget *table;

View File

@ -1,4 +1,4 @@
#include "applicationmanagerpage.h"
#include "applicationmanagerpage.h"
#include <QSvgRenderer>
#include <QPainter>
@ -12,20 +12,21 @@ ApplicationManagerPage::ApplicationManagerPage(int category, ApplicationManager
{
ui.setupUi(this);
this->category = category;
this->parent = parent;
this->application_manager = application_manager;
sqlite_helper.get_buttons(button_structs);
layout = new QVBoxLayout;
sqlite_helper.get_all_software(softwares, category);
table = new QTableWidget(this);
table->setColumnCount(8);
table->setColumnCount(9);
QStringList titles;
titles<< QString::fromLocal8Bit("图标") << QString::fromLocal8Bit("名称") << QString::fromLocal8Bit("全名") << QString::fromLocal8Bit("开发者") << QString::fromLocal8Bit("最后使用日期") << QString::fromLocal8Bit("添加到导航条") <<QString::fromLocal8Bit("设置") << QString::fromLocal8Bit("打开");
titles<< QString::fromLocal8Bit("图标") << QString::fromLocal8Bit("名称") << QString::fromLocal8Bit("全名") << QString::fromLocal8Bit("开发者") << QString::fromLocal8Bit("最后使用日期")<<QString::fromLocal8Bit("排序") << QString::fromLocal8Bit("添加到导航条") <<QString::fromLocal8Bit("设置") << QString::fromLocal8Bit("打开");
table->setHorizontalHeaderLabels(titles);
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
table->setStyleSheet("QTableWidget{border:1px;outline:1px;align: center;} QQTableWidget::widget QTableWidget::item {text-align: center;}");
table->horizontalHeader()->setDefaultAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
int i = 0;
for (i = 0; i < 8; i++)
for (i = 0; i < 9; i++)
{
table->horizontalHeader()->setSectionResizeMode(i, QHeaderView::Stretch);
@ -34,92 +35,6 @@ ApplicationManagerPage::ApplicationManagerPage(int category, ApplicationManager
QTableWidgetItem* item = new QTableWidgetItem;
item->setTextAlignment(Qt::AlignCenter);
table->setItemPrototype(item);
for (auto software : softwares)
{
table->insertRow(i);
table->setItem(i, 1, new QTableWidgetItem(software.name));
table->setItem(i, 2, new QTableWidgetItem(software.orig_name));
table->setItem(i, 3, new QTableWidgetItem(software.dev));
QString date;
std::tm* time;
time = std::localtime(&software.use_time);
date = QString::number(1900 + time->tm_year, 10);
date += "/";
date += QString::number(1 + time->tm_mon, 10);
date += "/";
date += QString::number(time->tm_mday, 10);
if (software.use_time == 0) {
date.clear();
}
table->setItem(i, 4, new QTableWidgetItem(date));
Record2 record2;
record2.name = software.name;
record2.icon = new QSvgWidget;
QFile file(software.logo);
if(file.exists())
{
record2.icon->load(software.logo);
}
else {
record2.icon->load(QApplication::applicationDirPath() + DEFAULT_IMAGE);
}
record2.icon->setMaximumSize(80, 80);
table->setCellWidget(i, 0, record2.icon);
record2.settings = new MiniButton(software.orig_name, "settings");
record2.settings->setText(QString::fromLocal8Bit("设置"));
record2.settings->setMaximumSize(60, 40);
connect(record2.settings, &MiniButton::click0, record2.settings, &MiniButton::onclick2);
connect(record2.settings, &MiniButton::click2, application_manager, &ApplicationManager::onclick2);
record2.open = new MiniButton(software.orig_name,software.op);
record2.open->setText(QString::fromLocal8Bit("打开"));
record2.open->setMaximumSize(60, 40);
connect(record2.open, &MiniButton::click0, record2.open, &MiniButton::onclick2);
connect(record2.open, &MiniButton::click2, application_manager, &ApplicationManager::onclick2);
record2.exe_file = software.path;
record2.orig_name = software.orig_name;
record2.url = software.url;
record2.op = software.op;
record2.func = software.func;
connect(this, &ApplicationManagerPage::onclick3, (MainWindowLayout*)((MainScreen*)application_manager->parent)->parent, &MainWindowLayout::clickButton);
for(int i=0;i<8;i++)
{
record2.categories[i] = false;
}
for(int i=0;i<8;i++)
{
if (software.category_id.contains(QString::number(i+1)))
{
record2.categories[i] = true;
}
}
record2.sort = software.sort;
record2.check_box = new QCheckBox;
if(software.type=="navbar")
{
record2.check_box->setCheckState(Qt::Checked);
checked.insert(software.orig_name, true);
}
else
{
record2.check_box->setCheckState(Qt::Unchecked);
checked.insert(software.orig_name, false);
}
connect(record2.check_box, &QCheckBox::clicked, this, &ApplicationManagerPage::onclicked);
QTableWidgetItem* check_box_item = new QTableWidgetItem;
table->setItem(i, 5, check_box_item);
table->setCellWidget(i, 5, record2.check_box);
check_box_item->setTextAlignment(Qt::AlignCenter);
table->setCellWidget(i, 6, record2.settings);
//table->item(i, 5)->setTextAlignment(Qt::AlignCenter);
table->setCellWidget(i, 7, record2.open);
//table->item(i, 6)->setTextAlignment(Qt::AlignCenter);
rows.insert(software.orig_name, record2);
table->resizeColumnToContents(0);
//table->item(i, 0)->setTextAlignment(Qt::AlignCenter);
//table->verticalHeader()->setSectionResizeMode(i, QHeaderView::ResizeToContents);
i++;
}
layout->addWidget(table);
setLayout(layout);
@ -134,11 +49,11 @@ ApplicationManagerPage::~ApplicationManagerPage()
delete layout;
}
void ApplicationManagerPage::onclicked()
void ApplicationManagerPage::onclicked(int state)
{
for(int i=0;i<table->rowCount();i++)
{
if(((QCheckBox *)table->cellWidget(i,5))->checkState()==Qt::Checked)
if(((QCheckBox *)table->cellWidget(i,6))->checkState()==Qt::Checked)
{
if(!checked[table->item(i,2)->text()])
{
@ -146,9 +61,10 @@ void ApplicationManagerPage::onclicked()
bool ok=sqlite_helper.edit_software(table->item(i, 1)->text(), orig_name, rows[orig_name].exe_file, QString::number(rows[orig_name].sort), rows[orig_name].categories,"navbar");
if(!ok)
{
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("更新部分或全部失败"));
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("更新部分或全部失败"));
break;
}
checked[table->item(i, 2)->text()] = true;
}
}else
{
@ -158,18 +74,27 @@ void ApplicationManagerPage::onclicked()
bool ok = sqlite_helper.edit_software(table->item(i, 1)->text(), orig_name, rows[orig_name].exe_file, QString::number(rows[orig_name].sort), rows[orig_name].categories, "app");
if (!ok)
{
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("更新部分或全部失败"));
QMessageBox::critical(this, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("更新部分或全部失败"));
break;
}
checked[table->item(i, 2)->text()] = false;
}
}
}
emit application_manager->refresh();
//在后面refresh避免因为refresh导致信号和槽断开
}
//刷新页面
void ApplicationManagerPage::refresh()
{
for(auto button:application_manager->buttons)
{
button->update();
}
int rowcount = table->rowCount();
for(auto i : connections)
{
disconnect(i);
}
for(int i=0;i<rowcount;i++)
{
table->removeRow(0);
@ -197,37 +122,56 @@ void ApplicationManagerPage::refresh()
date += QString::number(time->tm_mday, 10);
table->setItem(i, 4, new QTableWidgetItem(date));
}
else
{
table->setItem(i, 4, new QTableWidgetItem(QString::fromLocal8Bit("从未使用")));
}
Record2 record2;
record2.name = software.name;
record2.icon = new QSvgWidget;
QFile file(software.logo);
record2.icon = new QLabel;
QFile file(software.img);
record2.icon->setMaximumSize(50, 50);
record2.icon->setScaledContents(true);
if (file.exists())
{
record2.icon->load(software.logo);
QPixmap pixmap(software.img);
//pixmap.scaled(40, 40);
record2.icon->setPixmap(pixmap);
}
else {
record2.icon->load(QApplication::applicationDirPath() + DEFAULT_IMAGE);
QPixmap pixmap(QApplication::applicationDirPath() + DEFAULT_PNG);
//pixmap.scaled(40, 40);
record2.icon->setPixmap(pixmap);
}
record2.icon->setMaximumSize(80, 80);
table->setCellWidget(i, 0, record2.icon);
if(!software.locked)
{
record2.settings = new MiniButton(software.orig_name, "settings");
record2.settings->setText(QString::fromLocal8Bit("设置"));
record2.settings->setText(QString::fromLocal8Bit("设置"));
record2.settings->setMaximumSize(60, 40);
connect(record2.settings, &MiniButton::click0, record2.settings, &MiniButton::onclick2);
connect(record2.settings, &MiniButton::click2, application_manager, &ApplicationManager::onclick2);
QMetaObject::Connection connect1 = connect(record2.settings, &MiniButton::clicked, record2.settings, &MiniButton::onclick2);
connections << connect1;
QMetaObject::Connection connect2 = connect(record2.settings, &MiniButton::click2, application_manager, &ApplicationManager::onclick2);
connections << connect2;
table->setCellWidget(i, 7, record2.settings);
}
record2.open = new MiniButton(software.orig_name, "open");
record2.open->setText(QString::fromLocal8Bit("打开"));
record2.open->setText(QString::fromLocal8Bit("打开"));
record2.open->setMaximumSize(60, 40);
connect(record2.open, &MiniButton::click0, record2.open, &MiniButton::onclick2);
connect(record2.open, &MiniButton::click2, application_manager, &ApplicationManager::onclick2);
QMetaObject::Connection connect3=connect(record2.open, &MiniButton::clicked, record2.open, &MiniButton::onclick2);
connections << connect3;
QMetaObject::Connection connect4=connect(record2.open, &MiniButton::click2, application_manager, &ApplicationManager::onclick2);
connections << connect4;
record2.exe_file = software.path;
record2.orig_name = software.orig_name;
record2.url = software.url;
for (int i = 0; i < 8; i++)
for (int i = 0; i < CATEGORIES_NUM; i++)
{
record2.categories[i] = false;
}
for (int i = 0; i < 8; i++)
for (int i = 0; i < CATEGORIES_NUM; i++)
{
if (software.category_id.contains(QString::number(i+1)))
{
@ -236,10 +180,11 @@ void ApplicationManagerPage::refresh()
}
record2.op = software.op;
record2.func = software.func;
connect(this, &ApplicationManagerPage::onclick3, (MainWindowLayout*)((MainScreen*)application_manager->parent)->parent, &MainWindowLayout::clickButton);
QMetaObject::Connection connect5 = connect(this, &ApplicationManagerPage::onclick3, (MainWindowLayout*)((MainScreen*)application_manager->parent)->parent, &MainWindowLayout::clickButton);
connections<<connect5;
record2.sort = software.sort;
record2.check_box = new QCheckBox;
if (software.type == "navbar")
if (software.is_navbar)
{
record2.check_box->setCheckState(Qt::Checked);
checked.insert(software.orig_name, true);
@ -249,19 +194,27 @@ void ApplicationManagerPage::refresh()
record2.check_box->setCheckState(Qt::Unchecked);
checked.insert(software.orig_name, false);
}
connect(record2.check_box, &QCheckBox::clicked, this, &ApplicationManagerPage::onclicked);
if(software.locked)
{
record2.check_box->setEnabled(false);
}
else
{
record2.check_box->setEnabled(true);
}
QMetaObject::Connection connect6 = connect(record2.check_box, &QCheckBox::stateChanged, this, &ApplicationManagerPage::onclicked);
connections << connect6;
QMetaObject::Connection connect7 = connect(record2.check_box, &QCheckBox::stateChanged, mainWindowLayout->navBar, &NavBar::refresh);
connections << connect7;
table->setItem(i, 5, new QTableWidgetItem(QString::number(software.sort)));
QTableWidgetItem* check_box_item = new QTableWidgetItem;
table->setItem(i, 5, check_box_item);
table->setCellWidget(i, 5, record2.check_box);
table->setItem(i, 6, check_box_item);
table->setCellWidget(i, 6, record2.check_box);
check_box_item->setTextAlignment(Qt::AlignCenter);
table->setCellWidget(i, 6, record2.settings);
//table->item(i, 5)->setTextAlignment(Qt::AlignCenter);
table->setCellWidget(i, 7, record2.open);
//table->item(i, 6)->setTextAlignment(Qt::AlignCenter);
table->setCellWidget(i, 8, record2.open);
rows.insert(software.orig_name, record2);
table->resizeColumnToContents(0);
//table->item(i, 0)->setTextAlignment(Qt::AlignCenter);
//table->verticalHeader()->setSectionResizeMode(i, QHeaderView::ResizeToContents);
i++;
}
}

View File

@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <QTableWidget>
#include <QVBoxLayout>
@ -17,7 +17,7 @@ class ApplicationManagerPage : public QWidget
{
Q_OBJECT
signals:
void onclick3(QString op, QString func, QString url, QString path,QString initial_position="");
void onclick3(QString orig_name,QString op, QString func, QString url, QString path,QString initial_position="");
public:
ApplicationManagerPage(int category, ApplicationManager *application_manager,QWidget *parent = nullptr);
~ApplicationManagerPage();
@ -28,6 +28,7 @@ private:
QVBoxLayout* layout;
QHBoxLayout* layout_top;
QHBoxLayout* layout_bottom;
QList<QMetaObject::Connection> connections;
QMiniBlink* miniblink;
QList<MiniButton*> buttons;
QList<Record> softwares;
@ -39,7 +40,8 @@ private:
ApplicationManager* application_manager;
Title *title;
int category;
QWidget *parent;
public slots:
void refresh();
void onclicked();
void onclicked(int state);
};

View File

@ -1,4 +1,4 @@
//
//
// Created by HW on 2023/07/26.
//
@ -9,6 +9,7 @@
typedef struct taButtonStruct{
QImage *image;
QImage *image_cover;
QImage *png;
QString text;
QString orig_name;
QString url;

View File

@ -1,37 +1,39 @@
//
// Created by 孙羽 on 2023/07/27.
//
// Created by 孙羽 on 2023/07/27.
//
//说明:没有注释的项请勿修改
//说明:没有注释的项请勿修改
#ifndef OFFICEASSISTANT_CONFIG_H
#define OFFICEASSISTANT_CONFIG_H
#define CONFIG_URL "http://softapi.s103.y01.cn/addons/Kmdsoft/Index/config" //获取导航栏信息的地址
#define OP_URL "http://softapi.s103.y01.cn/addons/Kmdsoft/Index/op" //上传是否设置开机启动、是否建立桌面快捷方式的地址
#define DEVICE_URL "http://softapi.s103.y01.cn/addons/Kmdsoft/Index/device" //上传设备信息的地址
#define WECHAT_URL " http://softapi.s103.y01.cn/addons/Kmdsoft/Wxdk/open"
#define BASE_URL "http://softapi.s103.y01.cn/" //域名
#define DEFAULT_FILE "/config/config.kmd" //默认配置文件位置
#define CONFIG_URL "http://softapi.s103.y01.cn/addons/Kmdsoft/Index/config" //获取导航栏信息的地址
#define OP_URL "http://softapi.s103.y01.cn/addons/Kmdsoft/Index/op" //上传是否设置开机启动、是否建立桌面快捷方式的地址
#define DEVICE_URL "http://softapi.s103.y01.cn/addons/Kmdsoft/Index/device" //上传设备信息的地址
#define WECHAT_URL "http://softapi.s103.y01.cn/addons/Kmdsoft/Wxdk/open"
#define BASE_URL "http://softapi.s103.y01.cn/" //域名
#define DEFAULT_FILE "/config/config.kmd" //默认配置文件位置
#define DEFAULT_NAVBAR_FILLE "/config/default_navbar.kmd"
#define KEY "3b046cfe4a2a3e62141a4840f2006210a3224e3615312bef6e19f4983921abe0" //Key
#define NAME "办公助手" //中文名
#define LOGO_TITLEBAR "/images/icon/logo_navbar.png" //标题栏图标
#define ENG_NAME "OfficeAssistant" //英文名
#define LENG_NAME L"OfficeAssistant" //英文名(宽字符)
#define NAME "办公助手" //中文名
#define LOGO_TITLEBAR "/images/logo_titlebar.png" //标题栏图标
#define ENG_NAME "OfficeAssistant" //英文名
#define LENG_NAME L"OfficeAssistant" //英文名(宽字符)
#define ADD_AUTOSTART 1
#define ADD_SHORTCUT 2
#define VERSION "1.0.0" //软件版本
#define VERSION "1.0.0" //软件版本
#define RELEASE "20230801" //Release
#define SOFTWARE_URL "http://softapi.s103.y01.cn/addons/Kmdsoft/App/update/type/add"
#define DEFAULT_BACKGROUND_COLOR "#333332" //默认背景色,若从服务器读不到即使用这个
#define DEFAULT_BACKGROUND_COLOR "#333332" //默认背景色,若从服务器读不到即使用这个
#define DEFAULT_COLOR "#3399FF" //
#define DEFAULT_TEXT_COLOR "#FFFFFF" //默认文字颜色
#define DEFAULT_COVER_COLOR "#0033FF" //鼠标指向后变成的颜色,也是“添加应用”等几个按钮的默认颜色
#define DEFAULT_IMAGE "/images/svg/default.svg" //默认图标
#define DEFAULT_TEXT_COLOR "#FFFFFF" //默认文字颜色
#define DEFAULT_COVER_COLOR "#0033FF" //鼠标指向后变成的颜色,也是“添加应用”等几个按钮的默认颜色
#define DEFAULT_IMAGE "/images/svg/default.svg" //默认图标
#define DEFAULT_SVG_PATH "/images/svg/"
#define DEFAULT_LOGO "/images/logo.png" //logo路径
#define TITLE " " //标题栏
#define TEXT_SIZE 7 //字体大小。不是所有字体受此项控制
#define DEFAULT_LOGO "/images/logo.png" //logo路径
#define DEFAULT_PNG_PATH "/images/png/" //png路径
#define TITLE " " //标题栏
#define TEXT_SIZE 7 //字体大小。不是所有字体受此项控制
#define DEFAULT_PNG "/images/png/default.png" //默认PNG图标
#define TEXT_SIZE_BIG 10
//分类
//分类
#define ALL 1
#define ELITE 2
#define SOFT 3
@ -40,4 +42,7 @@
#define CUSTOM_1 6
#define CUSTOM_2 7
#define OTHERS 8
#define CATEGORIES_NUM 8
#define FIND 2
#endif //OFFICEASSISTANT_CONFIG_H

View File

@ -1,10 +1,11 @@
//
//
// Created by HW on 2023/07/27.
//
#ifndef OFFICEASSISTANT_GLOBALVARIABLES_H
#define OFFICEASSISTANT_GLOBALVARIABLES_H
#include "exitmanager.h"
class ApplicationManager;
class MainWindowLayout;
extern ExitManager exit_manager;
extern double scale;
@ -12,4 +13,8 @@ extern MainWindowLayout *mainWindowLayout;
extern QString url_param;
extern bool autostart;
extern bool agree;
extern QString background_color;
extern QString text_color;
extern QString text_cover_color;
extern ApplicationManager *application_manager;
#endif //OFFICEASSISTANT_GLOBALVARIABLES_H

Binary file not shown.

View File

@ -1,4 +1,4 @@
//
//
// Created by HW on 2023/07/27.
//
@ -34,7 +34,7 @@ MainScreen::MainScreen(QWidget *parent) :
button->setStyleSheet("border-style:none;padding:10px;border-radius:5px;background-color:#09bb07;color:white;font-family:SimHei");
//Plus Math icon by Icons8
QString dir = QApplication::applicationDirPath();
button->setText(QString::fromLocal8Bit("打开微信"));
button->setText(QString::fromLocal8Bit("打开微信"));
//button->setStyleSheet("text-color:white");
layout = new QHBoxLayout;
miniblink = new QMiniBlink(this);
@ -80,31 +80,43 @@ MainScreen::~MainScreen() {
void MainScreen::firstUrl(QString url)
{
QString url_full;
if (url.contains("http"))
if (url.isEmpty())
{
url_full = url;
url_full = "";
}
else if (url.contains("?"))
{
url_full = BASE_URL + url + url_param;
emit changeUrl(url_full);
}
else
{
url_full = BASE_URL + url + url_param;
}
url_full = BASE_URL + url + "?" + url_param;
emit changeUrl(url_full);
}
}
void MainScreen::clickButton1(QString op,QString url) {
QString url_full;
if(url.contains("http"))
if (url.isEmpty())
{
url_full = url;
}else
url_full = "";
}
else if (url.contains("?"))
{
url_full = BASE_URL + url + url_param;
emit changeUrl(url_full);
}
else
{
url_full = BASE_URL + url + "?" + url_param;
emit changeUrl(url_full);
}
if (op == "openwechat") {
OpenWeChatRequest open_wechat_request;
QString msg = open_wechat_request.sendRequest();
if(msg!="ok")
{
QMessageBox::information(this, QString::fromLocal8Bit("提示"), msg);
QMessageBox::information(this, QString::fromLocal8Bit("提示"), msg);
return;
}
widget->setHidden(false);

View File

@ -1,4 +1,4 @@
//
//
// Created by HW on 2023/07/27.
//
@ -27,6 +27,7 @@ public:
explicit MainScreen(QWidget *parent = nullptr);
~MainScreen() override;
QWidget* parent;
ApplicationManager* application_manager;
public slots:
void clickButton1(QString op, QString url);
void firstUrl(QString url);
@ -38,7 +39,6 @@ private:
QVBoxLayout *layout_left;
QPushButton *button;
QIcon *icon;
ApplicationManager* application_manager;
QWidget *broswer;
static bool isInited();
QWidget *widget;

View File

@ -1,4 +1,4 @@
//
//
// Created by HW on 2023/07/26.
//
@ -25,92 +25,7 @@ MainWindow::MainWindow(QWidget *parent) :
icon = new QIcon(path);
setWindowIcon(*icon);
setStyleSheet("*{font-family:SimHei;}");
QFile file(QApplication::applicationDirPath() + DEFAULT_FILE);
if(!file.open(QIODevice::Text|QIODevice::ReadOnly))
{
QMessageBox::warning(nullptr, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("无法打开配置文件"));
exit_manager.exit(1);
}
QByteArray buffer;
buffer = file.readAll();
file.close();
QJsonDocument document = QJsonDocument::fromJson(buffer);
if(document.isObject())
{
if(document.object().value("agree").isUndefined())
{
QMessageBox msg;
msg.setWindowTitle(QString::fromLocal8Bit("用户体验改善计划"));
msg.setText(QString::fromLocal8Bit("为改善我们的服务质量,我们将向服务器发送以下信息:\n"
"1.您的计算机配置;\n"
"2.您计算机上的软件安装列表;\n"
"3.您是否设置了开机启动,以及是不是通过开机启动的方式启动本软件。\n"
"第二项信息是我们提供服务所必需的,如您选择不同意但继续使用本软件,则第二项数据将正常发送,但第一项和第三项数据不会发送。选择不同意不影响您使用本软件。"));
msg.addButton(QString::fromLocal8Bit("同意"), QMessageBox::AcceptRole);
msg.addButton(QString::fromLocal8Bit("不同意"), QMessageBox::RejectRole);
int ret = msg.exec();
if(ret==QMessageBox::AcceptRole)
{
QJsonObject obj_root = document.object();
obj_root.insert("agree", true);
document.setObject(obj_root);
agree = true;
DeviceRequest* device_request = new DeviceRequest;//构造函数直接发出去数据了
delete device_request;
}else
{
QJsonObject obj_root = document.object();
obj_root.insert("agree", false);
document.setObject(obj_root);
agree = false;
}
if(file.open(QIODevice::WriteOnly|QIODevice::Text))
{
file.write(document.toJson());
file.close();
}
}
else if(document.object().value("agree").toBool())
{
agree = true;
DeviceRequest* device_request = new DeviceRequest;
delete device_request;
}
}
else
{
QMessageBox msg;
msg.setWindowTitle(QString::fromLocal8Bit("用户体验改善计划"));
msg.setText(QString::fromLocal8Bit("为改善我们的服务质量,我们将向服务器发送以下信息:\n"
"1.您的计算机配置;\n"
"2.您计算机上的软件安装列表;\n"
"3.您是否设置了开机启动,以及是不是通过开机启动的方式启动本软件。\n"
"第二项信息是我们提供服务所必需的,如您选择不同意但继续使用本软件,则第二项数据将正常发送,但第一项和第三项数据不会发送。选择不同意不影响您使用本软件。"));
msg.addButton(QString::fromLocal8Bit("同意"), QMessageBox::AcceptRole);
msg.addButton(QString::fromLocal8Bit("不同意"), QMessageBox::RejectRole);
int ret = msg.exec();
if (ret == QMessageBox::AcceptRole)
{
QJsonObject obj_root;
obj_root.insert("agree", true);
document.setObject(obj_root);
agree = true;
DeviceRequest* device_request = new DeviceRequest;//构造函数直接发出去数据了
delete device_request;
}
else
{
QJsonObject obj_root;
obj_root.insert("agree", false);
document.setObject(obj_root);
agree = false;
}
if (file.open(QIODevice::WriteOnly | QIODevice::Text))
{
file.write(document.toJson());
file.close();
}
}
}
MainWindow::~MainWindow() {

View File

@ -1,4 +1,4 @@
//
//
// Created by HW on 2023/07/26.
//
@ -17,14 +17,11 @@ MainWindowLayout::MainWindowLayout(QWidget *parent) :
mainWindowLayout = this;
QList<ButtonStruct> list;
mainScreen = new MainScreen(this);
navBar=new NavBar(mainScreen,this);
navBar = new NavBar(mainScreen, this);
emit mainScreen->application_manager->refresh_tab();
navBar->setMinimumHeight(0);
navBar->setMaximumHeight(this->height() / 8);
mainScreen->setMinimumHeight(0);
//navBar->setAttribute(Qt::WA_DeleteOnClose);
//QSizePolicy sizePolicy(QSizePolicy::Policy::Fixed, QSizePolicy::QSizePolicy::Fixed);
//navBar->setSizePolicy(sizePolicy);
//layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(navBar,1);
layout->addWidget(mainScreen,7);
layout->setMargin(0);
@ -48,7 +45,10 @@ void MainWindowLayout::resizeEvent(QResizeEvent *event) {
//layout->setAlignment(Qt::AlignmentFlag::AlignHCenter);
}
void MainWindowLayout::clickButton(QString op, QString func, QString url,QString path,QString initial_position) {
void MainWindowLayout::clickButton(QString orig_name,QString op, QString func, QString url,QString path,QString initial_position) {
SQLiteHelper sqlite_helper;
sqlite_helper.use_software(orig_name);
emit mainScreen->application_manager->refresh();
QString root_path = QApplication::applicationDirPath();
if(op=="app")
{
@ -59,7 +59,7 @@ void MainWindowLayout::clickButton(QString op, QString func, QString url,QString
{
path = root_path + path;
path.replace("/", "\\");
WinExec(path.toStdString().c_str(), SW_SHOW);
ShellExecute(GetDesktopWindow(), L"open", path.toStdWString().c_str(), L"", initial_position.toStdWString().c_str(), SW_SHOW);
emit clickButton1(op, url);
}
}
@ -76,7 +76,9 @@ void MainWindowLayout::clickButton(QString op, QString func, QString url,QString
}
}
else if(op=="soft"){
ShellExecute(GetDesktopWindow(), L"open",path.toStdWString().c_str(),L"",initial_position.toStdWString().c_str(),SW_SHOW);
path.replace("/", "\\");
initial_position.replace("/", "\\");
WinExec(path.toStdString().c_str(), SW_SHOW);
emit clickButton1(op, url);
}else
{

View File

@ -1,4 +1,4 @@

//
// Created by HW on 2023/07/26.
//
@ -22,10 +22,10 @@ signals:
void clickButton1(QString op,QString url);
public:
explicit MainWindowLayout(QWidget *parent = nullptr);
NavBar* navBar;
~MainWindowLayout() override;
public slots:
void clickButton(QString op, QString func, QString url, QString path, QString initial_position);
void clickButton(QString orig_name,QString op, QString func, QString url, QString path, QString initial_position);
protected:
void resizeEvent(QResizeEvent *event) override;
//void paintEvent(QPaintEvent *event) override;
@ -34,7 +34,6 @@ private:
Ui::MainWindowLayout *ui;
QVBoxLayout *layout;
//QList<ButtonStruct *> list;
NavBar *navBar;
ButtonStruct *buttons;
MainScreen *mainScreen;
ConfigResponse *configResponse;

View File

@ -1,4 +1,4 @@
#include "minibutton.h"
#include "minibutton.h"
#include <QPainter>
#include "config.h"
#include "globalvariables.h"
@ -6,7 +6,6 @@
MiniButton::MiniButton(QString orig_name, QString op, QWidget* parent)
{
this->orig_name = orig_name;
q_color.setNamedColor(DEFAULT_BACKGROUND_COLOR);
this->op = op;
connect(this, &MiniButton::click, this, &MiniButton::onclick2);
@ -15,11 +14,6 @@ MiniButton::MiniButton(ButtonStruct button_struct, QWidget *parent)
: QPushButton(parent)
{
ui.setupUi(this);
q_color.setNamedColor(DEFAULT_COVER_COLOR);
QString style_sheet = "MiniButton:{background-color:";
style_sheet += DEFAULT_TEXT_COLOR;
style_sheet += ";}";
setStyleSheet(style_sheet);
connect(this, &MiniButton::click, this, &MiniButton::onclick1);
this->button_struct = button_struct;
}
@ -33,6 +27,7 @@ void MiniButton::paintEvent(QPaintEvent* event)
setContentsMargins(0, 0, 0, 0);
QRect rect(0, 0, this->width(), this->height());
QPainter painter(this);
q_color.setNamedColor(background_color);
painter.fillRect(rect, q_color);
int text_x = (width() - TEXT_SIZE * text().length() * scale * 3) / 2;
@ -40,15 +35,11 @@ void MiniButton::paintEvent(QPaintEvent* event)
QFont ft;
ft.setPixelSize(TEXT_SIZE);
QRectF text_rect(text_x, text_y, TEXT_SIZE * text().length() * scale * 3, TEXT_SIZE * scale * 3);
painter.setPen(DEFAULT_TEXT_COLOR);
painter.setPen(text_color);
painter.drawText(text_rect, Qt::AlignCenter, text());
}
void MiniButton::mouseReleaseEvent(QMouseEvent* event)
{
emit click0();
}
void MiniButton::onclick1()
{

View File

@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <QPushButton>
@ -18,7 +18,6 @@ public:
~MiniButton();
protected:
void paintEvent(QPaintEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override;
private:
QString orig_name;
QString op;

View File

@ -1,4 +1,4 @@
#include "mysettingsdialog.h"
#include "mysettingsdialog.h"
#include <Windows.h>
#include <QClipBoard>
#include "netio.h"
@ -12,9 +12,9 @@ MySettingsDialog::MySettingsDialog(QWidget *parent)
setWindowFlags(Qt::WindowCloseButtonHint);
this->setFixedSize(width(), height());
HKEY hRoot = HKEY_CURRENT_USER;
wchar_t *szSubKey = (wchar_t *)"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
wchar_t *szSubKey = L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
HKEY hKey;
DWORD dwDisposition = REG_OPENED_EXISTING_KEY; // 如果不存在不创建
DWORD dwDisposition = REG_OPENED_EXISTING_KEY; // 如果不存在不创建
LONG lRet = RegCreateKeyEx(hRoot, szSubKey, 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition);
if (lRet != ERROR_SUCCESS) {
@ -22,9 +22,10 @@ MySettingsDialog::MySettingsDialog(QWidget *parent)
}
QString app = QApplication::applicationFilePath();
app.replace("/", "\\");
DWORD size=128+sizeof(wchar_t);
char reg[128] = { 0 };
lRet = RegQueryValueEx(hKey, L"OfficeAssistant", NULL, NULL,(LPBYTE)reg, &size);
app += " autostart";
DWORD size=256*sizeof(wchar_t);
wchar_t reg[256] = { 0 };
lRet = RegQueryValueEx(hKey, LENG_NAME, NULL, NULL,(LPBYTE)reg, &size);
if (lRet==0) {
ui.autostart->setChecked(true);
}
@ -47,11 +48,11 @@ void MySettingsDialog::autoStart(int state)
HKEY hRoot = HKEY_CURRENT_USER;
wchar_t *szSubKey = (wchar_t*)L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
HKEY hKey;
DWORD dwDisposition = REG_OPENED_EXISTING_KEY; // 如果不存在不创建
DWORD dwDisposition = REG_OPENED_EXISTING_KEY; // 如果不存在不创建
LONG lRet = RegCreateKeyEx(hRoot, szSubKey, 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition);
if (lRet != ERROR_SUCCESS) {
QMessageBox::critical(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("创建开机启动项失败"));
QMessageBox::critical(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("创建开机启动项失败"));
return;
}
QString app = QApplication::applicationFilePath();
@ -61,7 +62,7 @@ void MySettingsDialog::autoStart(int state)
lRet = RegSetValueEx(hKey, LENG_NAME, 0, REG_SZ, (BYTE*)app.toStdWString().c_str(), app.length()*sizeof(wchar_t));
if (lRet == ERROR_SUCCESS)
{
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("创建开机启动项成功"));
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("创建开机启动项成功"));
}
RegCloseKey(hKey);
if(agree)
@ -78,14 +79,14 @@ void MySettingsDialog::autoStart(int state)
LONG lRet = RegCreateKeyEx(hRoot, szSubKey, 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition);
if (lRet != ERROR_SUCCESS) {
QMessageBox::critical(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("移除开机启动项失败。"));
QMessageBox::critical(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("移除开机启动项失败。"));
return;
}
QString app = QApplication::applicationFilePath();
lRet = RegDeleteValue(hKey, LENG_NAME);
if (lRet == ERROR_SUCCESS)
{
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("移除开机启动项成功。"));
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("移除开机启动项成功。"));
}
RegCloseKey(hKey);
if(agree)
@ -116,9 +117,9 @@ void MySettingsDialog::createShortcut() {
QString srcFile = QApplication::applicationFilePath();
bool succeed=QFile::link(srcFile, deskTopPath);
if (succeed) {
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("创建快捷方式成功。"));
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("创建快捷方式成功。"));
}
else {
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("创建快捷方式失败。"));
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("创建快捷方式失败。"));
}
}

View File

@ -1,4 +1,4 @@
//
//
// Created by HW on 2023/07/26.
//
@ -42,6 +42,7 @@ void ConvertImageToTransparent(QImage &img)
NavBar::NavBar(MainScreen *mainScreen,QWidget *parent) :
QWidget(parent), ui(new Ui::NavBar) {
ui->setupUi(this);
this->parent = parent;
//this->setAttribute(Qt::WA_DeleteOnClose);
buffer = new QByteArray;
/*QString style = "background-color:";
@ -55,18 +56,18 @@ NavBar::NavBar(MainScreen *mainScreen,QWidget *parent) :
config_request.sendRequest(&config_response);
SQLiteHelper sqlite_helper;
sqlite_helper.get_software(&buttonStructs, &config_response);
if(!config_response.succeed)
{
qColor.setNamedColor(buttonStructs[0].background_color);
qColor.setNamedColor(background_color);
}else
{
qColor.setNamedColor(config_response.basic.backgroud_color);
qColor.setNamedColor(background_color);
}
layout2 = new QHBoxLayout;
layout_right = new QHBoxLayout;
layout_left = new QHBoxLayout;
getLogoFromInternet(&config_response);
logo_label = new QLabel(this);
logo_label->setAttribute(Qt::WA_TranslucentBackground);
//*logo = logo->scaled(this->width() / (5 / scale), this->height());
@ -85,7 +86,7 @@ NavBar::NavBar(MainScreen *mainScreen,QWidget *parent) :
MyButton *myButton = new MyButton(buttonStruct, height(), height(), &buttons,this);
myButton->setMaximumHeight(parent->height() / 8);
layout_right->addWidget(myButton);
//myButton->show();
myButton->show();
connect(myButton, &MyButton::clicked1, mainWindowLayout, &MainWindowLayout::clickButton);
buttons << myButton;
}
@ -138,9 +139,7 @@ void NavBar::resizeEvent(QResizeEvent *event) {
}
logo_label->setMaximumSize(event->size().width() / 5, event->size().height());
}
/*void NavBar::getLogoFromInternet(ConfigResponse *configResponse) {
qColor.setNamedColor(configResponse->basic.backgroud_color);
void NavBar::getLogoFromInternet(ConfigResponse *configResponse) {
QUrl url_logo(configResponse->basic.logo_url);
QNetworkRequest *request_logo = new QNetworkRequest(url_logo);
manager = new QNetworkAccessManager;
@ -153,20 +152,21 @@ void NavBar::resizeEvent(QResizeEvent *event) {
timer.stop();
buffer = new QByteArray;
delete request_logo;
reply->close();
if (downloadSuccess == true) {
if (downloadSuccess == true&& reply->error() == QNetworkReply::NoError) {
*buffer = reply->readAll();
logo = new ;
logo->loadFromData(*buffer);
QFile logo(QApplication::applicationDirPath() + DEFAULT_LOGO);
if (logo.open(QIODevice::WriteOnly)) {
logo.write(*buffer);
logo.close();
}
buffer->clear();
}else
{
getLogoFromLocal();
reply->close();
}
delete manager;
manager = nullptr;
}*/
}
void NavBar::storeToBuffer() {
buffer = new QByteArray;
@ -178,31 +178,24 @@ void NavBar::cancelDownload() {
downloadSuccess = false;
}
/*void NavBar::getLogoFromLocal() {
QString dir = QApplication::applicationDirPath();
QFile file(dir + DEFAULT_FILE);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
QMessageBox::warning(nullptr, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("无法打开配置文件"));
exit(1);
void NavBar::refresh(int state)
{
SQLiteHelper sqlite_helper;
buttonStructs.clear();
sqlite_helper.get_software(&buttonStructs, background_color,text_color,text_cover_color);
for(auto button:buttons)
{
layout_right->removeWidget(button);
delete button;
buttons.removeOne(button);
}
buffer->clear();
*buffer = file.readAll();
file.close();
QJsonDocument *qJsonDocument = new QJsonDocument;
*qJsonDocument = QJsonDocument::fromJson(*buffer);
QJsonObject *obj_root = new QJsonObject;
if (qJsonDocument->isObject()) {
*obj_root = qJsonDocument->object();
delete qJsonDocument;
QString logo_path = obj_root->value("basic").toObject().value("logo").toString();
logo = new QPixmap(logo_path);
QJsonArray *array = new QJsonArray;
for (auto buttonStruct : buttonStructs) {
MyButton* myButton = new MyButton(buttonStruct, height(), height(), &buttons, this);
myButton->setMaximumHeight(parent->height() / 8);
layout_right->addWidget(myButton);
//myButton->show();
connect(myButton, &MyButton::clicked1, mainWindowLayout, &MainWindowLayout::clickButton);
buttons << myButton;
}
else {
QMessageBox::warning(nullptr, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("配置文件损坏"));
delete obj_root;
exit(1);
}
delete obj_root;
}*/
emit application_manager->refresh();//在这里refresh避免因为refresh导致信号和槽断开
}

View File

@ -1,4 +1,4 @@
//
//
// Created by HW on 2023/07/26.
//
@ -28,6 +28,8 @@ class NavBar : public QWidget {
Q_OBJECT
signals:
void firstUrl(QString url);
public slots:
void refresh(int state);
public:
NavBar(MainScreen *mainScreen,QWidget *parent = nullptr);
@ -37,6 +39,8 @@ protected:
void resizeEvent(QResizeEvent *event) override;
void getLogoFromInternet(ConfigResponse* configResponse);
private:
Ui::NavBar *ui;
@ -46,13 +50,13 @@ private:
QByteArray *buffer;
int width2;
int height2;
QWidget* parent;
QNetworkAccessManager *manager;
QNetworkReply *reply;
QEventLoop eventLoop;
QPixmap *logo;
QLabel *logo_label;
bool downloadSuccess=true;
//void getLogoFromInternet(ConfigResponse *configResponse);
//void getLogoFromLocal();
MainScreen *mainScreen;
QHBoxLayout *layout_left;

View File

@ -1,4 +1,4 @@
//
//
// Created by HW on 2023/07/27.
//
@ -31,11 +31,14 @@
#pragma comment(lib, "Qt5Network.lib")
#endif
#pragma comment(lib,"comsuppw.lib")
//读取注册表获取MachineUUID
QString background_color;
QString text_color;
QString text_cover_color;
//读取注册表获取MachineUUID
bool IsWin11AndLater()
{
//Windows 10 从内部版本 10240 开始,以内部版本 19044 结束。Windows 11 从内部版本 22000 开始,那么:
//Windows 10 从内部版本 10240 开始,以内部版本 19044 结束。Windows 11 从内部版本 22000 开始,那么:
//Environment.OSVersion.Version.Build >= 22000;
NTSTATUS(WINAPI * RtlGetVersion)(LPOSVERSIONINFOEXW);
OSVERSIONINFOEXW osInfo;
@ -54,40 +57,40 @@ RequestBodyBase::RequestBodyBase(){
wchar_t unix_time[65]={0};
wsprintf(unix_time,L"%ld",std::time(0));
QString request_id=QString::fromWCharArray(unix_time);
//打开配置文件
//打开配置文件
QString dir=QApplication::applicationDirPath();
QFile *infFile=new QFile(dir+"/config/information.kmd");
if(!infFile->open(QIODevice::ReadOnly|QIODevice::Text)){
QMessageBox::critical(nullptr,QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("无法打开配置文件"));
QMessageBox::critical(nullptr,QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("无法打开配置文件"));
delete infFile;
exit_manager.exit(1);
}
//读取配置文件
//读取配置文件
QByteArray bytes;
bytes=infFile->readAll();
infFile->close();
delete infFile;
//转化为json
//转化为json
qJsonDocument=QJsonDocument::fromJson(bytes);
if(qJsonDocument.isObject()){
//读取数据,写入对应字段
//读取数据,写入对应字段
QJsonObject obj_root=qJsonDocument.object();
if(obj_root.value("product")==QJsonValue::Undefined){
QMessageBox::critical(nullptr, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("配置文件损坏"));
QMessageBox::critical(nullptr, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("配置文件损坏"));
exit_manager.exit(1);
}
product=obj_root.value("product").toString();
if(obj_root.value("partner_id")==QJsonValue::Undefined){
QMessageBox::critical(nullptr , QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("配置文件损坏"));
QMessageBox::critical(nullptr , QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("配置文件损坏"));
exit_manager.exit(1);
}
parter_id=obj_root.value("partner_id").toString();
}else{
//处理错误
QMessageBox::critical(nullptr, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("配置文件损坏"));
//处理错误
QMessageBox::critical(nullptr, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("配置文件损坏"));
exit_manager.exit(1);
}
//获取操作系统版本
//获取操作系统版本
this->os="Windows";
OSVERSIONINFOEXW os;
os.dwOSVersionInfoSize=sizeof(os);
@ -96,12 +99,12 @@ RequestBodyBase::RequestBodyBase(){
*(FARPROC*)&RtlGetVersion = GetProcAddress(GetModuleHandleA("ntdll"), "RtlGetVersion");
if (RtlGetVersion != nullptr) {
RtlGetVersion(&os);
switch (os.dwMajorVersion) {//主版本号
case 5: //不兼容Windows 2000因此5.x一定是Windows XP
switch (os.dwMajorVersion) {//主版本号
case 5: //不兼容Windows 2000因此5.x一定是Windows XP
os_version = "Windows XP";
break;
case 6:
switch (os.dwMinorVersion) { //次版本号
switch (os.dwMinorVersion) { //次版本号
case 0:
os_version = "Windows Vista or Windows Server 2008";
break;
@ -117,7 +120,7 @@ RequestBodyBase::RequestBodyBase(){
default:
os_version = "Unknown";
}
case 10: //这几个系统都是10.0
case 10: //这几个系统都是10.0
if (IsWin11AndLater()) {
os_version = "Windows 11 or Windows Server 2022";
}
@ -135,10 +138,10 @@ RequestBodyBase::RequestBodyBase(){
this->release = RELEASE;
this->version = VERSION;
//读取MachineGUID并取MD5作为device_id
//读取MachineGUID并取MD5作为device_id
QByteArray hash = QCryptographicHash::hash(getMachineGUID().toUtf8(), QCryptographicHash::Md5);
device_id = hash.toHex();
//加入json序列
//加入json序列
QJsonValue value = device_id;
QJsonObject obj_root = qJsonDocument.object();
obj_root.insert("device_id", value);
@ -156,16 +159,15 @@ RequestBodyBase::RequestBodyBase(){
QJsonValue sign_json(sign);
QJsonValue requestId_json=QJsonValue(request_id);
obj_root=qJsonDocument.object();
//插入request_id
//插入request_id
obj_root.insert(QString::fromLocal8Bit("request_id"),requestId_json);
obj_root.insert(QString::fromLocal8Bit("os"), os_json);
obj_root.insert(QString::fromLocal8Bit("os_version"), os_version_json);
obj_root.insert(QString::fromLocal8Bit("sign"), sign_json);
qJsonDocument.setObject(obj_root);
url_param = "?";
url_param += "product=";
url_param = "&product=";
url_param += product;
url_param += "&parter_id=";
url_param += "&partner_id=";
url_param += parter_id;
url_param += "&os=";
url_param += this->os;
@ -188,29 +190,26 @@ RequestBodyBase::RequestBodyBase(){
void ConfigRequest::sendRequest(ConfigResponse *configResponse) {
timer = new QTimer(this);
if(agree)
{
QJsonObject obj_root = qJsonDocument.object();
obj_root.insert("autostart", autostart);
qJsonDocument.setObject(obj_root);
}
QNetworkAccessManager *httpMgr = new QNetworkAccessManager();
QNetworkRequest requestInfo;
//HTTP请求
//请求头
//HTTP请求
//请求头
QString url = CONFIG_URL;
requestInfo.setUrl(QUrl(CONFIG_URL));
requestInfo.setHeader(QNetworkRequest::ContentTypeHeader,QVariant("application/json"));
//保存响应的变量
//保存响应的变量
reply = httpMgr->post(requestInfo,qJsonDocument.toJson());
qDebug() << qJsonDocument.toJson();
//开启一个循环,直到超时或者获取到数据为止
//开启一个循环,直到超时或者获取到数据为止
connect(reply,&QNetworkReply::finished, &eventLoop, &QEventLoop::quit);
//设置定时器防止超时
//设置定时器防止超时
connect(timer,&QTimer::timeout,this,&ConfigRequest::cancelDownload);
timer->start(5000);
//启动循环
//启动循环
eventLoop.exec();
timer->stop();
//delete httpMgr;
@ -219,11 +218,11 @@ void ConfigRequest::sendRequest(ConfigResponse *configResponse) {
configResponse->succeed = false;
//memset(configResponse,0,sizeof(*configResponse));
auto error = reply->error();
//如果没有错误
//如果没有错误
if(reply->error() == QNetworkReply::NoError) {
buffer = reply->readAll();
}else{
//如果有错误
//如果有错误
configResponse->succeed=false;
//delete reply;
delete timer;
@ -232,13 +231,20 @@ void ConfigRequest::sendRequest(ConfigResponse *configResponse) {
}
//qDebug() << result.toJson();
result = QJsonDocument::fromJson(buffer);
//如果数据完整
//如果数据完整
if(result.isObject()){
QJsonObject obj_root=result.object();
QJsonArray array;
array = obj_root.value("data").toObject().value("menu").toArray();
QJsonObject obj_basic = obj_root.value("data").toObject().value("basic").toObject();
QJsonObject obj_data = obj_root.value("data").toObject();
if(!obj_data.value("basic").isObject())
{
configResponse->succeed=false;
delete timer;
return;
}
QJsonObject obj_basic=obj_data.value("basic").toObject();
configResponse->basic.logo_url = obj_basic.value("logo").toString();
configResponse->basic.device_id = obj_basic.value("device_id").toString();
configResponse->basic.dev_id = obj_basic.value("dev_id").toString();
@ -246,18 +252,29 @@ void ConfigRequest::sendRequest(ConfigResponse *configResponse) {
configResponse->basic.backgroud_color = obj_basic.value("backgroud_color").toString();
configResponse->basic.title_color = obj_basic.value("title_color").toString();
configResponse->basic.title_cover_color = obj_basic.value("title_cover_color").toString();
auto i=0;
for(auto value:array){
QJsonObject object=value.toObject();
Button button;
button.img=object.value("img").toString();
button.orig_name= object.value("orig_name").toString();
// button.img_cover=object.value("img_cover").toString();
button.title=object.value("title").toString();
button.categroy_id = object.value("category_id").toString();
button.img = object.value("logo").toString();
button.png = object.value("img").toString();
button.img_name = object.value("img_name").toString();
button.name = object.value("name").toString();
button.type = object.value("type").toString();
button.sort = object.value("sort").toInt();
button.status = object.value("status").toInt();
button.is_navbar = object.value("is_navbar").toBool();
button.is_elite = object.value("is_elite").toBool();
button.orig_name = object.value("orig_name").toString();
button.categroy_id = object.value("categroy_id").toString();
button.op = object.value("op").toString();
button.func=object.value("func").toString();
button.url=object.value("url").toString();
button.func = object.value("func").toString();
button.url = object.value("url").toString();
button.dev = object.value("dev").toString();
button.locked = object.value("locked").toBool();
button.is_delete = object.value("is_delete").toBool();
button.version = object.value("version").toString();
configResponse->buttons << button;
i++;
}
@ -269,7 +286,7 @@ void ConfigRequest::sendRequest(ConfigResponse *configResponse) {
file.close();
}
}else{
//数据不完整
//数据不完整
configResponse->succeed=false;
//delete reply;
delete timer;
@ -288,18 +305,18 @@ void RequestBodyBase::sendRequest() {
timer = new QTimer(this);
QNetworkAccessManager *httpMgr = new QNetworkAccessManager();
QNetworkRequest requestInfo;
//HTTP请求
//请求头
//HTTP请求
//请求头
requestInfo.setUrl(QUrl(OP_URL));
requestInfo.setHeader(QNetworkRequest::ContentTypeHeader,QVariant("application/json"));
//保存响应的变量
//保存响应的变量
reply = httpMgr->post(requestInfo,qJsonDocument.toJson());
//开启一个循环,直到超时或者获取到数据为止
//开启一个循环,直到超时或者获取到数据为止
connect(reply,&QNetworkReply::finished, this, &RequestBodyBase::cancelDownload);
//设置定时器防止超时
//设置定时器防止超时
connect(timer,&QTimer::timeout,&eventLoop,&QEventLoop::quit);
timer->start(5000);
//启动循环
//启动循环
eventLoop.exec();
delete timer;
delete httpMgr;
@ -308,69 +325,22 @@ void RequestBodyBase::sendRequest() {
DeviceRequest::DeviceRequest() : RequestBodyBase() {
//CPU
QString cpu = QSysInfo::currentCpuArchitecture();
//内存大小
//内存大小
MEMORYSTATUSEX status;
status.dwLength = sizeof(status);
GlobalMemoryStatusEx(&status);
int ram = status.ullTotalPhys / 1024 / 1024;
//硬盘大小
//硬盘大小
QStorageInfo storage = QStorageInfo::root();
int disk = storage.bytesTotal() / static_cast<qulonglong>(1024 * 1024 * 1024);
//显卡型号
QStringList gpus;
BOOL success;
DWORD deviceIndex = 0;
DISPLAY_DEVICE displayDevice;
displayDevice.cb = sizeof(displayDevice);
while (EnumDisplayDevices(NULL, deviceIndex, &displayDevice, 0)) {
WCHAR valueName[128];
DWORD valueSize;
DWORD valueType;
BYTE valueData[MAX_PATH];
HKEY hKey;
WCHAR keyName[128];
wsprintf(keyName, L"SYSTEM\\CurrentControlSet\\Control\\Video\\%s\\HardwareInformation",
displayDevice.DeviceID);
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyName, 0, KEY_READ, &hKey) == ERROR_SUCCESS) {
valueSize = sizeof(valueData);
wsprintf(valueName, L"HardwareInformation.AdapterString");
if (RegQueryValueEx(hKey, valueName, NULL, &valueType, valueData, &valueSize) == ERROR_SUCCESS) {
Q_ASSERT(valueType == REG_SZ);
QString adapterString = QString::fromWCharArray((wchar_t *) valueData, valueSize / sizeof(wchar_t) - 1);
gpus.append(adapterString);
}
RegCloseKey(hKey);
}
deviceIndex++;
displayDevice.cb = sizeof(displayDevice);
}
//主板型号
QString motherboard = QSysInfo::prettyProductName();
//WMI获取网卡型号
HRESULT hr = CoInitializeEx(0, COINIT_MULTITHREADED);
//WMI获取网卡型号
HRESULT hr = CoInitializeEx(0, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
if (FAILED(hr)) {
std::cerr << "Failed to initialize COM library." << std::endl;
return;
}
QStringList netCards;
hr = CoInitializeSecurity(
NULL,
-1,
NULL,
NULL,
RPC_C_AUTHN_LEVEL_DEFAULT,
RPC_C_IMP_LEVEL_IMPERSONATE,
NULL,
EOAC_NONE,
NULL
);
if (FAILED(hr)) {
std::cerr << "Failed to initialize security." << std::endl;
CoUninitialize();
return;
}
IWbemLocator* pLoc = NULL;
hr = CoCreateInstance(
@ -425,7 +395,7 @@ DeviceRequest::DeviceRequest() : RequestBodyBase() {
IEnumWbemClassObject* pEnumerator = NULL;
hr = pSvc->ExecQuery(
_bstr_t("WQL"),
_bstr_t("SELECT * FROM Win32_NetworkAdapter WHERE PhysicalAdapter = TRUE AND NetConnectionStatus = 3"),
_bstr_t("SELECT * FROM Win32_NetworkAdapter WHERE PhysicalAdapter = TRUE"),
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
NULL,
&pEnumerator
@ -455,7 +425,79 @@ DeviceRequest::DeviceRequest() : RequestBodyBase() {
pClassObj->Release();
}
//WMI获取声卡型号
pEnumerator->Release();
pEnumerator = nullptr;
// 获取 CPU 信息
hr = pSvc->ExecQuery(bstr_t("WQL"), bstr_t("SELECT * FROM Win32_Processor"), WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &pEnumerator);
IWbemClassObject* pclsObj = NULL;
uReturn = 0;
QString cpu;
while (pEnumerator) {
HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn);
if (0 == uReturn) break;
VARIANT vtProp;
hr = pclsObj->Get(L"Name", 0, &vtProp, 0, 0);
if (SUCCEEDED(hr)) {
cpu=QString::fromWCharArray(vtProp.bstrVal);
VariantClear(&vtProp);
}
pclsObj->Release();
}
// 获取主板信息
QString motherboard;
hr = pSvc->ExecQuery(bstr_t("WQL"), bstr_t("SELECT * FROM Win32_BaseBoard"), WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &pEnumerator);
while (pEnumerator) {
HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn);
if (0 == uReturn) break;
VARIANT vtProp;
hr = pclsObj->Get(L"Product", 0, &vtProp, 0, 0);
if (SUCCEEDED(hr)) {
motherboard=QString::fromWCharArray(vtProp.bstrVal);
VariantClear(&vtProp);
}
pclsObj->Release();
}
pEnumerator->Release();
pEnumerator=nullptr;
//WMI获取显卡型号
hr = pSvc->ExecQuery(
bstr_t("WQL"),
bstr_t("SELECT * FROM Win32_VideoController"),
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
NULL,
&pEnumerator);
if (FAILED(hr))
{
std::cerr << "Query failed." << std::endl;
pSvc->Release();
pLoc->Release();
CoUninitialize();
return;
}
QStringList graphicsCards;
pclsObj->Release();
pclsObj = NULL;
uReturn = 0;
while (pEnumerator)
{
HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn);
if (0 == uReturn) break;
VARIANT vtProp;
hr = pclsObj->Get(L"Name", 0, &vtProp, 0, 0);
if (SUCCEEDED(hr))
{
graphicsCards<< QString::fromWCharArray(vtProp.bstrVal);
VariantClear(&vtProp);
}
pclsObj->Release();
}
//WMI获取声卡型号
hr = pSvc->ExecQuery(
_bstr_t("WQL"),
_bstr_t("SELECT * FROM Win32_SoundDevice"),
@ -515,7 +557,7 @@ DeviceRequest::DeviceRequest() : RequestBodyBase() {
hr = pClassObj->Get(L"Manufacturer", 0, &vtProp, 0, 0);
if (SUCCEEDED(hr))
{
std::wcout << "Manufacturer: " << vtProp.bstrVal << std::endl;
RAMModel<<QString::fromWCharArray(vtProp.bstrVal);
VariantClear(&vtProp);
}
@ -531,18 +573,41 @@ DeviceRequest::DeviceRequest() : RequestBodyBase() {
pSvc->Release();
pLoc->Release();
CoUninitialize();
DISPLAY_DEVICE d = { sizeof(DISPLAY_DEVICE) };
::EnumDisplayDevices(NULL, 0, &d, 0);
QString monitor=QString::fromWCharArray(d.DeviceString, wcslen(d.DeviceString));
//发送
//构造JSON
DISPLAY_DEVICE dd;
ZeroMemory(&dd, sizeof(dd));
dd.cb = sizeof(dd);
int deviceIndex = 0;
QStringList monitors;
// 枚举显卡设备
while (EnumDisplayDevices(0, deviceIndex, &dd, 0))
{
DISPLAY_DEVICE monitor;
ZeroMemory(&monitor, sizeof(monitor));
monitor.cb = sizeof(monitor);
int monitorIndex = 0;
// 对每个显卡枚举其连接的显示器
while (EnumDisplayDevices(dd.DeviceName, monitorIndex, &monitor, 0))
{
// 打印显示器型号
monitors<<QString::fromWCharArray(monitor.DeviceString);
monitorIndex++;
}
deviceIndex++;
}
//发送
//构造JSON
QJsonDocument *device=new QJsonDocument;
QJsonObject *object=new QJsonObject;
object->insert("CPU",QJsonValue(cpu));
object->insert("RAM",QJsonValue(ram));
object->insert("Hard_Disk",QJsonValue(disk));
QJsonArray *gpu_array=new QJsonArray;
for(auto gpu:gpus) {
for(auto gpu:graphicsCards)
{
gpu_array->append(gpu);
}
object->insert("GPU",*gpu_array);
@ -566,7 +631,13 @@ DeviceRequest::DeviceRequest() : RequestBodyBase() {
}
object->insert("Audio_Card",*audioCards_json);
delete audioCards_json;
object->insert("Monitor",monitor);
QJsonArray *monitors_json=new QJsonArray;
for(auto monitor:monitors)
{
monitors_json->append(monitor);
}
object->insert("Monitor",*monitors_json);
delete monitors_json;
device->setObject(*object);
delete object;
QJsonObject obj_root=qJsonDocument.object();
@ -576,19 +647,22 @@ DeviceRequest::DeviceRequest() : RequestBodyBase() {
timer = new QTimer(this);
QNetworkAccessManager *httpMgr = new QNetworkAccessManager();
QNetworkRequest requestInfo;
//HTTP请求
//请求头
//HTTP请求
//请求头
requestInfo.setUrl(QUrl(DEVICE_URL));
requestInfo.setHeader(QNetworkRequest::ContentTypeHeader,QVariant("application/json"));
//保存响应的变量
//保存响应的变量
qDebug()<<qJsonDocument.toJson();
reply = httpMgr->post(requestInfo,qJsonDocument.toJson());
//开启一个循环,直到超时或者获取到数据为止
//开启一个循环,直到超时或者获取到数据为止
connect(reply,&QNetworkReply::finished, &eventLoop, &QEventLoop::quit);
//设置定时器防止超时
//设置定时器防止超时
connect(timer,&QTimer::timeout,this,&DeviceRequest::cancelDownload);
timer->start(5000);
//启动循环
//启动循环
eventLoop.exec();
qDebug()<<reply->error();
qDebug()<<reply->readAll();
delete httpMgr;
}
bool SoftwareRequest::sendRequest(QHash<QString,QString>&startMenu, QHash<QString, Record> *records, QJsonArray &software_exists)
@ -596,8 +670,8 @@ bool SoftwareRequest::sendRequest(QHash<QString,QString>&startMenu, QHash<QStrin
timer = new QTimer(this);
QNetworkAccessManager* httpMgr = new QNetworkAccessManager();
QNetworkRequest requestInfo;
//HTTP请求
//请求头
//HTTP请求
//请求头
QJsonArray array;
for(auto record : *records)
{
@ -618,40 +692,41 @@ bool SoftwareRequest::sendRequest(QHash<QString,QString>&startMenu, QHash<QStrin
QJsonObject object;
object.insert("reg", array);
object.insert("start", menu_list);
object.insert("exists", software_exists);
object.insert("app", software_exists);
obj_root.insert("data", object);
obj_root.insert("type", "update");
qJsonDocument.setObject(obj_root);
QString url = SOFTWARE_URL;
requestInfo.setUrl(url);
requestInfo.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/json"));
//保存响应的变量
//保存响应的变量
reply = httpMgr->post(requestInfo, qJsonDocument.toJson());
qDebug() << qJsonDocument.toJson();
//开启一个循环,直到超时或者获取到数据为止
//开启一个循环,直到超时或者获取到数据为止
connect(reply, &QNetworkReply::finished, &eventLoop, &QEventLoop::quit);
//设置定时器防止超时
//设置定时器防止超时
connect(timer, &QTimer::timeout, this, &SoftwareRequest::cancelDownload);
timer->start(5000);
//启动循环
//启动循环
eventLoop.exec();
timer->stop();
delete timer;
QJsonDocument result;
// auto error = reply->error();
//如果没有错误
//如果没有错误
qDebug() << reply->error();
auto result2=reply->readAll();
if (reply->error() == QNetworkReply::NoError) {
result = QJsonDocument::fromJson(reply->readAll());
result = QJsonDocument::fromJson(result2);
}
else {
//如果有错误
//如果有错误
delete httpMgr;
return false;
}
//qDebug() << result.toJson();
//如果数据完整
records->clear();
//如果数据完整
if (result.isObject()) {
QJsonObject obj_root2 = result.object();
QJsonArray array = obj_root2.value("data").toObject().value("menu").toArray();
@ -687,21 +762,30 @@ bool SoftwareRequest::sendRequest(QHash<QString,QString>&startMenu, QHash<QStrin
file.close();
}
}
(*records)[orig_name].logo = dir + orig_name + ".svg";
(*records)[orig_name].name = object.value("name").toString();
(*records)[orig_name].locked = object.value("locked").toBool();
(*records)[orig_name].url = object.value("url").toString();
(*records)[orig_name].path = object.value("path").toString();
if ((*records)[orig_name].path.isEmpty())
{
delete httpMgr;
return false;
}
Record record;
record.orig_name = orig_name;
record.path = object.value("path").toString();
record.img = dir + orig_name + ".svg";
record.name = object.value("name").toString();
record.version = object.value("version").toString();
record.app_id=object.value("app_id").toString();
record.locked=object.value("locked").toBool();
record.type=object.value("type").toString();
record.category_id=object.value("category_id").toString();
record.status=object.value("status").toBool();
record.op=object.value("op").toString();
record.func=object.value("func").toString();
record.initial_position=object.value("initial_position").toString();
record.url=object.value("url").toString();
record.logo=object.value("logo").toString();
record.img=object.value("img").toString();
record.is_navbar=object.value("is_navbar").toBool();
record.is_elite=object.value("is_elite").toBool();
records->insert(orig_name, record);
}
}
else {
//数据不完整
//数据不完整
//delete reply;
delete httpMgr;
return false;
@ -718,22 +802,24 @@ QString OpenWeChatRequest::sendRequest(bool notuse)
timer = new QTimer(this);
QNetworkAccessManager* httpMgr = new QNetworkAccessManager();
QNetworkRequest requestInfo;
//HTTP请求
//请求头
//HTTP请求
//请求头
requestInfo.setUrl(QUrl(WECHAT_URL));
requestInfo.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/json"));
//保存响应的变量
//保存响应的变量
reply = httpMgr->post(requestInfo, qJsonDocument.toJson());
//开启一个循环,直到超时或者获取到数据为止
//开启一个循环,直到超时或者获取到数据为止
connect(reply, &QNetworkReply::finished, this, &OpenWeChatRequest::cancelDownload);
//设置定时器防止超时
//设置定时器防止超时
connect(timer, &QTimer::timeout, &eventLoop, &QEventLoop::quit);
timer->start(5000);
//启动循环
//启动循环
eventLoop.exec();
timer->stop();
qDebug() << reply->error();
QByteArray buffer = reply->readAll();
QJsonDocument reply_json = QJsonDocument::fromJson(buffer);
if(!reply_json.isObject())
{
delete timer;
@ -743,7 +829,6 @@ QString OpenWeChatRequest::sendRequest(bool notuse)
}
delete timer;
delete httpMgr;
delete reply;
return reply_json.object().value("msg").toString();
}
@ -755,18 +840,18 @@ void OpRequest::sendRequest()
qJsonDocument.setObject(object);
QNetworkAccessManager* httpMgr = new QNetworkAccessManager();
QNetworkRequest requestInfo;
//HTTP请求
//请求头
//HTTP请求
//请求头
requestInfo.setUrl(QUrl(OP_URL));
requestInfo.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/json"));
//保存响应的变量
//保存响应的变量
reply = httpMgr->post(requestInfo, qJsonDocument.toJson());
//开启一个循环,直到超时或者获取到数据为止
//开启一个循环,直到超时或者获取到数据为止
connect(reply, &QNetworkReply::finished, this, &OpRequest::cancelDownload);
//设置定时器防止超时
//设置定时器防止超时
connect(timer, &QTimer::timeout, &eventLoop, &QEventLoop::quit);
timer->start(5000);
//启动循环
//启动循环
eventLoop.exec();
timer->stop();
delete timer;

View File

@ -1,4 +1,4 @@
//
//
// Created by HW on 2023/07/27.
//
@ -17,13 +17,24 @@
typedef struct {
QString img;
QString img_cover;
QString title;
QString png;
QString img_name;
QString name;
QString type;
int sort;
int status;
bool is_navbar;
bool is_elite;
QString orig_name;
QString categroy_id;
QString op;
QString func;
QString url;
QString dev;
bool locked;
bool is_delete;
QString version;
} Button;
struct ConfigResponse {
bool succeed;
@ -126,6 +137,13 @@ class OpenWeChatRequest:public RequestBodyBase
{
public:
OpenWeChatRequest():RequestBodyBase(){}
QString sendRequest(bool notuse=false/*为了构成函数重载,凑数的*/);
QString sendRequest(bool notuse=false/*为了构成函数重载,凑数的*/);
};
class OpenAppRequest:public RequestBodyBase
{
public:
OpenAppRequest():RequestBodyBase(){}
QString sendRequest(QString app_name);
};
#endif //OFFICEASSISTANT_NETIO_H

View File

@ -1,8 +1,82 @@
#include "qminiblink.h"
#include "qminiblink.h"
#include <functional>
#include <QThread>
#include <QDebug>
#include <thread>
#pragma comment (lib,"Comctl32.lib")
struct DownInfo {
std::string url;
size_t recvSize;
size_t allSize;
};
void MB_CALL_TYPE onNetJobDataRecvCallback(void* ptr, mbNetJob job, const char* data, int length)
{
DownInfo* info = (DownInfo*)ptr;
info->recvSize += length;
char* output = (char*)malloc(0x1000);
sprintf_s(output, 0x990, "onNetJobDataRecvCallback: %d %d, %f\n", info->allSize, info->recvSize, info->recvSize / (info->allSize + 1.0));
OutputDebugStringA(output);
free(output);
}
unsigned int __stdcall msgBoxThread(void* param)
{
std::function<void(void)>* callback = (std::function<void(void)>*)param;
(*callback)();
delete callback;
return 0;
}
void MB_CALL_TYPE onNetJobDataFinishCallback(void* ptr, mbNetJob job, mbLoadingResult result)
{
OutputDebugStringA("onNetJobDataFinishCallback\n");
std::wstring* title = new std::wstring;
*title += L" 下载完成:";
std::function<void(void)>* callback = new std::function<void(void)>([title, result] {
LPCWSTR lpCaption = (result == MB_LOADING_SUCCEEDED ? L"下载成功" : L"下载失败");
MessageBoxW(nullptr, title->c_str(), lpCaption, MB_OK);
delete title;
});
unsigned int threadId = 0; // 为了不卡blink线程messagbox放到另外个线程弹出
std::thread msgBox(msgBoxThread, callback);
msgBox.detach();
}
static mbDownloadOpt MB_CALL_TYPE onDownloadCallback(mbWebView webView,
void* param,
size_t expectedContentLength,
const char* url,
const char* mime,
const char* disposition,
mbNetJob job,
mbNetJobDataBind* dataBind)
{
char* output = (char*)malloc(0x8000);
sprintf_s(output, 0x7990, "onDownloadCallback: %d %s\n", expectedContentLength, url);
OutputDebugStringA(output);
free(output);
DownInfo* info = new DownInfo();
info->url = url;
info->recvSize = 0;
info->allSize = expectedContentLength;
mbDownloadBind bind = { 0 };
bind.param = info;
bind.recvCallback = onNetJobDataRecvCallback;
bind.finishCallback = onNetJobDataFinishCallback;
bind.saveNameCallback = nullptr;
return mbPopupDialogAndDownload(webView, nullptr, expectedContentLength, url, mime, disposition, job, dataBind, &bind);
//return mbDownloadByPath(webView, nullptr, L"P:\\", expectedContentLength, url, mime, disposition, job, dataBind, &bind);
}
QMiniBlink::QMiniBlink(QWidget *parent)
: QWidget(parent){
@ -26,6 +100,7 @@ void QMiniBlink::init() {
mbMoveWindow(this->mbView, 0, 0, rect.right - rect.left, rect.bottom - rect.top);
//while(this->firstUrl.isEmpty()){}
//mbLoadURL(this->mbView, this->firstUrl.toStdString().c_str());
mbOnDownloadInBlinkThread(mbView,onDownloadCallback, nullptr);
SetWindowSubclass((HWND)this->winId(), subClassProc, 0, (DWORD_PTR)this);
//mbRunMessageLoop();
}

View File

@ -6,13 +6,52 @@
<rect>
<x>0</x>
<y>0</y>
<width>1142</width>
<height>806</height>
<width>600</width>
<height>400</height>
</rect>
</property>
<property name="windowTitle">
<string>QMiniBlink</string>
</property>
<widget class="QCheckBox" name="checkBox">
<property name="geometry">
<rect>
<x>110</x>
<y>130</y>
<width>401</width>
<height>61</height>
</rect>
</property>
<property name="text">
<string>我同意加入用户体验改善计划</string>
</property>
</widget>
<widget class="QPushButton" name="detail">
<property name="geometry">
<rect>
<x>70</x>
<y>280</y>
<width>150</width>
<height>46</height>
</rect>
</property>
<property name="text">
<string>查看详情</string>
</property>
</widget>
<widget class="QPushButton" name="submit">
<property name="geometry">
<rect>
<x>370</x>
<y>280</y>
<width>150</width>
<height>46</height>
</rect>
</property>
<property name="text">
<string>确定</string>
</property>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlError>
#include <QtSql/QSqlQuery>
@ -14,11 +14,15 @@ class SoftwareRequest;
typedef struct tagRecord{
int id;
int sort;
QString initial_position;
QString app_id;
bool locked;
bool is_navbar;
bool is_elite;
QString type;
QString category_id;
QString logo;
QString img;
QString name;
QString orig_name;
QString version;
@ -47,15 +51,20 @@ class SQLiteHelper : public QObject
public:
SQLiteHelper(QObject *parent = nullptr);
bool update_software();
bool insert_software(QString name, QString orig_name, QString path, QString sort, bool* categories);
bool insert_software(QString name, QString orig_name, QString path, QString sort, bool* categories, QString logo, QString img,QString type,bool locked,QString op,QString func,QString url,bool is_navbar,bool is_elite,QString dev);
int insert_software(QString name, QString orig_name, QString path, QString sort, bool* categories);
bool edit_software(QString name, QString orig_name, QString path, QString sort, bool* categories,QString type="");
bool get_software(QList<ButtonStruct>* buttons, ConfigResponse* config_response);
bool get_software(QList<ButtonStruct>* button_structs,QString background_color , QString title_color, QString title_cover_color);
bool update_app();
bool get_buttons(QList<ButtonStruct> &buttons);
bool get_category(QList<Categrory>& categrories, bool is_edit,bool all=false);
bool set_category(QList<Categrory>& categrories);
bool get_all_software(QList<Record> &softwares,int category);
bool get_a_software(QString orig_name, Record2 *record);
bool update_total();//警告:这个函数必须用于事务中
bool use_software(QString orig_name);
QSqlDatabase db;
~SQLiteHelper();
@ -64,6 +73,8 @@ private:
QNetworkReply* reply;
QEventLoop eventLoop;
bool downloadSuccess;
bool delete_software(QString orig_name);
bool execute_query(QString sql, QList<Record>& softwares);
void cancelDownload();
};

View File

@ -0,0 +1,35 @@
#include "userimprove.h"
#include "globalvariables.h"
UserImprove::UserImprove(QWidget* parent)
: QDialog(parent)
{
ui.setupUi(this);
connect(ui.submit, &QPushButton::clicked, this, &UserImprove::submit);
connect(ui.detail, &QPushButton::clicked, this, &UserImprove::showDetail);
setFixedSize(600, 400);
}
UserImprove::~UserImprove()
{
}
void UserImprove::submit()
{
if (ui.checkBox->checkState() == Qt::Checked)
{
agree = true;
}
else
{
agree = false;
}
close();
}
void UserImprove::showDetail()
{
QString path = QApplication::applicationDirPath();
QString license = path + "/detail.txt";
license.replace("/", "\\");
ShellExecute(GetDesktopWindow(), L"open", L"notepad.exe", license.toStdWString().c_str(), nullptr, SW_SHOW);
}

View File

@ -0,0 +1,18 @@
#pragma once
#include <QDialog>
#include "ui_userimprove.h"
class UserImprove : public QDialog
{
Q_OBJECT
public:
UserImprove(QWidget *parent = nullptr);
~UserImprove();
private slots:
void submit();
void showDetail();
private:
Ui::UserImproveClass ui;
};

View File

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>UserImproveClass</class>
<widget class="QDialog" name="UserImproveClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>400</height>
</rect>
</property>
<property name="windowTitle">
<string>用户体验改善计划</string>
</property>
<widget class="QPushButton" name="detail">
<property name="geometry">
<rect>
<x>80</x>
<y>310</y>
<width>150</width>
<height>46</height>
</rect>
</property>
<property name="text">
<string>查看详情</string>
</property>
</widget>
<widget class="QPushButton" name="submit">
<property name="geometry">
<rect>
<x>330</x>
<y>310</y>
<width>150</width>
<height>46</height>
</rect>
</property>
<property name="text">
<string>确定</string>
</property>
</widget>
<widget class="QCheckBox" name="checkBox">
<property name="geometry">
<rect>
<x>110</x>
<y>170</y>
<width>371</width>
<height>28</height>
</rect>
</property>
<property name="text">
<string>我同意加入用户体验改善计划</string>
</property>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

3
config/config.kmd Normal file
View File

@ -0,0 +1,3 @@
{
"agree": true
}

Binary file not shown.

BIN
images/app.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@ -1 +0,0 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1691497575694" class="icon" viewBox="0 0 1243 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4021" xmlns:xlink="http://www.w3.org/1999/xlink" width="242.7734375" height="200"><path d="M839.68 323.584c13.312 0 26.624 1.243 39.863 2.414-35.62-166.62-214.309-291.109-417.865-291.109-227.62 0.805-414.135 155.868-414.135 352.768 0 113.518 62.171 207.14 165.449 279.625l-41.691 124.343 144.969-72.411c51.931 10.24 93.623 20.48 144.896 20.48 13.312 0 25.965-0.585 38.62-1.756a318.61 318.61 0 0 1-12.655-87.04c0.586-180.516 155.795-327.24 352.622-327.24zM616.887 211.383c31.451 0 51.931 20.48 51.931 51.931 0 30.72-20.48 51.932-51.931 51.932-30.793 0-62.172-20.553-62.172-51.932 0-31.451 31.379-51.931 62.172-51.931zM327.022 315.246c-30.72 0-62.172-20.553-62.172-51.932 0-31.451 31.452-51.931 62.172-51.931 30.793 0 51.931 20.48 51.931 51.931 0 30.72-20.48 51.932-51.931 51.932z m890.807 331.337c0-165.45-165.45-300.69-352.11-300.69-196.828 0-352.037 135.24-352.037 300.69 0 166.034 155.21 300.763 352.037 300.763 41.106 0 82.798-10.24 124.416-20.553l113.518 62.172-31.379-103.278c83.383-63.342 145.555-146.14 145.555-239.104zM751.616 594.65c-20.48 0-41.691-20.48-41.691-41.691 0-20.48 21.211-41.691 41.691-41.691 31.451 0 51.931 20.553 51.931 41.691 0 21.211-20.48 41.691-51.931 41.691z m227.694 0c-20.553 0-41.107-20.48-41.107-41.691 0-20.48 20.48-41.691 41.107-41.691 31.378 0 51.931 20.553 51.931 41.691 0 21.211-20.553 41.691-51.931 41.691z" fill="#00CE12" p-id="4022"></path></svg>

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 7.7 KiB

BIN
images/logo_titlebar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@ -1,72 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>发生错误</title>
<meta name="robots" content="noindex,nofollow" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<link rel="shortcut icon" href="/assets/img/favicon.ico" />
<style>
* {-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;}
html,body,div,span,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,abbr,address,cite,code,del,dfn,em,img,ins,kbd,q,samp,small,strong,sub,sup,var,b,i,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,caption,article,aside,canvas,details,figcaption,figure,footer,header,hgroup,menu,nav,section,summary,time,mark,audio,video {margin:0;padding:0;border:0;outline:0;vertical-align:baseline;background:transparent;}
article,aside,details,figcaption,figure,footer,header,hgroup,nav,section {display:block;}
html {font-size:16px;line-height:24px;width:100%;height:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;overflow-y:scroll;overflow-x:hidden;}
img {vertical-align:middle;max-width:100%;height:auto;border:0;-ms-interpolation-mode:bicubic;}
body {min-height:100%;background:#f4f6f8;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:"Helvetica Neue",Helvetica,"PingFang SC","Hiragino Sans GB","Microsoft YaHei",微软雅黑,Arial,sans-serif;}
.clearfix {clear:both;zoom:1;}
.clearfix:before,.clearfix:after {content:"\0020";display:block;height:0;visibility:hidden;}
.clearfix:after {clear:both;}
body.error-page-wrapper,.error-page-wrapper.preview {background-position:center center;background-repeat:no-repeat;background-size:cover;position:relative;}
.error-page-wrapper .content-container {border-radius:2px;text-align:center;box-shadow:0 0 30px rgba(99,99,99,0.06);padding:50px;background-color:#fff;width:100%;max-width:560px;position:absolute;left:50%;top:50%;margin-top:-220px;margin-left:-280px;}
.error-page-wrapper .content-container.in {left:0px;opacity:1;}
.error-page-wrapper .head-line {transition:color .2s linear;font-size:40px;line-height:60px;letter-spacing:-1px;margin-bottom:20px;color:#777;}
.error-page-wrapper .subheader {transition:color .2s linear;font-size:32px;line-height:46px;color:#494949;}
.error-page-wrapper .hr {height:1px;background-color:#eee;width:80%;max-width:350px;margin:25px auto;}
.error-page-wrapper .context {transition:color .2s linear;font-size:16px;line-height:27px;color:#aaa;}
.error-page-wrapper .context p {margin:0;}
.error-page-wrapper .context p:nth-child(n+2) {margin-top:16px;}
.error-page-wrapper .buttons-container {margin-top:35px;overflow:hidden;}
.error-page-wrapper .buttons-container a {transition:text-indent .2s ease-out,color .2s linear,background-color .2s linear;text-indent:0px;font-size:14px;text-transform:uppercase;text-decoration:none;color:#fff;background-color:#2ecc71;border-radius:99px;padding:8px 0 8px;text-align:center;display:inline-block;overflow:hidden;position:relative;width:45%;}
.error-page-wrapper .buttons-container a:hover {text-indent:15px;}
.error-page-wrapper .buttons-container a:nth-child(1) {float:left;}
.error-page-wrapper .buttons-container a:nth-child(2) {float:right;}
@media screen and (max-width:580px) {
.error-page-wrapper {padding:30px 5%;}
.error-page-wrapper .content-container {padding:37px;position:static;left:0;margin-top:0;margin-left:0;}
.error-page-wrapper .head-line {font-size:36px;}
.error-page-wrapper .subheader {font-size:27px;line-height:37px;}
.error-page-wrapper .hr {margin:30px auto;width:215px;}
}
@media screen and (max-width:450px) {
.error-page-wrapper {padding:30px;}
.error-page-wrapper .head-line {font-size:32px;}
.error-page-wrapper .hr {margin:25px auto;width:180px;}
.error-page-wrapper .context {font-size:15px;line-height:22px;}
.error-page-wrapper .context p:nth-child(n+2) {margin-top:10px;}
.error-page-wrapper .buttons-container {margin-top:29px;}
.error-page-wrapper .buttons-container a {float:none !important;width:65%;margin:0 auto;font-size:13px;padding:9px 0;}
.error-page-wrapper .buttons-container a:nth-child(2) {margin-top:12px;}
}
</style>
</head>
<body class="error-page-wrapper">
<div class="content-container">
<div class="head-line">
<img src="/assets/img/error.svg" alt="" width="120"/>
</div>
<div class="subheader">
你所浏览的页面暂时无法访问{"s":"\/assets\/addons\/kmdsoft\/images\/wxdk\/menu\/hao123.svg"} </div>
<div class="hr"></div>
<div class="context">
<p>
你可以返回上一页重试 </p>
</div>
<div class="buttons-container">
<a href="/">返回主页</a>
<a href="javascript:" onclick="history.go(-1)">返回上一页</a>
</div>
</div>
</body>
</html>

1
images/svg/default.svg Normal file
View File

@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1691679612388" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1664" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M541.696 86.308571l316.952381 140.775619A73.142857 73.142857 0 0 1 902.095238 293.936762v436.126476a73.142857 73.142857 0 0 1-43.446857 66.852572l-316.952381 140.751238a73.142857 73.142857 0 0 1-59.392 0l-316.952381-140.751238A73.142857 73.142857 0 0 1 121.904762 730.063238V293.936762a73.142857 73.142857 0 0 1 43.446857-66.852572l316.952381-140.751238a73.142857 73.142857 0 0 1 59.392 0zM195.047619 362.788571v367.274667l286.476191 127.21981V485.546667L195.047619 362.788571z m633.904762 2.633143l-274.285714 117.516191V851.870476L828.952381 730.063238V365.421714zM512 153.185524L207.335619 288.475429l307.760762 131.900952 304.591238-130.56L512 153.185524z" p-id="1665"></path></svg>

After

Width:  |  Height:  |  Size: 1019 B