首页 > 其他分享 >一个练习项目,好玩的bbs-前端部分

一个练习项目,好玩的bbs-前端部分

时间:2024-06-21 15:33:12浏览次数:18  
标签:status bbs 前端 data msg datajson var jiekou 好玩

common.js

function setCookie(name, value, daysToLive = 7) {
    let cookie = name + "=" + encodeURIComponent(value);
    if (typeof daysToLive === "number") {
        cookie += "; max-age=" + (daysToLive*24*60*60); // max-age单位是秒
    }
    document.cookie = cookie;
}

function getCookie(name) {
    const cookies = document.cookie.split("; ");
    for (let i = 0; i < cookies.length; i++) {
        const [cookieName, cookieValue] = cookies[i].split("=");
        if (name === cookieName) {
            return decodeURIComponent(cookieValue);
        }
    }
    return "";
}

function deleteCookie(name) {
    setCookie(name, "", -1); // 设置为过去的时间即可删除
}

function gotoeditpost(contentId){
    window.location.href= "/postedit.html?id="+contentId;
}

function getlang(){
    var jiekou = '/api';
    $.get(jiekou+"/", function(data, status, request){
        if(status != "success"){
            layer.msg("访问接口["+jiekou+"]出错了,状态:"+status, {icon: 2});
        }
        console.log("接口:"+jiekou+",Server信息:"+request.getResponseHeader('Server'));
        $("#langInfo").html(data);
    });
}

function register(username, password, nickname){
    data = {}
    var jiekou = '/api/user/register';
    $.get(jiekou+"?username="+username+"&password="+password+"&nickname="+nickname, function(data, status, request){
        if(status != "success"){
            layer.msg("访问接口["+jiekou+"]出错了,状态:"+status, {icon: 2});
        }
        console.log("接口:"+jiekou+",Server信息:"+request.getResponseHeader('Server'));
        
        try{
            var datajson = JSON.parse(data);
        }
        catch{
            var datajson = data;
        }

        var msg = datajson.msg;
        if(msg){
            layer.msg(msg, {icon: 2});
            return false;
        }
        window.location.href= "/";
    });
}

function login(username, password){
    data = {}
    var jiekou = '/api/user/login';
    $.get(jiekou+"?username="+username+"&password="+password, function(data, status, request){
        if(status != "success"){
            layer.msg("访问接口["+jiekou+"]出错了,状态:"+status, {icon: 2});
        }
        console.log("接口:"+jiekou+",Server信息:"+request.getResponseHeader('Server'));
        
        try{
            var datajson = JSON.parse(data);
        }
        catch{
            var datajson = data;
        }

        var msg = datajson.msg;
        if(msg){
            layer.msg(msg, {icon: 2});
            return false;
        }
        var sessionId = datajson.data.sessionId;
        var userId = datajson.data.id;
        setCookie("sessionId", sessionId);
        setCookie("userId", userId);
        window.location.href= "/";
    });
}

function logout(){
    var sessionId = getCookie("sessionId");
    var jiekou = '/api/user/logout';
    $.get(jiekou+"?sessionId="+sessionId, function(data, status, request){
        if(status != "success"){
            layer.msg("访问接口["+jiekou+"]出错了,状态:"+status, {icon: 2});
        }
        console.log("接口:"+jiekou+",Server信息:"+request.getResponseHeader('Server'));
        
        try{
            var datajson = JSON.parse(data);
        }
        catch{
            var datajson = data;
        }

        var msg = datajson.msg;
        if(msg){
            layer.msg(msg, {icon: 2});
            return false;
        }
        
        deleteCookie("sessionId");
        deleteCookie("userId");
        window.location.href = "/";
        return true;
    });
}

