asp.net core + layui.js 搭建倉儲系統

  先放幾張網站圖片:css

 

  第一步先從layui 網站https://www.layui.com/doc/ 下載相關文件,複製到項目 wwwroot 目錄下:html

 

 

   

  而後在 _Layout.cshtml 中引用 layui.js 和 layui.css,以及添加左側欄和頭部佈局(具體操做見 : https://www.layui.com/doc/element/nav.html)ios

  後端框架:數據庫

  

 

  控制器經過依賴注入引用服務(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" }); }); } }

 

原文出處:https://www.cnblogs.com/afei-24/p/11592697.htmlcookie

相關文章
相關標籤/搜索