镜像自地址
https://github.com/binary-husky/gpt_academic.git
已同步 2025-12-06 14:36:48 +00:00
fix: welcome card flip bug
这个提交包含在:
@@ -67,6 +67,17 @@ class WelcomeMessage {
|
|||||||
this.card_array = [];
|
this.card_array = [];
|
||||||
this.static_welcome_message_previous = [];
|
this.static_welcome_message_previous = [];
|
||||||
this.reflesh_time_interval = 15*1000;
|
this.reflesh_time_interval = 15*1000;
|
||||||
|
|
||||||
|
|
||||||
|
const reflesh_render_status = () => {
|
||||||
|
for (let index = 0; index < this.card_array.length; index++) {
|
||||||
|
const card = this.card_array[index];
|
||||||
|
card.classList.remove('hide');
|
||||||
|
card.classList.remove('show');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const pageFocusHandler = new PageFocusHandler();
|
||||||
|
pageFocusHandler.addFocusCallback(reflesh_render_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
begin_render() {
|
begin_render() {
|
||||||
@@ -106,8 +117,12 @@ class WelcomeMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const card = this.card_array[index];
|
const card = this.card_array[index];
|
||||||
|
// 已经包含了 hide 属性?
|
||||||
|
if (card.classList.contains('hide') || card.classList.contains('show')) {
|
||||||
card.classList.remove('hide');
|
card.classList.remove('hide');
|
||||||
card.classList.remove('show');
|
card.classList.remove('show');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// 等待动画结束
|
// 等待动画结束
|
||||||
card.addEventListener('transitionend', () => {
|
card.addEventListener('transitionend', () => {
|
||||||
@@ -158,7 +173,7 @@ class WelcomeMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async update() {
|
async update() {
|
||||||
console.log('update')
|
// console.log('update')
|
||||||
var page_width = document.documentElement.clientWidth;
|
var page_width = document.documentElement.clientWidth;
|
||||||
const width_to_hide_welcome = 1200;
|
const width_to_hide_welcome = 1200;
|
||||||
if (!await this.isChatbotEmpty() || page_width < width_to_hide_welcome) {
|
if (!await this.isChatbotEmpty() || page_width < width_to_hide_welcome) {
|
||||||
@@ -269,3 +284,34 @@ class WelcomeMessage {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class PageFocusHandler {
|
||||||
|
constructor() {
|
||||||
|
this.hasReturned = false;
|
||||||
|
this.focusCallbacks = [];
|
||||||
|
|
||||||
|
// Bind the focus and blur event handlers
|
||||||
|
window.addEventListener('visibilitychange', this.handleFocus.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to handle the focus event
|
||||||
|
handleFocus() {
|
||||||
|
if (this.hasReturned) {
|
||||||
|
this.focusCallbacks.forEach(callback => callback());
|
||||||
|
}
|
||||||
|
this.hasReturned = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to add a custom callback function
|
||||||
|
addFocusCallback(callback) {
|
||||||
|
if (typeof callback === 'function') {
|
||||||
|
this.focusCallbacks.push(callback);
|
||||||
|
} else {
|
||||||
|
throw new Error('Callback must be a function');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
在新工单中引用
屏蔽一个用户