function getuserinfo(){
    var sessionId = getCookie("sessionId");
    
    if(sessionId == ""){
        var mylocation = window.location.href;
        var flagtmp = mylocation.indexOf("userlogin.html");
        //console.log(mylocation);
        //console.log(flagtmp);
        if(flagtmp > 0){
            $("#nicknamespan").html("<a href='/'>返回首页</a>");
        }
        else{
            $("#nicknamespan").html("<a href='/userlogin.html'>登录</a> | <a href='/'>返回首页</a>");
        }
    }
    else{
        data = {}
        var jiekou = '/api/user/getuserinfo';
        $.get(jiekou+"?sessionId="+sessionId, function(data, status, request){
            if(status != "success"){
                layer.msg("访问接口["+jiekou+"]出错了,状态:"+status, {icon: 2});
            }
            console.log("接口:"+jiekou+",Server信息:"+request.getResponseHeader('Server'));
            
            try{
                var datajson = JSON.parse(data);
            }
            catch{
                var datajson = data;
            }
            
            var msg = datajson.msg;
            if(msg){
                layer.msg(msg, {icon: 2});
                $("#nicknamespan").html("<a href='/userlogin.html'>登录</a> | <a href='/'>返回首页</a>");
                return false;
            }
            var datatmp = datajson.data;
            if(!datatmp){
                layer.msg("返回数据为空,我次奥", {icon: 2});
                return false;
            }
            
            var userId = datajson.data.id;
            var nickname = datajson.data.nickname;
            setCookie("sessionId", sessionId);
            setCookie("userId", userId);
            $("#nicknamespan").html("登录用户:<font color=red>"+nickname+"</font> | <a href='javascript:logout();'>退出</a> | <a href='/'>返回首页</a>");
        });
    }
}

function getpostlist(page){
    var userId = getCookie("userId");
    data = {}
    var jiekou = '/api/post/list';
    $.get(jiekou+"?page="+page, function(data, status, request){
        if(status != "success"){
            layer.msg("访问接口["+jiekou+"]出错了,状态:"+status, {icon: 2});
        }
        console.log("接口:"+jiekou+",Server信息:"+request.getResponseHeader('Server'));
        
        try{
            var datajson = JSON.parse(data);
        }
        catch{
            var datajson = data;
        }

        var msg = datajson.msg;
        if(msg){
            layer.msg(msg, {icon: 2});
            return false;
        }
        var totalpage = datajson.data.totalpage;
        var data = datajson.data.data;
        
        $("#postlist").empty();
        var tmp = "";
        tmp += "<tr bgcolor=\"#CC9966\">\n";
        tmp += "<td width=\"5%\">序号</td>\n";
        tmp += "<td width=\"35%\">标题</td>\n";
        tmp += "<td width=\"20%\">发帖人</td>\n";
        tmp += "<td width=\"15%\">回复数</td>\n";
        tmp += "<td width=\"15%\">最后更新时间</td>\n";
        tmp += "<td width=\"10%\">操作</td>\n";
        tmp += "</tr>\n";
        $("#postlist").append(tmp);
        for(var i = 0; i < data.length; i++){
            var tmp = "";
            var bgcolor = i % 2 ? '#FFFAF4' : '#FFEEDD';
            tmp += "<tr bgcolor=\""+bgcolor+"\">\n";
            tmp += "<td>"+(i+1)+"</td>\n";
            tmp += "<td><a href='/postdetail.html?id="+data[i].id+"'>"+data[i].title+"</a></td>\n";
            tmp += "<td>"+data[i].userNickename+"</td>\n";
            tmp += "<td>"+data[i].replyNum+"</td>\n";
            tmp += "<td>"+data[i].updateTime+"</td>\n";
            if(userId == data[i].userId){
                tmp += "<td><a href='javascript:gotoeditpost("+data[i].id+")'>编辑</a> | <a href='javascript:if(confirm(\"是否要执行此操作?\")){delpost("+data[i].id+");}'>删除</a></td>\n";
            }
            else{
                tmp += "<td></td>\n";
            }
            tmp += "</tr>\n";
            $("#postlist").append(tmp);
        }
        
        $("#page").empty();
        $("#page").append("<a href='javascript:getpostlist(1)'>首页</a> ");
        for(var i = 1; i <= totalpage; i++){
            $("#page").append("<a href='javascript:getpostlist("+i+")'>"+i+"</a> ");
        }
        $("#page").append("<a href='javascript:getpostlist("+totalpage+")'>末页</a> ");
    });
}

