asp.net core + layui.js 搭建仓储系统
先放几张网站图片:
第一步先从layui 网站https://www.layui.com/doc/ 下载相关文件,复制到项目 wwwroot 目录下:
然后在 _Layout.cshtml 中引用 layui.js 和 layui.css,以及添加左侧栏和头部布局(具体操作见 : https://www.layui.com/doc/element/nav.html)
后端框架:
控制器通过依赖注入引用服务(asp.net core 默认支持)。
Startup.cs 配置数据库连接,Session(用于登录和菜单缓存),添加服务到服务容器。
public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMemoryCache(); services.AddSession(options => { options.IdleTimeout = TimeSpan.FromMinutes(10); }); services.Configure<CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(); services.AddMvc( options => { options.Filters.Add<HttpGlobalExceptionFilter>(); //加入全局异常类 }).SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddDbContext<AccessManagementContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"), providerOptions => providerOptions.EnableRetryOnFailure())); services.AddDbContext<LuJCDBContext>(options => options.UseSqlServer(Configuration["WMSConnectionStrings:DefaultConnection"], providerOptions => providerOptions.EnableRetryOnFailure())); services.AddTransient<CompanyServices, CompanyServices>(); services.AddTransient<BasicInfoServices, BasicInfoServices>(); services.AddTransient<AppMenuServices>(); services.AddTransient<IAccountServices,AccountServices>(); services.AddTransient<BranchServices>(); services.AddTransient<PresetFunctionServices>(); services.AddTransient<RoleServices>(); services.AddTransient<LocationServices>(); services.AddTransient<SupplierServices>(); services.AddTransient<CustomerServices>(); services.AddTransient<MeasureServices>(); services.AddTransient<ProductCategoryServices>(); services.AddTransient<ProductServices>(); services.AddTransient<InStorageServices>(); services.AddTransient<OutStorageServices>(); services.AddTransient<BadReportServices>(); services.AddTransient<CheckStockServices>(); services.AddTransient<LocalProductServices>(); //services.AddScoped<AddHeaderFilterWithDI>(); services.AddAutoMapper(typeof(Startup)); Mapper.Initialize(cfg => { cfg.AddProfile<AccessManagementProfile>(); } ); //Mapper.Initialize(cfg => cfg.CreateMap<AppMenu, AppMenuViewModel>()); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env,ILoggerFactory loggerFactory) { app.UseSession(); loggerFactory.AddNLog(); //添加NLog NLog.LogManager.LoadConfiguration("nlog.config"); app.UseLog(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseAuthentication(); app.UseHttpsRedirection(); app.UseStaticFiles(); var cookiePolicyOptions = new CookiePolicyOptions { MinimumSameSitePolicy = SameSiteMode.Strict, }; app.UseCookiePolicy(cookiePolicyOptions); app.UseAccountSession(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); routes.MapAreaRoute("IMS", "IMS", "IMS/{controller}/{action}/{id?}", defaults: new { Controller = "Location", Action = "Index" }); routes.MapAreaRoute("WMS", "WMS", "WMS/{controller}/{action}/{id?}", defaults: new { Controller = "InStorage", Action = "Index" }); routes.MapAreaRoute("Report", "Report", "Report/{controller}/{action}/{id?}", defaults: new { Controller = "LocalProduct", Action = "Index" }); }); } }
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析