react利用wangEditor写评论和@功能

news2024/7/4 6:15:30

先引入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 menu

const 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'); //父级id
    const [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 ,设置为 inline
            return 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) {
        // 获取光标位置,定位 modal
        const 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); // 插入 mention
        editor.move(1); // 移动光标
    }
    function hideModal(editor) {
        setIsModalVisible(false);
        console.log(editor, '隐藏');
        // 隐藏 modal
    }
    // 及时销毁 editor
    useEffect(() => {
        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 (
        <>
            <Button
                className="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' }} />
                    <Editor
                        defaultConfig={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>
                    <div
                        className="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) }}>
                        <List
                            size="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>
            <div
                className="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>
                                    <List
                                        size="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>
                                <List
                                    size="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();

        // // 定位 modal
        console.log(rect, rect1, 'top left');
        setTopPosition(`${rect1.top - rect.top - 5}px`);
        setLeftPosition(`${rect1.left - rect.left + 10}px`);
        // focus input
        selectRef.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 (
        <Select
            ref={selectRef}
            showSearch
            allowClear
            placeholder="请选择提出人"
            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>
    );
}

实现效果
评论的效果

@的效果

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

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

相关文章

IPv6网络实验:地址自动生成与全球单播通信探索

文章目录 一、实验背景与目的二、实验拓扑三、实验需求四、实验解法1. 在R1和PC3上开启IPv6链路本地地址自动生成&#xff0c;测试是否能够使用链路本地地址互通2. 为R1配置全球单播地址2001::1/64&#xff0c;使PC3能够自动生成与R1同一网段的IPv6地址3. 测试R1和PC3是否能够使…

动力学约束下的运动规划算法——Hybrid A*算法(附程序实现及详细解释)

前言&#xff08;推荐读一下&#xff09; 本文主要介绍动力学约束下的运动规划算法中非常经典的Hybrid A*算法&#xff0c;大致分为三部分&#xff0c;第一部分是在传统A * 算法的基础上&#xff0c;对Hybrid A * 算法的原理、流程进行理论介绍。第二部分是详细分析 MotionPl…

[C++]vector使用和模拟实现

&#x1f941;作者&#xff1a; 华丞臧 &#x1f4d5;​​​​专栏&#xff1a;【C】 各位读者老爷如果觉得博主写的不错&#xff0c;请诸位多多支持(点赞收藏关注)。如果有错误的地方&#xff0c;欢迎在评论区指出。 推荐一款刷题网站 &#x1f449;LeetCode 文章目录 一、vec…

什么是Flex容器和Flex项目(Flex Container and Flex Item)?它们之间有什么关系?

聚沙成塔每天进步一点点 ⭐ 专栏简介⭐ Flex容器和Flex项目⭐ Flex容器⭐ Flex项目⭐ 关系⭐ 写在最后 ⭐ 专栏简介 前端入门之旅&#xff1a;探索Web开发的奇妙世界 记得点击上方或者右侧链接订阅本专栏哦 几何带你启航前端之旅 欢迎来到前端入门之旅&#xff01;这个专栏是为…

OpenCV: cv2.findContours - ValueError: too many values to unpack

OpenCV找轮廓findContours报错 ValueError: not enough values to unpack (expected 3,got 2) 问题指向这行代码&#x1f447; binary, cnts, hierarchy cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE ) 报错的意思是需要3个返回值但只给了两…

【C++】快速排序的学习和介绍

前言 本篇文章我们先会学习快速排序这个算法&#xff0c;之后我们会学习sort这个函数 分治算法 在学习快速排序之前&#xff0c;我们先来学习一下分治算法&#xff0c;快速排序就是分治算法的一种&#xff0c;下面是分治算法的介绍&#xff0c; 分治算法&#xff0c;就是”…

设计模式-迭代器

文章目录 1. 引言1.1 概述1.2 设计模式1.3 迭代器模式的应用场景1.4 迭代器模式的作用 2. 基本概念2.1 迭代器 Iterator2.2 聚合 Aggregate2.3 具体聚合 ConcreteAggregate 3. Java 实现迭代器模式3.1 Java 集合框架3.2 Java 迭代器接口3.3 Java 迭代器模式实现示例 4. 迭代器模…

ESP32系列ESP32-D0WD双模BLE4.2+2.4G WIFI SoC芯片

目录 ESP32系列简介ESP32系列SoC功能框图ESP32-D0WD-V3芯片特性 ESP32系列SoC对比 ESP32系列简介 ESP32-DU1906和ESP32-DU1906-U两款AI模组&#xff0c;是基于ESP32-D0WD-V3芯片和语音芯片DU1906设计&#xff0c;集Wi-Fi、 传统蓝牙、低功耗蓝牙性能&#xff0c;以及音频语音处…

11.添加侧边栏,并导入数据

修改CommonAside的代码&#xff1a; <template><div><el-menu default-active"1-4-1" class"el-menu-vertical-demo" open"handleOpen" close"handleClose":collapse"isCollapse"><!--<el-menu-it…

管理类联考——逻辑——形式逻辑——汇总篇——知识点突破——假言——各种假言

角度 多重假言 &#xff08;1&#xff09;如果A&#xff0c;那么B&#xff0c;除非C。 符号化为&#xff1a;┐C→ (A→B)。 等价于&#xff1a;┐C→ (┐A∨B)。 等价于&#xff1a;C∨(┐A∨B)。 等价于&#xff1a;C∨┐A∨B。 等价于&#xff1a;┐(C∨┐A&#xff09;→…

K8S自动化运维容器化(Docker)集群程序

K8S自动化运维容器化集群程序 一、K8S概述1.什么是K8S2.为什么要用K8S3.作用及功能 二、K8S的特性1.弹性伸缩2.自我修复3.服务发现和复制均衡4.自动发布和回滚5.集中化配置管理和秘钥管理6.存储编排7.任务批量处理运行 三、K8S的集群架构1.架构2.模式3.工作4.流程图 四、K8S的核…

电子电路原理题目整理(2)

半导体是一种既不是导体也不是绝缘体的材料&#xff0c;其中包含自由电子和空穴&#xff0c;空穴的存在使半导体具有特殊的性质。 1.为什么铜是电的良导体&#xff1f; 从原子结构来看&#xff0c;铜原子的价带轨道上有一个价电子&#xff0c;由于核心和价电子之间的吸引力很弱…

【zookeeper】zookeeper的shell操作

Zookeeper的shell操作 本章节将分享一些zookeeper客服端的一些命令&#xff0c;实验操作有助于理解zookeeper的数据结构。 Zookeeper命令工具 在前一章的基础上&#xff0c;在启动Zookeeper服务之后&#xff0c;输入以下命令&#xff0c;连接到Zookeeper服务。连接成功之后&…

Shell - 根据进程名过滤进程信息

文章目录 #/bin/bash #Function: 根据输入的程序的名字过滤出所对应的PID&#xff0c;并显示出详细信息&#xff0c;如果有几个PID&#xff0c;则全部显示 read -p "请输入要查询的进程名&#xff1a;" NAME Nps -aux | grep $NAME | grep -v grep | wc -l ##统计进程…

go学习part20(1)反射

283_尚硅谷_反射基本介绍和示意图_哔哩哔哩_bilibili 1.介绍 1&#xff09;基本数据类型的类型和类别一致&#xff0c;但是结构体等不一样。 2)反射的例子&#xff08;桥连接&#xff0c;序列化&#xff09; 序列化指定tag&#xff0c;会反射生成tag字符串 3&#xff09;refl…

【Alibaba中间件技术系列】「RocketMQ技术专题」RocketMQ消息发送的全部流程和落盘原理分析

RocketMQ目前在国内应该是比较流行的MQ 了&#xff0c;目前本人也在公司的项目中进行使用和研究&#xff0c;借着这个机会&#xff0c;分析一下RocketMQ 发送一条消息到存储一条消息的过程&#xff0c;这样会对以后大家分析和研究RocketMQ相关的问题有一定的帮助。 分析的总体…

如何增长LLM推理token,从直觉到数学

背景&#xff1a; 最近大模型输入上文长度增长技术点的研究很火。为何要增长token长度,为何大家如此热衷于增长输入token的长度呢&#xff1f;其实你如果是大模型比价频繁的使用者&#xff0c;这个问题应该不难回答。增长了输入token的长度&#xff0c;那需要多次出入才能得到…

【LeetCode】383. 赎金信 - hashmap/数组

这里写自定义目录标题 2023-8-28 22:54:39 383. 赎金信 2023-8-28 22:54:39 次数 ----> hashmap 和 数组来进行实现。 public class Solution {public boolean canConstruct(String ransomNote, String magazine) {// num 用于存储小写字母出现的次数int[] num new in…

vue报错RangeError: Maximum call stack size exceeded

这种情况&#xff0c;一般是跳转路由时发生此类错误&#xff0c;像我的就是如此。比如路由指向的vue文件里代码有错误&#xff0c;或者设置路由时重定向了路由自己&#xff0c;造成死循环。 1、首先检查自己跳转的路由地址的代码本身是否有语法错误之类的&#xff0c;造成错误…

如何实现的手机实景自动直播,都有哪些功能呢?

手机实景自动直播最近真的太火了&#xff0c;全程只需要一部手机&#xff0c;就能完成24小时直播带货&#xff0c;不需要真人出镜&#xff0c;不需要场地&#xff0c;不需要搭建直播间&#xff0c;只需要一部手机就可以了。真人语音讲解&#xff0c;真人智能回复&#xff0c;实…