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

element tree树形结构默认展开全部

背景:

el-tree树形结构,默认展开全部,使用属性default-expand-all【是否默认展开所有节点】;默认展开一级,设置default-expanded-keys【默认展开的节点的 key 的数组】属性值为数组。

因为我这里的数据第一级是四川【省下面的所有市级】,所以只需要把四川的node-key="pid"的值找出,即四川为 51,赋值给default-expanded-keys,那么default-expanded-keys=[51]就实现的下面右图的效果。

效果展示:

左图:默认展开全部,右图:展开一级

核心代码:

//:default-expand-all = "true"默认展开全部
//:default-expanded-keys="[51]"默认展开四川<el-treestyle="max-width: 600px":data="state.ferryPortList":props="state.defaultProps"@node-click="handleNodeClick"node-key="pid":default-expand-all = "true"/>

官网链接:点击跳转

写到这儿变完成了。。。以下是el-tree组件的一些属性说明:

一、el-tree组件的属性

 el-tree的属性及其含义:

:data="state.ferryPortList"

展示数据

 :props="state.defaultProps"

配置选项

defaultProps: {label: "name",value: "pid",},

node-key="pid" 

设置node-key属性,每个树节点用来作为唯一标识的属性,整棵树应该是唯一的。

例如:node-key="id" 或 node-key="pid" 

:default-expand-all = "true"

是否默认展开所有节点

:default-expanded-keys="state.expandedKeys" 

默认展开的节点的 key 的数组

 示例数据:

接口数据结构,一维数组:

