小编NoK*_*Key的帖子

自动聚焦于可搜索的

我正在使用新的可搜索修饰符:https://developer.apple.com/documentation/swiftui/form/searchable(text:placement:)。当用户使用该修饰符进入视图时,该文本字段不会自动聚焦。

有没有办法让注意力集中在 上searchable?这是我的观点,它被称为NavigationLink

import SwiftUI

struct UserFindView: View {
    @State private var searchText = ""

    var body: some View {
        Text("Please search")
                .searchable(text: $searchText)
                .navigationTitle("Title")
                .navigationBarTitleDisplayMode(.inline)
    }
}
Run Code Online (Sandbox Code Playgroud)

swift swiftui

12
推荐指数
1
解决办法
3029
查看次数

Future 生成器闭包时出错:捕获的变量无法转义“FnMut”闭包主体

我想创建一个简单的 websocket 服务器。我想处理传入的消息并发送响应,但收到错误:

error: captured variable cannot escape `FnMut` closure body
  --> src\main.rs:32:27
   |
32 |       incoming.for_each(|m| async {
   |  _________________________-_^
   | |                         |
   | |                         inferred to be a `FnMut` closure
33 | |         match m {
34 | |             // Error here...
35 | |             Ok(message) => do_something(message, db, &mut outgoing).await,
36 | |             Err(e) => panic!(e)
37 | |         }
38 | |     }).await;
   | |_____^ returns a reference to a captured variable which escapes the closure …
Run Code Online (Sandbox Code Playgroud)

rust async-await

9
推荐指数
1
解决办法
9840
查看次数

如何使用 Cargo 在 Github Actions 中下载另一个私有存储库?

问题

我有一个私有 Rust 项目 (A),它依赖于另一个私有 Rust 项目 (B)。在我的本地机器上,它可以工作,因为我登录了 git。我不知道如何在 Github Actions 中登录 git。我不确定是否需要。我读了很多关于 SSH 和 HTTPS 的内容,以至于我忘记了我必须做什么。

我看到了https://github.com/webfactory/ssh-agenthttps://github.com/fusion-engineering/setup-git-credentials和其他一些操作,但我只是猜测我需要做的事情我无法让它工作。

设置

这是我在项目 A 中的 Cargo.toml 文件:

...
[dependencies]
b = { git = "https://github.com/me/b.git" }
Run Code Online (Sandbox Code Playgroud)

这在 Github Actions 中失败,因为 Github Actions 无法在没有某些令牌的情况下下载私有存储库。我创建了一个个人访问令牌并将我的 Cargo.toml 更改为:

...
[dependencies]
b = { git = "https://ignore:MyPersonalAccessToken@github.com/me/b" }
Run Code Online (Sandbox Code Playgroud)

但我收到一封来自 Github 的电子邮件,说我的令牌已被撤销,因为不允许将其硬编码在代码中......

现在我不知道该怎么办。我可以将令牌放入我的 github 秘密中,但我不知道我的 Cargo.toml 如何使用它。

有没有一种简单的方法可以在 Github Actions 中登录 git?我尝试了https://github.com/OleksiyRudenko/gha-git-credentials并配置了我的工作流程,如下所示:

- uses: oleksiyrudenko/gha-git-credentials@v2-latest
  with:
    token: '${{ secrets.GIT_CREDENTIALS }}'
    global: true …
Run Code Online (Sandbox Code Playgroud)

github rust rust-cargo github-actions

9
推荐指数
1
解决办法
4312
查看次数

使用 PGP Bouncy Castle 依赖项创建 CipherOutputStream

我想OutputStream从另一个创建一个OutputStream,其中新的OutputStream将自动加密我写入的内容OutputStream。我想使用 Bouncy Castle,因为我已经将该依赖项用于其他功能。

我在互联网上看到了如何使用 Bouncy Castle 加密数据的各种问题,但答案要么加密给定File(我不使用文件,我使用OutputStreams)要么有大量代码需要复制粘贴。我不敢相信这一定是那么困难。

