UNPKG

sard-uniapp

Version:

sard-uniapp 是一套基于 Uniapp + Vue3 框架开发的兼容多端的 UI 组件库

37 lines (36 loc) 1.19 kB
import { defaultShareSheetProps, } from '../share-sheet/common'; import { defaultConfig } from '../config'; import { getAllImperatives, getAvailableImperative, getImperatives, } from '../../use'; export const defaultShareSheetAgentProps = () => ({ ...defaultShareSheetProps(), id: 'shareSheet', ...defaultConfig.shareSheetAgent, }); export const imperativeName = 'shareSheet'; const show = (options = {}) => { const { id = defaultShareSheetAgentProps().id } = options; const imperative = getAvailableImperative(imperativeName, id); if (imperative) { imperative.show(options); } }; const shareSheet = (options) => { show(options); }; const hide = (id = defaultShareSheetAgentProps().id) => { const imperatives = getImperatives(imperativeName, id); if (imperatives && imperatives.length > 0) { imperatives.forEach((item) => { item.imperative.hide(); }); } }; const hideAll = () => { const mapImperatives = getAllImperatives()[imperativeName]; if (mapImperatives) { Object.keys(mapImperatives).forEach(hide); } }; shareSheet.hide = hide; shareSheet.hideAll = hideAll; export { shareSheet };