7月10号总结 (1)

今天开始写web项目,画了一下登录界面,借鉴了一下网上的资源。

html 复制代码
<!DOCTYPE html>
<html lang="zh.CN">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录系统</title>
    <style>
      /* Flex布局实现垂直水平居中 */
      body {
        margin: 0;
        height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
        background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
        font-family: 'Arial', sans-serif;
      }

      .login-container {
        width: 350px;
        padding: 40px;
        background: white;
        border-radius: 10px;
        box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
        animation: fadeIn 0.5s ease;
      }

      @keyframes fadeIn {
        from { opacity: 0; transform: translateY(-20px); }
        to { opacity: 1; transform: translateY(0); }
      }

      h2 {
        text-align: center;
        margin-bottom: 30px;
      }

      .input-group{
        margin-bottom: 20px;
        position: relative;
      }

      input {
        width: 100%;
        padding: 12px 15px;
        border: 1px solid #ddd;
        border-radius: 5px;
        font-size: 16px;
        transition: border 0.3s;
      }

      input:focus {
        border-color: #4285f4;
        outline: none;
        box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.2);
      }

      label {
        position: absolute;
        left: 15px;
        top: 12px;
        color: #999;
        transition: all 0.3s;
        pointer-events: none;
      }

      input:focus + label,
      input:not(:placeholder-shown) + label {
        top: -10px;
        left: 10px;
        font-size: 12px;
        background: white;
        padding: 0 5px;
        color: #4285f4;
      }

      button {
        width: 100%;
        padding: 12px;
        background: #4285f4;
        color: white;
        border: none;
        border-radius: 5px;
        font-size: 16px;
        cursor: pointer;
        transition: background 0.3s;
      }
      button:hover {
        background: #3367d6;
      }

      .error-message {
        color: #d32f2f;
        font-size: 14px;
        margin-top: 5px;
        height: 20px;
      }
    </style>

  </head>
  <body>
    <!--    登录的容器   -->
    <div class="login-container">
      <h2>欢迎登录</h2>
      <form action="" id="loginForm">
        <div class="input-group">
          <input type="text" id="username" autocomplete="off" placeholder=" ">
          <label for="username"> 用户名</label>
          <div class="error-message" id="username-error"></div>
        </div>
        <div class="input-group">
          <input type="password" id="password" placeholder=" ">
          <label for="password"> 密码</label>
          <div class="error-message" id="password-error"></div>
        </div>
        <button typr="submit">登 录</button>
      </form>
      <script>
        let lf = document.getElementById("loginForm");
        lf.addEventListener("submit", async(e)=>{
          //这个的意思就是在提交之前我检查一下你的格式是否正确
          //相当于是正则表达式
          e.preventDefault();// 防止表单提交

          const username=document.getElementById("username").value.trim();
          const password=document.getElementById("password").value;

          if (!username){
            document.getElementById("username-error").textContent="请输入用户名";
              return;
                    }
                    if (!password){
                      document.getElementById("password-error").textContent="请输入密码";
                    return;
                    }

                    // 验证是否包含特殊字符
                    const regex = /[!@#$%^&*(),.?":{}|<>]/; // 定义特殊字符的正则表达式
                      if(!regex.test(username)){
                        document.getElementById("password-error").textContent='用户名至少包含一个特殊字符';
                      }

                      })

                    </script>
                  </div>
                </body>
              </html>

还写了类似于一个正则表达式的东西,密码必须带有特殊字符,否则提示错误

jsx 复制代码
// 验证是否包含特殊字符
const regex = /[!@#$%^&*(),.?":{}|<>]/; // 定义特殊字符的正则表达式
if(!regex.test(username)){
  document.getElementById("password-error").textContent='用户名至少包含一个特殊字符';
}

画了一个er图

用户有哪些属性

用户:ID、用户名、密码、性别、生日(吧龄)、头像、年龄、账号状态、个人简介、粉丝、关注、IP地址、最后IP地址、创建时间、评论

有些没有属性没有写到,到时候慢慢添加

还学了些建表的操作语句

接下来边学习双token边写

相关推荐
超哥--5 小时前
B站视频内容智能分析系统(九):React 前端与管理面板
前端·react.js·前端框架
Cutecat_8 小时前
视频字幕处理工具横向:提取模式 vs 编辑模式,该如何选择
android·前端·ios·语音识别
qq_422152579 小时前
PDF 加水印工具怎么选?2026 年文档版权保护方案对比
前端·pdf·github
kyriewen9 小时前
手写 Promise.all、race、any:不到 30 行代码,解决并发异步的所有姿势
前端·javascript·面试
brucelee18610 小时前
OpenClaw 浏览器控制(Chrome MCP)完整教程
前端·chrome
ct97810 小时前
React 状态管理方案深度对比
开发语言·前端·react
胡志辉的博客10 小时前
深入浅出理解浏览器事件循环:从一道输出题讲到 Chrome 源码
前端·javascript·chrome·chromium·event loop
代码不加糖10 小时前
js中不会冒泡的事件有哪些?
前端·javascript·vue.js
懂懂tty11 小时前
Vue2与Vue3之间API差异
前端·javascript·vue.js
AI焦点11 小时前
跨越协议鸿沟:Tool Use状态机从Anthropic到OpenAI兼容体系的适配要点
前端·人工智能