]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
Improve 优化回放缓存
authorqydysky <qydysky@foxmail.com>
Sun, 21 Jul 2024 12:44:37 +0000 (20:44 +0800)
committerqydysky <qydysky@foxmail.com>
Sun, 21 Jul 2024 12:44:37 +0000 (20:44 +0800)
Reply/F.go
demo/html/artPlayer/index.html
go.mod
go.sum

index ac7ac2d9227e5e59fc00c030942a7ec6f990cd7b..73a13e4603ee68065316752645498b88a19fbc47 100644 (file)
@@ -1214,20 +1214,17 @@ func init() {
                                w.Header().Set("content-type", "text/html")
                        }
 
-                       //cache
-                       if bp, ok := cache.IsCache("html/streamList/" + p); ok {
-                               w.Header().Set("Cache-Control", "max-age=60")
-                               _, _ = w.Write(*bp)
-                               return
-                       }
-                       w = cache.Cache("html/streamList/"+p, time.Minute, w)
-
                        f := file.New("html/streamList/"+p, 0, true)
                        if !f.IsExist() || f.IsDir() {
                                w.WriteHeader(http.StatusNotFound)
                                return
                        }
 
+                       // mod
+                       if info, e := f.Stat(); e == nil && pweb.NotModified(r, w, info.ModTime()) {
+                               return
+                       }
+
                        b, _ := f.ReadAll(humanize.KByte, humanize.MByte)
                        _, _ = w.Write(b)
                })
@@ -1322,6 +1319,11 @@ func init() {
                                return
                        }
 
+                       // mod
+                       if info, e := f.Stat(); e == nil && pweb.NotModified(r, w, info.ModTime()) {
+                               return
+                       }
+
                        b, _ := f.ReadAll(humanize.KByte, humanize.MByte)
                        _, _ = w.Write(b)
                })
@@ -1358,6 +1360,11 @@ func init() {
                                return
                        }
 
+                       // mod
+                       if info, e := f.Stat(); e == nil && pweb.NotModified(r, w, info.ModTime()) {
+                               return
+                       }
+
                        b, _ := f.ReadAll(humanize.KByte, humanize.MByte)
                        _, _ = w.Write(b)
                })
index fc303def4307a8868b757965f1262e1e15171d9e..ca37351c96daad66c5c84dcafdf7fcd88d1c1caf 100644 (file)
     </head>
     <body>
         <div class="artplayer-app"></div>
-        <script>
-            /**
-             * @function addDOM 添加节点
-             * @version 0.0
-             * @param {*} El 添加到哪个元素
-             * @param {*} ElN 添加的元素名
-             * @param {*} text 元素内的值
-             * @param {*} cla 该元素属性,数组,[[属性名,属性值],[..,..],]
-             */
-            function addDOM(El,ElN,text,cla){
-                var d=document.createElement(ElN);
-                if(text)d.innerHTML=text;
-                for(var i=0;i<cla.length;i++)d.setAttribute(cla[i][0],cla[i][1]);
-                El.appendChild(d);
-            }
-            addDOM(document.body, "script", "", [["src", "bundle.js?_="+new Date().getTime()]])
-        </script>
+        <script src="bundle.js"></script>
     </body>
 </html>
\ No newline at end of file
diff --git a/go.mod b/go.mod
index 931fdebc0a02475f252b98aa3a59aa956cbacd2c..f8de8d7f18616085d0fb9ae80da7aa554f8c9ab0 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -5,7 +5,7 @@ go 1.22.2
 require (
        github.com/gotk3/gotk3 v0.6.4
        github.com/mdp/qrterminal/v3 v3.2.0
-       github.com/qydysky/part v0.28.20240721025108
+       github.com/qydysky/part v0.28.20240721124143
        github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
        github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
        golang.org/x/text v0.16.0
diff --git a/go.sum b/go.sum
index 2bfa75c356c1ad0ae8521a6b53ada7b672255fdd..6b258fd5a3fbaef35f387ceac4fd73e1f5d1bf7e 100644 (file)
--- a/go.sum
+++ b/go.sum
@@ -46,8 +46,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 github.com/qydysky/biliApi v0.0.0-20240707084224-dd146610f462 h1:SblV/m+0mx6QgH2YYvdjE5QxhyfE/EOQglJ1PGd3x3E=
 github.com/qydysky/biliApi v0.0.0-20240707084224-dd146610f462/go.mod h1:om024vfxALQ5vxsbaGoMm8IS0esLYBnEOpJI8FsGoDg=
-github.com/qydysky/part v0.28.20240721025108 h1:3E8dRdVYfYDMNgMG1mIVigrj0i3fi4LsriKTHpo+EXc=
-github.com/qydysky/part v0.28.20240721025108/go.mod h1:dgagZnPYRFZDbt7XJf7nADOJLoYwlebD9B8Z8g5aHhI=
+github.com/qydysky/part v0.28.20240721124143 h1:PX5BIhrrrnKN/VJFJSeg+qzdAPKb+N199vDtPjyNK5g=
+github.com/qydysky/part v0.28.20240721124143/go.mod h1:dgagZnPYRFZDbt7XJf7nADOJLoYwlebD9B8Z8g5aHhI=
 github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
 github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
 github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=