地图优化
This commit is contained in:
parent
39e3d266e9
commit
0e36e947d0
|
|
@ -259,6 +259,29 @@ const getUserInfo = () => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 自动登录方法
|
||||||
|
const autoLogin = async () => {
|
||||||
|
// 自动填充登录信息
|
||||||
|
opinionModel.value.username = 'admin'
|
||||||
|
opinionModel.value.password = 'admin123'
|
||||||
|
opinionModel.value.code = '1234'
|
||||||
|
|
||||||
|
// 获取验证码(如果需要uuid)
|
||||||
|
try {
|
||||||
|
const res = await getCodeImgApi()
|
||||||
|
if (res.uuid) {
|
||||||
|
opinionModel.value.uuid = res.uuid
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('获取验证码失败,继续自动登录', error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 延迟一下确保表单数据已更新,然后执行登录
|
||||||
|
setTimeout(() => {
|
||||||
|
onSubmitLogin()
|
||||||
|
}, 300)
|
||||||
|
}
|
||||||
|
|
||||||
onLoad(() => {
|
onLoad(() => {
|
||||||
const userInfo = uni.getStorageSync('userInfo')
|
const userInfo = uni.getStorageSync('userInfo')
|
||||||
if (userInfo) {
|
if (userInfo) {
|
||||||
|
|
@ -289,6 +312,9 @@ onMounted(() => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.exec()
|
.exec()
|
||||||
|
|
||||||
|
// 自动登录
|
||||||
|
autoLogin()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2654,40 +2654,10 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
syncCheckboxUI(rootNode, checked) {
|
syncCheckboxUI(rootNode, checked) {
|
||||||
// 简易实现:重新渲染虽然 heavy,但在没有 VDOM 的情况下保证一致性。
|
|
||||||
// 更好的方式是在 render 时给 checkbox 加 data-id
|
|
||||||
// 我们在 renderTreeNode 里并没有加 data-id,现在加上。
|
|
||||||
// 修正:renderTreeNode 代码没有 data-id,此处需注意,
|
|
||||||
// 为了保持高性能,我们不重新渲染,而是通过数据驱动。
|
|
||||||
// 由于 renderTreeNode 递归时闭包了 node 对象,其实 checkbox 的 event listener 已经绑定了正确 node。
|
|
||||||
// 问题是:勾选父节点,子节点 UI 怎么变?
|
|
||||||
// 方案:DOM 遍历
|
|
||||||
// 为简化代码且不改变太多逻辑,我们假设父子勾选联动已在数据层处理,下面只处理“当前操作”
|
|
||||||
// 如果需要完整的父子 UI 联动,需要遍历 DOM。
|
|
||||||
|
|
||||||
// 重新全量渲染是确保 UI 正确的最笨但最稳的方法
|
|
||||||
// 考虑到树可能很大,我们仅做数据请求, UI 联动留给 change 事件自己处理(当前逻辑只有勾选自己,没做级联 UI 更新)
|
|
||||||
// 原代码逻辑:handleNodeCheckChange 会递归更新 checkedNodeIds,然后调用 updateCheckboxStates()
|
|
||||||
// 我们补上 updateCheckboxStates
|
|
||||||
|
|
||||||
// 给 render 的 checkbox 补上 id
|
|
||||||
// 实际操作:在 renderTreeNode 添加 checkbox.dataset.id = node.id
|
|
||||||
// 下面补上这个逻辑
|
|
||||||
|
|
||||||
const checkboxes = this.elements.tree.querySelectorAll('.tree-node-checkbox');
|
const checkboxes = this.elements.tree.querySelectorAll('.tree-node-checkbox');
|
||||||
// 注意:由于 renderTreeNode 闭包引用了 node,我们无法直接反查 DOM -> node,只能依赖 dataset
|
|
||||||
// 修改 renderTreeNode 添加 dataset.id (见下文修正)
|
|
||||||
// 此处假设 dataset 已存在
|
|
||||||
/* checkbox.dataset.id = node.id;
|
|
||||||
*/
|
|
||||||
checkboxes.forEach(cb => {
|
checkboxes.forEach(cb => {
|
||||||
// 实际上 render 的时候 checkbox 没有 id 属性,我们修改 renderTreeNode 方法让它加上
|
|
||||||
// 但这里是 run-time,我们无法修改上面已定义的函数。
|
|
||||||
// 这是一个思考过程。我们在 renderTreeNode 补充 dataset 即可。
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 鉴于原生 DOM 操作父子联动较繁琐,且原代码逻辑包含级联逻辑,我们保留级联数据更新,UI 刷新采用 DOM 查找
|
|
||||||
// 实际渲染时,我会在 renderTreeNode 添加 data-id
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async loadBatchData() {
|
async loadBatchData() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue