小编Fer*_*reu的帖子

ECONNREFUSED 在“下一个构建”期间。与“下一个开发者”配​​合良好

我有一个非常简单的 NextJS 9.3.5 项目。目前,它有一个页面/用户和一个pages/api/users从本地 MongoDB 表中检索所有用户的页面

它使用“next dev”在本地构建良好但是,它在“next build”失败并出现ECONNREFUSED错误

页面/用户

import fetch from "node-fetch"
import Link from "next/link"

export async function getStaticProps({ params }) {
  const res = await fetch(`http://${process.env.VERCEL_URL}/api/users`)
  const users = await res.json()
  return { props: { users } }
}

export default function Users({ users }) {
  return (
    <ul>
      {users.map(user => (
        <li key={user.id}>
          <Link href="/user/[id]" as={`/user/${user._id}`}>
            <a>{user.name}</a>
          </Link>
        </li>
      ))}
    </ul>
  );
}
Run Code Online (Sandbox Code Playgroud)

页面/api/用户

import mongoMiddleware from "../../lib/api/mongo-middleware";
import apiHandler from "../../lib/api/api-handler";

export …
Run Code Online (Sandbox Code Playgroud)

build mongodb hadoop-yarn next.js

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

如何关闭 Material UI 上下文菜单而不显示默认上下文菜单?

我正在尝试使用材质 UI 菜单在 div 上显示上下文菜单,如https://material-ui.com/components/menus/#context-menu中所示

这有效,我可以右键单击并显示它。

然而,material-ui 上下文菜单在显示时会注入一个透明的 div 覆盖菜单后面的整个屏幕。这意味着任何进一步的点击都会被该元素拦截。当检测到左键单击时,该元素似乎将关闭菜单,但如果您右键单击页面上的其他任何位置(包括上下文菜单不相关的位置),该元素将移动并继续显示相同的上下文菜单。

有没有办法在没有这个透明 div 的情况下显示菜单,该透明 div 会从我的页面中删除控制?

您可以在示例中看到此操作: https: //material-ui.com/components/menus/#context-menu 右键单击​​文本,然后右键单击其他任何位置(当菜单仍然显示时)可以触发菜单出现在整个页面上,甚至在应用栏中,菜单选项没有任何意义。

reactjs material-ui

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

如何在 Django 模板中显示对象计数

我有一个程序可以发布一些地方并在 HTML 模板中显示它们,但我也想向用户展示我拥有的许多这些地方,我想知道如何才能做到这一点。

我的models.py中有:

class Places(models.Model):
     name=models.CharField(max_length=100)
     text=models.TextField()
     website=models.URLField()
     published_date = models.DateTimeField(
            blank=True, null=True)

def __str__(self):
    return self.name

def publish(self):
        self.published_date = timezone.now()
        self.save()
Run Code Online (Sandbox Code Playgroud)

在views.py中:

def places(request):
     places=Places.objects.order_by('-published_date')[:10]
     return render(request, 'templates/places.html', {'places':places})
Run Code Online (Sandbox Code Playgroud)

和 html 模板:

<div class="container">
<h2>Places<span class="badge"> HERE'S WHERE I WANT THE NUMBER OF PLACES</h2>
</div>
Run Code Online (Sandbox Code Playgroud)

我希望你能帮助我。感谢您的回答

django

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

如何关闭输入响应的 InputStream(jax.rs)

@GET
@Path("/{id}/content")
@Produces({ "application/octet-stream" })
public Response getDocumentContentById(@PathParam("id") String docId) {

    InputStream is = getDocumentStream(); // some method which gives stream
    ResponseBuilder responseBuilder = Response.ok(is);
    responseBuilder.header("Content-Disposition", "attachment; filename=" + fileName);
    return responseBuilder.build();

}
Run Code Online (Sandbox Code Playgroud)

这里我如何关闭 InputStream 是?如果某物(jax.rs)自动关闭。请给我一些信息。谢谢你。

rest cxf jakarta-ee

5
推荐指数
1
解决办法
2121
查看次数

即使安装了所有必需的软件包,Matplotlib 也未安装

我是一名 Mac 用户,试图安装这个特定版本的 matplotlib,但我不断收到此错误。我已确保我拥有所需的软件包,但不确定如何确保它们位于正确的位置。目前,我无法使绘图适用于我正在处理的各种代码。错误如下:

pip3 install matplotlib==3.0.3
Collecting matplotlib==3.0.3
Using cached matplotlib-3.0.3.tar.gz (36.6 MB)
ERROR: Command errored out with exit status 1:
 command: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/g5/20g6q1l91sd1v97fz778n5wr0000gp/T/pip-install-yozx599p/matplotlib/setup.py'"'"'; __file__='"'"'/private/var/folders/g5/20g6q1l91sd1v97fz778n5wr0000gp/T/pip-install-yozx599p/matplotlib/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/g5/20g6q1l91sd1v97fz778n5wr0000gp/T/pip-install-yozx599p/matplotlib/pip-egg-info
     cwd: /private/var/folders/g5/20g6q1l91sd1v97fz778n5wr0000gp/T/pip-install-yozx599p/matplotlib/
Complete output (44 lines):
IMPORTANT WARNING:
    pkg-config is not installed.
    matplotlib may not be able to find some of its dependencies
============================================================================
Edit setup.cfg to change the build options

