Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: 修改getStatus请求间隔+ 通过时间戳取代版本号解决缓存问题 + 增加登录失效时自动重定向到登录页面 #173

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions web/assets/js/util/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ class HttpUtil {
Vue.prototype.$message.success(msg.msg);
} else {
Vue.prototype.$message.error(msg.msg);
if (msg.msg == '登录时效已过,请重新登录') {
setTimeout(()=> {
Vue.prototype.$message.warning("即将开始重新登录!")
setTimeout(()=> {window.location.reload()},3000)
},2000)
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion web/controller/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net"
"net/http"
"strings"
"time"
"x-ui/config"
"x-ui/logger"
"x-ui/web/entity"
Expand Down Expand Up @@ -82,7 +83,8 @@ func html(c *gin.Context, name string, title string, data gin.H) {

func getContext(h gin.H) gin.H {
a := gin.H{
"cur_ver": config.GetVersion(),
"cur_ver": config.GetVersion(),
"timeStamp": time.Now().Unix(),
}
if h != nil {
for key, value := range h {
Expand Down
13 changes: 7 additions & 6 deletions web/html/common/js.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
<script src="{{ .base_path }}assets/qrcode/qrious.min.js"></script>
<script src="{{ .base_path }}assets/clipboard/clipboard.min.js"></script>
<script src="{{ .base_path }}assets/uri/URI.min.js"></script>
<script src="{{ .base_path }}assets/js/axios-init.js?{{ .cur_ver }}"></script>
<script src="{{ .base_path }}assets/js/util/common.js?{{ .cur_ver }}"></script>
<script src="{{ .base_path }}assets/js/util/date-util.js?{{ .cur_ver }}"></script>
<script src="{{ .base_path }}assets/js/util/utils.js?{{ .cur_ver }}"></script>
<script src="{{ .base_path }}assets/js/model/xray.js?{{ .cur_ver }}"></script>
<script src="{{ .base_path }}assets/js/model/models.js?{{ .cur_ver }}"></script>
<!-- 这里通过插入时间戳,避免因为浏览器缓存原因无法读取到js文件修改的变化 -->
<script src="{{ .base_path }}assets/js/axios-init.js?{{ .timeStamp }}"></script>
<script src="{{ .base_path }}assets/js/util/common.js?{{ .timeStamp }}"></script>
<script src="{{ .base_path }}assets/js/util/date-util.js?{{ .timeStamp }}"></script>
<script src="{{ .base_path }}assets/js/util/utils.js?{{ .timeStamp }}"></script>
<script src="{{ .base_path }}assets/js/model/xray.js?{{ .timeStamp }}"></script>
<script src="{{ .base_path }}assets/js/model/models.js?{{ .timeStamp }}"></script>
<script>
const basePath = '{{ .base_path }}';
axios.defaults.baseURL = basePath;
Expand Down
2 changes: 1 addition & 1 deletion web/html/xui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ <h2>请谨慎选择,旧版本可能配置不兼容</h2>
} catch (e) {
console.error(e);
}
await PromiseUtil.sleep(2000);
await PromiseUtil.sleep(15000);
}
},
});
Expand Down