MeowRain
Life is SimpleLife is Simple
meowrain 发布于 收录于 前端 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 import type { AxiosInstance, AxiosResponse, InternalAxiosRequestConfig, } from "axios"; import axios from "axios"; declare module "#app" { interface NuxtApp { $axios: AxiosInstance; } } const handleRequestHeader = (config: InternalAxiosRequestConfig<any>) => { const token = localStorage.
meowrain 发布于 收录于 前端 AXIOS请求执行过程 请求流程和拦截器 代码 封装好
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 import type { AxiosInstance, AxiosResponse, InternalAxiosRequestConfig, } from "axios"; import axios from "axios"; const handleRequestHeader = (config: InternalAxiosRequestConfig<any>) => { const token = localStorage.
父子组件传值 父组件向子组件传值 defineProps
父组件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 <script setup lang="ts"> import { onMounted, ref } from 'vue' import TestView from '../views/TestView.vue' let imgUrl = ref<string>() onMounted(async ()=>{ const response = await fetch('https://api.waifu.pics/sfw/waifu') const json = await response.json() imgUrl.value = json.url; }) </script> <template> <div> <TestView :url="imgUrl"/> </div> </template> <style></style> 子组件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 <script setup lang="ts"> import { defineProps, toRef, watch, watchEffect } from 'vue'; const props = defineProps({ url:String }) watch(()=>props.
meowrain 发布于 收录于 折腾 下载mysql8.0 https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.40-winx64.zip
解压 改配置文件 新建data文件夹
新建my.ini
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 [mysqld] default-time_zone = '+8:00' basedir=D:\Software\mysql-8.0.40-winx64 datadir=D:\Software\mysql-8.0.40-winx64\data bind-address=127.0.0.1 mysqlx-bind-address= 127.0.0.1 max_connections=200 max_connect_errors=10 character-set-server=utf8 [mysql] default-character-set=utf8 [client] port=3306 执行命令 1 2 cd bin .\mysqld.exe --initialize --console 会出现初始密码,临时存一下
1 ./mysqld.exe --install mysql 点任务栏的搜索,搜服务 打开找Mysql
连接mysql 1 mysql -u root -p 会提示输入密码,把刚才的临时密码粘进来就行了
然后需要改密码
1 2 alter user 'root'@'localhost' IDENTIFIED BY '123456'; exit 1 mysql -u root -p 使用图形化 点Installer 下载上安装
meowrain 发布于 收录于 Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 Helloworld.vue <template> <div> <h1>Helloworld </h1> <button @click="trigEmit">点击触发父组件传来的函数</button> <button @click="()=>{ console.log(props.name) }">点击打印从父组件传来的值</button> </div> </template> <script setup> /** * * defineProps:用于声明接收的数据(从父组件传递的 props)。 defineEmits:用于声明和触发事件(子组件通知父组件)。 */ import { defineProps,defineEmits } from 'vue'; const props = defineProps(['name']) const emit = defineEmits(["fun"]) const trigEmit = ()=>{ emit("fun","meowrain") } </script> <style scoped></style> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 app.
使用效果 上传api 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 /** * uploadImageApi(File,string) 上传图片 * @param image - File类型,图片文件 * @param string - string 类型,imageType 图片类型 * @returns Promise<baseResponse<IUploadImageResponse>> */ export function uploadImageApi(image: File, imageType: string): Promise<baseResponse<IUploadImageResponse>> { // 向服务器发送post请求,发送form-data // 内容分别为image-> 图片二进制文件 // imageType-> 图片类型 const data = new FormData(); data.append('image', image); data.append('imageType', imageType); return useAxios.post('/api/file/image', data, { headers: { 'Content-Type': 'multipart/form-data', }, }); } 头像上传组件 avatar-cropper.
meowrain 发布于 收录于 Go golang使用bcrypt实现密码加密和验证 介绍 把用户的密码存入数据库的时候,我们当然不能使用明文存储,要对密码进行一次加密,然后再存储到数据库中。
我们一般采用哈希算法实现对密码的加密,因为哈希算法得到的加密数据是不可逆的
哈希算法(Hash Algorithm)是一种将任意长度的数据映射为固定长度数据的算法。哈希算法广泛应用于数据完整性校验、密码存储、数字签名等领域。以下是一些常见的哈希算法:
简单的哈希算法 1. MD5 (Message Digest Algorithm 5) 输出长度: 128位(16字节) 特点: 速度快,但安全性较低,容易受到碰撞攻击。 应用: 文件校验、旧版密码存储。 2. SHA-1 (Secure Hash Algorithm 1) 输出长度: 160位(20字节) 特点: 安全性较MD5高,但仍存在碰撞风险。 应用: 数字签名、SSL证书。 3. SHA-2 (Secure Hash Algorithm 2) 子算法: SHA-224, SHA-256, SHA-384, SHA-512 输出长度: 224位、256位、384位、512位 特点: 安全性高,广泛使用。 应用: 数字签名、SSL/TLS、区块链。 4. SHA-3 (Secure Hash Algorithm 3) 子算法: SHA3-224, SHA3-256, SHA3-384, SHA3-512 输出长度: 224位、256位、384位、512位 特点: 基于Keccak算法,与SHA-2结构不同,安全性高。 应用: 数字签名、密码存储。 5. RIPEMD-160 (RACE Integrity Primitives Evaluation Message Digest 160) 输出长度: 160位(20字节) 特点: 安全性较高,常用于比特币地址生成。 应用: 数字签名、区块链。 6.
meowrain 发布于 收录于 前端 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <link rel="stylesheet" type="text/css" href="assests/style.css"> </head> <body> <div class="container"> <div id="app" style="--day-mode: true;"> <div class="content"> <p>Hello,there is test1</p> </div> <div class="content"> <p>Hello,there is test1</p> </div> <div class="content"> <p>Hello,there is test1</p> </div> </div> <div class="btns"> <button onclick="toggleToNightMode()">Switch to Night Mode</button> <button onclick="toggleToDayMode()">Switch to Day Mode</button> </div> </div> <script src="assests/script.
meowrain 发布于 收录于 Go 用Go简单实现Github授权登录并获取github用户信息 参考: 没错,用三方 Github 做授权登录就是这么简单!(OAuth2.0实战)-腾讯云开发者社区-腾讯云 (tencent.com)
首先我们需要了解一下什么是Oauth2.0
可以看阮一峰老师的这个文章::理解OAuth2.0
一口气说出 OAuth2.0 的四种授权方式 (qq.com)
一.授权流程 二.注册应用 要想得到一个网站的OAuth授权,必须要到它的网站进行身份注册,拿到应用的身份识别码 ClientID 和 ClientSecret。
注册 传送门 https://github.com/settings/applications/new,有几个必填项。
Application name:我们的应用名;
Homepage URL:应用主页链接;
Authorization callback URL:这个是github 回调我们项目的地址,用来获取授权码和令牌。
https://docs.github.com/zh/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps
提交后会看到就可以看到客户端ClientID 和客户端密匙ClientSecret,到这我们的准备工作就完事了。
三.授权开发 获取授权码 我们请求https://github.com/login/oauth/authorize?client_id=yourclient_id& redirect_uri=your_redirect_url/authorize
请求后会提示让我们授权,同意授权后会重定向到authorize/redirect,并携带授权码code;如果之前已经同意过,会跳过这一步直接回调。
然后我就回跳转到redirect_url,能拿到这个code
http://localhost:8080/callback?code=ac3d9c25eb39752b34c2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 package main import ( "fmt" "io/ioutil" "log" "net/http" "net/url" ) const ( clientID = "" clientSecret = "" redirectURI = "http://localhost:8080/callback" // 确保与 GitHub 应用配置一致 ) func loginHandler(w http.