.video-container {
position: relative;
width: 100%;
padding-top: 56.25%; /* 16:9 aspect ratio (height/width = 9/16 * 100%) */
}
.video-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
文心一言API小后端(.Net 7)我没有写什么详细的介绍,这是流水账记录,里面有很多代码是没有用的,但是我懒得删,就当是记录自己的问题吧。
这是之前写过的一个ASP.NET Core的文心一言API,后面过了将近一年又拿出来修改了一下,部署在云服务上了,写这玩意的目的是为了Linux和一些考试去作弊用的,因为我发现学校使用极域管理机房电脑,禁止浏览器访问页面是封的80标准端口,所以就写了个API,把它部署在非80端口上,就绕过极域的封禁去使用ai,但考试改成笔试了。
项目文件
...
.video-container {
position: relative;
width: 100%;
padding-top: 56.25%; /* 16:9 aspect ratio (height/width = 9/16 * 100%) */
}
.video-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
装饰者模式:动态扩展对象功能主要代码:
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455public abstract class Beverage { public string description = "Unknown Beverage"; public virtual s ...
.video-container {
position: relative;
width: 100%;
padding-top: 56.25%; /* 16:9 aspect ratio (height/width = 9/16 * 100%) */
}
.video-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
桥接模式:将抽象部分与它的实现部分分离,使它们都可以独立地变化。主要代码
123456789101112131415161718192021222324252627282930313233343536///<桥接模式>public interface TV{ public void TuneChannel();}public abstract class RemoteControl{ public TV _tv; publi ...
.video-container {
position: relative;
width: 100%;
padding-top: 56.25%; /* 16:9 aspect ratio (height/width = 9/16 * 100%) */
}
.video-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
适配器模式:将一个类的接口转换成客户希望的另外一个接口,即接口转换的桥梁。代码:
12345678910111213141516171819202122///<适配器模式>public interface ITarget{ void Request();}public class Adaptee{ public void SpecificRequest() { Console.WriteLine(& ...
.video-container {
position: relative;
width: 100%;
padding-top: 56.25%; /* 16:9 aspect ratio (height/width = 9/16 * 100%) */
}
.video-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
观察者模式代码:
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061///<观察者模式>//1. 定义观察者接口public interface IObserver { void Update(string message);}//2. 定义主题(被观察者)接口public ...
.video-container {
position: relative;
width: 100%;
padding-top: 56.25%; /* 16:9 aspect ratio (height/width = 9/16 * 100%) */
}
.video-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
当对象需要根据内部状态改变行为时,常见做法:
12345switch(currentState) { case "New": ProcessNew(); break; case "Shipped": ProcessShipped(); break; case "Delivered": ProcessDelivered(); break;}
问题:
状态转换逻辑散落在各处
新增状态需修 ...
.video-container {
position: relative;
width: 100%;
padding-top: 56.25%; /* 16:9 aspect ratio (height/width = 9/16 * 100%) */
}
.video-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
策略模式:动态切换算法当业务需要支持多种算法变体时,常见做法:
12if(paymentMethod == "Cash") ProcessCash();else if(paymentMethod == "CreditCard") ProcessCreditCard();
但是这样容易出现一些问题:
新增支付方式需修改核心代码
支付逻辑与控制器耦合
难以单独测试支付算法
解决方案:策略模式
123456789101112131415161 ...
.video-container {
position: relative;
width: 100%;
padding-top: 56.25%; /* 16:9 aspect ratio (height/width = 9/16 * 100%) */
}
.video-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
什么是粘包? 是指如果当发送端快速发送多条数据,但是接收端没有及时调用Receive,那么数据会在接收端的缓存中积累。
例如:当发送端先发送“1,2,3,4”四个字节,紧接着又发送“5,6,7,8”四个字节的数据;等到接收端调用Receive的时候,接收端的操作系统已经将接收到的全部数据写入缓存区,共接收到“8”个字节。
什么是半包? 也就是当发送端发送的数据太长了,但是接收端的缓存区没有足够的空间接收全部数据,就会接收一部分数据,另一
部分等下一次调用Receive的时候在接收 ...
后端开发
未读
.video-container {
position: relative;
width: 100%;
padding-top: 56.25%; /* 16:9 aspect ratio (height/width = 9/16 * 100%) */
}
.video-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
简单工厂模式:用多态优化对象创建(基于订单处理系统案例)问题场景当业务需要根据不同条件创建不同对象时,常见做法是使用switch或if-else分支:
12if(orderType == "Book") CreateBookHandler();else if(orderType == "Video") CreateVideoHandler();
这种写法会导致:
新增类型需修改核心逻辑
创建逻辑散落在各处
单元测试困难
解决方案:简单工 ...
.video-container {
position: relative;
width: 100%;
padding-top: 56.25%; /* 16:9 aspect ratio (height/width = 9/16 * 100%) */
}
.video-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
目录:第1章 绪论
1.1 什么是数据结构1.1.1 数据结构的定义1.1.2 逻辑结构1.1.3 存储结构1.1.4 数据运算1.1.5 数据类型和抽象数据类型1.2 算法及其描述1.2.1 什么是算法1.2.2 算法设计的目标1.2.3 算法描述1.3 算法分析1.3.1 算法分析概述1.3.2 算法时间性能分析1.3.3 算法空间性能分析1.4 数据结构+算法=程序1.4.1 程序和数据结构1.4.2 算法和程序1.4.3 算法和数据结构1.4.4 数据结构的发展第2 ...




