当前位置: 首页 > 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 类型。对于在语言边界传递不…...

KubeSphere 容器平台高可用:环境搭建与可视化操作指南

Linux_k8s篇 欢迎来到Linux的世界&#xff0c;看笔记好好学多敲多打&#xff0c;每个人都是大神&#xff01; 题目&#xff1a;KubeSphere 容器平台高可用&#xff1a;环境搭建与可视化操作指南 版本号: 1.0,0 作者: 老王要学习 日期: 2025.06.05 适用环境: Ubuntu22 文档说…...

Unity3D中Gfx.WaitForPresent优化方案

前言 在Unity中&#xff0c;Gfx.WaitForPresent占用CPU过高通常表示主线程在等待GPU完成渲染&#xff08;即CPU被阻塞&#xff09;&#xff0c;这表明存在GPU瓶颈或垂直同步/帧率设置问题。以下是系统的优化方案&#xff1a; 对惹&#xff0c;这里有一个游戏开发交流小组&…...

大型活动交通拥堵治理的视觉算法应用

大型活动下智慧交通的视觉分析应用 一、背景与挑战 大型活动&#xff08;如演唱会、马拉松赛事、高考中考等&#xff09;期间&#xff0c;城市交通面临瞬时人流车流激增、传统摄像头模糊、交通拥堵识别滞后等问题。以演唱会为例&#xff0c;暖城商圈曾因观众集中离场导致周边…...

LeetCode - 394. 字符串解码

题目 394. 字符串解码 - 力扣&#xff08;LeetCode&#xff09; 思路 使用两个栈&#xff1a;一个存储重复次数&#xff0c;一个存储字符串 遍历输入字符串&#xff1a; 数字处理&#xff1a;遇到数字时&#xff0c;累积计算重复次数左括号处理&#xff1a;保存当前状态&a…...

如何为服务器生成TLS证书

TLS&#xff08;Transport Layer Security&#xff09;证书是确保网络通信安全的重要手段&#xff0c;它通过加密技术保护传输的数据不被窃听和篡改。在服务器上配置TLS证书&#xff0c;可以使用户通过HTTPS协议安全地访问您的网站。本文将详细介绍如何在服务器上生成一个TLS证…...

在Ubuntu中设置开机自动运行(sudo)指令的指南

在Ubuntu系统中&#xff0c;有时需要在系统启动时自动执行某些命令&#xff0c;特别是需要 sudo权限的指令。为了实现这一功能&#xff0c;可以使用多种方法&#xff0c;包括编写Systemd服务、配置 rc.local文件或使用 cron任务计划。本文将详细介绍这些方法&#xff0c;并提供…...

【Web 进阶篇】优雅的接口设计:统一响应、全局异常处理与参数校验

系列回顾&#xff1a; 在上一篇中&#xff0c;我们成功地为应用集成了数据库&#xff0c;并使用 Spring Data JPA 实现了基本的 CRUD API。我们的应用现在能“记忆”数据了&#xff01;但是&#xff0c;如果你仔细审视那些 API&#xff0c;会发现它们还很“粗糙”&#xff1a;有…...

GitHub 趋势日报 (2025年06月08日)

&#x1f4ca; 由 TrendForge 系统生成 | &#x1f310; https://trendforge.devlive.org/ &#x1f310; 本日报中的项目描述已自动翻译为中文 &#x1f4c8; 今日获星趋势图 今日获星趋势图 884 cognee 566 dify 414 HumanSystemOptimization 414 omni-tools 321 note-gen …...

智能分布式爬虫的数据处理流水线优化:基于深度强化学习的数据质量控制

在数字化浪潮席卷全球的今天&#xff0c;数据已成为企业和研究机构的核心资产。智能分布式爬虫作为高效的数据采集工具&#xff0c;在大规模数据获取中发挥着关键作用。然而&#xff0c;传统的数据处理流水线在面对复杂多变的网络环境和海量异构数据时&#xff0c;常出现数据质…...

Java 二维码

Java 二维码 **技术&#xff1a;**谷歌 ZXing 实现 首先添加依赖 <!-- 二维码依赖 --><dependency><groupId>com.google.zxing</groupId><artifactId>core</artifactId><version>3.5.1</version></dependency><de…...