mirror of
https://gitee.com/spark-store-project/spark-web-app-runtime.git
synced 2025-07-03 12:16:01 +08:00
修复多个窗口共用同一个配置文件导致锁定的问题(https://gitee.com/spark-store-project/spark-web-app-runtime/issues/IA759Q)
This commit is contained in:
parent
a95e7e1beb
commit
d197bd3a04
spark-webapp-runtime
@ -38,7 +38,7 @@ MainWindow::MainWindow(QString szTitle,
|
|||||||
, m_isFullScreen(nFullScreen)
|
, m_isFullScreen(nFullScreen)
|
||||||
, m_isFixedSize(nFixSize)
|
, m_isFixedSize(nFixSize)
|
||||||
, m_isHideButton(nHideButtons)
|
, m_isHideButton(nHideButtons)
|
||||||
, m_widget(new Widget(m_url, this))
|
, m_widget(new Widget(m_url, this, m_title))
|
||||||
, m_tray(new QSystemTrayIcon(this))
|
, m_tray(new QSystemTrayIcon(this))
|
||||||
, btnBack(new DToolButton(titlebar()))
|
, btnBack(new DToolButton(titlebar()))
|
||||||
, btnForward(new DToolButton(titlebar()))
|
, btnForward(new DToolButton(titlebar()))
|
||||||
|
@ -2,16 +2,19 @@
|
|||||||
#include "webengineview.h"
|
#include "webengineview.h"
|
||||||
#include "webenginepage.h"
|
#include "webenginepage.h"
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
#include <QWebEngineProfile>
|
||||||
#include <DApplication>
|
#include <DApplication>
|
||||||
|
|
||||||
DWIDGET_USE_NAMESPACE
|
DWIDGET_USE_NAMESPACE
|
||||||
|
|
||||||
Widget::Widget(QString szUrl, QWidget *parent)
|
Widget::Widget(QString szUrl, QWidget *parent, QString szTitle)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, m_webEngineView(new WebEngineView(this))
|
, m_webEngineView(new WebEngineView(this))
|
||||||
, m_spinner(new DSpinner(this))
|
, m_spinner(new DSpinner(this))
|
||||||
, mainLayout(new QStackedLayout(this))
|
, mainLayout(new QStackedLayout(this))
|
||||||
, m_szUrl(szUrl)
|
, m_szUrl(szUrl)
|
||||||
|
, m_szTitle(szTitle)
|
||||||
{
|
{
|
||||||
initUI();
|
initUI();
|
||||||
initConnections();
|
initConnections();
|
||||||
@ -54,6 +57,15 @@ void Widget::initUI()
|
|||||||
page->setUrl(QUrl());
|
page->setUrl(QUrl());
|
||||||
if (!m_szUrl.isEmpty()) {
|
if (!m_szUrl.isEmpty()) {
|
||||||
page->setUrl(QUrl(m_szUrl));
|
page->setUrl(QUrl(m_szUrl));
|
||||||
|
// 设置新的 cookie 路径以防止冲突(https://gitee.com/spark-store-project/spark-web-app-runtime/issues/IA759Q)
|
||||||
|
QString cookiePath = QDir::homePath() +
|
||||||
|
"/.config/spark-webapp-runtime/" +
|
||||||
|
QUrl::toPercentEncoding(m_szTitle); // 使用 url 转移以便正确将标题做为文件名
|
||||||
|
QWebEngineProfile *profile = page->profile();
|
||||||
|
if (!QDir(cookiePath).exists()) {
|
||||||
|
QDir().mkpath(cookiePath);
|
||||||
|
}
|
||||||
|
profile->setPersistentStoragePath(cookiePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *spinnerWidget = new QWidget(this);
|
QWidget *spinnerWidget = new QWidget(this);
|
||||||
|
@ -17,7 +17,7 @@ class Widget : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Widget(QString szUrl = nullptr, QWidget *parent = nullptr);
|
explicit Widget(QString szUrl = nullptr, QWidget *parent = nullptr, QString szTitle = nullptr);
|
||||||
~Widget();
|
~Widget();
|
||||||
|
|
||||||
QWebEnginePage *getPage();
|
QWebEnginePage *getPage();
|
||||||
@ -46,6 +46,7 @@ private:
|
|||||||
QStackedLayout *mainLayout = nullptr;
|
QStackedLayout *mainLayout = nullptr;
|
||||||
|
|
||||||
QString m_szUrl;
|
QString m_szUrl;
|
||||||
|
QString m_szTitle;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WIDGET_H
|
#endif // WIDGET_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user