当前位置: 首页 > news >正文

react利用wangEditor写评论和@功能

先引入wangeditor写评论功能

import React, { useEffect, useState, useRef, forwardRef, useImperativeHandle } from 'react';
import '@wangeditor/editor/dist/css/style.css';
import { Editor, Toolbar } from '@wangeditor/editor-for-react';
import { Button, Card, Col, Form, List, Row, Select, Tag, message, Mentions } from 'antd';
import { wsPost, wsGet } from '@models/BaseModel';
import { ListItemDataType, fakeList } from '../../List';
import { LikeOutlined, LoadingOutlined, MessageOutlined, StarOutlined } from '@ant-design/icons';
import ArticleListContent from '../../ArticleListContent/index';
import './style.less';
import closeImg from '../../../../image/close.svg';
// import { createToolbar } from '@wangeditor/editor/dist/editor/src';
import { position, offset } from 'caret-pos';
import { IDomEditor, DomEditor, IModalMenu, SlateNode, Boot } from '@wangeditor/editor';
import mentionModule, { MentionElement } from '@wangeditor/plugin-mention';
import PersonModal from './personModal';
// Extend menuconst IconText = ({ type, text }) => {switch (type) {case 'star-o':return (<span><StarOutlined style={{ marginRight: 8 }} />{text}</span>);case 'like-o':return (<span><LikeOutlined style={{ marginRight: 8 }} />{text}</span>);case 'message':return (<span><MessageOutlined style={{ marginRight: 8 }} />{text}</span>);default:return null;}
};const Comments = forwardRef((props, CommentRef) => {const [editor, setEditor] = useState(null); // 存储 editor 实例const [html, setHtml] = useState();const [loading, setLoading] = useState(true);const [commentVis, setCommentVis] = useState(false);const [commentParentId, setCommentParentId] = useState('0'); //父级idconst [messageApi, contextHolder] = message.useMessage();const [buttonLoading, setButtonLoading] = useState(false);const [personList, setPersonList] = useState([]); //人员const [isModalVisible, setIsModalVisible] = useState(false);const formRef = useRef();// const toolbar = DomEditor.getToolbar(editor)// const curToolbarConfig = toolbar.getConfig()// console.log( curToolbarConfig.toolbarKeys )useImperativeHandle(CommentRef, () => ({closeHand: () => {if (editor == null) return;setCommentVis(false);editor.clear();setEditor(null);},}));const withAttachment = editor => {const { isInline, isVoid } = editor;const newEditor = editor;newEditor.isInline = elem => {const type = DomEditor.getNodeType(elem);if (type === 'attachment') return true; // 针对 type: attachment ,设置为 inlinereturn isInline(elem);};return newEditor;};useEffect(() => {console.log(props.dataList, props.type, 'nbsp');}, [props.dataList]);useEffect(() => {Boot.registerPlugin(withAttachment);Boot.registerModule(mentionModule);wsGet({url: '/api/problem/getUsers',handler: res => {const { code, data, msg } = res;switch (code) {case 20000: {setPersonList(data);break;}default:message.error(msg);break;}},});}, []);const toolbarConfig = {toolbarKeys: ['bold','underline','italic',// 'emotion',{key: 'group-image', // 必填,要以 group 开头title: '图片', // 必填iconSvg:'<svg viewBox="0 0 1024 1024"><path d="M959.877 128l0.123 0.123v767.775l-0.123 0.122H64.102l-0.122-0.122V128.123l0.122-0.123h895.775zM960 64H64C28.795 64 0 92.795 0 128v768c0 35.205 28.795 64 64 64h896c35.205 0 64-28.795 64-64V128c0-35.205-28.795-64-64-64zM832 288.01c0 53.023-42.988 96.01-96.01 96.01s-96.01-42.987-96.01-96.01S682.967 192 735.99 192 832 234.988 832 288.01zM896 832H128V704l224.01-384 256 320h64l224.01-192z"></path></svg>', // 可选menuKeys: ['uploadImage'], // 下级菜单 key ,必填},{key: 'group-video', // 必填,要以 group 开头title: '视频', // 必填iconSvg:'<svg viewBox="0 0 1024 1024"><path d="M981.184 160.096C837.568 139.456 678.848 128 512 128S186.432 139.456 42.816 160.096C15.296 267.808 0 386.848 0 512s15.264 244.16 42.816 351.904C186.464 884.544 345.152 896 512 896s325.568-11.456 469.184-32.096C1008.704 756.192 1024 637.152 1024 512s-15.264-244.16-42.816-351.904zM384 704V320l320 192-320 192z"></path></svg>', // 可选menuKeys: ['uploadVideo'], // 下级菜单 key ,必填},'codeBlock',],};const editorConfig = {placeholder: '请输入内容...',MENU_CONF: {uploadImage: {server: '/api/problem/uploadimag',fieldName: 'files',maxFileSize: 20 * 1024 * 1024,meta: {ifToken: '1',},metaWithUrl: true,headers: {token: localStorage.getItem('X-Auth-Token'),},onBeforeUpload() {setButtonLoading(true);message.loading({content: '上传中',duration: 0,});},onSuccess(file, res) {setButtonLoading(false);message.destroy();console.log(`${file.name} 上传成功`, res);},onError(file, err, res) {// console.log(`${file.name} 上传出错`, err, res)message.error(res.msg);},customInsert(res, insertFn) {console.log(res);// 从 res 中找到 url alt href ,然后插入图片insertFn(res.data[0].filePath, res.data[0].fileName, res.data[0].filePath);},},uploadVideo: {server: '/api/problem/uploadimag',fieldName: 'files',maxFileSize: 200 * 1024 * 1024,meta: {ifToken: '1',},metaWithUrl: true,headers: {token: localStorage.getItem('X-Auth-Token'),},timeout: 15 * 1000,onBeforeUpload() {console.log(messageApi, 'shipinzou');setButtonLoading(true);message.loading({content: '上传中',duration: 0,});},onSuccess(file, res) {setButtonLoading(false);message.destroy();console.log(`${file.name} 上传成功`, res);},onError(file, err, res) {// console.log(`${file.name} 上传出错`, err, res)message.error(res.msg);},customInsert(res, insertFn) {console.log(res);// 从 res 中找到 url alt href ,然后插入图片insertFn(res.data[0].filePath, res.data[0].fileName, res.data[0].filePath);},},},EXTEND_CONF: {mentionConfig: {showModal, // 必须hideModal, // 必须},},};function showModal(editor) {// 获取光标位置,定位 modalconst domSelection = document.getSelection();const domRange = domSelection.getRangeAt(0);if (domRange == null) return;const selectionRect = domRange.getBoundingClientRect();// 获取编辑区域 DOM 节点的位置,以辅助定位const containerRect = editor.getEditableContainer().getBoundingClientRect();// 显示 modal 弹框,并定位// PS:modal 需要自定义,如 <div> 或 Vue React 组件setIsModalVisible(true);console.log(selectionRect, containerRect, '展示');// 当触发某事件(如点击一个按钮)时,插入 mention 节点}function insertMention(id, name) {const mentionNode = {type: 'mention', // 必须是 'mention'value: name, // 文本info: { id }, // 其他信息,自定义children: [{ text: '' }], // 必须有一个空 text 作为 children};editor.restoreSelection(); // 恢复选区editor.deleteBackward('character'); // 删除 '@'editor.insertNode(mentionNode); // 插入 mentioneditor.move(1); // 移动光标}function hideModal(editor) {setIsModalVisible(false);console.log(editor, '隐藏');// 隐藏 modal}// 及时销毁 editoruseEffect(() => {return () => {if (editor == null) return;editor.destroy();// editor.MENU_CONF['uploadImage'] =setEditor(null);};}, [editor]);function extractDataInfoValues(inputString) {const regex = /data-info="([^"]*)"/g;const dataInfoValues = [];let match;while ((match = regex.exec(inputString)) !== null) {const decodedValue = decodeURIComponent(match[1]);dataInfoValues.push(JSON.parse(decodedValue).id);}return dataInfoValues;}function handleText() {// console.log(editor.getHtml(), html, editor.getText(), 'sdsdsds');const ids = extractDataInfoValues(html);if (editor.isEmpty()) {message.error('内容不可为空');return;}let commentType = '';switch (props.type) {case '1':commentType = 'reason';break;case '2':commentType = 'tempProject';break;case '3':commentType = 'longProject';break;case '4':commentType = 'validateProject';break;case '5':commentType = 'validateSummary';break;case '6':commentType = 'reviewRecords';break;case '7':commentType = 'proConclution';break;}let param = {commentType: commentType,content: html,problemId: props.id,parentId: commentParentId,ids: ids,};wsPost({url: '/api/problem/insertComment',data: param,handler: res => {const { code, data, msg } = res;switch (code) {case 20000: {if (editor == null) return;editor.clear();setCommentVis(false);message.success('新增成功');props.getQuery();break;}default:message.error(msg);break;}},});}function extractContent(inputString, startSymbol, endSymbol) {const regex = new RegExp(`${startSymbol}(.*?)${endSymbol}(?!\\S)`, 'g');const matches = inputString.matchAll(regex);const result = Array.from(matches, match => match[1]);return result;}function printHtml() {if (editor == null) return;}const addCommpent = id => {setCommentParentId(id);setCommentVis(true);};const handleClose = () => {setCommentVis(false);editor.clear();setEditor(null);};const changeEditor = editor => {setHtml(editor.getHtml()), console.log(editor.getHtml(), editor.getText(), 'xiugai');};return (<><ButtonclassName="commontClass"style={{ position: 'absolute', right: '10px', top: '10px', zIndex: '2' }}type="primary"loading={buttonLoading}onClick={() => {addCommpent(0);}}>新增</Button><ArticleListContent data={props.dataList} addCommpent={addCommpent} />{commentVis && <div style={{ width: '100%', height: '350px' }} />}{commentVis && (<div id="editcontent" className="commontClass" style={{ border: '1px solid #ccc', zIndex: 100, marginTop: '15px', position: 'fixed', bottom: '0', width: 'calc(100vw - 250px)', minHeight: '300px' }}><div style={{ position: 'absolute', right: '10px', bottom: '10px', zIndex: 2 }}><Button type="primary" loading={buttonLoading} onClick={handleText}>发表</Button></div><div className="closeImg" onClick={handleClose}><img src={closeImg} alt="" /></div><Toolbar editor={editor} defaultConfig={toolbarConfig} mode="default" style={{ borderBottom: '1px solid #ccc' }} /><EditordefaultConfig={editorConfig}value={html}onCreated={setEditor}onChange={editor => {changeEditor(editor);}}mode="default"style={{ height: '300px' }}/>{isModalVisible && <PersonModal hideModal={hideModal} insertMention={insertMention}></PersonModal>}</div>)}{/* <div style={{ marginTop: '15px' }}>{html}</div> */}{/* 渲染html */}{/* <div dangerouslySetInnerHTML={{__html: `'<p>hello <strong>world</strong>.</p><p><img src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" alt="test" data-href="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" style="width: 30%;"/><img src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" alt="test" data-href="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" style=""/><img src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" alt="test" data-href="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" style=""/><img src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" alt="test" data-href="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" style=""/></p>'`}}></div> */}</>);
});export default Comments;