function getpostdetail(id){
    var userId = getCookie("userId");
    var jiekou = '/api/post/detail';
    $.get(jiekou+"?id="+id, function(data, status, request){
        if(status != "success"){
            layer.msg("访问接口["+jiekou+"]出错了,状态:"+status, {icon: 2});
        }
        console.log("接口:"+jiekou+",Server信息:"+request.getResponseHeader('Server'));
        
        try{
            var datajson = JSON.parse(data);
        }
        catch{
            var datajson = data;
        }

        var msg = datajson.msg;
        if(msg){
            layer.msg(msg, {icon: 2});
            return false;
        }
        var datatmp = datajson.data;
        if(!datatmp){
            layer.msg("返回数据为空,我次奥", {icon: 2});
            return false;
        }
        
        $("#title").html(datajson.data.title);
        $("#content").html(datajson.data.content);
        
        if(userId != datajson.data.userId){
            $("#postedit").hide();
            $("#postdel").hide();
        }
        else{
            $("#postedit").show();
            $("#postdel").show();
        }
    })
}

function getpostedit(id){
    var userId = getCookie("userId");
    var jiekou = '/api/post/detail';
    $.get(jiekou+"?id="+id, function(data, status, request){
        if(status != "success"){
            layer.msg("访问接口["+jiekou+"]出错了,状态:"+status, {icon: 2});
        }
        console.log("接口:"+jiekou+",Server信息:"+request.getResponseHeader('Server'));
        
        try{
            var datajson = JSON.parse(data);
        }
        catch{
            var datajson = data;
        }

        var msg = datajson.msg;
        if(msg){
            layer.msg(msg, {icon: 2});
            return false;
        }
        var datatmp = datajson.data;
        if(!datatmp){
            layer.msg("返回数据为空,我次奥", {icon: 2});
            return false;
        }
        
        $("#title").val(datajson.data.title);
        $("#content").val(datajson.data.content);
        
        if(userId != datajson.data.userId){
            $("#postsend").hide();
        }
        else{
            $("#postsend").show();
        }
    })
}

function addpost(title, content){
    var sessionId = getCookie("sessionId");
    var jiekou = '/api/post/add';
    $.get(jiekou+"?title="+title+"&content="+content+"&sessionId=" + sessionId, function(data, status, request){
        if(status != "success"){
            layer.msg("访问接口["+jiekou+"]出错了,状态:"+status, {icon: 2});
        }
        console.log("接口:"+jiekou+",Server信息:"+request.getResponseHeader('Server'));
        
        try{
            var datajson = JSON.parse(data);
        }
        catch{
            var datajson = data;
        }

        var msg = datajson.msg;
        if(msg){
            layer.msg(msg, {icon: 2});
            return false;
        }
        
        window.location.href= "/";
    })
}

function editpost(title, content, id){
    var sessionId = getCookie("sessionId");
    var jiekou = '/api/post/edit';
    $.get(jiekou+"?id="+id+"&title="+title+"&content="+content+"&sessionId=" + sessionId, function(data, status, request){
        if(status != "success"){
            layer.msg("访问接口["+jiekou+"]出错了,状态:"+status, {icon: 2});
        }
        console.log("接口:"+jiekou+",Server信息:"+request.getResponseHeader('Server'));
        
        try{
            var datajson = JSON.parse(data);
        }
        catch{
            var datajson = data;
        }

        var msg = datajson.msg;
        if(msg){
            layer.msg(msg, {icon: 2});
            return false;
        }
        
        window.location.href= "/";
    })
}

function delpost(id){
    var sessionId = getCookie("sessionId");
    var jiekou = '/api/post/delete';
    $.get(jiekou+"?id="+id+"&sessionId=" + sessionId, function(data, status, request){
        if(status != "success"){
            layer.msg("访问接口["+jiekou+"]出错了,状态:"+status, {icon: 2});
        }
        console.log("接口:"+jiekou+",Server信息:"+request.getResponseHeader('Server'));
        
        try{
            var datajson = JSON.parse(data);
        }
        catch{
            var datajson = data;
        }

        var msg = datajson.msg;
        if(msg){
            layer.msg(msg, {icon: 2});
            return false;
        }
        
        window.location.href= "/";
    })
}

