如何删除生产中的 Create React App 示例

How to remove Create react app sample in production

我有一个已成功部署到生产服务器中的域。 但是每当我打开它时,地址栏中都会显示一个 Install app: Create React app sample

有什么办法可以去掉这个。 我应该在我的代码中更改什么? 有什么建议吗?

//客户端package.json

{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "axios": "^0.19.2",
    "bootstrap": "^4.4.1",
    "bootstrap-less": "^3.3.8",
    "moment": "^2.24.0",
    "node-sass": "^4.13.1",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "redux-thunk": "^2.3.0",
    "uuid": "^7.0.3"
  },
  "scripts": {
    "start": "react-scripts start",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
    ],
    "development": [
      "last 1 chrome version",
    ]
  },
  "proxy": "http://localhost:5000"
}

//manifest.json

{
  "short_name": "React App",
  "name": "Create React App Sample",
  "icons": [
    {
      "src": "favicon.ico",
      "sizes": "64x64 32x32 24x24 16x16",
      "type": "image/x-icon"
    },
    {
      "src": "logo192.png",
      "type": "image/png",
      "sizes": "192x192"
    },
    {
      "src": "logo512.png",
      "type": "image/png",
      "sizes": "512x512"
    }
  ],
  "start_url": ".",
  "display": "standalone",
  "theme_color": "#000000",
  "background_color": "#ffffff"
}

您需要更改 manifest.json 文件,您可能会在 create-react-app 创建的 public 文件夹中找到它。

manifest.json 文件被 serviceWorker 用来让用户将你的 webapp 安装为应用程序,你可以跳过 short_name 属性,但你应该提供一个正确的名称。但跳过两者不会对应用程序的功能造成任何问题,在这种情况下浏览器将为您的应用程序使用默认名称(即无标题)。

根据我的建议,您应该同时提供 short_namename 属性。

在那里

{
  "short_name": "React App",
  "name": "Create React App Sample", // you need to change this
  "icons": [
    {
      "src": "favicon.ico",
      "sizes": "192x192",
      "type": "image/png"
    }
  ],
  "start_url": "./index.html",
  "display": "standalone",
  "theme_color": "#000000",
  "background_color": "#ffffff"
}