这个问题描述了与这个问题中解释的相同的问题,但是由于它没有提供任何代码,我正在打开一个新的代码。
使用Modifier.animateContentSize(),我可以为卡内内容的扩展设置动画,但是,与我所知应该发生的情况相反,我无法为内容的缩小设置动画。
每当我在按钮变大后单击按钮时,它不会播放缩小的动画,而是立即恢复到原始大小,没有任何类型的过渡。
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun TheThing() {
var expanded by remember { mutableStateOf(false) }
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
Column {
Card(
onClick = { expanded = !expanded },
modifier = Modifier
.padding(16.dp)
.fillMaxWidth()
.animateContentSize()
) {
Text("Clickable", style = MaterialTheme.typography.displayMedium)
if (expanded) {
Text("More text here... ")
Text("More text here... ")
Text("More text here... ")
Text("More text …Run Code Online (Sandbox Code Playgroud) 我已经成功地在我的 WebAPI 中设置了 JWT 身份验证/授权,但是有一个问题:我可以创建一个新的用户帐户,生成它的 JWT 令牌,然后在令牌仍然有效时删除该帐户。 在授权之前,我应该如何以及在哪里检查与令牌关联的用户是否确实存在?
这是我设置 JWT ( Startup.cs) 的代码:
var secretKey = Configuration.GetValue<string>("SecretKey");
var symmetricKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(secretKey));
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.TokenValidationParameters = new TokenValidationParameters()
{
ValidateIssuer = true,
ValidateAudience = true,
ValidateIssuerSigningKey = true,
ValidIssuer = "localhost",
ValidAudience = "localhost",
IssuerSigningKey = symmetricKey
};
});
Run Code Online (Sandbox Code Playgroud)
我在[Authorize]控制器上使用该属性,并且用户 ID 在 JWT 令牌中。
提前致谢!
authentication authorization jwt asp.net-core asp.net-core-webapi
本质上,我试图编写的是一个函数,它接受不同类型的数组(用它做一些事情),然后仅基于该数组中的最后一个元素返回一个类型(先前的元素已被处理,但仅处理了最后一个元素用于返回值)。
我知道我可以编写一个函数,该函数返回基于所有元素类型的数组,如下所示。
function arraymod<T extends unknown[]>(
...input: {
[index in keyof T]: ParamType<T[index]>
}
): T {
return input.map(unparam);
}
Run Code Online (Sandbox Code Playgroud)
我想要的是一个执行类似操作的函数。
function takelast<T extends unknown[]>(
...input: {
[index in keyof T]: ParamType<T[index]>
}
): LastElementOf<T> /* What would this return type be? */ {
return unparam(input[input.length - 1]);
Run Code Online (Sandbox Code Playgroud)
(ParamType<T>只是unparam一些用于说明的示例类型/函数)
如何编写一个类型LastElementOf<T>来给出元组T(或数组,即使这只是任何元素的类型)的最后一个元素的类型。