function getreplylist(page, contentId){
    var userId = getCookie("userId");
    data = {}
    var jiekou = '/api/reply/list';
    $.get(jiekou+"?contentId="+contentId+"&page="+page, function(data, status, request){
        if(status != "success"){
            layer.msg("访问接口["+jiekou+"]出错了,状态:"+status, {icon: 2});
        }
        console.log("接口:"+jiekou+",Server信息:"+request.getResponseHeader('Server'));
        
        try{
            var datajson = JSON.parse(data);
        }
        catch{
            var datajson = data;
        }

        var msg = datajson.msg;
        if(msg){
            layer.msg(msg, {icon: 2});
            return false;
        }
        var totalpage = datajson.data.totalpage;
        var data = datajson.data.data;
        
        $("#replylist").empty();
        var tmp = "";
        tmp += "<tr bgcolor=\"#CC9966\">\n";
        tmp += "<td width=\"5%\">序号</td>\n";
        tmp += "<td width=\"35%\">内容</td>\n";
        tmp += "<td width=\"20%\">回复人</td>\n";
        tmp += "<td width=\"20%\">回复时间</td>\n";
        tmp += "<td width=\"20%\">操作</td>\n";
        tmp += "</tr>\n";
        $("#replylist").append(tmp);
        for(var i = 0; i < data.length; i++){
            var tmp = "";
            var bgcolor = i % 2 ? '#FFFAF4' : '#FFEEDD';
            tmp += "<tr bgcolor=\""+bgcolor+"\">\n";
            tmp += "<td>"+(i+1)+"</td>\n";
            tmp += "<td>"+data[i].content+"</td>\n";
            tmp += "<td>"+data[i].replyUserNickename+"</td>\n";
            tmp += "<td>"+data[i].addTime+"</td>\n";
            if(userId == data[i].replyUserId){
                tmp += "<td><a href='javascript:editreply("+data[i].id+", \""+data[i].content+"\", "+contentId+")'>编辑</a> | <a href='javascript:delreply("+data[i].id+", "+contentId+")'>删除</a></td>\n";
            }
            else{
                tmp += "<td></td>\n";
            }
            tmp += "</tr>\n";
            $("#replylist").append(tmp);
        }
        
        $("#page").empty();
        $("#page").append("<a href='javascript:getreplylist(1, "+contentId+")'>首页</a> ");
        for(var i = 1; i <= totalpage; i++){
            $("#page").append("<a href='javascript:getreplylist("+i+", "+contentId+")'>"+i+"</a> ");
        }
        $("#page").append("<a href='javascript:getreplylist("+totalpage+", "+contentId+")'>末页</a> ");
    });
}

function addreply(content, contentId){
    var sessionId = getCookie("sessionId");
    if(content){
        var jiekou = '/api/reply/add';
        $.get(jiekou+"?contentId="+contentId+"&content="+content+"&sessionId=" + sessionId, function(data, status, request){
            if(status != "success"){
                layer.msg("访问接口["+jiekou+"]出错了,状态:"+status, {icon: 2});
            }
            console.log("接口:"+jiekou+",Server信息:"+request.getResponseHeader('Server'));
            
            try{
                var datajson = JSON.parse(data);
            }
            catch{
                var datajson = data;
            }

            var msg = datajson.msg;
            if(msg){
                layer.msg(msg, {icon: 2});
                return false;
            }
            
            window.location.href= "/postdetail.html?id="+contentId;
        })
    }
}

function editreply(replyId, content, contentId){
    var sessionId = getCookie("sessionId");
    var content = prompt("请输入回复", content);
    if(content){
        var jiekou = '/api/reply/edit';
        $.get(jiekou+"?id="+replyId+"&content="+content+"&sessionId=" + sessionId, function(data, status, request){
            if(status != "success"){
                layer.msg("访问接口["+jiekou+"]出错了,状态:"+status, {icon: 2});
            }
            console.log("接口:"+jiekou+",Server信息:"+request.getResponseHeader('Server'));
            
            try{
                var datajson = JSON.parse(data);
            }
            catch{
                var datajson = data;
            }

            var msg = datajson.msg;
            if(msg){
                layer.msg(msg, {icon: 2});
                return false;
            }
            
            window.location.href= "/postdetail.html?id="+contentId;
        })
    }
}

