gerson
2025-01-21 da76b81ea4195d857642d9ef922b3715cdbff8cf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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);
            }
        },
    });
}