评论递归ArticleListContent,jsx

import { Avatar, List, Space, Card } from 'antd';
import React, { useEffect, useState } from 'react';
import moment from 'moment';
import './index.less';
import { fakeList } from '../List';
import { LikeOutlined, LoadingOutlined, MessageOutlined, StarOutlined } from '@ant-design/icons';const getMarginLeftNum = num => {return 30 * num;
};const GetContent = props => {const [loading, setLoading] = useState(false);const IconText = ({ icon, text, id, num }) => {if (num <= 1) {return (<Space><divclassName="commontClass"onClick={() => {props.addCommpent(id);}}>{React.createElement(icon)}{text}</div></Space>);}return <Space />;};console.log(props.num, 'props.num');return (<div>{props.item.map((o, index) => {return (<div key={index} style={{ marginLeft: getMarginLeftNum(props.num + 1) }}><Listsize="large"loading={loading}rowKey="id"itemLayout="vertical"dataSource={[o]}renderItem={item => (<List.Item key={o.id}><Card title={item.creator} bordered={false} extra={[<IconText icon={MessageOutlined} key="message" type="message" id={item.id} num={props.num} />]}><div className={'description'} dangerouslySetInnerHTML={{ __html: item.content }} /><div className={'extra'}><em>{moment(item.createDate).format('YYYY-MM-DD HH:mm')}</em></div></Card></List.Item>)}/>{o.children && <GetContent item={o.children} num={props.num + 1} addCommpent={props.addCommpent} />}</div>);})}</div>);
};const ArticleListContent = props => {const [loading, setLoading] = useState(false);const IconText = ({ icon, text, id }) => (<Space><divclassName="commontClass"onClick={() => {props.addCommpent(id);}}>{React.createElement(icon)}{text}</div></Space>);return (<div className={'listContent'} style={{ minHeight: '200px' }}>{!props.data && <div style={{ fontSize: '18px', fontWeight: '500', color: '#8d8989', display: 'flex', alignItems: 'center', justifyContent: 'center', paddingTop: '50px' }}>暂无内容</div>}{props.data &&props.data.map((item, index) => {item, 'item';if (!item.children) {return (<div key={index} className="commentItem"><Card><Listsize="large"loading={loading}rowKey="id"key={index}itemLayout="vertical"dataSource={[item]}renderItem={item => (<List.Item key={item.id}><Card title={item.creator} bordered={false} extra={[<IconText icon={MessageOutlined} key="message" type="message" id={item.id} />]}><div className={'description'} dangerouslySetInnerHTML={{ __html: item.content }} /><div className={'extra'}><em>{moment(item.createDate).format('YYYY-MM-DD HH:mm')}</em></div></Card></List.Item>)}/></Card></div>);}return (<div key={index} className="commentItem"><Card><Listsize="large"loading={loading}key={index}rowKey="id"itemLayout="vertical"dataSource={[item]}renderItem={item => (<List.Item key={item.id}><Card title={item.creator} bordered={false} extra={[<IconText icon={MessageOutlined} key="message" type="message" id={item.id} />]}><div className={'description'} dangerouslySetInnerHTML={{ __html: item.content }} /><div className={'extra'}><em>{moment(item.createDate).format('YYYY-MM-DD HH:mm')}</em></div></Card></List.Item>)}/>{item.children && <GetContent item={item.children} num={1} addCommpent={props.addCommpent} />}</Card></div>);})}</div>);
};export default ArticleListContent;