function delreply(replyId, contentId){
    if(confirm("是否要执行此操作?")){
        var sessionId = getCookie("sessionId");
        var jiekou = '/api/reply/delete';
        $.get(jiekou+"?id="+replyId+"&sessionId=" + sessionId, function(data, status, request){
            if(status != "success"){
                layer.msg("访问接口["+jiekou+"]出错了,状态:"+status, {icon: 2});
            }
            console.log("接口:"+jiekou+",Server信息:"+request.getResponseHeader('Server'));
            
            try{
                var datajson = JSON.parse(data);
            }
            catch{
                var datajson = data;
            }

            var msg = datajson.msg;
            if(msg){
                layer.msg(msg, {icon: 2});
                return false;
            }
            
            window.location.href= "/postdetail.html?id="+contentId;
        })
    }
}

 

postindex.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>BBS首页</title>
      <link rel="stylesheet" href="/layui/css/layui.css">
</head>

<body>

<span style="float:right;" id="nicknamespan">载入数据中...</span><br /><br />

<h2>帖子列表</h2>

<button id="postadd" style="display:none;">发布帖子</button>
<br /><br />

<table id="postlist" border="1" bordercolor="#003366" style="border-collapse:collapse;width:100%"><tr bgcolor="#FFFAF4"><td>载入数据中...</td></tr></table>
<br />

<div id="page"></div>
<br /><br />

<div style="text-align:center;" id="langInfo">载入数据中...</div>

</body>

<script src="/jquery.min.js"></script>
<script src="/layui/layui.js"></script>
<script src="/common.js?id=2"></script>
<script>
$(document).ready(function(){
    var userId = getCookie("userId");
    var page = 1;
    if(userId <= 0){
        $("#postadd").hide();
    }
    else{
        $("#postadd").show();
    }
    
    $("#postadd").click(function(){
        window.location.href= "/postadd.html";
    })
    
    getuserinfo();
    getpostlist(page);
    getlang();
});
</script>

</html>

 

postdetail.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>帖子详情</title>
      <link rel="stylesheet" href="/layui/css/layui.css">
</head>

<body>

<span style="float:right;" id="nicknamespan">载入数据中...</span><br /><br />

<b>主题:</b>
<span id="title" style="color:red;">载入数据中...</span>
<br /><br />

<b>内容:</b>
<div id="content">载入数据中...</div>
<br />

<button id="postedit" style="display:none;">编辑帖子</button>
<button id="postdel" style="display:none;">删除帖子</button>
<button id="replyadd" style="display:none;">回复帖子</button>
<br /><br />

<table id="replylist" border="1" bordercolor="#003366" style="border-collapse:collapse;width:100%"><tr bgcolor="#FFFAF4"><td>载入数据中...</td></tr></table>
<br />

<div id="page"></div><br />

<div style="text-align:center;" id="langInfo">载入数据中...</div>


</body>

<script src="/jquery.min.js"></script>
<script src="/layui/layui.js"></script>
<script src="/common.js?id=2"></script>
<script>
$(document).ready(function(){
    const params = new URLSearchParams(window.location.search);
    var contentId = params.get('id');
    var page = 1;
    
    getuserinfo();
    getlang();
    
    var userId = getCookie("userId");
    if(userId <= 0){
        $("#replyadd").hide();
    }
    else{
        $("#replyadd").show();
    }
    
    getpostdetail(contentId);
    getreplylist(page, contentId);
    

    $("#postedit").click(function(){
        window.location.href= "/postedit.html?id="+contentId;
    });
    
    $("#postdel").click(function(){
        if(confirm("是否要执行此操作?")){
            delpost(contentId);
        }
    });
    
    $("#replyadd").click(function(){
        var content = prompt("请输入回复", "");
        addreply(content, contentId);
    });
});
</script>