//示例数据结构,对象数组,一维数组[{pid: 0,parentId: -1,name: "全部",type: -1,count: null,visible: null,geom: null,ferryPortAreaVos: [],portShipVoList: null,},{pid: 51,parentId: 0,name: "四川 (24)",type: 0,count: 24,visible: null,geom: "0101000000F7CC920035045A40BE839F3880923E40",ferryPortAreaVos: [],portShipVoList: null,},{pid: 5113,parentId: 51,name: "南充 (24)",type: 1,count: 24,visible: null,geom: "01010000000DE02D90A0845A40CFF753E3A5CB3E40",ferryPortAreaVos: [],portShipVoList: null,},{pid: 511302,parentId: 5113,name: "顺庆",type: 2,count: 0,visible: null,geom: "01010000000DE02D90A0845A40CFF753E3A5CB3E40",ferryPortAreaVos: [],portShipVoList: null,},{pid: 511303,parentId: 5113,name: "高坪",type: 2,count: 0,visible: null,geom: "0101000000B37BF2B050875A40F4FDD478E9C63E40",ferryPortAreaVos: [],portShipVoList: null,},{pid: 511304,parentId: 5113,name: "嘉陵",type: 2,count: 0,visible: null,geom: "0101000000C898BB9690835A40E17A14AE47C13E40",ferryPortAreaVos: [],portShipVoList: null,},{pid: 511321,parentId: 5113,name: "南部 (17)",type: 2,count: 17,visible: null,geom: "0101000000575BB1BFEC825A40643BDF4F8D573F40",ferryPortAreaVos: [{name: "仙家坟渡口",pid: 80,areaId: 511321,type: 100,ferryShipVoList: [],},{name: "太霞三岔河码头",pid: 78,areaId: 511321,type: 100,ferryShipVoList: [],},{name: "太霞乡西河码头",pid: 76,areaId: 511321,type: 100,ferryShipVoList: [],},{name: "富利镇宋家咀渡口(上)",pid: 70,areaId: 511321,type: 100,ferryShipVoList: [],},{name: "富利镇宋家咀渡口(下)",pid: 28,areaId: 511321,type: 100,ferryShipVoList: [{pid: 17,cname: null,name: "西充渡船",mmsi: null,carryPassengersNum: null,status: null,areaId: 511321,type: 101,speakerDto: null,},{pid: 29,cname: null,name: "富利渡船",mmsi: null,carryPassengersNum: null,status: null,areaId: 511321,type: 101,speakerDto: null,},],},{name: "李家岩渡口",pid: 79,areaId: 511321,type: 100,ferryShipVoList: [],},{name: "杨家洞渡口",pid: 74,areaId: 511321,type: 100,ferryShipVoList: [],},{name: "楠木镇泸溪场渡口(上)",pid: 67,areaId: 511321,type: 100,ferryShipVoList: [],},{name: "楠木镇泸溪场渡口(下)",pid: 71,areaId: 511321,type: 100,ferryShipVoList: [],},{name: "江石岭渡口",pid: 85,areaId: 511321,type: 100,ferryShipVoList: [],},{name: "河口上渡口",pid: 83,areaId: 511321,type: 100,ferryShipVoList: [],},{name: "观音岩渡口(上)",pid: 69,areaId: 511321,type: 100,ferryShipVoList: [],},{name: "观音岩渡口(下)",pid: 66,areaId: 511321,type: 100,ferryShipVoList: [],},{name: "金鸡河渡口",pid: 81,areaId: 511321,type: 100,ferryShipVoList: [],},{name: "陈家口渡口",pid: 86,areaId: 511321,type: 100,ferryShipVoList: [],},{name: "鲁家坝渡口",pid: 82,areaId: 511321,type: 100,ferryShipVoList: [],},{name: "麻溪寺渡口",pid: 84,areaId: 511321,type: 100,ferryShipVoList: [],},],portShipVoList: null,},{pid: 511322,parentId: 5113,name: "营山",type: 2,count: 0,visible: null,geom: "01010000002A3A92CB7FA45A403333333333133F40",ferryPortAreaVos: [],portShipVoList: null,},{pid: 511323,parentId: 5113,name: "蓬安 (5)",type: 2,count: 5,visible: null,geom: "010100000048E17A14AE9B5A40BEC1172653053F40",ferryPortAreaVos: [{name: "八字老渡口上",pid: 64,areaId: 511323,type: 100,ferryShipVoList: [{pid: 51,cname: null,name: "川蓬安渡0012",mmsi: null,carryPassengersNum: null,status: null,areaId: 511323,type: 101,speakerDto: null,},{pid: 52,cname: null,name: "川蓬安渡0011",mmsi: null,carryPassengersNum: null,status: null,areaId: 511323,type: 101,speakerDto: null,},],},{name: "八字老渡口下",pid: 63,areaId: 511323,type: 100,ferryShipVoList: [{pid: 51,cname: null,name: "川蓬安渡0012",mmsi: null,carryPassengersNum: null,status: null,areaId: 511323,type: 101,speakerDto: null,},{pid: 52,cname: null,name: "川蓬安渡0011",mmsi: null,carryPassengersNum: null,status: null,areaId: 511323,type: 101,speakerDto: null,},],},{name: "八字老渡口下(对岸)",pid: 68,areaId: 511323,type: 100,ferryShipVoList: [{pid: 51,cname: null,name: "川蓬安渡0012",mmsi: null,carryPassengersNum: null,status: null,areaId: 511323,type: 101,speakerDto: null,},],},{name: "史家坝渡口",pid: 62,areaId: 511323,type: 100,ferryShipVoList: [],},{name: "金坡梁村渡口",pid: 61,areaId: 511323,type: 100,ferryShipVoList: [{pid: 50,cname: null,name: "川蓬安客0050",mmsi: null,carryPassengersNum: null,status: null,areaId: 511323,type: 101,speakerDto: null,},],},],portShipVoList: null,},{pid: 511324,parentId: 5113,name: "仪陇",type: 2,count: 0,visible: null,geom: "01010000000C022B8716995A404A0C022B87863F40",ferryPortAreaVos: [],portShipVoList: null,},{pid: 511325,parentId: 5113,name: "西充",type: 2,count: 0,visible: null,geom: "01010000003108AC1C5A785A408FC2F5285CFF3E40",ferryPortAreaVos: [],portShipVoList: null,},{pid: 511381,parentId: 5113,name: "阆中 (2)",type: 2,count: 2,visible: null,geom: "010100000051DA1B7C617E5A400000000000903F40",ferryPortAreaVos: [{name: "犀牛渡口",pid: 59,areaId: 511381,type: 100,ferryShipVoList: [{pid: 49,cname: null,name: "川阆中渡0020",mmsi: null,carryPassengersNum: null,status: null,areaId: 511381,type: 101,speakerDto: null,},],},{name: "鞍子湾渡口",pid: 58,areaId: 511381,type: 100,ferryShipVoList: [{pid: 49,cname: null,name: "川阆中渡0020",mmsi: null,carryPassengersNum: null,status: null,areaId: 511381,type: 101,speakerDto: null,},],},],portShipVoList: null,},];

