asp.net core + layui.js 搭建仓储系统

  先放几张网站图片:

asp.net core + layui.js 搭建仓储系统_第1张图片

asp.net core + layui.js 搭建仓储系统_第2张图片

asp.net core + layui.js 搭建仓储系统_第3张图片

asp.net core + layui.js 搭建仓储系统_第4张图片

 

  第一步先从layui 网站https://www.layui.com/doc/ 下载相关文件,复制到项目 wwwroot 目录下:

asp.net core + layui.js 搭建仓储系统_第5张图片

 

 

   

  然后在 _Layout.cshtml 中引用 layui.js 和 layui.css,以及添加左侧栏和头部布局(具体操作见 : https://www.layui.com/doc/element/nav.html)

  后端框架:

  asp.net core + layui.js 搭建仓储系统_第6张图片

 

  控制器通过依赖注入引用服务(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(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(); //加入全局异常类
                }).SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
            services.AddDbContext(options =>
                options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"),
                providerOptions => providerOptions.EnableRetryOnFailure()));
            services.AddDbContext(options =>
                options.UseSqlServer(Configuration["WMSConnectionStrings:DefaultConnection"],
                providerOptions => providerOptions.EnableRetryOnFailure()));
            services.AddTransient();
            services.AddTransient();
            services.AddTransient();
            services.AddTransient();
            services.AddTransient();
            services.AddTransient();
            services.AddTransient();
            services.AddTransient();
            services.AddTransient();
            services.AddTransient();
            services.AddTransient();
            services.AddTransient();
            services.AddTransient();
            services.AddTransient();
            services.AddTransient(); 
            services.AddTransient();
            services.AddTransient();
            services.AddTransient();
            //services.AddScoped();
            services.AddAutoMapper(typeof(Startup));
            Mapper.Initialize(cfg =>
                {
                    cfg.AddProfile();
                }
            );
            //Mapper.Initialize(cfg => cfg.CreateMap());
        }

        // 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" });
            });
            
        }
    }

 

你可能感兴趣的:(asp.net core + layui.js 搭建仓储系统)