QT-window记事本

news2024/11/18 11:40:24

QT-window记事本

  • 一、演示效果
  • 二、核心代码
  • 三、下载连接


一、演示效果

请添加图片描述

二、核心代码

#include <QMessageBox>
#include <QFileDialog>
#include <QDebug>
#include <QProcess>
#include <QDesktopServices>
#include <QDateTime>
#include <QFontDialog>
#include <QTextBlock>
#include <QFileIconProvider>
#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow),
      settings("MyNotepad")
{
    ui->setupUi(this);

    // 读取设置
    if (!settings.value("wordWrap", true).toBool())
    {
        ui->actionWord_Wrap_W->setChecked(false);
        ui->plainTextEdit->setWordWrapMode(QTextOption::NoWrap);
    }
    if (!settings.value("statusBar", true).toBool())
    {
        this->statusBar()->hide();
        ui->actionStatus_Bar_S->setChecked(false);
    }

    // 恢复字体
    QString fs;
    if (!(fs = settings.value("font").toString()).isEmpty())
    {
        QFont f;
        f.fromString(fs);
        ui->plainTextEdit->setFont(f);
    }

    // 状态栏
    posLabel = new QLabel(u8"第 1 行,第 1 列", this);
    zoomLabel = new QLabel(u8"100%", this);
    lineLabel = new QLabel(u8"Windows (CRLF)", this);
    codecLabel = new QLabel(u8"GBK", this);
    ui->statusbar->addPermanentWidget(new QLabel(this), 6);
    ui->statusbar->addPermanentWidget(posLabel, 3);
    ui->statusbar->addPermanentWidget(zoomLabel, 1);
    ui->statusbar->addPermanentWidget(lineLabel, 3);
    ui->statusbar->addPermanentWidget(codecLabel, 1);

    // 设置为系统notepad图标
    QFileIconProvider ip;
    QIcon icon = ip.icon(QFileInfo("C:\\Windows\\System32\\notepad.exe"));
    qApp->setWindowIcon(icon);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::openFile(QString path)
{
    filePath = path;

    if (path.isEmpty())
    {
        savedContent = "";
        fileName = u8"无标题";
    }
    else
    {
        QFile file(path);
        if (!file.exists())
        {
            qWarning() << u8"文件不存在";
            return ;
        }
        fileName = QFileInfo(path).baseName();

        // 读取文件
        if (!file.open(QIODevice::ReadOnly))
        {
            qWarning() << u8"打开文件失败";
            return ;
        }
        savedContent = QString::fromLocal8Bit(file.readAll());
    }
    ui->plainTextEdit->setPlainText(savedContent);
    updateWindowTitle();
}

bool MainWindow::isModified() const
{
    return ui->plainTextEdit->toPlainText() != savedContent;
}

/**
 * @brief MainWindow::askSave
 * @return 是否继续
 */
bool MainWindow::askSave()
{
    if (!isModified())
        return true;

    // 有未保存的更改
    int btn = QMessageBox::question(this, u8"记事本", u8"你想更改保存到 " + (fileName.isEmpty() ? u8"无标题" : fileName) + u8" 吗?", u8"保存(&S)", u8"不保存(&N)", u8"取消");
    if (btn == 2) // 取消
        return false;
    if (btn == 0) // 保存
    {
        return on_actionSave_triggered();
    }
    return true;
}

void MainWindow::updateWindowTitle()
{
    this->setWindowTitle((isModified() ? "*" : "") + fileName + u8" - 记事本");
}

void MainWindow::createFindDialog()
{
    findDialog = new FindDialog(settings, this);

    connect(findDialog, &FindDialog::signalShow, this, [=]{
        ui->actionFind_Next_N->setEnabled(true);
        ui->actionFind_Prev_V->setEnabled(true);
    });
    connect(findDialog, &FindDialog::signalHide, this, [=]{
        ui->actionFind_Next_N->setEnabled(false);
        ui->actionFind_Prev_V->setEnabled(false);
    });
    /* connect(findDialog, &FindDialog::signalTextChanged, this, [=](const QString& text){
        this->findText = text;
    }); */
    connect(findDialog, &FindDialog::signalFindNext, this, &MainWindow::on_actionFind_Next_N_triggered);
    connect(findDialog, &FindDialog::signalFindPrev, this, &MainWindow::on_actionFind_Prev_V_triggered);
    connect(findDialog, &FindDialog::signalReplaceNext, this, [=]{
        const QString& findText = findDialog->getFindText();
        const QString& replaceText = findDialog->getReplaceText();
        if (findText.isEmpty())
            return ;

        // 替换 逻辑上分为:查找、选中、替换
        const QString& selectedText = ui->plainTextEdit->textCursor().selectedText();
        if ((findDialog->isCaseSensitive() && selectedText != findText)
                || selectedText.toLower() != findText.toLower())
        {
            // 如果选中的词不是findText,则查找下一个
            on_actionFind_Next_N_triggered();
            qInfo() << u8"查找:" << findText;
        }
        else
        {
            // 已选中,则替换选中的
            QTextCursor tc = ui->plainTextEdit->textCursor();
            tc.insertText(replaceText);
            ui->plainTextEdit->setTextCursor(tc);
            qInfo() << u8"替换:" << findText << "->" << replaceText;
            on_actionFind_Next_N_triggered(); // 查找下一个
        }
    });
    connect(findDialog, &FindDialog::signalReplaceAll, this, [=]{
        const QString& findText = findDialog->getFindText();
        const QString& replaceText = findDialog->getReplaceText();
        if (findText.isEmpty())
            return ;
        qInfo() << u8"全部替换:" << findText << "->" << replaceText;

        QString content = ui->plainTextEdit->toPlainText();
        QTextCursor tc = ui->plainTextEdit->textCursor();
        tc.setPosition(0);
        tc.setPosition(content.length(), QTextCursor::KeepAnchor);
        content.replace(findText, replaceText);
        tc.insertText(content);
        // ui->plainTextEdit->setTextCursor(tc);     // 不调用这句话,保留替换之前的位置
        // ui->plainTextEdit->setPlainText(content); // 这个会导致无法撤销,而且会重置光标位置到开头
    });
}

void MainWindow::showEvent(QShowEvent *e)
{
    this->restoreGeometry(settings.value("mainwindow/geometry").toByteArray());
    this->restoreState(settings.value("mainwindow/state").toByteArray());

    QMainWindow::showEvent(e);
}

void MainWindow::closeEvent(QCloseEvent *e)
{
    if (!askSave())
    {
        e->ignore();
        return ;
    }
    settings.setValue("mainwindow/geometry", this->saveGeometry());
    settings.setValue("mainwindow/state", this->saveState());

    QMainWindow::closeEvent(e);
}

void MainWindow::on_plainTextEdit_textChanged()
{
    if (fileName.isEmpty())
        fileName = u8"无标题";
    updateWindowTitle();

    bool empty = ui->plainTextEdit->toPlainText().isEmpty();
    ui->actionFind_F->setEnabled(!empty);
    ui->actionReplace_R->setEnabled(!empty);
    ui->actionFind_Next_N->setEnabled(!empty && findDialog && findDialog->isVisible());
    ui->actionFind_Prev_V->setEnabled(!empty && findDialog && findDialog->isVisible());
}

void MainWindow::on_plainTextEdit_cursorPositionChanged()
{
    QTextCursor tc = ui->plainTextEdit->textCursor();

    QTextLayout* ly = tc.block().layout();
    int posInBlock = tc.position() - tc.block().position(); // 当前光标在block内的相对位置
    int line = ly->lineForTextPosition(posInBlock).lineNumber() + tc.block().firstLineNumber();

    int col = tc.columnNumber(); // 第几列
    // int row = tc.blockNumber(); // 第几段,无法识别WordWrap的第几行
    posLabel->setText(u8"第 " + QString::number(line + 1) + u8" 行,第 " + QString::number(col + 1) + u8" 列");
}

void MainWindow::on_plainTextEdit_undoAvailable(bool b)
{
    ui->actionUndo_U->setEnabled(b);
}

void MainWindow::on_plainTextEdit_selectionChanged()
{
    bool selected = ui->plainTextEdit->textCursor().hasSelection();
    ui->actionSearch_By_Bing->setEnabled(selected);
    ui->actionCut_T->setEnabled(selected);
    ui->actionCopy_C->setEnabled(selected);
    ui->actionDelete_L->setEnabled(selected);
    ui->actionReselect_Chinese->setEnabled(selected);
}

void MainWindow::on_actionNew_triggered()
{
    if (!askSave())
        return ;

    openFile("");
}

void MainWindow::on_actionNew_Window_triggered()
{
    QProcess p(this);
    p.startDetached(QApplication::applicationFilePath(), {"-new"});
}

void MainWindow::on_actionOpen_triggered()
{
    if (!askSave())
        return ;

    QString recentPath = settings.value("recent/filePath").toString();
    QString path = QFileDialog::getOpenFileName(this, u8"打开", recentPath, "*.txt");
    if (path.isEmpty())
        return ;

    openFile(path);
}

bool MainWindow::on_actionSave_triggered()
{
    if (filePath.isEmpty()) // 没有路径,另存为
    {
        QString recentPath = settings.value("recent/filePath").toString();
        QString path = QFileDialog::getSaveFileName(this, u8"另存为", recentPath, "*.txt");
        if (path.isEmpty())
            return false;
        settings.setValue("recent/filePath", path);
        filePath = path;
        fileName = QFileInfo(path).baseName();
    }

    // 写出文件
    QFile file(filePath);
    if (!file.open(QIODevice::WriteOnly))
    {
        qWarning() << "打开文件失败";
        return false;
    }
    QTextStream ts(&file);
    ts.setCodec("GBK");
    savedContent = ui->plainTextEdit->toPlainText();
    ts << savedContent;
    file.close();
    qInfo() << "save:" << filePath << savedContent.length();
    updateWindowTitle();
    return true;
}

bool MainWindow::on_actionSave_As_triggered()
{
    QString temp = filePath;
    filePath = "";
    if (!on_actionSave_triggered()) // 直接调用保存的
        filePath = temp;
    return true;
}

void MainWindow::on_actionExit_triggered()
{
    if (!askSave())
        return ;

    this->close();
}

void MainWindow::on_actionUndo_U_triggered()
{
    ui->plainTextEdit->undo();
}

void MainWindow::on_actionCut_T_triggered()
{
    ui->plainTextEdit->cut();
}

void MainWindow::on_actionCopy_C_triggered()
{
    ui->plainTextEdit->copy();
}

void MainWindow::on_actionPaste_P_triggered()
{
    ui->plainTextEdit->paste();
}

void MainWindow::on_actionDelete_L_triggered()
{
    QTextCursor tc = ui->plainTextEdit->textCursor();
    int pos = tc.position();
    if (pos >= ui->plainTextEdit->toPlainText().length())
        return ;
    tc.setPosition(pos + 1, QTextCursor::MoveMode::KeepAnchor);
    tc.removeSelectedText();
}

void MainWindow::on_actionSearch_By_Bing_triggered()
{
    // !这里是转到UTF-8,保存到txt是保存为GBK
    QByteArray key = ui->plainTextEdit->textCursor().selectedText().toUtf8().toPercentEncoding();
    QDesktopServices::openUrl(QUrl("https://cn.bing.com/search?q=" + key + "&form=NPCTXT"));
}


void MainWindow::on_actionSelect_All_A_triggered()
{
    ui->plainTextEdit->selectAll();
}

void MainWindow::on_actionTime_Date_D_triggered()
{
    ui->plainTextEdit->insertPlainText(QDateTime::currentDateTime().toString("hh:mm yyyy/MM/dd"));
}

void MainWindow::on_actionWord_Wrap_W_triggered()
{
    if (ui->plainTextEdit->wordWrapMode() == QTextOption::NoWrap)
    {
        ui->plainTextEdit->setWordWrapMode(QTextOption::WordWrap);
        ui->actionWord_Wrap_W->setChecked(true);
        settings.setValue("wordWrap", true);
    }
    else
    {
        ui->plainTextEdit->setWordWrapMode(QTextOption::NoWrap);
        ui->actionWord_Wrap_W->setChecked(false);
        settings.setValue("wordWrap", false);
    }
}

void MainWindow::on_actionFont_F_triggered()
{
    bool ok;
    QFont f = QFontDialog::getFont(&ok, ui->plainTextEdit->font(), this, u8"字体");
    if (!ok)
        return ;

    ui->plainTextEdit->setFont(f);
    settings.setValue("font", f.toString());
}

void MainWindow::on_actionZoom_In_I_triggered()
{
    if (zoomSize >= 500)
        return ;

    ui->plainTextEdit->zoomIn(1);
    zoomSize += 10;
    zoomLabel->setText(QString::number(zoomSize) + "%");
}

void MainWindow::on_actionZoom_Out_O_triggered()
{
    if (zoomSize <= 10)
        return ;

    ui->plainTextEdit->zoomOut(1);
    zoomSize -= 10;
    zoomLabel->setText(QString::number(zoomSize) + "%");
}

void MainWindow::on_actionZoom_Default_triggered()
{
    QString fs;
    if (!(fs = settings.value("font").toString()).isEmpty())
    {
        QFont f;
        f.fromString(fs);
        ui->plainTextEdit->setFont(f);
    }
    else
    {
        ui->plainTextEdit->setFont(qApp->font());
    }

    zoomSize = 100;
    zoomLabel->setText(QString::number(zoomSize) + "%");
}

void MainWindow::on_actionStatus_Bar_S_triggered()
{
    if (this->statusBar()->isHidden())
    {
        this->statusBar()->show();
        ui->actionStatus_Bar_S->setChecked(true);
        settings.setValue("statusBar", true);
    }
    else
    {
        this->statusBar()->hide();
        ui->actionStatus_Bar_S->setChecked(false);
        settings.setValue("statusBar", false);
    }
}

void MainWindow::on_actionAbout_A_triggered()
{
    QMessageBox::about(this, u8"关于", u8"高仿 Windows 记事本的 Qt 实现方案");
}

void MainWindow::on_actionFind_F_triggered()
{
    if (!findDialog)
    {
        createFindDialog();
    }
    findDialog->openFind(false);
}

void MainWindow::on_actionFind_Next_N_triggered()
{
    const QString& text = findDialog->getFindText();
    if (text.isEmpty())
        return ;

    QTextDocument::FindFlags flags;
    if (findDialog->isCaseSensitive())
        flags |= QTextDocument::FindCaseSensitively;
    bool rst = ui->plainTextEdit->find(text, flags);
    if (!rst && findDialog->isLoop()
            && ui->plainTextEdit->toPlainText().contains(text)) // 没找到,尝试从头开始
    {
        qInfo() << "从开头查找";
        QTextCursor tc = ui->plainTextEdit->textCursor();
        tc.setPosition(0);
        ui->plainTextEdit->setTextCursor(tc);
        on_actionFind_Next_N_triggered();
    }
}

void MainWindow::on_actionFind_Prev_V_triggered()
{
    const QString& text = findDialog->getFindText();
    if (text.isEmpty())
        return ;

    QTextDocument::FindFlags flags = QTextDocument::FindBackward;
    if (findDialog->isCaseSensitive())
        flags |= QTextDocument::FindCaseSensitively;
    bool rst = ui->plainTextEdit->find(text, flags);
    if (!rst && findDialog->isLoop()
            && ui->plainTextEdit->toPlainText().contains(text))
    {
        qInfo() << "从末尾查找";
        QTextCursor tc = ui->plainTextEdit->textCursor();
        tc.setPosition(ui->plainTextEdit->toPlainText().length());
        ui->plainTextEdit->setTextCursor(tc);
        on_actionFind_Prev_V_triggered();
    }
}

void MainWindow::on_actionReplace_R_triggered()
{
    if (!findDialog)
    {
        createFindDialog();
    }
    findDialog->openFind(true);
}

void MainWindow::on_actionGoto_G_triggered()
{
    // TODO:转到
    // 我的记事本这个选项一直是灰色的
}

void MainWindow::on_actionHelp_triggered()
{
    QDesktopServices::openUrl(QUrl("https://github.com/iwxyi/Qt-notepad"));
}

void MainWindow::on_actionFeedback_F_triggered()
{
    QDesktopServices::openUrl(QUrl("https://github.com/iwxyi/Qt-notepad/issues"));
}

void MainWindow::on_plainTextEdit_customContextMenuRequested(const QPoint&)
{
    QMenu* menu = new QMenu();

    QMenu* insertUnicodeControlCharsMenu = new QMenu("插入 Unicode 控制字符(&I)", menu);
    QList<QPair<QString, QString>> unicodeControlChars{
        {"LRM", "&Left-to-right mark"},
        {"RLM", "&Right-to-left mark"},
        {"ZWJ", "Zero width joiner"},
        {"ZWNJ", "Zero width &non-joiner"},
        {"LRE", "Start of left-to-right &embedding"},
        {"RLE", "Start of right-to-left e&mbedding"},
        {"LRO", "Start of left-to-right &override"},
        {"RLO", "Start of right-to-left o&verride"},
        {"PDF", "&Pop directional formatting"},
        {"NADS", "N&ational digit shapes substitution"},
        {"NODS", "Nominal (European) &digit shapes"},
        {"ASS", "Activate &symmetric swapping"},
        {"ISS", "Inhibit s&ymmetric swapping"},
        {"AAFS", "Activate Arabic &form shaping"},
        {"IAFS", "Inhibit Arabic form s&haping"},
        {"RS", "Record Separator (&Block separator)"},
        {"US", "Unit Separator (&Segment separator)"}
    };
    for (auto p: unicodeControlChars)
    {
        QAction* action = new QAction(p.first, insertUnicodeControlCharsMenu);
        action->setToolTip(p.second);
        // TODO: 把提示也显示出来
        connect(action, &QAction::triggered, ui->plainTextEdit, [=]{
            // TODO: 插入 Unicode 控制字符
            // ui->plainTextEdit->insertPlainText("\u202c");
        });
        insertUnicodeControlCharsMenu->addAction(action);
    }

    menu->addAction(ui->actionUndo_U);
    menu->addSeparator();
    menu->addAction(ui->actionCut_T);
    menu->addAction(ui->actionCopy_C);
    menu->addAction(ui->actionPaste_P);
    menu->addAction(ui->actionDelete_L);
    menu->addSeparator();
    menu->addAction(ui->actionSelect_All_A);
    menu->addSeparator();
    menu->addAction(ui->actionRead_Direction);
    menu->addAction(ui->actionShow_Unicode_Control_Chars);
    menu->addMenu(insertUnicodeControlCharsMenu);
    menu->addSeparator();
    menu->addAction(ui->actionRead_Mode);
    menu->addAction(ui->actionReselect_Chinese);
    menu->addSeparator();
    menu->addAction(ui->actionSearch_By_Bing);

    menu->exec(QCursor::pos());
    menu->deleteLater();
}

void MainWindow::on_actionRead_Direction_triggered()
{
    auto direction = ui->actionRead_Direction->isChecked() ? Qt::RightToLeft : Qt::LeftToRight;
    ui->plainTextEdit->setLayoutDirection(direction);
}

void MainWindow::on_actionRead_Mode_triggered()
{
    if (ui->plainTextEdit->isReadOnly())
    {
        ui->plainTextEdit->setReadOnly(false);
        ui->actionRead_Mode->setText(u8"关闭输入法(&L)");
    }
    else
    {
        ui->plainTextEdit->setReadOnly(true);
        ui->actionRead_Mode->setText(u8"打开输入法(&O)");
    }
}

void MainWindow::on_actionShow_Unicode_Control_Chars_triggered()
{
    // TODO: 显示 Unicode 控制字符
}

void MainWindow::on_actionReselect_Chinese_triggered()
{
    // TODO: 汉字重选
}

void MainWindow::on_actionPrefrence_triggered()
{
    // TODO: 页面设置
}

void MainWindow::on_actionPrint_triggered()
{
    // TODO: 打印
}

#include "finddialog.h"
#include "ui_finddialog.h"

FindDialog::FindDialog(QSettings &settings, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::FindDialog),
    settings(settings)
{
    ui->setupUi(this);
    //this->setWindowFlags(Qt::WindowContextHelpButtonHint);

    // 读取数据
    ui->findEdit->setText(settings.value("find/findText").toString());
    ui->replaceEdit->setText(settings.value("find/replaceText").toString());
    ui->caseSensitiveCheck->setChecked(settings.value("find/caseSensitive").toBool());
    ui->loopCheck->setChecked(settings.value("find/loop").toBool());
    if (!settings.value("find/down", true).toBool())
        ui->upRadio->setChecked(true);
}

FindDialog::~FindDialog()
{
    delete ui;
}

void FindDialog::openFind(bool replace)
{
    ui->label_3->setVisible(replace);
    ui->replaceEdit->setVisible(replace);
    ui->replaceButton->setVisible(replace);
    ui->replaceAllButton->setVisible(replace);
    ui->groupBox->setVisible(!replace);
    QDialog::show(); // open/exec会导致模态
    ui->findEdit->setFocus();
    ui->findEdit->selectAll();
    this->adjustSize();

    if (!replace)
        setWindowTitle(u8"查找");
    else
        setWindowTitle(u8"替换");
}

const QString FindDialog::getFindText() const
{
    return ui->findEdit->text();
}

const QString FindDialog::getReplaceText() const
{
    return ui->replaceEdit->text();
}

bool FindDialog::isCaseSensitive() const
{
    return ui->caseSensitiveCheck->isChecked();
}

bool FindDialog::isLoop() const
{
    return ui->loopCheck->isChecked();
}

void FindDialog::on_findNextButton_clicked()
{
    if (ui->upRadio->isChecked())
        emit signalFindPrev();
    else
        emit signalFindNext();
    settings.setValue("find/findText", ui->findEdit->text());
}

void FindDialog::on_replaceButton_clicked()
{
    emit signalReplaceNext();
    settings.setValue("find/replaceText", ui->replaceEdit->text());
}

void FindDialog::on_replaceAllButton_clicked()
{
    emit signalReplaceAll();
    settings.setValue("find/replaceText", ui->replaceEdit->text());
}

void FindDialog::on_cancelButton_clicked()
{
    this->close();
}

void FindDialog::on_caseSensitiveCheck_clicked()
{
    settings.setValue("find/caseSensitive", ui->caseSensitiveCheck->isChecked());
}

void FindDialog::on_loopCheck_clicked()
{
    settings.setValue("find/loop", ui->loopCheck->isChecked());
}

void FindDialog::on_upRadio_clicked()
{
    settings.setValue("find/down", false);
}

void FindDialog::on_downRadio_clicked()
{
    settings.setValue("find/down", true);
}

void FindDialog::showEvent(QShowEvent *event)
{
    emit signalShow();
    adjustSize();
    QWidget::showEvent(event);
}

void FindDialog::hideEvent(QHideEvent *event)
{
    emit signalHide();
    QWidget::hideEvent(event);
}

void FindDialog::on_findEdit_returnPressed()
{
    on_findNextButton_clicked();
}

void FindDialog::on_replaceEdit_returnPressed()
{
    on_replaceButton_clicked();
}

三、下载连接

https://download.csdn.net/download/u013083044/89660580

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2066150.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

孙宇晨:区块链领域的坚韧领航者,以智慧铸就行业基石

​ 在区块链领域&#xff0c;孙宇晨以其卓越的智慧与不懈的韧性&#xff0c;成为行业内备受瞩目的领军人物。从创立波场 TRON 到引领去中心化的变革&#xff0c;孙宇晨始终以坚定的信念和独特的战略眼光推动着区块链技术的发展。 孙宇晨的成功不仅仅是因为他对技术的深入…

叉车驾驶员状态监控系统,司机身份安全识别,强化监管能力建设!

人脸识别技术作为人工智能领域的一个重要分支&#xff0c;已经广泛应用于安全识别、个人化推荐、社交网络等多个领域。其基于计算机视觉、图像处理、人脸检测、特征提取和人脸识别等先进技术&#xff0c;能够实现对人脸图像的精准分析和识别。在叉车驾驶场景中&#xff0c;AI人…

windows mfc webview2 接收html信息

webview2导入到mfc参考&#xff1a; windows vs2022 MFC使用webview2嵌入网页-CSDN博客 webview2与js交互参考&#xff1a;WebView2教程(基于C)【四】JS与C互访&#xff08;上&#xff09;_window.chrome.webview.postmessage-CSDN博客 一、JS端发送和接收 JS中&#xff0c;…

12代装win7影响性能吗?12代酷睿装win7关闭小核提高性能方法

12代酷睿装win7影响性能吗&#xff1f;12代酷睿装win7在性能上有点损耗&#xff0c;可以关闭小核提高性能。有些小朋友不知道怎么关闭上核来提高性能&#xff0c;下面电脑系统城小编就教大家12代酷睿装win7关闭核提高性能方法。 12代酷睿装win7说明&#xff1a;关闭小核解锁更多…

【分布式】分布式Session共享

这里通过SpringSession来实现Session的共享&#xff0c;Session数据存储在Redis中 SpringSession的操作指南&#xff1a; https://docs.spring.io/spring-session/docs/2.5.6/reference/html5/guides/boot-redis.html 导入相关的依赖 <dependency><groupId>org.s…

算法入门-递归3

第四部分&#xff1a;递归 143.重排链表&#xff08;中等&#xff09; 题目&#xff1a;给定一个单链表 L 的头节点 head &#xff0c;单链表 L 表示为&#xff1a; L0 → L1 → … → Ln - 1 → Ln 请将其重新排列后变为&#xff1a; L0 → Ln → L1 → Ln - 1 → L2 → …

问题-小技巧-win11状态栏卡住

目前我只知道治标不治本的办法&#xff0c;打开任务管理器&#xff0c;找到Windows资源管理器右键重新启动&#xff0c;就可以解决这个问题。 这个问题我觉得是Win11自己的问题&#xff0c;等有新的发现&#xff0c;会进行补充。

使用Hutool工具类轻松生成验证码

效果图&#xff1a; 引入依赖&#xff1a; <!--hutool工具包--> <dependency><groupId>cn.hutool</groupId><artifactId>hutool-all</artifactId><version>5.7.15</version> </dependency>核心代码 import cn.hutool.…

使用docker-compose运行kafka及验证(无需zookpeer)

前言&#xff1a;要求安装docker-compose kafka镜像版本&#xff1a;apache/kafka:3.8.0 可能存在镜像拉不下来的情况&#xff1a; 1、vim /etc/docker/daemon.json {"data-root":"/data/docker","registry-mirrors": ["https://docker.m…

高性价比百元蓝牙耳机如何选择?四款首选高性价比蓝牙耳机推荐

不知道什么时候开始&#xff0c;有线耳机悄悄的淡出了我们的视线。现在几乎都是蓝牙耳机首当前冲&#xff0c;因为比起有线耳机&#xff0c;蓝牙耳机更携带方便&#xff0c;拿出来就是秒连&#xff0c;体验感也不差。而且随着蓝牙耳机的价格不断下降&#xff0c;同时&#xff0…

【图文并茂】ant design pro 如何优雅奇妙地添加修改密码的功能

如上图所示&#xff0c;我们要加这样的一个功能&#xff0c;如何做呢&#xff1f; 首先要写好前端页面&#xff0c;再对接好后端&#xff0c;然后我们要判断当前密码是否正确&#xff0c;如果正确才能新密码修改好。 前端页面 src/pages/account/change-password/index.tsx …

【直观表格】常见神经网络计算复杂度对比 ——从时间复杂度和空间复杂度角度剖析

常见神经网络计算复杂度对比 ——从时间复杂度和空间复杂度角度剖析 【表格】常见神经网络计算复杂度对比 神经网络类型时间复杂度空间复杂度关键参数备注多层感知机&#xff08;MLP&#xff09; O ( n ⋅ d ⋅ h ) O(n \cdot d \cdot h) O(n⋅d⋅h) O ( d ⋅ h h ) O(d \c…

helm安装jenkins保姆级别

一、创建nfs服务器 这一步跳过、自行百度 注意&#xff1a;要给共享目录赋予权限chmod一下&#xff0c;不然到时候容器没办法在目录里面创建文件&#xff0c;初始化时候会报错误代码2 二、添加Jenkins的Helm仓库 helm repo add jenkinsci https://charts.jenkins.io helm re…

护眼台灯真的有用吗?学生护眼台灯十大牌子推荐

在当前近视患者剧增&#xff0c;我们发现近视还与青光眼的发生有关联&#xff0c;这是一种可能导致永久性视力丧失的眼病。青光眼通常是由于眼内压力过高造成的视神经损伤。高度近视患者的眼球结构变化可能增加眼压&#xff0c;从而提高患青光眼的风险。预防近视变得非常重要&a…

html js弹幕功能

效果如上 html <!DOCTYPE html> <html><head><meta charset"utf-8" /><title></title><script charset"utf-8" src"https://unpkg.com/vue2.6.14/dist/vue.min.js" type"text/javascript">…

[C语言]-基础知识点梳理-编译、链接、预处理

前言 各位师傅大家好&#xff0c;我是qmx_07,今天来给大家讲解以下程序运行会经历哪些事情 翻译环境和运⾏环境 在ANSIC的任何⼀种实现中&#xff0c;存在两个不同的环境 第1种是翻译环境&#xff0c;在这个环境中源代码被转换为可执⾏的机器指令&#xff08;⼆进制指令&a…

[FSCTF 2023]ez_php2

[FSCTF 2023]ez_php2 点开之后是一段php代码&#xff1a; <?php highlight_file(__file__); Class Rd{public $ending;public $cl;public $poc;public function __destruct(){echo "All matters have concluded";die($this->ending);}public function __call…

django宿舍管理系统 ---附源码98595

目 录 摘要 1 绪论 1.1 研究背景与意义 1.2 国内外研究现状 1.3论文结构与章节安排 2 宿舍管理系统系统分析 2.1 可行性分析 2.2 系统流程分析 2.2.1 数据增加流程 2.2.2 数据修改流程 2.2.3 数据删除流程 2.3 系统功能分析 2.3.1 功能性分析 2.3.2 非功能性分析…

vue vite创建项目步骤

1. 创建vue项目 node版本需18以上 不然报错 npm init vuelatest2. 项目配置 配置项目的icon配置项目的标题配置jsconfig.json 3. 项目目录结构划分 4.css样式的重置 npm install normalize.cssreset.css html {line-height: 1.2; }body, h1, h2, h3, h4, ul, li {padding…

aspose-words将tinymce中的换页符转换为word的换页符

aspose-words版本&#xff1a;21.1 java&#xff1a;1.8 tinymc&#xff1a;5.0.16 public void convertPageBreak() throws Exception{String sourceHtml "hello<!-- pagebreak -->world";sourceHtml sourceHtml.replaceAll("<!-- pagebreak -->…