数据处理后,多维数组:

树形结构绑定的:data是经过处理之后的值,例如以下:

[{"pid": 51,"parentId": 0,"name": "四川 (24)","type": 0,"count": 24,"visible": null,"geom": "0101000000F7CC920035045A40BE839F3880923E40","ferryPortAreaVos": [],"portShipVoList": null,"children": [{"pid": 5113,"parentId": 51,"name": "南充 (24)","type": 1,"count": 24,"visible": null,"geom": "01010000000DE02D90A0845A40CFF753E3A5CB3E40","ferryPortAreaVos": [],"portShipVoList": null,"children": [{"pid": 511302,"parentId": 5113,"name": "顺庆","type": 2,"count": 0,"visible": null,"geom": "01010000000DE02D90A0845A40CFF753E3A5CB3E40","ferryPortAreaVos": [],"portShipVoList": null,"children": []},{"pid": 511303,"parentId": 5113,"name": "高坪","type": 2,"count": 0,"visible": null,"geom": "0101000000B37BF2B050875A40F4FDD478E9C63E40","ferryPortAreaVos": [],"portShipVoList": null,"children": []},{"pid": 511304,"parentId": 5113,"name": "嘉陵","type": 2,"count": 0,"visible": null,"geom": "0101000000C898BB9690835A40E17A14AE47C13E40","ferryPortAreaVos": [],"portShipVoList": null,"children": []},{"pid": 511321,"parentId": 5113,"name": "南部 (17)","type": 2,"count": 17,"visible": null,"geom": "0101000000575BB1BFEC825A40643BDF4F8D573F40","ferryPortAreaVos": [{"name": "仙家坟渡口","pid": 80,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "太霞三岔河码头","pid": 78,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "太霞乡西河码头","pid": 76,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "富利镇宋家咀渡口(上)","pid": 70,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "富利镇宋家咀渡口(下)","pid": 28,"areaId": 511321,"type": 100,"ferryShipVoList": [{"pid": 17,"cname": null,"name": "西充渡船","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511321,"type": 101,"speakerDto": null},{"pid": 29,"cname": null,"name": "富利渡船","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511321,"type": 101,"speakerDto": null}]},{"name": "李家岩渡口","pid": 79,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "杨家洞渡口","pid": 74,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "楠木镇泸溪场渡口(上)","pid": 67,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "楠木镇泸溪场渡口(下)","pid": 71,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "江石岭渡口","pid": 85,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "河口上渡口","pid": 83,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "观音岩渡口(上)","pid": 69,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "观音岩渡口(下)","pid": 66,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "金鸡河渡口","pid": 81,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "陈家口渡口","pid": 86,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "鲁家坝渡口","pid": 82,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "麻溪寺渡口","pid": 84,"areaId": 511321,"type": 100,"ferryShipVoList": []}],"portShipVoList": null,"children": [{"name": "仙家坟渡口","pid": 80,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "太霞三岔河码头","pid": 78,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "太霞乡西河码头","pid": 76,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "富利镇宋家咀渡口(上)","pid": 70,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "富利镇宋家咀渡口(下)","pid": 28,"areaId": 511321,"type": 100,"ferryShipVoList": [{"pid": 17,"cname": null,"name": "西充渡船","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511321,"type": 101,"speakerDto": null},{"pid": 29,"cname": null,"name": "富利渡船","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511321,"type": 101,"speakerDto": null}]},{"name": "李家岩渡口","pid": 79,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "杨家洞渡口","pid": 74,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "楠木镇泸溪场渡口(上)","pid": 67,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "楠木镇泸溪场渡口(下)","pid": 71,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "江石岭渡口","pid": 85,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "河口上渡口","pid": 83,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "观音岩渡口(上)","pid": 69,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "观音岩渡口(下)","pid": 66,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "金鸡河渡口","pid": 81,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "陈家口渡口","pid": 86,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "鲁家坝渡口","pid": 82,"areaId": 511321,"type": 100,"ferryShipVoList": []},{"name": "麻溪寺渡口","pid": 84,"areaId": 511321,"type": 100,"ferryShipVoList": []}]},{"pid": 511322,"parentId": 5113,"name": "营山","type": 2,"count": 0,"visible": null,"geom": "01010000002A3A92CB7FA45A403333333333133F40","ferryPortAreaVos": [],"portShipVoList": null,"children": []},{"pid": 511323,"parentId": 5113,"name": "蓬安 (5)","type": 2,"count": 5,"visible": null,"geom": "010100000048E17A14AE9B5A40BEC1172653053F40","ferryPortAreaVos": [{"name": "八字老渡口上","pid": 64,"areaId": 511323,"type": 100,"ferryShipVoList": [{"pid": 51,"cname": null,"name": "川蓬安渡0012","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511323,"type": 101,"speakerDto": null},{"pid": 52,"cname": null,"name": "川蓬安渡0011","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511323,"type": 101,"speakerDto": null}]},{"name": "八字老渡口下","pid": 63,"areaId": 511323,"type": 100,"ferryShipVoList": [{"pid": 51,"cname": null,"name": "川蓬安渡0012","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511323,"type": 101,"speakerDto": null},{"pid": 52,"cname": null,"name": "川蓬安渡0011","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511323,"type": 101,"speakerDto": null}]},{"name": "八字老渡口下(对岸)","pid": 68,"areaId": 511323,"type": 100,"ferryShipVoList": [{"pid": 51,"cname": null,"name": "川蓬安渡0012","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511323,"type": 101,"speakerDto": null}]},{"name": "史家坝渡口","pid": 62,"areaId": 511323,"type": 100,"ferryShipVoList": []},{"name": "金坡梁村渡口","pid": 61,"areaId": 511323,"type": 100,"ferryShipVoList": [{"pid": 50,"cname": null,"name": "川蓬安客0050","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511323,"type": 101,"speakerDto": null}]}],"portShipVoList": null,"children": [{"name": "八字老渡口上","pid": 64,"areaId": 511323,"type": 100,"ferryShipVoList": [{"pid": 51,"cname": null,"name": "川蓬安渡0012","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511323,"type": 101,"speakerDto": null},{"pid": 52,"cname": null,"name": "川蓬安渡0011","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511323,"type": 101,"speakerDto": null}]},{"name": "八字老渡口下","pid": 63,"areaId": 511323,"type": 100,"ferryShipVoList": [{"pid": 51,"cname": null,"name": "川蓬安渡0012","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511323,"type": 101,"speakerDto": null},{"pid": 52,"cname": null,"name": "川蓬安渡0011","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511323,"type": 101,"speakerDto": null}]},{"name": "八字老渡口下(对岸)","pid": 68,"areaId": 511323,"type": 100,"ferryShipVoList": [{"pid": 51,"cname": null,"name": "川蓬安渡0012","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511323,"type": 101,"speakerDto": null}]},{"name": "史家坝渡口","pid": 62,"areaId": 511323,"type": 100,"ferryShipVoList": []},{"name": "金坡梁村渡口","pid": 61,"areaId": 511323,"type": 100,"ferryShipVoList": [{"pid": 50,"cname": null,"name": "川蓬安客0050","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511323,"type": 101,"speakerDto": null}]}]},{"pid": 511324,"parentId": 5113,"name": "仪陇","type": 2,"count": 0,"visible": null,"geom": "01010000000C022B8716995A404A0C022B87863F40","ferryPortAreaVos": [],"portShipVoList": null,"children": []},{"pid": 511325,"parentId": 5113,"name": "西充","type": 2,"count": 0,"visible": null,"geom": "01010000003108AC1C5A785A408FC2F5285CFF3E40","ferryPortAreaVos": [],"portShipVoList": null,"children": []},{"pid": 511381,"parentId": 5113,"name": "阆中 (2)","type": 2,"count": 2,"visible": null,"geom": "010100000051DA1B7C617E5A400000000000903F40","ferryPortAreaVos": [{"name": "犀牛渡口","pid": 59,"areaId": 511381,"type": 100,"ferryShipVoList": [{"pid": 49,"cname": null,"name": "川阆中渡0020","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511381,"type": 101,"speakerDto": null}]},{"name": "鞍子湾渡口","pid": 58,"areaId": 511381,"type": 100,"ferryShipVoList": [{"pid": 49,"cname": null,"name": "川阆中渡0020","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511381,"type": 101,"speakerDto": null}]}],"portShipVoList": null,"children": [{"name": "犀牛渡口","pid": 59,"areaId": 511381,"type": 100,"ferryShipVoList": [{"pid": 49,"cname": null,"name": "川阆中渡0020","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511381,"type": 101,"speakerDto": null}]},{"name": "鞍子湾渡口","pid": 58,"areaId": 511381,"type": 100,"ferryShipVoList": [{"pid": 49,"cname": null,"name": "川阆中渡0020","mmsi": null,"carryPassengersNum": null,"status": null,"areaId": 511381,"type": 101,"speakerDto": null}]}]}]}]}
]

多维数组,绑定给树结构。。。 

封装方法:

对接口的数据进行处理,把平面数组转树形结构:

/*** 平面数组转树形结构* @param data 平面数组* @param pid 树节点元素的id* @param idKey id字段* @param pidKey pid字段* @param sortKey 可选,排序字段* @returns {*[]}*/
export function arrayToTreeRec({data, pid = 0, idKey = 'id', pidKey = 'parent_id', sortKey = ''}) {const map = {};let tree = [];const d = JSON.parse(JSON.stringify(data))for (const item of d) {map[item[idKey]] = {...item, children: item.ferryPortAreaVos && item.ferryPortAreaVos.length ? item.ferryPortAreaVos : []};}for (const item of Object.values(map)) {if (item[pidKey] === pid) {tree.push(item);} else {map[item[pidKey]].children.push(item);if (sortKey) {map[item[pidKey]].children = map[item[pidKey]].children.sort((a, b) => a[sortKey] - b[sortKey])}}}if (sortKey) tree = tree.sort((a, b) => a[sortKey] - b[sortKey])return tree
}

相关文章:

element tree树形结构默认展开全部

背景&#xff1a; el-tree树形结构&#xff0c;默认展开全部&#xff0c;使用属性default-expand-all【是否默认展开所有节点】&#xff1b;默认展开一级&#xff0c;设置default-expanded-keys【默认展开的节点的 key 的数组】属性值为数组。 因为我这里的数据第一级是四川【省…...

统计登录系统10秒内连续登录失败超过3次的用户

为防止暴力破解用户账号的行为&#xff0c;在输入账号和密码时一般都会限制用户尝试密码输出错误的次数&#xff0c;如果用户多次输错密码后&#xff0c;将在一段时间内锁定账号&#xff0c;常见的有银行类APP、个税App等应用&#xff0c;如下是用户账号密码输入错误的提示图&a…...

音视频软件工程师面试题

一、基础知识 编解码相关 H.264 和 H.265(HEVC)的主要区别是什么?视频编解码的基本流程是什么?关键技术有哪些?音频编解码(如 AAC、MP3、Opus)的区别和应用场景?什么是 B 帧、P 帧、I 帧?它们的作用是什么? 流媒体协议RTMP、HTTP-FLV、HLS、WebRTC 的区别和应用场景…...

架构师面试(十四):注册中心设计

问题 大家或多或少都接触过【注册中心】&#xff0c;对注册中心的基本功能&#xff0c;如&#xff1a;服务注册、服务发现、健康检查和变更通知 &#xff0c;肯定是耳熟能详的&#xff1b;那么大家对注册中心的架构设计是否了解呢&#xff1f; 如果让你负责设计一个分布式的注…...

ctf-web: php原生类利用 -- GHCTF Popppppp

源代码 <?php error_reporting(0); class CherryBlossom { public $fruit1; public $fruit2; public function __construct($a) {$this->fruit1 $a; } function __destruct() { echo $this->fruit1; } public function __toString() { $newFunc …...

「Unity3D」UGUI将元素固定在,距离屏幕边缘的某个比例,以及保持元素自身比例

在不同分辨率的屏幕下&#xff0c;UI元素按照自身像素大小&#xff0c;会发生位置与比例的变化&#xff0c;本文仅利用锚点&#xff08;Anchors&#xff09;使用&#xff0c;来实现UI元素&#xff0c;固定在某个比例距离的屏幕边缘。 首先&#xff0c;将元素的锚点设置为中心&…...

nextjs15简要介绍以及配置eslint和prettier

目录 一、Next.js 何时使用服务器端渲染&#xff08;SSR&#xff09;&#xff1f;何时使用静态生成&#xff08;SSG&#xff09;&#xff1f; 1、服务器端渲染&#xff08;SSR - getServerSideProps&#xff09; 2、 静态生成&#xff08;SSG - getStaticProps&#xff09; …...

存储过程和自定义函数在银行信贷业务中的应用(oracle)

数据校验和清洗 例如&#xff0c;检查客户的年龄是否在合理范围内&#xff0c;贷款金额是否符合规定的上下限等。 对于不符合规则的数据&#xff0c;可以进行清洗和修正。比如&#xff0c;将空值替换为默认值&#xff0c;或者对错误的数据进行纠正。 CREATE OR REPLACE PROC…...

基于Ollama平台部署的Qwen大模型实现聊天机器人

文章目录 基于Ollama平台部署的Qwen大模型实现聊天机器人1 概述2 技术栈2.1 开发技术2.2 环境 3 技术架构4 实现步骤4.1 环境搭建4.1.1 WSL配置及Ubuntu安装4.1.2 Ollama安装及模型部署 4.2 模块安装4.2.1 安装Streamlit 1.42.24.2.2 安装requests 2.32.34.2.3 安装ollama 0.4.…...

在 JDK 1.8 的 ConcurrentHashMap 中,为什么存在两种插入方式?

在 JDK 1.8 的 ConcurrentHashMap 中&#xff0c;之所以对“容器为空”和“计算位置为空”采取不同的处理方式&#xff0c;主要是因为 并发场景下的性能优化和并发安全保证。我们可以分开来看这两种情况&#xff1a; 1. 容器为空时&#xff0c;使用 volatile CAS 初始化 原因…...

如何让powershell的界面变成全屏显示?

刚打开powershell&#xff0c;原来的样子&#xff1a; 全屏&#xff1a;可以按一下键盘上的alt enter 键&#xff0c;效果&#xff1a;...

语音识别踩坑记录

本来想在原来的语音识别的基础上增加本地扩展本地词典&#xff0c; 采用的语音识别是Vosk识别器&#xff0c;模型是 vosk-model-small-cn-0.22 // 初始化Vosk识别器 if (recognizer null) {using (Model model new Model(modelPath)){string grammar "{""…...

图片查看器:用PyQt5实现本地图片预览工具

通过python代码&#xff0c;基于PyQt5实现本地图片预览查看工具。 我们对窗口进行了圆角设计&#xff0c;图片的翻页按钮半透明处理&#xff0c;当鼠标移动至按钮上的动画效果&#xff0c;当选择某一张图片&#xff0c;进行左右翻页则轮播同目录所有支持的图片格式。 import …...

Deepin通过二进制方式升级部署高版本 Docker

一、背景&#xff1a; 在Deepin系统中通过二进制方式升级部署高版本 Docker&#xff0c;下面将详细介绍二进制方式升级部署高版本 Docker 的具体步骤。 二、操作步骤 1.根据需求下载二进制文件&#xff0c;下载地址如下&#xff1a; https://mirrors.tuna.tsinghua.e…...

车架号VIN查询 API 接口用JAVA如何调用?

以下是车架号VIN查询 API 接口用JAVA如何调用的示例代码&#xff1a; package com.shuxun.data.impl.demo;import com.shuxun.common.core.util.HttpUtil; import org.apache.commons.codec.digest.DigestUtils;import java.util.HashMap; import java.util.Map;public class …...

Vulnhub 靶机 VulnOSv2 write up opendocman cms 32075 sql注入 账号密码 ssh连接 37292.c 脏牛提权

Vulnhub 靶机 VulnOSv2 write up opendocman cms 32075 sql注入 账号密码 ssh连接 37292.c 脏牛提权 一、信息收集 1、首先拿到靶场先扫一下ip arp-scan -l 3、 2、指纹扫描 nmap -sS -sV 192.168.66.178nmap -p- -sV -A 192.168.66.253 PORT STATE SERVICE VERSION 22…...

爬虫的精准识别:基于 User-Agent 的正则实现

&#x1f9d1; 博主简介&#xff1a;CSDN博客专家&#xff0c;历代文学网&#xff08;PC端可以访问&#xff1a;https://literature.sinhy.com/#/?__c1000&#xff0c;移动端可微信小程序搜索“历代文学”&#xff09;总架构师&#xff0c;15年工作经验&#xff0c;精通Java编…...

Python数据分析之数据可视化

Python 数据分析重点知识点 本系列不同其他的知识点讲解&#xff0c;力求通过例子让新同学学习用法&#xff0c;帮助老同学快速回忆知识点 可视化系列&#xff1a; Python基础数据分析工具数据处理与分析数据可视化机器学习基础 四、数据可视化 图表类型与选择 根据数据特…...

【免费】2004-2020年各省货运量数据

2004-2020年各省货运量数据 1、时间&#xff1a;2004-2020年 2、来源&#xff1a;国家统计局、统计年鉴 3、指标&#xff1a;行政区划代码、地区、年份、货运量(万吨) 4、范围&#xff1a;31省 5、指标解释&#xff1a;货运量指在一定时期内&#xff0c;各种运输工具实际运…...

【CXX】6.6 UniquePtr<T> — std::unique_ptr<T>

std::unique_ptr 的 Rust 绑定称为 UniquePtr。有关 Rust API 的文档&#xff0c;请参见链接。 限制&#xff1a; 目前仅支持 std::unique_ptr<T, std::default_delete>。未来可能会支持自定义删除器。 UniquePtr 不支持 T 为不透明的 Rust 类型。对于在语言边界传递不…...

接口测试中缓存处理策略

在接口测试中&#xff0c;缓存处理策略是一个关键环节&#xff0c;直接影响测试结果的准确性和可靠性。合理的缓存处理策略能够确保测试环境的一致性&#xff0c;避免因缓存数据导致的测试偏差。以下是接口测试中常见的缓存处理策略及其详细说明&#xff1a; 一、缓存处理的核…...

Chapter03-Authentication vulnerabilities

文章目录 1. 身份验证简介1.1 What is authentication1.2 difference between authentication and authorization1.3 身份验证机制失效的原因1.4 身份验证机制失效的影响 2. 基于登录功能的漏洞2.1 密码爆破2.2 用户名枚举2.3 有缺陷的暴力破解防护2.3.1 如果用户登录尝试失败次…...

手游刚开服就被攻击怎么办?如何防御DDoS?

开服初期是手游最脆弱的阶段&#xff0c;极易成为DDoS攻击的目标。一旦遭遇攻击&#xff0c;可能导致服务器瘫痪、玩家流失&#xff0c;甚至造成巨大经济损失。本文为开发者提供一套简洁有效的应急与防御方案&#xff0c;帮助快速应对并构建长期防护体系。 一、遭遇攻击的紧急应…...

【配置 YOLOX 用于按目录分类的图片数据集】

现在的图标点选越来越多&#xff0c;如何一步解决&#xff0c;采用 YOLOX 目标检测模式则可以轻松解决 要在 YOLOX 中使用按目录分类的图片数据集&#xff08;每个目录代表一个类别&#xff0c;目录下是该类别的所有图片&#xff09;&#xff0c;你需要进行以下配置步骤&#x…...

工业自动化时代的精准装配革新:迁移科技3D视觉系统如何重塑机器人定位装配

AI3D视觉的工业赋能者 迁移科技成立于2017年&#xff0c;作为行业领先的3D工业相机及视觉系统供应商&#xff0c;累计完成数亿元融资。其核心技术覆盖硬件设计、算法优化及软件集成&#xff0c;通过稳定、易用、高回报的AI3D视觉系统&#xff0c;为汽车、新能源、金属制造等行…...

Java + Spring Boot + Mybatis 实现批量插入

在 Java 中使用 Spring Boot 和 MyBatis 实现批量插入可以通过以下步骤完成。这里提供两种常用方法&#xff1a;使用 MyBatis 的 <foreach> 标签和批处理模式&#xff08;ExecutorType.BATCH&#xff09;。 方法一&#xff1a;使用 XML 的 <foreach> 标签&#xff…...

嵌入式学习笔记DAY33(网络编程——TCP)

一、网络架构 C/S &#xff08;client/server 客户端/服务器&#xff09;&#xff1a;由客户端和服务器端两个部分组成。客户端通常是用户使用的应用程序&#xff0c;负责提供用户界面和交互逻辑 &#xff0c;接收用户输入&#xff0c;向服务器发送请求&#xff0c;并展示服务…...

动态 Web 开发技术入门篇

一、HTTP 协议核心 1.1 HTTP 基础 协议全称 &#xff1a;HyperText Transfer Protocol&#xff08;超文本传输协议&#xff09; 默认端口 &#xff1a;HTTP 使用 80 端口&#xff0c;HTTPS 使用 443 端口。 请求方法 &#xff1a; GET &#xff1a;用于获取资源&#xff0c;…...

C++.OpenGL (20/64)混合(Blending)

混合(Blending) 透明效果核心原理 #mermaid-svg-SWG0UzVfJms7Sm3e {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-SWG0UzVfJms7Sm3e .error-icon{fill:#552222;}#mermaid-svg-SWG0UzVfJms7Sm3e .error-text{fill…...

[ACTF2020 新生赛]Include 1(php://filter伪协议)

题目 做法 启动靶机&#xff0c;点进去 点进去 查看URL&#xff0c;有 ?fileflag.php说明存在文件包含&#xff0c;原理是php://filter 协议 当它与包含函数结合时&#xff0c;php://filter流会被当作php文件执行。 用php://filter加编码&#xff0c;能让PHP把文件内容…...