Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBlandy committed Jul 21, 2024
1 parent 20ccd4e commit 64c922d
Show file tree
Hide file tree
Showing 25 changed files with 709 additions and 17 deletions.
32 changes: 31 additions & 1 deletion Discourse/discourse.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
# 删除Swap

* 停止swap分区
/sbin/swapoff /swapfile
swapoff /swapfile

* 删除swap分区文件
rm -rf /swapfile
Expand Down Expand Up @@ -314,3 +314,33 @@
# 重新构建



------------------------------------------
国内的代理源
------------------------------------------
# 删除默认的官方源
gem sources --remove https://rubygems.org/


# 添加源任意
gem sources -a https://ruby.taobao.org/
gem sources -a https://gems.ruby-china.com/

# 查看当前源
gem sources -l # https://ruby.taobao.org


# app.yaml 配置文件末尾添加配置

hooks:
after_code:
# 通过这个命令设置 yarn 的镜像地址
- exec:
cd: /var/www/discourse
cmd:
- "yarn config set registry https://registry.npm.taobao.org/"
# 设置 yarn 的超时时间
- exec:
cd: $home
cmd:
- "su discourse -c 'yarn config set network-timeout 6000000 -g'"
17 changes: 17 additions & 0 deletions GIT/git-github加速.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-----------------
配置全局加速地址
-----------------
# 全局配置
git config --global url."https://gitclone.com/".insteadOf https://

#取消
git config --global --unset url."https://gitclone.com/".insteadOf

# 查看配置
git config --list

-----------------
也可以尝试切换协议
-----------------

git config --global url."https://".insteadOf git://
2 changes: 2 additions & 0 deletions Js/bom/bom.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ BOM
# 文档
https://developer.mozilla.org/zh-CN/docs/Web/API

# 参考
https://wangdoc.com/javascript/bom/
7 changes: 7 additions & 0 deletions Js/dom/dom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-----------------------
Dom 编程
-----------------------
# “文档对象模型”(Document Object Model)编程
# 参考
https://wangdoc.com/javascript/dom/

2 changes: 1 addition & 1 deletion Js/js-数据类型-Object.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Object
toLocaleString()
* 返回对象的字符串表示,该字符串反映对象所在的本地化执行环境。

toString()
toString()
* 返回对象的字符串表示。❑

valueOf()
Expand Down
4 changes: 3 additions & 1 deletion Js/js-模块.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ import 指令
// 通过 mod 引用模块导出的变量
mod.foo(); // foo

* import * 会忽略 export default
* import * 可以通过 default 关键字访问默认导出
import * as f from './foo'
console.log(f.default);

* 模块的对象,也是不允许修改的
import * as mod from "./module.js";
Expand Down
5 changes: 5 additions & 0 deletions Js/js-语法.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@
let val = obj?.bar?.foo ?? 'defaultVal';
console.log(val); // defaultVal

* || 的不同
* 使用 ?? 时,只有当左边的值为 null undefined 时才返回右边的值。
* 使用 || 时,左边的值会转换为布尔值判断,为 true 返回左边的值,false 返回右边的值。


* && || 的优先级问题,如果多个逻辑运算符一起使用,必须用括号表明优先级,否则会报错。
(lhs && middle) ?? rhs;
lhs && (middle ?? rhs);
Expand Down
7 changes: 5 additions & 2 deletions Js/web/web.js → Js/web/1-web.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
---------------
Web API
---------------
# 包含了 Dom Bom 的接口
# 包含了 Dom Bom 的接口文档
# 在线文档
https://developer.mozilla.org/zh-CN/docs/Web/API


# 学习文档
https://wangdoc.com/webapi/

4 changes: 3 additions & 1 deletion Js/web/Element.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ this
* 可选,FullscreenOptions 对象
* 提供切换到全屏模式的控制选项。目前,唯一的选项是 'navigationUI',这控制了是否在元素处于全屏模式时显示导航条 UI。
* 默认值是 'auto',表明这将由浏览器来决定是否显示导航条。


* Ok 后返回一个 resolved Promise,值为 undefined。
* 这个方法需要用于触发,而不能直接通过顺序执行代码来自动全屏。


----------------------
Expand Down
1 change: 1 addition & 0 deletions Js/内置对象/Object.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Object
Object.prototype.__defineSetter__()已弃用
Object.prototype.__lookupGetter__()已弃用
Object.prototype.__lookupSetter__()已弃用

Object.prototype.hasOwnProperty(prop)
* 返回一个布尔值,表示对象自有属性(而不是继承来的属性)中是否具有指定的属性 prop。

Expand Down
3 changes: 2 additions & 1 deletion TypeScript/ts-declare.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ declare

