src/ZKEACMS/Common/Service/TemplateService.cs
(开头部分) 11KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
/* http://www.zkea.net/
* Copyright (c) ZKEASOFT. All rights reserved.
* http://www.zkea.net/licenses */
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.IO;
using ZKEACMS.Theme;
using ZKEACMS.Extend;
using Easy.Extend;
using ZKEACMS.Common.Models;
using Microsoft.AspNetCore.Hosting;
using Easy.RepositoryPattern;
using Easy.Cache;
using System.IO.Compression;
namespace ZKEACMS.Common.Service
{
public class TemplateService : ITemplateService
{
protected readonly IThemeService _themeService;
protected readonly IWebHostEnvironment _webHostEnvironment;
private const string _themeFolderName = "themes";
private const string _viewFolderName = "Views";
private const string _viewImportsFileName = "_ViewImports.cshtml";
private readonly string _templateFilesCacheKey = "TemplateFilesCacheKey";
private readonly ICacheManager<List<TemplateFile>> _cacheMgr;
public TemplateService(IWebHostEnvironment hostingEnvironment, IThemeService themeService, ICacheManager<List<TemplateFile>> cacheManager)
{
_webHostEnvironment = hostingEnvironment;
_themeService = themeService;
_cacheMgr = cacheManager;
}
public virtual string[] GetAvailableTemplates()
{
List<string> templates = new List<string>();
using (ZipArchive archive = ZipFile.OpenRead(Path.Combine(_webHostEnvironment.ContentRootPath, "Templates.zip")))
{
foreach (ZipArchiveEntry entry in archive.Entries)
{
int index = entry.Name.LastIndexOf('.');
templates.Add(entry.Name.Substring(0, index));
}
}
return templates.OrderBy(m => m).ToArray();
}
public virtual List<string> GetThemeNames()
{
List<string> list = new List<string>();
var themes = _themeService.GetAllThemes();
if (themes != null && themes.Count() > 0)
{
foreach (var item in themes)
{
string path = _webHostEnvironment.MapWebRootPath(_themeFolderName, item.ID);
if (ExtFile.ExistDirectory(path))
{
list.Add(item.ID);
后面还有 228 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。