这是我的设置:

  1. 我正在使用这个 Bouncy Castle 依赖项 (V1.68)
  2. 我正在使用 Java 8
  3. 我有一个由https://pgpkeygen.com/生成的公钥和私钥。算法为 RSA,密钥大小为 1024。
  4. 我将公钥和私钥作为文件保存在我的机器上
  5. 我想确保下面的测试通过

我注释掉了一些代码,Cipher 上的 init 函数(代码编译,但测试失败)。我不知道应该在 init 函数中放入什么作为第二个参数。读取函数来自:https : //github.com/jordanbaucke/PGP-Sign-and-Encrypt/blob/472d8932df303d6861ec494a3e942ea268eaf25f/src/SignAndEncrypt.java#L272。只有 testEncryptDecryptWithoutSigning 是我写的。

代码:

@Test
void testEncryptDecryptWithoutSigning() throws Exception {
    // The data will be written to this property
    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    Security.addProvider(new BouncyCastleProvider());

    PGPSecretKey privateKey = readSecretKey(pathToFile("privatekey0"));
    Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
    //cipher.init(Cipher.ENCRYPT_MODE, privateKey); …
Run Code Online (Sandbox Code Playgroud)

java bouncycastle pgp

8
推荐指数
1
解决办法
293
查看次数

缺少node-v59-linux-x64/grpc_node.node

我正在尝试在我的服务器中使用Firebase管理员SDK.当我部署时,我得到错误,我在firebase-admin node_module map中缺少文件node-v59-linux-x64/grpc_node.node.我在我的包中添加了"grpc":"1.7.1",但是在NPM更新后我仍然没有得到该文件.我得到一个旧版本,node-v57.我还检查了这条路径https://registry.npmjs.org/grpc/-/grpc-1.7.1.tgz,但我找不到该文件.我删除了我的node_modules映射并再次运行npm install,仍然没有node-v59.

我如何/在哪里下载该文件?有没有人可以把文件放在这里,所以我可以手动添加它?

错误:找不到模块'/data/app/node_modules/grpc/src/node/extension_binary/node-v59-linux-x64/grpc_node.node'

github node.js npm firebase grpc

6
推荐指数
2
解决办法
2674
查看次数

失败:构建失败并出现异常。, kaptGenerateStubsDebugKotlin

我收到以下错误,并且我一直在寻找答案几个小时:

> Task :entities:bundleLibCompileToJarDebug

> Task :app:kaptGenerateStubsDebugKotlin FAILED
e: Could not load module <Error module>

> Task :app:mergeLibDexDebug

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:kaptGenerateStubsDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error. See log for more details
Run Code Online (Sandbox Code Playgroud)

突然出现这个错误。我尝试了以下操作:

  1. 删除了 .idea 目录
  2. 重新启动我的电脑
  3. 删除所有gradle缓存
  4. 重建项目

错误依然存在。还有其他建议吗?

android android-studio

6
推荐指数
1
解决办法
2232
查看次数

node-v57-linux-x64/grpc_node.node缺失

完全遵循以下步骤时:

https://firebase.google.com/docs/admin/setup

并部署到我的服务器,我收到此错误:

2017-10-16 19:19:56 4199bf47fc2d ---> Starting app
2017-10-16 19:19:56 4199bf47fc2d Detected server.js file
2017-10-16 19:19:57 4199bf47fc2d module.js:529
2017-10-16 19:19:57 4199bf47fc2d     throw err;
2017-10-16 19:19:57 4199bf47fc2d     ^
2017-10-16 19:19:57 4199bf47fc2d 
2017-10-16 19:19:57 4199bf47fc2d Error: Cannot find module '/data/app/node_modules/firebase-admin/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64/grpc_node.node'
2017-10-16 19:19:57 4199bf47fc2d     at Function.Module._resolveFilename (module.js:527:15)
2017-10-16 19:19:57 4199bf47fc2d     at Function.Module._load (module.js:476:23)
2017-10-16 19:19:57 4199bf47fc2d     at Module.require (module.js:568:17)
2017-10-16 19:19:57 4199bf47fc2d     at require (internal/module.js:11:18)
2017-10-16 19:19:57 4199bf47fc2d     at Object.<anonymous> (/data/app/node_modules/firebase-admin/node_modules/grpc/src/node/src/grpc_extension.js:30:15)
2017-10-16 19:19:57 4199bf47fc2d     at Module._compile (module.js:624:30)
2017-10-16 19:19:57 4199bf47fc2d     at Object.Module._extensions..js …
Run Code Online (Sandbox Code Playgroud)

github node.js npm firebase

5
推荐指数
2
解决办法
5519
查看次数

Typescript 类实例到 JavaScript 对象

这是我的代码:

class A{
    test: string
    constructor(test: string){
        this.test = test
    }
}
const a = new A("hi")
console.log(a)
Run Code Online (Sandbox Code Playgroud)

这是我的输出:

一个{测试:'嗨'}

当我想将其作为 Javascript 对象上传时,它被拒绝,因为它不是 Javascript 对象。我可以这样做:

const someJSON = JSON.stringify(a)
const javascriptObject = JSON.parse(someJSON)
Run Code Online (Sandbox Code Playgroud)

但我认为一定有更好的方法,这感觉就像一个黑客。如何将 TypeScript 类实例转换为纯 JavaScript 对象?

javascript typescript

3
推荐指数
1
解决办法
3604
查看次数

将文件 Bitnami Wordpress 上传到通过 application/json 提供的 .wellknown

我刚刚开始使用 Bitnami Wordpress for Apache,但在为 iOS 实现密码自动填充时遇到问题:https://developer.apple.com/documentation/xcode/supporting-linked-domains

简而言之,应该可以从域上的目录apple-app-site-association获取名为的文件:.well-known

https://<fully qualified domain>/.well-known/apple-app-site-association
Run Code Online (Sandbox Code Playgroud)

application/json

问题是,我遇到的几乎所有教程都已经过时了。以配置 apple-app-site-association 文件与 WordPress为例。他们正在谈论类似的路径/etc/apache2/sites-available/default-ssl,但我没有目录/etc/apache

我通过 SFTP 连接到服务器。我看到我的根目录是/home/bitname/. 在其中,我看到一个stack包含 wordpress 目录的目录。我将文件上传到此目录,然后可以立即从我的域下载它。但是当我创建一个新.well-known目录并将文件放入其中时,我无法访问以下域:

https://<fully qualified domain>/.well-known/apple-app-site-association

我像这样重新启动了 Apache:

sudo /opt/bitnami/ctlscript.sh restart apache

但这不起作用。有什么建议么?

wordpress bitnami ios ios-universal-links

3
推荐指数
1
解决办法
571
查看次数

转换引用内的类型!给出特征错误

我收到此错误:

该特征quote::to_tokens::ToTokens未实现 proc_macro::Ident

当我尝试运行此代码时:

#[proc_macro_hack]
pub fn between(input: TokenStream) -> TokenStream {
    let idents = input
        .into_iter()
        .map(|i| match i {
            TokenTree::Ident(b) => {
                b
            },
            _ => panic!()
        })
        .collect::<Vec<_>>();

    let new_token_stream = quote! {
        (#(#idents),*)
    };

    new_token_stream.into()
}
Run Code Online (Sandbox Code Playgroud)

这就是我想使用它的方式:

fn main() {
    let a = 1;
    let b = 2;

    // Expand to (a, b);
    between!(a, b);
}
Run Code Online (Sandbox Code Playgroud)

我还有一个包含上述代码的小项目: https: //bitbucket.org/JoshSinne/pm/src/master/。为什么我无法转换Ident内部令牌?我尝试使用parseinto但这对我来说没有成功。谢谢!

rust rust-proc-macros

2
推荐指数
1
解决办法
1682
查看次数