</html>

 

postadd.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>发帖</title>
      <link rel="stylesheet" href="/layui/css/layui.css">
</head>

<body>

<span style="float:right;" id="nicknamespan">载入数据中...</span><br /><br />

<b>主题:</b>
<input type="text" id="title" style="width:575px;" value="测试帖子">
<br /><br />

<b>内容:</b>
<textarea id="content" cols=70 rows=7>测试帖子内容</textarea>
<br /><br />

<button id="postsend" style="display:none;">发帖</button>
<br /><br />

<div style="text-align:center;" id="langInfo">载入数据中...</div>

</body>

<script src="/jquery.min.js"></script>
<script src="/layui/layui.js"></script>
<script src="/common.js?id=2"></script>
<script>
$(document).ready(function(){
    getuserinfo();
    getlang();
    
    var userId = getCookie("userId");
    if(userId <= 0){
        $("#postsend").hide();
    }
    else{
        $("#postsend").show();
    }
    
    $("#postsend").click(function(){
        var title = $("#title").val();
        var content = $("#content").val();
        addpost(title, content);
    })
});
</script>

</html>

 

postedit.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>编辑帖子</title>
      <link rel="stylesheet" href="/layui/css/layui.css">
</head>

<body>

<span style="float:right;" id="nicknamespan">载入数据中...</span><br /><br />

<b>主题:</b>
<input type="text" id="title" style="width:575px;" value="载入数据中...">
<br /><br />

<b>内容:</b>
<textarea id="content" cols=70 rows=7>载入数据中...</textarea>
<br /><br />

<button id="postsend" style="display:none;">编辑帖子</button>
<br /><br />

<div style="text-align:center;" id="langInfo">载入数据中...</div>

</body>

<script src="/jquery.min.js"></script>
<script src="/layui/layui.js"></script>
<script src="/common.js?id=2"></script>
<script>
$(document).ready(function(){
    const params = new URLSearchParams(window.location.search);
    var contentId = params.get('id');
    
    getuserinfo();
    getpostedit(contentId);
    getlang();
    
    $("#postsend").click(function(){
        var title = $("#title").val();
        var content = $("#content").val();
        editpost(title, content, contentId);
    })
});
</script>

</html>

 

userlogin.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>用户登录</title>
      <link rel="stylesheet" href="/layui/css/layui.css">
</head>

<body>

<span style="float:right;" id="nicknamespan">载入数据中...</span><br /><br />

用户名:<input type="text" id="username" value="root"><br />
密码:<input type="password" id="password" value="123456"><br />
<input type="button" id="loginbutton" value="登录">
<input type="button" id="registerbutton" value="注册">
<br /><br />

<div style="text-align:center;" id="langInfo">载入数据中...</div>

</body>

<script src="/jquery.min.js"></script>
<script src="/layui/layui.js"></script>
<script src="/common.js?id=2"></script>
<script>
$(document).ready(function(){
    $("#loginbutton").click(function(){
        var username = $("#username").val();
        var password = $("#password").val();
        login(username, password);
    })
    
    $("#registerbutton").click(function(){
        window.location.href= "/userregister.html";
    })
    
    getuserinfo();
    getlang();
});
</script>

</html>

 

userregister.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>用户注册</title>
      <link rel="stylesheet" href="/layui/css/layui.css">
</head>

<body>

<span style="float:right;" id="nicknamespan">载入数据中...</span><br /><br />

昵称:<input type="text" id="nickname" value="测试用户"><br />
用户名:<input type="text" id="username" value="test"><br />
密码:<input type="password" id="password" value="123456"><br />
<input type="button" id="registerbutton" value="注册">
<br /><br />

<div style="text-align:center;" id="langInfo">载入数据中...</div>

</body>

<script src="/jquery.min.js"></script>
<script src="/layui/layui.js"></script>
<script src="/common.js?id=2"></script>
<script>
$(document).ready(function(){
    $("#registerbutton").click(function(){
        var username = $("#username").val();
        var password = $("#password").val();
        var nickname = $("#nickname").val();
        register(username, password, nickname);
    })
    
    getuserinfo();
    getlang();
});
</script>