@功能自定义的组件 personModal.jsx

import { Modal, Form, Input, Select, message } from 'antd';
import { ModalForm, ProFormTextArea } from '@ant-design/pro-components';
import { wsPost, wsGet } from '@models/BaseModel';
import React, { ReactDOM, useEffect, useRef, useState } from 'react';
const { Option } = Select;export default function CsModal(props) {const selectRef = useRef();const [personList, setPersonList] = useState([]); //人员const [topPosition, setTopPosition] = useState('');const [leftPosition, setLeftPosition] = useState('');useEffect(() => {// 获取光标位置const domSelection = document.getSelection();const domRange = domSelection?.getRangeAt(0);if (domRange == null) return;const rect = document.getElementById('editcontent').getBoundingClientRect();const rect1 = domRange.getBoundingClientRect();// // 定位 modalconsole.log(rect, rect1, 'top left');setTopPosition(`${rect1.top - rect.top - 5}px`);setLeftPosition(`${rect1.left - rect.left + 10}px`);// focus inputselectRef.current.focus();wsGet({url: '/api/problem/getUsers',handler: res => {const { code, data, msg } = res;switch (code) {case 20000: {setPersonList(data);break;}default:message.error(msg);break;}},});}, []);const onChangeSelect = e => {let name = personList.find(item => item.externalId === e);props.insertMention(e, name.name);props.hideModal();};return (<Selectref={selectRef}showSearchallowClearplaceholder="请选择提出人"style={{ width: '150px', position: 'absolute', top: topPosition, left: leftPosition }}optionFilterProp="children"filterOption={(input, option) => option?.children?.toLowerCase().indexOf(input?.toLowerCase()) >= 0}filterSort={(optionA, optionB) => {return optionA?.children?.toLowerCase().localeCompare(optionB?.children?.toLowerCase());}}onChange={onChangeSelect}>{personList.length > 0 &&personList.map(item => {return (<Option key={item.externalId} value={item.externalId}>{item.name}</Option>);})}</Select>);
}