* 使用时,自己的脚本使用三斜杠命令,加载这个类型声明文件。
/// <reference path="node.d.ts"/> // 导入 node.d.ts 中各个模块定义的类型
import type { UserResponse } from "userApi" // 从 url 模块(定义在 node.d.ts 中)中导入 UserResponse 类型
import type { UserResponse } from "url" // 从 url 模块(定义在 node.d.ts 中)中导入 UserResponse 类型

// 如果没有上面这一行命令,自己的脚本使用外部模块时,就需要在脚本里面使用 declare 命令单独给出外部模块的类型。

5 changes: 5 additions & 0 deletions TypeScript/ts-tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ tsconfig.json
}
]
}

-------------------
tsconfig.json 配置
-------------------

37 changes: 37 additions & 0 deletions TypeScript/ts-内置指令.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
------------------
注释指令
------------------
# 所谓“注释指令”,指的是采用 JS 双斜杠注释的形式,向编译器发出的命令。

// @ts-nocheck
* 告诉编译器不对当前脚本进行类型检查,可以用于 TypeScript 脚本,也可以用于 JavaScript 脚本。

// @ts-check
* 如果一个 JavaScript 脚本顶部添加了 '// @ts-check',那么编译器将对该脚本进行类型检查,不论是否启用了checkJs编译选项。

// @ts-ignore
* 告诉编译器不对下一行代码进行类型检查,可以用于 TypeScript 脚本,也可以用于 JavaScript 脚本。

// @ts-expect-error
* 主要用在测试用例,当下一行有类型错误时,它会压制 TypeScript 的报错信息(即不显示报错信息),把错误留给代码自己处理。



------------------
JS 文档
------------------
# TypeScript 直接处理 JS 文件时,如果无法推断出类型,会使用 JS 脚本里面的 JSDoc 注释。
# 使用 JSDoc 时,有两个基本要求。
(1)JSDoc 注释必须以 '/**' 开始,其中星号(*)的数量必须为两个。若使用其他形式的多行注释,则 JSDoc 会忽略该条注释。
(2)JSDoc 注释必须与它描述的代码处于相邻的位置,并且注释在上,代码在下。

/**
* @param {string} somebody
*/
function sayHello(somebody) {
console.log('Hello ' + somebody);
}

// @param是一个 JSDoc 声明,表示下面的函数sayHello()的参数somebody类型为string。


4 changes: 4 additions & 0 deletions TypeScript/ts-内置类型.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--------------------------
TypeScript 内置类型
--------------------------

39 changes: 39 additions & 0 deletions TypeScript/ts-模块.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,43 @@ TS 模块



----------------------
TS 模块
----------------------
# 导出 - demo.ts

// 直接导出类型
export type Bar = string;

// 声明类型
type Foo = string
type Zoo = number | boolean;

// 导出默认类型
export default Zoo;

// 导出具名类型
export {
type Foo as RFoo,
type Zoo as RZoo
};

// 也可以
export type {
Foo,
Zoo,
}

# 导入
import type { Bar, RFoo, RZoo, Foo, Zoo } from './demo'

import type DeaultType from './demo'

let a: RFoo;
let b: RZoo;
let c: DeaultType;
let d: Foo;
let e: Zoo;
let f: Bar;


8 changes: 8 additions & 0 deletions TypeScript/ts-类型-any.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ any
console.log(arr.length); // 3
}

// 使用 as 指定其类型
let val:unknown;

val = () => console.log('Hi');

(val as Function)();


# never 类型
* “空类型” 的概念,即该类型为空,不包含任何值。
* 不能赋给它任何值,否则都会报错。
Expand Down
26 changes: 16 additions & 10 deletions TypeScript/ts-类型-类.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,20 +219,26 @@

# 类与接口的合并
* TS 不允许两个同名的类,但是允许和类同名的接口,接口会被合并进类中。
interface A {
y: number;
interface Foo {
name: string // 接口的属性
age: number
}

class A {
x: number = 1;
class Foo {
address: string[]; // 类的属性
constructor(address: string[]){
this.address = address // 初始化类的属性
this.name = "KK" // 初始化接口的属性
}
}

let a = new A();
a.y // 没赋值前,读取接口属性: undefined
a.y = 10; // 设置接口属性
// 初始化类的属性
const foo:Foo = new Foo(['CN', 'CQ']);

// 初始化接口的属性
foo.age = 25;

a.x // 1
a.y // 10 // 再次读取接口属性:10
console.log(JSON.stringify(foo)); // {"address":["CN","CQ"],"name":"KK","age":25}

# Class 类型
* TS 的类本身就是一种类型,但是它代表该类的实例类型,而不是 class 的自身类型。
Expand Down Expand Up @@ -274,7 +280,7 @@

// 错误
function createPoint (
PointClass: Point, // 这是一个 Point 类型的实例对象
PointClass: Point, // 这是一个 Point 类型的实例对象,而不是 Point 类本身(构造函数)
x: number,
y: number
) {
Expand Down
Loading

0 comments on commit 64c922d

Please sign in to comment.