src/ZKEACMS/Common/Service/VideoWidgetService.cs

(完整代码) 1KB

/* http://www.zkea.net/ 
 * Copyright (c) ZKEASOFT. All rights reserved. 
 * http://www.zkea.net/licenses */

using System;
using Easy;
using Easy.Extend;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using ZKEACMS.Common.Models;
using ZKEACMS.Widget;

namespace ZKEACMS.Common.Service
{
    public class VideoWidgetService : WidgetService<VideoWidget>
    {
        public VideoWidgetService(IWidgetBasePartService widgetService, IApplicationContext applicationContext, CMSDbContext dbContext)
            : base(widgetService, applicationContext, dbContext)
        {
        }
        public override DbSet<VideoWidget> CurrentDbSet => DbContext.VideoWidget;

        public override object Display(WidgetDisplayContext widgetDisplayContext)
        {
            VideoWidget videoWidget = widgetDisplayContext.Widget as VideoWidget;
            if (!videoWidget.Height.HasValue)
            {
                videoWidget.Height = 400;
            }

            if (videoWidget.Code.IsNotNullAndWhiteSpace() &&
                videoWidget.Code.StartsWith("<iframe ", StringComparison.OrdinalIgnoreCase) &&
                videoWidget.Code.IndexOf("style", StringComparison.OrdinalIgnoreCase) < 0)
            {
                videoWidget.Code = "<iframe style=\"width:100%;height:100%\" " + videoWidget.Code.Substring(8);
            }
            return videoWidget;
        }
    }
}

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。