实现效果
评论的效果

@的效果

相关文章:

react利用wangEditor写评论和@功能

先引入wangeditor写评论功能 import React, { useEffect, useState, useRef, forwardRef, useImperativeHandle } from react; import wangeditor/editor/dist/css/style.css; import { Editor, Toolbar } from wangeditor/editor-for-react; import { Button, Card, Col, For…...

Android之布局转圆角

Android之布局转圆角 文章目录 Android之布局转圆角说明一、效果图二、实现步骤1.自定义RoundRelativeLayout2.使用 总结 说明 很多需求比较无语&#xff0c;需要某个布局转圆角&#xff0c;像个显眼包一样&#xff0c;所以为了满足显眼包&#xff0c;必须整呐提示&#xff1a…...

Linux的目录结构特点

Linux的目录结构特点 1、使用树形目录结构来组织和管理文件。 2、整个系统只有一个根目录&#xff08;树根&#xff09;&#xff0c;Linux的根目录用“/”表示。 3、其他所有分区以及外部设备&#xff08;如硬盘&#xff0c;光驱等&#xff09;都是以根目录为起点&#xff0…...

【算法与数据结构】654、LeetCode最大二叉树

文章目录 一、题目二、解法三、完整代码 所有的LeetCode题解索引&#xff0c;可以看这篇文章——【算法和数据结构】LeetCode题解。 一、题目 二、解法 思路分析&#xff1a;【算法与数据结构】106、LeetCode从中序与后序遍历序列构造二叉树这两道题有些类似&#xff0c;相关代…...

您必须尝试的 4 种经典特征提取技术!

一、说明 特征提取如何实现&#xff1f;其手段并不是很多&#xff0c;有四个基本方法&#xff0c;作为AI工程师不能不知。因此&#xff0c;本篇将对四种特征提取给出系统的方法。 二、概述 图像分类长期以来一直是计算机视觉领域的热门话题&#xff0c;并希望能够保持这种状态。…...

Unity中Shader的遮罩的实现

文章目录 前言一、遮罩效果的实现主要是使用对应的纹理实现的&#xff0c;在属性中暴露对应的遮罩纹理&#xff0c;对其进行采样后&#xff0c;最后相乘输出即可二、如果需要像和主要纹理一样流动&#xff0c;则需要使用和_Time篇一样的方法实现流动即可 前言 Unity中Shader的…...

架构师成长之路|Redis key过期清除策略

Eviction policies maxmemory 100mb 当我们设置的内存达到指定的内存量时,清除策略的配置方式决定了默认行为。Redis可以为可能导致使用更多内存的命令返回错误,也可以在每次添加新数据时清除一些旧数据以返回到指定的限制。 当达到最大内存限制时,Redis所遵循的确切行为是…...

ubuntu20.04使用privoxy进行http代理转http代理,并定制http代理头(hide-user-agent的使用方法)

#sudo apt-get update;sudo apt install -y privoxy #sudo apt remove privoxyprivoxy --version; rootfv-az1239-825:/tmp# privoxy --version Privoxy version 3.0.28 (https://www.privoxy.org/) rootfv-az1239-825:/tmp# 安装完毕后,先停止服务,修改配置文件,再启动服…...

任意文件读取

文章目录 渗透测试漏洞原理任意文件读取1. 任意文件读取概述1.1 漏洞成因1.2 漏洞危害1.3 漏洞分类1.4 任意文件读取1.4.1 文件读取1.4.2 任意文件读取1.4.3 权限问题 1.5 任意文件下载1.5.1 一般情况1.5.2 PHP实现1.5.3 任意文件下载 2. 任意文件读取攻防2.1 路径过滤2.1.1 过…...

微信小程序餐饮外卖系统设计与实现

摘 要 随着现在的“互联网”的不断发展。现在传统的餐饮业也朝着网络化的方向不断的发展。现在线上线下的方式来实现餐饮的获客渠道增加&#xff0c;可以更好地帮助餐饮企业实现更多、更广的获客需求&#xff0c;实现更好的餐饮销售。截止到2021年末&#xff0c;我国的外卖市场…...

一文速览嵌入式六大出口

嵌入式行业的前景确实十分广阔&#xff0c;并且在许多领域都发挥着重要作用。以下是一些关键点&#xff0c;说明嵌入式系统的发展潜力和前途&#xff1a; 1. 物联网&#xff08;IoT&#xff09;&#xff1a;嵌入式系统是实现智能家居、智能城市、智能工厂等物联网设备的核心。物…...

华为云云服务器评测 | 宝塔8.0镜像应用

目录 &#x1f352;写在前面 &#x1f352;产品优势 &#x1f352;购买服务器 &#x1f352;服务器配置 &#x1f352;登录宝塔页面 &#x1f990;博客主页&#xff1a;大虾好吃吗的博客 &#x1f990;专栏地址&#xff1a;闲谈专栏地址 写在前面 云耀云服务器L实例是新一代开箱…...

构建简单的Node.js HTTP服务器,发布公网远程访问的快速方法

文章目录 前言1.安装Node.js环境2.创建node.js服务3. 访问node.js 服务4.内网穿透4.1 安装配置cpolar内网穿透4.2 创建隧道映射本地端口 5.固定公网地址 前言 Node.js 是能够在服务器端运行 JavaScript 的开放源代码、跨平台运行环境。Node.js 由 OpenJS Foundation&#xff0…...

ModaHub魔搭社区:向量数据库产业的现状与技术挑战

I. 向量数据库的崛起 什么是向量数据库 在过去的一段时间里,向量数据库逐渐在数据库领域崭露头角。那么,什么是向量数据库呢?简单来说,向量数据库是一种专门设计用来处理向量数据的数据库。这些向量数据可以是物理测量、机器学习模型输出、地理空间数据等。向量数据库使用…...

pmp和软件高项哪个含金量高?

人们常将PMP和高项放在一起比较&#xff0c;因为这两种证书都适用于项目经理职位&#xff0c;它们有高达60%的知识点重合度。在决定考哪一种证书之前&#xff0c;人们常常会感到困惑。 下面看一下pmp和软考高项的差异。 发证机构不同 PMP(Project Management Professional)是…...

手把手教你用Vite构建第一个Vue3项目

写在前面 在之前的文章中写过“如何创建第一个vue项目”&#xff0c;但那篇文章写的是创建vue2的 项目。 传送门如何创建第一个vue项目 打开Vue.js官网:https://cn.vuejs.org/&#xff0c;我们会发现Vue 2 将于 2023 年 12 月 31 日停止维护 虽然Vue2的项目还不少&#xff0…...

美创科技获通信网络安全服务能力评定(应急响应一级)认证!

近日&#xff0c;中国通信企业协会公布通信网络安全服务能力评定2023年第一批获证企业名单。 美创科技获得应急响应一级资质&#xff0c;成为2023年第一批获证企业之一&#xff01; 通信网络安全服务能力评定是对通信网络安全服务单位从事通信网络安全服务综合能力的评定&#…...

计算机视觉与人工智能在医美人脸皮肤诊断方面的应用

一、人脸皮肤诊断方法 近年来&#xff0c;随着计算机技术和人工智能的不断发展&#xff0c;中医领域开始逐渐探索利用这些先进技术来辅助面诊和诊断。在皮肤望诊方面&#xff0c;也出现了一些现代研究&#xff0c;尝试通过图像分析技术和人工智能算法来客观化地获取皮肤相关的…...

RCU501 RMP201-8 KONGSBERG 分布式处理单元

RCU501 RMP201-8 KONGSBERG 分布式处理单元 AutoChief600使用直接安装在主机接线盒中的分布式处理单元。进出发动机的所有信号都在双冗余CAN线路(发动机总线)上传输。 所有不重要的传感器都可以与K-Chief 600报警和监控系统共享&#xff0c;只需要一个主机接口。这一原则大大…...

说说 MVCC 的工作原理?

分析&回答 多版本并发控制(MVCC) InnoDB的MVCC&#xff0c;是通过在每行记录后面保存两个隐藏的列来实现。这两个列&#xff0c;一个保存了行的创建时间&#xff0c;一个保存行的删除时间&#xff0c;并不是实际的时间&#xff0c;而是系统版本号。每开始一个新的事务&am…...

微信小程序请求接口返回的二维码(图片),本地工具和真机测试都能显示,上线之后不显示问题

请求后端接口返回的图片&#xff1a; 页面展示&#xff1a; 代码实现&#xff1a; :show-menu-by-longpress"true" 是长按保存图片 base64Code 是转为base64的地址 <image class"code" :src"base64Code" alt"" :show-menu-by-long…...

Python小知识 - 1. Python装饰器(decorator)

Python装饰器&#xff08;decorator&#xff09; Python装饰器是一个很有用的功能&#xff0c;它可以让我们在不修改原有代码的情况下&#xff0c;为已有的函数或类添加额外的功能。 常见的使用场景有&#xff1a; a. 函数缓存&#xff1a;对于一些计算量较大的函数&#xff0c…...

如何访问GitHub

1、手动修改hosts 1.1、查找到最新的GitHub的hosts信息 通过链接&#xff1a;https://raw.hellogithub.com/hosts 进行查找最新的GitHub的hosts信息 1.2、查找到hosts文件位置 先找到 hosts 文件的位置&#xff0c;不同操作系统&#xff0c;hosts 文件的存储位置也不同&…...

【广州华锐互动】智能变电站AR仿真实训系统大大提高培训的效率和质量

随着电力行业的不断发展&#xff0c;变电站的建设和运维变得越来越重要。传统的变电站运维培训方式存在着诸多问题&#xff0c;如难以真实模拟变电站运行环境、信息传递不及时、难以掌握实际操作技能等问题。而智能变电站AR仿真实训系统可以为变电站运维人员带来全新的培训方式…...

手写Mybatis:第11章-流程解耦,封装结果集处理器

文章目录 一、目标&#xff1a;结果集处理器二、设计&#xff1a;结果集处理器三、实现&#xff1a;结果集处理器3.1 工程结构3.2 结果集处理器关系图3.3 出参参数处理3.3.1 结果映射Map3.3.2 结果映射封装3.3.3 修改映射器语句类3.3.4 映射构建器助手3.3.5 语句构建器调用助手…...

金融风控数据分析-信用评分卡建模(附数据集下载地址)

本文引用自&#xff1a; 金融风控&#xff1a;信用评分卡建模流程 - 知乎 (zhihu.com) 在原文的基础上加上了一部分自己的理解&#xff0c;转载在CSDN上作为保留记录。 本文涉及到的数据集可直接从天池上面下载&#xff1a; Give Me Some Credit给我一些荣誉_数据集-阿里云…...

ceph对象三元素data、xattr、omap

这里有一个ceph的原则&#xff0c;就是所有存储的不管是块设备、对象存储、文件存储最后都转化成了底层的对象object&#xff0c;这个object包含3个元素data&#xff0c;xattr&#xff0c;omap。data是保存对象的数据&#xff0c;xattr是保存对象的扩展属性&#xff0c;每个对象…...

使用 BERT 进行文本分类 (03/3)

一、说明 在使用BERT&#xff08;2&#xff09;进行文本分类时&#xff0c;我们讨论了什么是PyTorch以及如何预处理我们的数据&#xff0c;以便可以使用BERT模型对其进行分析。在这篇文章中&#xff0c;我将向您展示如何训练分类器并对其进行评估。 二、准备数据的又一个步骤 …...

Leetcode Top 100 Liked Questions(序号236~347)

236. Lowest Common Ancestor of a Binary Tree 题意&#xff1a;二叉树&#xff0c;求最近公共祖先&#xff0c;All Node.val are unique. 我的思路 首先把每个节点的深度得到&#xff0c;之后不停向上&#xff0c;直到val相同&#xff0c;存深度就用map存吧 但是它没有向…...

MySQL数据库学习【基础篇】

&#x1f4c3;基础篇 下方链接使用科学上网速度可能会更加快一点哦&#xff01; 请点击查看数据库MySQL笔记大全 通用语法及分类 DDL: 数据定义语言&#xff0c;用来定义数据库对象&#xff08;数据库、表、字段&#xff09;DML: 数据操作语言&#xff0c;用来对数据库表中的…...