BUILDING MATPLOTLIB
            matplotlib: yes [3.0.3]
                python: yes [3.8.0 …
Run Code Online (Sandbox Code Playgroud)

python matplotlib freetype

5
推荐指数
1
解决办法
666
查看次数

GitHub 操作构建的最后一个工件的 URL

我使用 GitHub-action 进行构建,它生成多个工件(具有不同的名称)。

有没有办法预测上次成功构建的工件的 URL?不知道 sha1,只知道工件和回购的名称?

github-actions

5
推荐指数
3
解决办法
1130
查看次数

Netlify 部署抛出:错误:无效版本:“1”

从昨天开始,我遇到了一个无法修复或找不到相关信息的错误。我可以在本地构建我的网站,不会出现错误,但是当我尝试在 Netlify 中部署它时,它失败并抛出:

\n
8:19:33 AM: \xe2\x80\x8b\n8:19:33 AM: \xe2\x94\x8c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x90\n8:19:33 AM: \xe2\x94\x82        Netlify Build        \xe2\x94\x82\n8:19:33 AM: \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x98\n8:19:33 AM: \xe2\x80\x8b\n8:19:33 AM: \xe2\x9d\xaf Version\n8:19:33 AM:   @netlify/build 2.0.20\n8:19:33 AM: \xe2\x80\x8b\n8:19:33 AM: \xe2\x9d\xaf Flags\n8:19:33 AM:   deployId: 5efc2a7760231502ad0a057d\n8:19:33 AM:   mode: buildbot\n8:19:33 AM: \xe2\x80\x8b\n8:19:33 AM: \xe2\x9d\xaf Current directory\n8:19:33 AM:   /opt/build/repo\n8:19:33 AM: \xe2\x80\x8b\n8:19:33 AM: \xe2\x9d\xaf Config file\n8:19:33 AM:   /opt/build/repo/netlify.toml\n8:19:33 AM: \xe2\x80\x8b\n8:19:33 AM: \xe2\x9d\xaf Context\n8:19:33 AM:   production\n8:19:33 AM: \xe2\x80\x8b\n8:19:33 AM: \xe2\x94\x8c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x90\n8:19:33 AM: \xe2\x94\x82     Core internal error     \xe2\x94\x82\n8:19:33 AM: \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x98\n8:19:33 AM: \xe2\x80\x8b\n8:19:33 AM:   Error message\n8:19:33 AM:   Error: Invalid version: "1"\n8:19:33 …
Run Code Online (Sandbox Code Playgroud)

continuous-deployment gatsby netlify netlify-cms netlify-cli

5
推荐指数
1
解决办法
599
查看次数

Azure静态Web应用程序环境变量

我正在尝试通过 Azure Static Web 应用程序发布 Gatsbyjs。我有一个插件(gatsby-source-contentful)。

我需要传递如下变量:

{
      resolve: `gatsby-source-contentful`,
      options: {
        spaceId: process.env.CONTENTFUL_SPACE_ID,
        accessToken: process.env.CONTENTFUL_ACCESS_TOKEN,
      },
},
Run Code Online (Sandbox Code Playgroud)

错误:

Running 'npm run build'...


> gatsby-starter-default@0.1.0 build /github/workspace
> gatsby build

success open and validate gatsby-configs - 0.021s
error Invalid plugin options for "gatsby-source-contentful":

- "accessToken" is required
- "spaceId" is required
not finished load plugins - 0.905s
Run Code Online (Sandbox Code Playgroud)

我可以在哪里通过这个?

谢谢。

environment-variables node.js contentful gatsby azure-static-web-app

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

Azure Linux Web 应用程序-读取目录时出现错误 eisdir 非法操作

我的 Linux 应用服务计划上托管的 Web 应用程序出现问题。它是一个静态的 gatsby 站点,在 kubernetes 中运行得非常好。我想在 Azure Web 应用程序(Linux 应用程序服务计划)中运行它,但除了主页之外刷新不起作用。这在我当地也很有效。我的网络应用程序中有以下设置:-

在此输入图像描述

假设我的网站主页 URL 是 abcd.com,当我导航到帮助页面 (abcd.com/help) 时,它工作正常。但是,如果我刷新页面或尝试直接访问 URL,则会出现错误:-“抱歉,请与站点管理员联系以获取错误:EISDIR ..”。我检查了 kudu 控件,可以看到相同的错误。我将 Web 应用程序的 zip 部署文件与 Kubernetes 版本进行了比较,两者看起来相同。我不确定这里的问题是什么。有人可以帮忙吗?

azure reactjs kubernetes azure-app-service-plans azure-web-app-service

5
推荐指数
0
解决办法
1337
查看次数

如何在内容丰富的富文本中呈现超链接?

我有一个盖茨比应用程序,我在其中渲染富文本内容。一切都运行良好,除了我无法获取我在内容丰富的 CMS 中超链接的文本。当前代码如下所示,我可以获取 url 或 uri(在内容丰富的情况下),但不能获取我超链接的值/文本。有人可以帮忙吗?

import React from 'react';
import { graphql, Link } from 'gatsby';
import Img from 'gatsby-image';
import { renderRichText } from 'gatsby-source-contentful/rich-text';

import { BLOCKS, MARKS, INLINES } from '@contentful/rich-text-types';

const Bold = ({ children }) => <span className="bold">{children}</span>;
const Text = ({ children }) => <p className="align-center">{children}</p>;

const website_url = 'https://stackoverflow.com';

// Setting the rendering options. Same as:
// https://github.com/contentful/rich-text/tree/master/packages/rich-text-react-renderer
const options = {
    renderMark: {
        [MARKS.BOLD]: (text) => <Bold>{text}</Bold>
    },
    renderNode: {
        [INLINES.HYPERLINK]: …
Run Code Online (Sandbox Code Playgroud)

reactjs contentful

5
推荐指数
1
解决办法
4465
查看次数