Ejemplo n.º 1
0
        /// <summary>
        /// get notification container, if not existed it will create a new container
        /// </summary>
        /// <param name="placement"></param>
        /// <returns></returns>
        private async ValueTask <string> GetContainer(VantNotifyPlacement placement)
        {
            if (!_containerDict.ContainsKey(placement))
            {
                Dictionary <string, object> attributes = new Dictionary <string, object>();
                attributes.Add("IsRtl", _isRtl);
                attributes.Add("Top", _top);
                attributes.Add("Bottom", _bottom);
                attributes.Add("Placement", placement);

                RenderFragment renderFragment = (builder) =>
                {
                    builder.OpenComponent <AntNotification>(0);
                    builder.AddMultipleAttributes(1, attributes);
                    builder.CloseComponent();
                };
                string htmlStr = await RenderAsync(renderFragment);

                await _jsRuntime.InvokeVoidAsync(JSInteropConstants.createNotificationContaner, htmlStr);

                string placementStr = placement.ToString();
                placementStr = placementStr[0] == 'T'
                    ? "t" + placementStr.Substring(1)
                    : "b" + placementStr.Substring(1);
                string className = ".ant-notification.ant-notification-" + placementStr;

                _containerDict.Add(placement, className);
            }
            return(_containerDict[placement]);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 全局默认配置修改
        /// </summary>
        /// <param name="defaultConfig"></param>
        public void Config(
            [NotNull] VantNotifyGlobalConfig defaultConfig)
        {
            if (defaultConfig == null)
            {
                return;
            }

            if (defaultConfig.Bottom != null)
            {
                _bottom = defaultConfig.Bottom.Value;
            }
            if (defaultConfig.Top != null)
            {
                _top = defaultConfig.Top.Value;
            }
            if (defaultConfig.Rtl != null)
            {
                _isRtl = defaultConfig.Rtl.Value;
            }
            if (defaultConfig.Placement != null)
            {
                _defaultPlacement = defaultConfig.Placement.Value;
            }
            if (defaultConfig.Duration != null)
            {
                _defaultDuration = defaultConfig.Duration.Value;
            }
            if (defaultConfig.CloseIcon != null)
            {
                _defaultCloseIcon = defaultConfig.CloseIcon;
            }
        }