浏览器可以多进程浏览
This commit is contained in:
parent
f9e3aa1aae
commit
c41a936bbf
@ -4,6 +4,7 @@ ctaiSessionWidget::ctaiSessionWidget()
|
|||||||
{
|
{
|
||||||
init_layout();
|
init_layout();
|
||||||
connect_signals();
|
connect_signals();
|
||||||
|
on_new_chat_clicked();
|
||||||
}
|
}
|
||||||
ctaiSessionWidget::~ctaiSessionWidget()
|
ctaiSessionWidget::~ctaiSessionWidget()
|
||||||
{
|
{
|
||||||
|
|||||||
94
src/main.cpp
94
src/main.cpp
@ -8,11 +8,11 @@
|
|||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QCefContext.h>
|
#include <QCefContext.h>
|
||||||
#include "QCefWidget/MainWindow.h"
|
#include "QCefWidget/MainWindow.h"
|
||||||
// #include <include/cef_app.h>
|
#include <include/cef_app.h>
|
||||||
// #include <include/cef_client.h>
|
#include <include/cef_client.h>
|
||||||
// #include <include/cef_render_handler.h>
|
#include <include/cef_render_handler.h>
|
||||||
// #include <include/cef_browser.h>
|
#include <include/cef_browser.h>
|
||||||
// // // 自定义 CefApp 类
|
// // 自定义 CefApp 类
|
||||||
// class CefAppQt : public CefApp, public CefBrowserProcessHandler
|
// class CefAppQt : public CefApp, public CefBrowserProcessHandler
|
||||||
// {
|
// {
|
||||||
// public:
|
// public:
|
||||||
@ -80,25 +80,69 @@
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
|
QString currentDir=QDir::currentPath();
|
||||||
|
qDebug() << "UI线程ID-1: " << QThread::currentThreadId();
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
qputenv("QT_QPA_PLATFORM", "windows:fontengine=freetype");
|
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");
|
||||||
QTranslator qtBaseTranslator;
|
config.setLogLevel(QCefConfig::LOGSEVERITY_VERBOSE);
|
||||||
if (!qtBaseTranslator.load(QStringLiteral(":/res/translator/qtbase_zh_CN.qm")))
|
config.setBridgeObjectName("CtaiClient");
|
||||||
{
|
config.setBuiltinSchemeName("Ctai");
|
||||||
// 处理加载翻译文件失败的情况
|
config.setWindowlessRenderingEnabled(false);
|
||||||
qDebug() << "Failed to load translation file.";
|
config.setRemoteDebuggingPort(9000);
|
||||||
return -1;
|
//config.setCachePath(currentDir+"/user/userData");
|
||||||
}
|
//config.setRootCachePath(currentDir+"/user/userCache");
|
||||||
a.installTranslator(&qtBaseTranslator);
|
//config.setResourceDirectoryPath(currentDir+"/Resources");
|
||||||
// 读取窗体的配置并初始化
|
//config.setLocalesDirectoryPath(currentDir+"/locales");
|
||||||
sui_init_config();
|
config.setAcceptLanguageList("zh-CN");
|
||||||
ctai x;
|
config.setBrowserSubProcessPath(currentDir+"/ctai.exe");
|
||||||
x.init_layout();
|
//config.addCommandLineSwitch("single-process");
|
||||||
// 仅限于windows平台
|
//config.addCommandLineSwitch("enable-gpu");
|
||||||
#if defined(__WIN32__)
|
//config.addCommandLineSwitch("in-process-gpu");
|
||||||
x.title()->set_type(QD_TYPE::QD_EXIT);
|
//config.addCommandLineSwitch("disable-gpu-compositing");
|
||||||
#endif
|
config.addCommandLineSwitch("headless");
|
||||||
x.show();
|
config.addCommandLineSwitch("use-mock-keychain");
|
||||||
return a.exec();
|
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