FineAdmin.Web/Content/lib/wangEditor/src/js/editor/upload/progress.js

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

/*
    上传进度条
*/

import $ from '../../util/dom-core.js'

function Progress(editor) {
    this.editor = editor
    this._time = 0
    this._isShow = false
    this._isRender = false
    this._timeoutId = 0
    this.$textContainer = editor.$textContainerElem
    this.$bar = $('<div class="w-e-progress"></div>')
}

Progress.prototype = {
    constructor: Progress,

    show: function (progress) {
        // 状态处理
        if (this._isShow) {
            return
        }
        this._isShow = true

        // 渲染
        const $bar = this.$bar
        if (!this._isRender) {
            const $textContainer = this.$textContainer
            $textContainer.append($bar)
        } else {
            this._isRender = true
        }

        // 改变进度(节流,100ms 渲染一次)
        if (Date.now() - this._time > 100) {
            if (progress <= 1) {
                $bar.css('width', progress * 100 + '%')
                this._time = Date.now()
            }
        }

        // 隐藏
        let timeoutId = this._timeoutId
        if (timeoutId) {
            clearTimeout(timeoutId)
        }
        timeoutId = setTimeout(() => {
            this._hide()
        }, 500)
    },

    _hide: function () {
        const $bar = this.$bar
        $bar.remove()

        // 修改状态
        this._time = 0
        this._isShow = false
后面还有 5 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。