import { App } from 'vue';
|
import { isSharePage } from '../stores/chatRoom';
|
|
/** @description 分享界面是否展示当前页面 */
|
export default function shareDirective(app: App) {
|
// v-share=false,默认为 false
|
app.directive('share', {
|
mounted(el, binding) {
|
/** @description 默认分享状态隐藏 */
|
const isShow = binding.value ?? false;
|
if (isSharePage.value) {
|
!isShow && el.parentNode.removeChild(el);
|
} else {
|
/** @description 非分享状态,isShow 就是要删掉当前元素 */
|
isShow && el.parentNode.removeChild(el);
|
}
|
},
|
});
|
}
|