浏览器可以多进程浏览
This commit is contained in:
parent
f9e3aa1aae
commit
c41a936bbf
@ -4,6 +4,7 @@ ctaiSessionWidget::ctaiSessionWidget()
|
||||
{
|
||||
init_layout();
|
||||
connect_signals();
|
||||
on_new_chat_clicked();
|
||||
}
|
||||
ctaiSessionWidget::~ctaiSessionWidget()
|
||||
{
|
||||
|
||||
94
src/main.cpp
94
src/main.cpp
@ -8,11 +8,11 @@
|
||||
#include <QStandardPaths>
|
||||
#include <QCefContext.h>
|
||||
#include "QCefWidget/MainWindow.h"
|
||||
// #include <include/cef_app.h>
|
||||
// #include <include/cef_client.h>
|
||||
// #include <include/cef_render_handler.h>
|
||||
// #include <include/cef_browser.h>
|
||||
// // // 自定义 CefApp 类
|
||||
#include <include/cef_app.h>
|
||||
#include <include/cef_client.h>
|
||||
#include <include/cef_render_handler.h>
|
||||
#include <include/cef_browser.h>
|
||||
// // 自定义 CefApp 类
|
||||
// class CefAppQt : public CefApp, public CefBrowserProcessHandler
|
||||
// {
|
||||
// public:
|
||||
@ -80,25 +80,69 @@
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
QString currentDir=QDir::currentPath();
|
||||
qDebug() << "UI线程ID-1: " << QThread::currentThreadId();
|
||||
QApplication a(argc, argv);
|
||||
qputenv("QT_QPA_PLATFORM", "windows:fontengine=freetype");
|
||||
// 加载语言包
|
||||
QTranslator qtBaseTranslator;
|
||||
if (!qtBaseTranslator.load(QStringLiteral(":/res/translator/qtbase_zh_CN.qm")))
|
||||
{
|
||||
// 处理加载翻译文件失败的情况
|
||||
qDebug() << "Failed to load translation file.";
|
||||
return -1;
|
||||
}
|
||||
a.installTranslator(&qtBaseTranslator);
|
||||
// 读取窗体的配置并初始化
|
||||
sui_init_config();
|
||||
ctai x;
|
||||
x.init_layout();
|
||||
// 仅限于windows平台
|
||||
#if defined(__WIN32__)
|
||||
x.title()->set_type(QD_TYPE::QD_EXIT);
|
||||
#endif
|
||||
x.show();
|
||||
return a.exec();
|
||||
QCefConfig config;
|
||||
config.setUserAgent("Mozilla/5.0 (Windows NT 10.0; CEF/3.2272.2035) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 SoftwareInformer/1.6.1400");
|
||||
config.setLogLevel(QCefConfig::LOGSEVERITY_VERBOSE);
|
||||
config.setBridgeObjectName("CtaiClient");
|
||||
config.setBuiltinSchemeName("Ctai");
|
||||
config.setWindowlessRenderingEnabled(false);
|
||||
config.setRemoteDebuggingPort(9000);
|
||||
//config.setCachePath(currentDir+"/user/userData");
|
||||
//config.setRootCachePath(currentDir+"/user/userCache");
|
||||
//config.setResourceDirectoryPath(currentDir+"/Resources");
|
||||
//config.setLocalesDirectoryPath(currentDir+"/locales");
|
||||
config.setAcceptLanguageList("zh-CN");
|
||||
config.setBrowserSubProcessPath(currentDir+"/ctai.exe");
|
||||
//config.addCommandLineSwitch("single-process");
|
||||
//config.addCommandLineSwitch("enable-gpu");
|
||||
//config.addCommandLineSwitch("in-process-gpu");
|
||||
//config.addCommandLineSwitch("disable-gpu-compositing");
|
||||
config.addCommandLineSwitch("headless");
|
||||
config.addCommandLineSwitch("use-mock-keychain");
|
||||
config.addCommandLineSwitch("disable-chrome-runtime");
|
||||
config.addCommandLineSwitchWithValue("enable-features","NetworkServiceInProcess");
|
||||
config.addCommandLineSwitchWithValue("log-severity","verbose");
|
||||
config.addCommandLineSwitchWithValue("lang","zh-CN");
|
||||
config.addCommandLineSwitchWithValue("builtin-scheme-name","Ctai");
|
||||
config.addCommandLineSwitchWithValue("bridge-obj-name","CtaiClient");
|
||||
config.addCommandLineSwitchWithValue("pack_loading_disabled","false");
|
||||
//config.addCommandLineSwitchWithValue("user-data-dir","false");
|
||||
//config.addCommandLineSwitchWithValue("log-file","false");
|
||||
config.addCommandLineSwitchWithValue("remote-allow-origins", "*");
|
||||
//禁用沙盒
|
||||
config.addCommandLineSwitchWithValue("no-sandbox","ture");
|
||||
//禁止多线程会话循环(单进程为true,多进程为false);
|
||||
config.addCommandLineSwitchWithValue("renderer-process-limit", "1");
|
||||
config.addCommandLineSwitchWithValue("external-message-pump","false");
|
||||
config.addCommandLineSwitchWithValue("multi-threaded-message-loop","true");
|
||||
QCefContext cefContext(&a, argc, argv, &config);
|
||||
MainWindow cw;
|
||||
cw.show();
|
||||
qDebug() << "UI线程ID-2: " << QThread::currentThreadId();
|
||||
// qputenv("QT_QPA_PLATFORM", "windows:fontengine=freetype");
|
||||
// // 加载语言包
|
||||
// QTranslator qtBaseTranslator;
|
||||
// if (!qtBaseTranslator.load(QStringLiteral(":/res/translator/qtbase_zh_CN.qm")))
|
||||
// {
|
||||
// // 处理加载翻译文件失败的情况
|
||||
// qDebug() << "Failed to load translation file.";
|
||||
// return -1;
|
||||
// }
|
||||
// a.installTranslator(&qtBaseTranslator);
|
||||
// // 读取窗体的配置并初始化
|
||||
// sui_init_config();
|
||||
// ctai x;
|
||||
// x.init_layout();
|
||||
// // 仅限于windows平台
|
||||
// #if defined(__WIN32__)
|
||||
// x.title()->set_type(QD_TYPE::QD_EXIT);
|
||||
// #endif
|
||||
// x.show();
|
||||
a.exec();
|
||||
qDebug() << "EXIT";
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user