mirror of
https://github.com/JannisX11/blockbench.git
synced 2024-12-09 04:50:29 +08:00
Improve start screen performance
This commit is contained in:
parent
2aac76d81c
commit
ebda6d4671
@ -148,6 +148,7 @@ function addRecentProject(data) {
|
|||||||
}
|
}
|
||||||
recent_projects.splice(0, 0, project)
|
recent_projects.splice(0, 0, project)
|
||||||
ipcRenderer.send('add-recent-project', data.path);
|
ipcRenderer.send('add-recent-project', data.path);
|
||||||
|
StartScreen.vue.updateThumbnails([data.path]);
|
||||||
updateRecentProjects()
|
updateRecentProjects()
|
||||||
}
|
}
|
||||||
async function updateRecentProjectThumbnail() {
|
async function updateRecentProjectThumbnail() {
|
||||||
@ -180,6 +181,7 @@ async function updateRecentProjectThumbnail() {
|
|||||||
project.path = store_path;
|
project.path = store_path;
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
StartScreen.vue.updateThumbnails([project.path]);
|
||||||
|
|
||||||
// Clean old files
|
// Clean old files
|
||||||
if (Math.random() < 0.2) {
|
if (Math.random() < 0.2) {
|
||||||
|
@ -143,6 +143,7 @@ onVueSetup(function() {
|
|||||||
search_term: '',
|
search_term: '',
|
||||||
isApp,
|
isApp,
|
||||||
mobile_layout: Blockbench.isMobile,
|
mobile_layout: Blockbench.isMobile,
|
||||||
|
thumbnails: {},
|
||||||
getIconNode: Blockbench.getIconNode
|
getIconNode: Blockbench.getIconNode
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -167,11 +168,17 @@ onVueSetup(function() {
|
|||||||
loadModelFile(files[0]);
|
loadModelFile(files[0]);
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getThumbnail(model_path) {
|
updateThumbnails(model_paths) {
|
||||||
let hash = model_path.hashCode().toString().replace(/^-/, '0');
|
this.recent.forEach(project => {
|
||||||
let path = PathModule.join(app.getPath('userData'), 'thumbnails', `${hash}.png`);
|
if (model_paths && !model_paths.includes(project.path)) return;
|
||||||
if (!fs.existsSync(path)) return;
|
let hash = project.path.hashCode().toString().replace(/^-/, '0');
|
||||||
return path + '?' + Math.round(Math.random()*255);
|
let path = PathModule.join(app.getPath('userData'), 'thumbnails', `${hash}.png`);
|
||||||
|
if (!fs.existsSync(path)) {
|
||||||
|
delete this.thumbnails[project.path];
|
||||||
|
} else {
|
||||||
|
this.thumbnails[project.path] = path + '?' + Math.round(Math.random()*255);
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
setListType(type) {
|
setListType(type) {
|
||||||
this.list_type = type;
|
this.list_type = type;
|
||||||
@ -262,6 +269,9 @@ onVueSetup(function() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
this.updateThumbnails();
|
||||||
|
},
|
||||||
template: `
|
template: `
|
||||||
<div id="start_screen">
|
<div id="start_screen">
|
||||||
<content>
|
<content>
|
||||||
@ -379,7 +389,7 @@ onVueSetup(function() {
|
|||||||
@click="openProject(project, $event)"
|
@click="openProject(project, $event)"
|
||||||
@contextmenu="recentProjectContextMenu(project, $event)"
|
@contextmenu="recentProjectContextMenu(project, $event)"
|
||||||
>
|
>
|
||||||
<img class="thumbnail_image" v-if="getThumbnail(project.path)" :src="getThumbnail(project.path)" />
|
<img class="thumbnail_image" v-if="thumbnails[project.path]" :src="thumbnails[project.path]" />
|
||||||
<span class="recent_project_name">{{ redact_names ? redacted : project.name }}</span>
|
<span class="recent_project_name">{{ redact_names ? redacted : project.name }}</span>
|
||||||
<span class="icon_wrapper" v-html="getIconNode(project.icon).outerHTML"></span>
|
<span class="icon_wrapper" v-html="getIconNode(project.icon).outerHTML"></span>
|
||||||
<div class="recent_favorite_button" :class="{favorite_enabled: project.favorite}" @click.stop="toggleProjectFavorite(project)" title="${tl('mode.start.recent.favorite')}">
|
<div class="recent_favorite_button" :class="{favorite_enabled: project.favorite}" @click.stop="toggleProjectFavorite(project)" title="${tl('mode.start.recent.favorite')}">
|
||||||
|
Loading…
Reference in New Issue
Block a user