</html>

 

标签:status,bbs,前端,data,msg,datajson,var,jiekou,好玩
From: https://www.cnblogs.com/xuxiaobo/p/18260621

相关文章

  • 一个练习项目,好玩的bbs-java
    java这个我是用springboot做的目录结构   application.ymlspring:datasource:driver-class-name:com.mysql.cj.jdbc.Driverurl:jdbc:mysql://127.0.0.1:3306/my_bbs?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2b8&am......
  • 一个练习项目,好玩的bbs-c#
    c#代码:usingMySql.Data.MySqlClient;usingSystem.Data;usingNewtonsoft.Json;usingSystem.Security.Cryptography;usingSystem.Text;intpagesize=20;stringsecretKey="saacac3423@21212";varbuilder=WebApplication.CreateSlimBuilder(args......
  • 一个练习项目,好玩的bbs-1
    目录结构 nginx配置:upstreambbs_upstream{server127.0.0.1:1081;#phpserver127.0.0.1:1086;#csharpeserver127.0.0.1:1087;#javaserver127.0.0.1:1084;#ruby-sinatraserver127.0.0.1:1104;#ruby-busker......
  • Swagger文档渲染,将Filter过滤器中抛出的异常错误消息返回前端显示
    一、应用场景在swagger通过/v2/api-docs获取到后端接口数据后,使用过滤器对/v2/api-docs请求进行拦截,然后对获取到的数据进行处理,当在处理过程中对Filter过滤器中抛出的异常错误消息进行捕获,并将捕获到的异常错误消息返回到前端二、示例代码@OverridepublicvoiddoFilte......
  • Nginx部署Vue前端项目,部署多个Vue项目
    参考:https://blog.csdn.net/qq_33454884/article/details/89212702启动闪退:https://blog.csdn.net/weixin_66383346/article/details/1326221561.下载安装nginx 下载地址:https://nginx.org/en/download.html  windows版:nginx/Windows-1.27.0解压后必须放在没有中文,没有空格......
  • 前端实现生成条形码并下载
    一、生成条形码下载JsBarcode.js库在对应项目的终端中,输入如下代码,安装:npminstalljsbarcode--save在二维码生成的页面中引入:importJsBarcodefrom"jsbarcode";使用示例:<!--条形码生成的页面--><template><div><svgid="barcode"></svg><......
  • BaseHref 以及前端路由的问题
    BaseHref以及前端路由的问题BaseHref是什么?MDN,说的直白一点就是,这个站点里面所有的访问主站的资源文件,都会在路由前面加上这个basehref,包括*js,scss,image,ajax,......**。如果一个DOM里面有多个这样的base,只有第一个会起作用。BaseHref在Angular工程的编译中有......
  • 网页实现前端轮盘抽奖
    参考链接Luckydraw/index.htmlatmain·alltrue6/Luckydraw(github.com)实现结果如下 代码如下:创建了一个旋转抽奖盘,用户点击“开始抽奖”按钮后,抽奖盘会旋转并最终停止在一个随机的奖项上,并显示抽中的奖品。引入jQuery库:使用CDN引入jQuery库,方便后续进行DOM操作......
  • 前端面试题日常练-day78 【面试题】
    题目希望这些选择题能够帮助您进行前端面试的准备,答案在文末在Sass中,以下哪个功能用于创建一个循环?a)@extendb)@forc)@importd)@includeSass中的混合器(Mixins)可以包含以下哪些内容?a)样式规则b)变量c)函数d)注释在Sass中,以下哪个符号用于引用其他选择......
  • Java智慧工地源码 5G智慧工地系统源码 使用SAAS部署 三维可视化管理,与一线生产过程相
    Java智慧工地源码5G智慧工地系统源码使用SAAS部署三维可视化管理,与一线生产过程相融合,集成数据后台,统一前端入口,呈现多方项目信息;智慧工地是指运用信息化手段,通过三维设计平台对工程项目进行精确设计和施工模拟,围绕施工过程管理,建立互联协同、智能生产、科学管理的施工项......