Code Monkey home page Code Monkey logo

version-polling's Introduction

Hi there 👋

  • 🤔 编写高质量、可维护、易扩展的程序代码
  • ✨ 开发3步走,测试->编码->重构

Github 统计

version-polling's People

Contributors

joeshutt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

version-polling's Issues

js文件加载不出来

Snipaste_2024-04-12_11-30-25
从昨天开始会频繁出现js文件加载不出来的问题,这个是因为什么额

Content-Encoding导致ETag变化

线上部署好后,第一次请求:
image
第二次请求:
image
由于Content-Encoding导致ETag变化,认为有更新,实际没有更新,这种情况如何避免?

通过 npm 引入写法项目报错运行不起来

在应用入口文件中代码如下:

import { createVersionPolling } from 'version-polling'
import { Button, notification, Space } from 'antd'

createVersionPolling({
  appETagKey: '__APP_ETAG__',
  pollingInterval: 5 * 1000, // 单位为毫秒
  silent: process.env.NODE_ENV === 'development', // 开发环境下不检测
  onUpdate: (self) => {
    notification.info({
      message: '页面有新的功能更新,请您点击确定按钮刷新查看~',
      btn: (
        <Space>
          <Button
            size="small"
            onClick={() => {
              notification.destroy()
              self.onCancel()
            }}
          >
            取消
          </Button>
          <Button
            type="primary"
            size="small"
            onClick={() => {
              notification.destroy()
              self.onRefresh()
            }}
          >
            确认
          </Button>
        </Space>
      ),
    })
  },
})

页面报错内容:

Uncaught Error: Module parse failed: Unexpected token (278:35)
You may need an appropriate loader to handle this file type.
|             _this.stop();
| 
>             _this.options.onUpdate?.(_this);
|           }
|         };
    at ./node_modules/.pnpm/[email protected]/node_modules/version-polling/dist/version-polling.js (value-equal.js:29:1)
    at __webpack_require__ (bootstrap:786:1)
    at fn (bootstrap:149:1)
    at Module.<anonymous> (index.css:45:1)
    at ./src/index.tsx (index.tsx:70:1)
    at __webpack_require__ (bootstrap:786:1)
    at fn (bootstrap:149:1)
    at 0 (utils.tsx:734:1)
    at __webpack_require__ (bootstrap:786:1)
    at checkDeferredModules (bootstrap:45:1)
    at Array.webpackJsonpCall

package.json 文件:

"react": "^17.0.1",
"webpack": "4.29.6",
"node": "v16.20.2",

关于onRefresh方法

查看源码如下:
onRefresh() {
window.location.reload();
}
window.location.reload();方法相当于浏览器正常刷新,如果出现重新打包的情况,还是会使用原来的缓存文件。使用window.location.reload(true);会不会好点,相当于清空缓存的刷新

Vue项目使用有什么需要注意的吗?

现在遇到两个问题:
1.页面不可见后,任务停止,页面恢复后会立即只执行一次,但是不会实时去执行了。
2.index.html 没有更新内容,但是等待 1 分钟左右,依然弹窗更新。
对于 Vue 这种SPA 单页应用。htmlFileUrl: ${location.origin},是否是需要这样配置?

Import error

export 'createVersionPolling' (imported as 'createVersionPolling') was not found in 'version-polling'

轮询更新

在pollingInterval字段里设置时长为 60 * 60 * 1000的间隔时间,当发布新版本时会立刻发现版本更新,是我的时间设置问题还是一直在每秒进行轮询

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.