@yqlar
2020-07-21T06:53:31.000000Z
字数 24526
阅读 1364
笔记
若笔记中有错漏或说明不清的地方,请加 QQ 234725468 讨论。
目录:
阴影工具
https://www.cssmatic.com/box-shadow
背景渐变
localStorage.removeItem('keys') 删除某个元素
localStorage.clear() 删除所有元素
window.devicePixelRatio // 取得设备一个虚拟像素对应的物理像素数
window.document.documentElement.getBoundingClientRect().width // 取得屏幕宽度
<video controls poster="/images/w3school.gif">
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
html {
cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="18" style="font-size:14px"><text y="16">🦄</text></svg>'), auto;
}
<form action="javascript:return true;">
<input type="search" name="search" id="search">
</form>
备注:(可能出现的影响)
其中form 必须有action。
如果你不想要action,因为它可能影响了你input的提交逻辑,可以重写一下onsubmit onclick等方法来实现。
也可以用简单的方法:action="javascript:return true;"。
另外,如果要移除搜索框的叉叉图标,可以设置样式
::-webkit-search-cancel-button { display: none; }
搬运下面两个网页的方法:
https://segmentfault.com/q/1010000002720680/a-1020000002720808
http://www.cnblogs.com/wei-lai/p/5157776.html
以下方法完全适配所有移动端和桌面端设备,解决安卓和 ios 的 1px 显示“难产”的问题
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>app</title>
<meta name="viewport" id="WebViewport" content="initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<script>
//
function scaling() {
let viewport = document.querySelector('meta[name=viewport]');
//下面是根据设备像素设置 viewport
let dpi = window.devicePixelRatio; // 取得设备一个虚拟像素对应的物理像素数
let dpiProp = String((1 / dpi).toFixed(6)); // 根据物理像素数计算缩放比例
const a = 'content';
let b = 'width=device-width,initial-scale='+ dpiProp + ', maximum-scale='+ dpiProp + ', minimum-scale='+ dpiProp + ', user-scalable=no';
viewport.setAttribute(a, b); // 配置 meta 标签的 content 内容
}
// 判断屏幕是否刷新或者移动端屏幕是否旋转
function init() {
const doc = window.document;
const docEl = doc.documentElement;
let tid = '';
window.addEventListener('resize', () => {
clearTimeout(tid);
tid = setTimeout(refreshRem(), 300);
}, false);
window.addEventListener('pageshow', (e) => {
if (e.persisted) {
clearTimeout(tid);
tid = setTimeout(refreshRem(), 300);
}
}, false);
refreshRem(docEl);
}
// 页面大小改变或者移动端屏幕旋转后自动刷新 rem
function refreshRem(docEl) {
const docE = docEl || window.document.documentElement;
const width = docE.getBoundingClientRect().width;
const rem = width / 20; // 将屏幕宽度分成20份, 1份为1rem
docE.style.fontSize = rem + 'px';
}
function _main() {
scaling();
init();
}
_main();
</script>
</head>
<body>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
备注:若是在 vue 环境下使用,可以配合
http://www.cnblogs.com/jhli/p/6125095.html
word-wrap: break-word;
word-break: break-word;
white-space: normal;
-webkit-tap-highlight-color: rgba(0,0,0,0);
-webkit-tap-highlight-color: transparent;
<select>
<option value='' disabled selected style='display:none;'>我是默认值,不影响选择</option>
<option value='1'>真正的选项</option>
</select>
可以直接写在 HTML 中
<!-- HTML -->
<svg class="gaussian-box" version="1.1"
xmlns="http://www.w3.org/2000/svg">
<defs>
<filter id="blur">
<feGaussianBlur in="SourceGraphic" stdDeviation="10"/>
</filter>
</defs>
<image :xlink:href="item" x="0" y="0" height="110%" width="110%" filter="url(#blur)"/>
</svg>
.headcover-enter {
opacity: 0;
}
.headcover-enter-active {
transition: all 0.5s ease;
}
.headcover-leave-active {
opacity: 0;
transition: all 0.5s ease;
}
// 自上而下出现, 自下而上消失
.down-enter-active{
transition: all 0.8s;
}
.down-leave-active {
transition: all 0.8s;
}
.down-enter{
transform: translate(rem(0), rem(-900));
}
.down-leave-to {
transform: translate(rem(0), rem(-1000));
}
.item {
animation: 1.5s xintiao linear infinite ;
}
@keyframes xintiao {
0% { -webkit-transform: scale(1); }
30% { -webkit-transform: scale(1); }
40% { -webkit-transform: scale(1); }
50% { -webkit-transform: scale(1.05); }
60% { -webkit-transform: scale(1); }
70% { -webkit-transform: scale(1.03); }
80% { -webkit-transform: scale(1); }
100% { -webkit-transform: scale(1); }
}
js:
created() {
const t = this.idx * 50;
setTimeout(()=> {
setTimeout(() => {
if (this.from === 'second') {
this.filter();
}
}, t);
}, 200);
},
css:
.item {
animation-name: xuanzhuan;
animation-duration: 0.35s;
animation-iteration-count: 1;
}
@keyframes xuanzhuan {
0% { transform: rotateY(90deg); }
50% { transform: rotateY(0deg); }
75% { transform: rotateY(25deg); }
100% { transform: rotateY(0deg); }
}
css 单行省略 和 多行省略
.单行 {
overflow: hidden;
text-overflow:ellipsis;
white-space: nowrap;
}
.多行 {
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 1; /* 限定行数为 1 */
-webkit-box-orient: vertical;
overflow: hidden;
}
https://segmentfault.com/q/1010000004597271
http://animista.net/play/entrances/bounce-in
http://www.cnblogs.com/lhb25/archive/2013/01/30/css3-border-radius.html
#d1{
width:0;
height:0;
border-width:50px;
border-style:solid;
border-top-left-radius: 15px;
opacity: 0.569;
border-color:red transparent transparent red;
}
更多三角形形式: http://www.cnblogs.com/shazhou-blog/p/5168740.html
table{
border-collapse:collapse;
border-spacing:0;
margin:0;
padding:0;
border:none;
}
* {
-webkit-touch-callout: none; /*系统默认菜单被禁用*/
-webkit-user-select: none; /*webkit浏览器*/
-khtml-user-select: none; /*早期浏览器*/
-moz-user-select: none; /*火狐*/
-ms-user-select: none; /*IE10*/
user-select: none;
}
在 ios 上,上面的设置会使得 input 框无法输入,所以还需要加下面的属性
input {
-webkit-user-select: auto; /*webkit浏览器*/
}
在需要滑动的盒子的 css 添加以下属性
-webkit-overflow-scrolling: touch;
* {
margin: 0;
padding: 0;
-webkit-box-sizing: border-box; /* 盒模型的宽高不受 border 和 padding 影响 */
-moz-box-sizing: border-box;
box-sizing: border-box;
}
去除 input 获取焦点时的外边框
.input {
outline: none;
}
去除 input type="number" 时右侧的按钮
chrome专用
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button {
-webkit-appearance: none !important;
margin: 0;
}
火狐专用
input[type="number"]{
-moz-appearance:textfield;
}
input 去掉背景色和焦点时的外框
background-color: transparent;
outline: none;
鼠标手:
cursor:
auto: 正常鼠标
crosshair: 十字鼠标
default: 默认鼠标
pointer: 一只手
move: 移动鼠标
e-resize,ne-resize,nw-resize,n-resize,se-resize,sw-resize,s-resize,w-resize: 改变大小鼠标
text: 文字鼠标
wait: 等待鼠标
help: 求助鼠标
progress: 过程鼠标
字体间距:
letter-spacing
text-shadow: 0px 0px 1px #e63642;
color: transparent;
-webkit-text-stroke: 2px #970008;
.背景色透明 {
background: rgb(0, 0, 0, 0) /* 前三个数字是颜色号,最后一位是颜色的透明度 */
}
.毛玻璃 {
background-color: rgba(0, 0, 0, 0.2);
/* 最后的一位小数时调节透明度的 1为全黑 0为全透明 */
-webkit-filter: blur(1px);
/* 毛边的范围 0px 无毛边 */
-moz-filter: blur(1px);
-ms-filter: blur(1px);
-o-filter: blur(1px);
filter: blur(1px);
}
只是透明度的设置
opacity:0.5
.flexd 定位重新定向 { /* flexd 重新以父元素定位 */
transform: translate(0, 0);
}
(目前为止比较好理解的笨方法,以后有好的方案会持续更新)
html {
font-size: 50px;
}
body {
font-size: 24px;
}
@media screen and (min-width:320px) {
html {
font-size: 21.333333333333332px;
}
body {
font-size: 12px;
}
}
@media screen and (min-width:360px) {
html {
font-size: 24px;
}
body {
font-size: 12px;
}
}
@media screen and (min-width:375px) {
html {
font-size: 25px;
}
body {
font-size: 12px;
}
}
@media screen and (min-width:384px) {
html {
font-size: 25.6px;
}
body {
font-size: 14px;
}
}
@media screen and (min-width:400px) {
html {
font-size: 26.666666666666668px;
}
body {
font-size: 14px;
}
}
@media screen and (min-width:414px) {
html {
font-size: 27.6px;
}
body {
font-size: 14px;
}
}
@media screen and (min-width:424px) {
html {
font-size: 28.266666666666667px;
}
body {
font-size: 14px;
}
}
@media screen and (min-width:480px) {
html {
font-size: 32px;
}
body {
font-size: 15.36px;
}
}
@media screen and (min-width:540px) {
html {
font-size: 36px;
}
body {
font-size: 17.28px;
}
}
@media screen and (min-width:720px) {
html {
font-size: 48px;
}
body {
font-size: 23.04px;
}
}
@media screen and (min-width:750px) {
html {
font-size: 50px;
}
body {
font-size: 24px;
}
}
可以参考 阮一峰--Flex 布局教程 有详细的图文说明,下面仅摘录文字,方便快速查找。
flex-direction: *属性决定主轴的方向*
row(默认值): 主轴为水平方向,起点在左端
row-reverse: 主轴为水平方向,起点在右端
column: 主轴为垂直方向,起点在上沿
column-reverse: 主轴为垂直方向,起点在下沿
flex-wrap: *如果一条轴线排不下,如何换行*
nowrap(默认): 不换行
wrap: 换行,第一行在上方
wrap-reverse: 换行,第一行在下方
flex-flow:
flex-flow: 属性是flex-direction属性和flex-wrap属性的简写形式,默认值为row nowrap
flex-flow: <flex-direction> || <flex-wrap>;
justify-content: *属性定义了项目在主轴上的对齐方式。*
flex-start(默认值): 左对齐
flex-end: 右对齐
center: 居中
space-between: 两端对齐,项目之间的间隔都相等
space-around: 每个项目两侧的间隔相等。所以,项目之间的间隔比项目与边框的间隔大一倍
align-items: *属性定义项目在交叉轴上如何对齐。*
flex-start: 交叉轴的起点对齐
flex-end: 交叉轴的终点对齐
center: 交叉轴的中点对齐
baseline: 项目的第一行文字的基线对齐
stretch(默认值): 如果项目未设置高度或设为auto,将占满整个容器的高。
align-content: *属性定义了多根轴线的对齐方式。如果项目只有一根轴线,该属性不起作用。*
flex-start: 与交叉轴的起点对齐
flex-end: 与交叉轴的终点对齐
center: 与交叉轴的中点对齐
space-between: 与交叉轴两端对齐,轴线之间的间隔平均分布
space-around: 每根轴线两侧的间隔都相等。所以,轴线之间的间隔比轴线与边框的间隔大一倍
stretch(默认值): 轴线占满整个交叉轴。
order: 数字; 默认为 0
*属性定义项目的排列顺序。数值越小,排列越靠前,默认为0*
flex-grow: 数字; 默认为 0
*如果所有项目的flex-grow属性都为1,则它们将等分剩余空间(如果有的话)。如果一个项目的flex-grow属性为2,其他项目都为1,则前者占据的剩余空间将比其他项多一倍。*
flex-shrink: 数字; 默认为 1 *属性定义了项目的缩小比例,默认为1,即如果空间不足,该项目将缩小。
*如果所有项目的flex-shrink属性都为1,当空间不足时,都将等比例缩小。如果一个项目的flex-shrink属性为0,其他项目都为1,则空间不足时,前者不缩小。*
.demo::-webkit-scrollbar {
display: none; /* Chrome Safari */
}
.demo {
scrollbar-width: none; /* firefox */
-ms-overflow-style: none; /* IE 10+ */
overflow-x: hidden;
overflow-y: auto;
}
https://www.cnblogs.com/yunser/p/7628031.html
location.href = 'weixin://'
var os = function() {
var ua = navigator.userAgent,
isWindowsPhone = /(?:Windows Phone)/.test(ua),
isSymbian = /(?:SymbianOS)/.test(ua) || isWindowsPhone,
isAndroid = /(?:Android)/.test(ua),
isFireFox = /(?:Firefox)/.test(ua),
isChrome = /(?:Chrome|CriOS)/.test(ua),
isTablet = /(?:iPad|PlayBook)/.test(ua) || (isAndroid && !/(?:Mobile)/.test(ua)) || (isFireFox && /(?:Tablet)/.test(ua)),
isPhone = /(?:iPhone)/.test(ua) && !isTablet,
isPc = !isPhone && !isAndroid && !isSymbian;
return {
isTablet: isTablet,
isPhone: isPhone,
isAndroid : isAndroid,
isPc : isPc
};
}();
arr.sort((a, b) => {
let t = b - a
return t
})
parseInt(Math.random() * 4)
randomFun(min, max) {
const r = max - min
return Math.round(Math.random() * r) + min
}
如果需要更高的精度,可以使用 performance.now() 来替换 Date.now(),这个 API 可以精确到千分之一毫秒。
new Date(parseInt(我是时间戳) * 1000).toLocaleString('chinese',{hour12:false})
new Date(parseInt(nS) * 1000).toLocaleString().substr(0,17)
// 2017-12-25 21:40:00 将标准时间解析为时间戳 此方法兼容 ios
Date.parse(new Date(d.replace(/-/g, '/')))
2018-10-17 21:59:01
filterTime(val) {
const add0 = (m) => {
return m < 10 ? '0' + m : m;
};
var time = new Date(val);
var y = time.getFullYear();
var m = time.getMonth() + 1;
var d = time.getDate();
var h = time.getHours();
var mm = time.getMinutes();
var s = time.getSeconds();
return y + '-' + add0(m) + '-' + add0(d) + ' ' + add0(h) + ':' + add0(mm) + ':' + add0(s);
},
arr[index] = arr.splice((index (" + or - ") 1), 1, arr[index])[0];
const data = decodeURIComponent(rulcode)
@这个是大海聚聚分享出来的,鸣谢!
他的个人网站 大海的个人网站
<script>
// 默认打开辅助线, “ctrl + m” 开关辅助线
var xkXian = function () {
var body = document.querySelector('body');
var style = '<style id="xm" media="screen">* {outline: 1px red dashed!important;} </style>'
var i = true;
body.insertAdjacentHTML('afterbegin', style);
body.addEventListener('keydown', function (event) {
if (event.keyCode === 77 && event.ctrlKey) {
if (i) {
var styletog = document.querySelector('#xm')
styletog.remove()
i= false
}else {
i = true
body.insertAdjacentHTML('afterbegin', style);
}
}
})
}
xkXian()
</script>
https://github.com/wuchangming/spy-debugger
取整
parseInt(Number, 10)
第一个参数为需要去除小数的参数,第二个参数为第一个参数的进制说明,默认为 10 进制。可自行配置 2, 8, 16 等等多种进制。
js 计算特效限制,会出现例如 9.21 * 100 = 921.0000000000001 的情况,所以使用如下公式来计算小数加减乘除
parseFloat((this.userInfo.balance * 100).toFixed(10))
var u = navigator.userAgent, app = navigator.appVersion;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
alert('是否是Android:'+isAndroid);
alert('是否是iOS:'+isiOS);
t=setTimeout("timedCount()",1000)
clearTimeout(t)
跨域:(jQuery)
<script type="text/javascript">
$.ajax({
url:"http://crossdomain.com/services.php",
dataType:'jsonp',
data:'data',
jsonp:'callback',
success:function(result) {
log(result)
},
timeout:3000
})
</script>
location.href = 我是 link
此方法兼容性较差,在移动端基本不可用
文字载体必须为 input 标签
input 标签不可编辑属性: readOnly="true" /* 背景不变色 */
disabled="true" /* 此属性不可用于一键复制,因为它禁止了 input获取焦点;背景变色 */
var btn = document.querySelector("button")
btn.addEventListener( 'click', function () {
document.getElementById("input").focus(); /* input 框获取焦点 */
document.getElementById("input").select(); /* 选中 input 框文字 */
document.execCommand('copy'); /* 复制文字进粘贴板 */
})
/* button 和 input 根据实际标签更改; 若考虑用户体验可在复制文字后再加个 blur 事件,清除 input 框的焦点 */
JSON.parse() 解析 JSON
JSON.stringify() 生成 JSON
string.split('符号')
以符号将字符串划分为数组
array.join('符号')
以符号将数组拼接成字符串
str.split(' ').join('').split('\n').join('') == ''
~~true == 1
~~false == 0
~~"" == 0
~~[] == 0
~~undefined == 0
~~!undefined == 1
~~null == 0
~~!null == 1
location.href
// /* eslint-disable global-require */
// const homePage = r => require.ensure([], () => r(require('@/components/views/homePage.vue')), 'chunkname1');
// /* eslint-disable global-require */
// const mine = r => require.ensure([], () => r(require('@/components/views/mine.vue')), 'chunkname2');
// /* eslint-disable global-require */
// const search = r => require.ensure([], () => r(require('@/components/views/search.vue')), 'chunkname3');
// /* eslint-disable global-require */
// const player = r => require.ensure([], () => r(require('@/components/views/player.vue')), 'chunkname4');
// /* eslint-disable global-require */
// const channel = r => require.ensure([], () => r(require('@/components/second_stage/channel.vue')), 'chunkname5');
// /* eslint-disable global-require */
// const myVideo = r => require.ensure([], () => r(require('@/components/second_stage/my_video.vue')), 'chunkname6');
// /* eslint-disable global-require */
// const videoInfo = r => require.ensure([], () => r(require('@/components/second_stage/video_info.vue')), 'chunkname7');
// /* eslint-disable global-require */
// const test = r => require.ensure([], () => r(require('@/test/test.vue')), 'chunkname8');
在组件上使用事件时需要在事件后添加 .native 修饰符
eg:
@scroll.native="test"
.stop
.prevent
.stop.prevent
.capture
.self
<!-- 阻止单击事件冒泡 -->
<a v-on:click.stop="doThis"></a>
<!-- 提交事件不再重载页面 -->
<form v-on:submit.prevent="onSubmit"></form>
<!-- 修饰符可以串联 -->
<a v-on:click.stop.prevent="doThat"></a>
<!-- 只有修饰符 -->
<form v-on:submit.prevent></form>
<!-- 添加事件侦听器时使用事件捕获模式 -->
<div v-on:click.capture="doThis">...</div>
<!-- 只当事件在该元素本身(而不是子元素)触发时触发回调 -->
<div v-on:click.self="doThat">...</div>
需求: 去除打包文件的 js 中的 map 文件
配置文件路径:./build/webpack.prod.conf.js
原配置: devtool: config.build.productionSourceMap ? '#source-map' : false,
现配置: devtool: false,
watch: {
'modalAjaxData.i_diamond': {
handler: function(val,oldVal) {
console.log(val, oldVal)
}
},
deep:true
// 深度复制,此处如果直接监听对象为 obj 内部的数据,那么可以不要 deep:true ,此处有坑,还需总结。
// handler 目前知道的是,这个是专有回调,不可用其他函数
},
此处需要知道 npm 命令行的基本方法
1.安装: npm install -g vue-cli
2.查看版本: vue -V (大写 V)
3.生成项目: vue init webpack *项目名称*
4.执行生成命令后需要填写项目基本信息和选择项目配置
5.下载项目依赖: npm install (在项目文件夹路径内执行,若 npm 下载太慢可转换 cnpm)
6.热加载项目,实时显示更新: npm run dev (此处只是更新在内存之中,没有生成最终的打包文件)
7.打包文件: npm run build
vue-cli 打包后引入文件路径错误的修复方法
项目/config/index.js
module.exports = {
build: {
assetsPublicPath: './'
}
}
1、添加 tsconfig.json 配置文件 内容:
{
"compilerOptions": {
"strict": true,
"module": "es2015",
"moduleResolution": "node",
"target": "es5",
"allowSyntheticDefaultImports": true,
"lib": [
"es2017",
"dom"
]
}
}
2、添加 typescript 和 ts-loader
npm install typescript ts-loader --save-dev
3、修改目录下bulid/webpack.base.conf.js文件,在文件内module>rules添加以下规则
{
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: /node_modules/,
options: {
appendTsSuffixTo: [/\.vue$/],
}
},
4、script 标签添加 lang="ts"
<script lang="ts"></script>
在命令行退出 node 的命令行为: Ctrl + D 或者 Ctrl + C 两次
npm 若在下载模块失败的时候,需要清理缓存,命令行为: npm cache clean
更新 npm 的命令行为: npm install -g npm
有时候 npm 不好使,就用 cnpm 以下是全局安装 cnpm 的命令行: npm install -g cnpm --registry=https://registry.npm.taobao.org
全局安装模块: npm install -g 模块名称
将模块安装在局部环境: 首先在命令行将地址定位到具体的文件夹,再执行命令: npm install -dev--save 模块名称
模块更新: npm update 模块名称
nrm npm镜像管理工具
nrm use npm 、 nrm use cnpm 切换镜像
nrm test npm 测试下载速度
nrm ls 查看现有镜像
https://www.npmjs.com/package/nrm
网址组成:(共四部分)
协议: http、https(加密后的 http 协议)。
主机: zhihu.com、baidu.com 等等网址。
端口: 一个二进制 16 位的数字,所以 10 进制的范围为 0 ~ 65535 ;http 协议默认的是 80。 一般浏览器会隐藏端口,不显示出来,所以一般看不到,也不用填写。
路径: 例如:“https://www.zhihu.com/question/59039141/answer/162660877
”
这个网址在 “https://www.zhihu.com/
” 之后的 “question/59039141/answer/162660877
” 就是路径,相当于服务器内文件的地址。
额外说明:
服务器端口(port)一般 1024 ~ 65535 之间的数字, 1024 以下要管理员权限才能使用
Openssl windows 安装下载地址 请下载 1.0.2 版本
1、安装在D盘,好配合后面的命令使用,不用修改太多
2、在解压后的目录, 即openssl.exe所在目录(bin文件夹)新建配置文件,名为openssl-1.0.2a.cnf,内容在后面
3、配置文件创建好之后在 bin 目录下用命令行执行以下命令
mkdir keys
copy /Y nul keys\index.txt
echo 01 >keys\serial
SET HOME=.
SET KEY_DIR=keys
4、生成ca证书,这一步生成了2个文件:ca.key为CA的私钥文件,ca.crt为CA的证书文件,这两个文件后面的证书签名做准备
openssl req -days 3650 -nodes -new -x509 -keyout keys\ca.key -out keys\ca.crt -config openssl-1.0.2a.cnf
5、生成服务端证书
生成服务器证书请求文件和服务器私钥
openssl req -days 3650 -nodes -new -keyout keys\server.key -out keys\server.csr -config openssl-1.0.2a.cnf
CA签名
openssl ca -days 3650 -out keys\server.crt -in keys\server.csr -extensions server -config openssl-1.0.2a.cnf
清除.old文件防止将来创建文件出现错误
del /q keys\*.old
6、生成客户端证书
生成客户端证书请求文件和客户端私钥
openssl req -days 3650 -nodes -new -keyout keys\client.key -out keys\client.csr -config
openssl-1.0.2a.cnf
CA签名
openssl ca -days 3650 -out keys\client.crt -in keys\client.csr -config openssl-1.0.2a.cnf
清除.old文件防止将来创建文件出现错误
del /q keys\*.old
生成的证书文件都在keys文件夹中
配置文件
openssl-1.0.2a.cnf
# For use with easy-rsa version 2.0 and OpenSSL 1.0.0*
# This definition stops the following lines choking if HOME isn't
# defined.
HOME = .
RANDFILE = $ENV::HOME/.rnd
openssl_conf = openssl_init
[ openssl_init ]
# Extra OBJECT IDENTIFIER info:
#oid_file = $ENV::HOME/.oid
oid_section = new_oids
engines = engine_section
# To use this configuration file with the "-extfile" option of the
# "openssl x509" utility, name here the section containing the
# X.509v3 extensions to use:
# extensions =
# (Alternatively, use a configuration file that has only
# X.509v3 extensions in its main [= default] section.)
[ new_oids ]
# We can add new OIDs in here for use by 'ca' and 'req'.
# Add a simple OID like this:
# testoid1=1.2.3.4
# Or use config file substitution like this:
# testoid2=${testoid1}.5.6
####################################################################
[ ca ]
default_ca = CA_default # The default ca section
####################################################################
[ CA_default ]
dir = $ENV::KEY_DIR # Where everything is kept
certs = $dir # Where the issued certs are kept
crl_dir = $dir # Where the issued crl are kept
database = $dir/index.txt # database index file.
new_certs_dir = $dir # default place for new certs.
certificate = $dir/ca.crt # The CA certificate
serial = $dir/serial # The current serial number
crl = $dir/crl.pem # The current CRL
private_key = $dir/ca.key # The private key
RANDFILE = $dir/.rand # private random number file
x509_extensions = usr_cert # The extentions to add to the cert
# Extensions to add to a CRL. Note: Netscape communicator chokes on V2 CRLs
# so this is commented out by default to leave a V1 CRL.
# crl_extensions = crl_ext
default_days = 3650 # how long to certify for
default_crl_days= 30 # how long before next CRL
default_md = md5 # use public key default MD
preserve = no # keep passed DN ordering
# A few difference way of specifying how similar the request should look
# For type CA, the listed attributes must be the same, and the optional
# and supplied fields are just that :-)
policy = policy_anything
# For the CA policy
[ policy_match ]
countryName = match
stateOrProvinceName = match
organizationName = match
organizationalUnitName = optional
commonName = supplied
name = optional
emailAddress = optional
# For the 'anything' policy
# At this point in time, you must list all acceptable 'object'
# types.
[ policy_anything ]
countryName = optional
stateOrProvinceName = optional
localityName = optional
organizationName = optional
organizationalUnitName = optional
commonName = supplied
name = optional
emailAddress = optional
####################################################################
[ req ]
default_bits = 1024
default_keyfile = privkey.pem
distinguished_name = req_distinguished_name
attributes = req_attributes
x509_extensions = v3_ca # The extentions to add to the self signed cert
# Passwords for private keys if not present they will be prompted for
# input_password = secret
# output_password = secret
# This sets a mask for permitted string types. There are several options.
# default: PrintableString, T61String, BMPString.
# pkix : PrintableString, BMPString (PKIX recommendation after 2004).
# utf8only: only UTF8Strings (PKIX recommendation after 2004).
# nombstr : PrintableString, T61String (no BMPStrings or UTF8Strings).
# MASK:XXXX a literal mask value.
string_mask = nombstr
# req_extensions = v3_req # The extensions to add to a certificate request
[ req_distinguished_name ]
countryName = Country Name (2 letter code)
countryName_default = CN
countryName_min = 2
countryName_max = 2
stateOrProvinceName = State or Province Name (full name)
stateOrProvinceName_default = LiaoNing
localityName = Locality Name (eg, city)
localityName_default = DaLian
0.organizationName = Organization Name (eg, company)
0.organizationName_default = KEY_ORG
# we can do this but it is not needed normally :-)
#1.organizationName = Second Organization Name (eg, company)
#1.organizationName_default = World Wide Web Pty Ltd
organizationalUnitName = Organizational Unit Name (eg, section)
#organizationalUnitName_default =
commonName = Common Name (eg, your name or your server\'s hostname)
commonName_max = 64
name = Name
name_max = 64
emailAddress = Email Address
emailAddress_default = mail@host.domain
emailAddress_max = 40
# JY -- added for batch mode
organizationalUnitName_default = KEY_OU
commonName_default = KEY_CN
name_default = KEY_NAME
# SET-ex3 = SET extension number 3
[ req_attributes ]
challengePassword = A challenge password
challengePassword_min = 4
challengePassword_max = 20
unstructuredName = An optional company name
[ usr_cert ]
# These extensions are added when 'ca' signs a request.
# This goes against PKIX guidelines but some CAs do it and some software
# requires this to avoid interpreting an end user certificate as a CA.
basicConstraints=CA:FALSE
# Here are some examples of the usage of nsCertType. If it is omitted
# the certificate can be used for anything *except* object signing.
# This is OK for an SSL server.
# nsCertType = server
# For an object signing certificate this would be used.
# nsCertType = objsign
# For normal client use this is typical
# nsCertType = client, email
# and for everything including object signing:
# nsCertType = client, email, objsign
# This is typical in keyUsage for a client certificate.
# keyUsage = nonRepudiation, digitalSignature, keyEncipherment
# This will be displayed in Netscape's comment listbox.
nsComment = "Easy-RSA Generated Certificate"
# PKIX recommendations harmless if included in all certificates.
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer:always
extendedKeyUsage=clientAuth
keyUsage = digitalSignature
# This stuff is for subjectAltName and issuerAltname.
# Import the email address.
# subjectAltName=email:copy
# Copy subject details
# issuerAltName=issuer:copy
#nsCaRevocationUrl = http://www.domain.dom/ca-crl.pem
#nsBaseUrl
#nsRevocationUrl
#nsRenewalUrl
#nsCaPolicyUrl
#nsSslServerName
[ server ]
# JY ADDED -- Make a cert with nsCertType set to "server"
basicConstraints=CA:FALSE
nsCertType = server
nsComment = "Easy-RSA Generated Server Certificate"
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer:always
extendedKeyUsage=serverAuth
keyUsage = digitalSignature, keyEncipherment
[ v3_req ]
# Extensions to add to a certificate request
basicConstraints = CA:FALSE
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
[ v3_ca ]
# Extensions for a typical CA
# PKIX recommendation.
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid:always,issuer:always
# This is what PKIX recommends but some broken software chokes on critical
# extensions.
#basicConstraints = critical,CA:true
# So we do this instead.
basicConstraints = CA:true
# Key usage: this is typical for a CA certificate. However since it will
# prevent it being used as an test self-signed certificate it is best
# left out by default.
# keyUsage = cRLSign, keyCertSign
# Some might want this also
# nsCertType = sslCA, emailCA
# Include email address in subject alt name: another PKIX recommendation
# subjectAltName=email:copy
# Copy issuer details
# issuerAltName=issuer:copy
# DER hex encoding of an extension: beware experts only!
# obj=DER:02:03
# Where 'obj' is a standard or added object
# You can even override a supported extension:
# basicConstraints= critical, DER:30:03:01:01:FF
[ crl_ext ]
# CRL extensions.
# Only issuerAltName and authorityKeyIdentifier make any sense in a CRL.
# issuerAltName=issuer:copy
authorityKeyIdentifier=keyid:always,issuer:always
[ engine_section ]
#
# If you are using PKCS#11
# Install engine_pkcs11 of opensc (www.opensc.org)
# And uncomment the following
# verify that dynamic_path points to the correct location
#
#pkcs11 = pkcs11_section
[ pkcs11_section ]
engine_id = pkcs11
dynamic_path = /usr/lib/engines/engine_pkcs11.so
MODULE_PATH = changeme
PIN = 1234
init = 0
才能重新连接服务器
rm -rf ~/.ssh/known_hosts
curl ifconfig.me
查看文件夹内容:
dir
/* 普通查看 */
dir /p
/* 分页查看 */
ping 网址
/* eg: ping zhihu.com
查看网址对应 ip */
ipconfig/all
查看本机域名可以只输入ipconfig
系统偏好设置->键盘->快捷键->应用快捷键->点击+号->弹出窗口,应用程序:选择谷歌应用,菜单标题重新加载此页(重点一定要和google app快捷键的标题一样),快捷键:F5。
解压文件:
xz 格式文件: xz -d 文件名.tar.xz
tar 格式文件: tar -xf 文件名.tar