Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | import { reactive } from 'vue'
const state = reactive({
open: false,
moduleCode: '',
father: '',
showTree: true,
readonly: false,
initialCateId: '',
key: 0,
// 事件回调
onUploaded: null,
onDeleted: null,
onSelected: null,
})
let keyCounter = 0
/**
* 文件 Modal 命令式调用 composable。
*
* 用法:
* const fileModal = useFileModal();
* fileModal.open({ moduleCode: 'b_port', father: '123' });
*/
export function useFileModal() {
function open(opts) {
keyCounter++
state.key = keyCounter
state.moduleCode = opts.moduleCode || ''
state.father = String(opts.father ?? '')
state.showTree = opts.showTree !== false
state.readonly = opts.readonly || false
state.initialCateId = opts.initialCateId || ''
state.onUploaded = opts.onUploaded || null
state.onDeleted = opts.onDeleted || null
state.onSelected = opts.onSelected || null
state.open = true
}
function close() {
state.open = false
}
return { open, close, state }
}
|