提交 f604f1c8 编写于 作者: J Johannes Rieken

store data globally #55033

上级 d983257e
......@@ -83,32 +83,40 @@ function readFile(file) {
function showPartsSplash(configuration) {
perf.mark('willShowPartsSplash');
let key;
let keep = false;
// this is the logic of StorageService#getWorkspaceKey and StorageService#toStorageKey
if (configuration.folderUri) {
let workspaceKey = require('vscode-uri').default.revive(configuration.folderUri).toString().replace('file:///', '').replace(/^\//, '');
key = `storage://workspace/${workspaceKey}/parts-splash`;
} else if (configuration.workspace) {
key = `storage://workspace/root:${configuration.workspace.id}/parts-splash`;
} else {
key = `storage://global/parts-splash`;
keep = true;
}
// TODO@Ben remove me after a while
perf.mark('willAccessLocalStorage');
let storage = window.localStorage;
perf.mark('didAccessLocalStorage');
let structure = storage.getItem(key);
if (structure) {
let splash = document.createElement('div');
splash.innerHTML = structure;
document.body.appendChild(splash);
let data;
try {
let raw = storage.getItem('storage://global/parts-splash-data');
data = JSON.parse(raw);
} catch (e) {
// ignore
}
if (!keep) {
storage.removeItem(key);
if (data) {
const splash = document.createElement('div');
const { layoutInfo, colorInfo } = data;
if (configuration.folderUri || configuration.workspace) {
// folder or workspace -> status bar color, sidebar
splash.innerHTML = `<div id="${data.id}">
<div style="position: absolute; width: 100%; left: 0; top: 0; height: ${layoutInfo.titleBarHeight}px; background-color: ${colorInfo.titleBarBackground};"></div>
<div style="position: absolute; height: calc(100% - ${layoutInfo.titleBarHeight}px); top: ${layoutInfo.titleBarHeight}px; ${layoutInfo.sideBarSide}: 0; width: ${layoutInfo.activityBarWidth}px; background-color: ${colorInfo.activityBarBackground};"></div>
<div style="position: absolute; height: calc(100% - ${layoutInfo.titleBarHeight}px); top: ${layoutInfo.titleBarHeight}px; ${layoutInfo.sideBarSide}: ${layoutInfo.activityBarWidth}px; width: ${layoutInfo.sideBarWidth}px; background-color: ${colorInfo.sideBarBackground};"></div>
<div style="position: absolute; width: 100%; bottom: 0; left: 0; height: ${layoutInfo.statusBarHeight}px; background-color: ${colorInfo.statusBarBackground};"></div>
</div>`;
} else {
// empty -> speical status bar color, no sidebar
splash.innerHTML = `<div id="${data.id}">
<div style="position: absolute; width: 100%; left: 0; top: 0; height: ${layoutInfo.titleBarHeight}px; background-color: ${colorInfo.titleBarBackground};"></div>
<div style="position: absolute; height: calc(100% - ${layoutInfo.titleBarHeight}px); top: ${layoutInfo.titleBarHeight}px; ${layoutInfo.sideBarSide}: 0; width: ${layoutInfo.activityBarWidth}px; background-color: ${colorInfo.activityBarBackground};"></div>
<div style="position: absolute; width: 100%; bottom: 0; left: 0; height: ${layoutInfo.statusBarHeight}px; background-color: ${colorInfo.statusBarNoFolderBackground};"></div>
</div>`;
}
document.body.appendChild(splash);
}
perf.mark('didShowPartsSplash');
}
......
......@@ -79,7 +79,7 @@ import { IBroadcastService, BroadcastService } from 'vs/platform/broadcast/elect
import { HashService } from 'vs/workbench/services/hash/node/hashService';
import { IHashService } from 'vs/workbench/services/hash/common/hashService';
import { ILogService } from 'vs/platform/log/common/log';
import { WORKBENCH_BACKGROUND } from 'vs/workbench/common/theme';
import { WORKBENCH_BACKGROUND, SIDE_BAR_BACKGROUND, ACTIVITY_BAR_BACKGROUND, STATUS_BAR_BACKGROUND, STATUS_BAR_NO_FOLDER_BACKGROUND, TITLE_BAR_ACTIVE_BACKGROUND } from 'vs/workbench/common/theme';
import { stat } from 'fs';
import { join } from 'path';
import { ILocalizationsChannel, LocalizationsChannelClient } from 'vs/platform/localizations/common/localizationsIpc';
......@@ -524,51 +524,23 @@ export class WorkbenchShell extends Disposable {
private _savePartsSplash() {
// capture html-structure
let state = this.contextService.getWorkbenchState();
let html = `<div id="${WorkbenchShell.PARTS_SPLASH_ID}">`;
// title part
let titleHeight: number;
{
let part = this.workbench.getContainer(Parts.TITLEBAR_PART);
let height = getTotalHeight(part);
let bg = part.style.backgroundColor || 'inhert';
html += `<div style="position: absolute; width: 100%; left: 0; top: 0; height: ${height}px; background-color: ${bg};"></div>`;
titleHeight = height;
}
// activitybar-part
let left = this.workbench.getSideBarPosition() === Position.LEFT;
let activityPartWidth: number;
{
let part = this.workbench.getContainer(Parts.ACTIVITYBAR_PART);
let width = getTotalWidth(part);
let bg = part.style.backgroundColor || 'inhert';
html += `<div style="position: absolute; height: calc(100% - ${titleHeight}px); top: ${titleHeight}px; ${left ? 'left' : 'right'}: 0; width: ${width}px; background-color: ${bg};"></div>`;
activityPartWidth = width;
}
// sidebar-part (only for folder/workspace cases)
if (state !== WorkbenchState.EMPTY) {
let part = this.workbench.getContainer(Parts.SIDEBAR_PART);
let width = getTotalWidth(part);
let bg = part.style.backgroundColor || 'inhert';
html += `<div style="position: absolute; height: calc(100% - ${titleHeight}px); top: ${titleHeight}px; ${left ? 'left' : 'right'}: ${activityPartWidth}px; width: ${width}px; background-color: ${bg};"></div>`;
}
// statusbar-part
{
let part = this.workbench.getContainer(Parts.STATUSBAR_PART);
let height = getTotalHeight(part);
let bg = part.style.backgroundColor || 'inhert';
html += `<div style="position: absolute; width: 100%; bottom: 0; left: 0; height: ${height}px; background-color: ${bg};"></div>`;
}
html += '\n</div>';
// store per workspace or globally
this.storageService.store('parts-splash', html, state === WorkbenchState.EMPTY ? StorageScope.GLOBAL : StorageScope.WORKSPACE);
// capture color/layout data
const theme = this.themeService.getTheme();
const colorInfo = {
titleBarBackground: theme.getColor(TITLE_BAR_ACTIVE_BACKGROUND).toString(),
activityBarBackground: theme.getColor(ACTIVITY_BAR_BACKGROUND).toString(),
sideBarBackground: theme.getColor(SIDE_BAR_BACKGROUND).toString(),
statusBarBackground: theme.getColor(STATUS_BAR_BACKGROUND).toString(),
statusBarNoFolderBackground: theme.getColor(STATUS_BAR_NO_FOLDER_BACKGROUND).toString(),
};
const layoutInfo = {
titleBarHeight: getTotalHeight(this.workbench.getContainer(Parts.TITLEBAR_PART)),
sideBarSide: this.workbench.getSideBarPosition() === Position.RIGHT ? 'right' : 'left',
activityBarWidth: getTotalWidth(this.workbench.getContainer(Parts.ACTIVITYBAR_PART)),
sideBarWidth: getTotalWidth(this.workbench.getContainer(Parts.SIDEBAR_PART)),
statusBarHeight: getTotalHeight(this.workbench.getContainer(Parts.STATUSBAR_PART)),
};
this.storageService.store('parts-splash-data', JSON.stringify({ id: WorkbenchShell.PARTS_SPLASH_ID, colorInfo, layoutInfo }), StorageScope.GLOBAL);
}
private _removePartsSplash(): void {
......
......@@ -6256,10 +6256,6 @@ vscode-textmate@^4.0.1:
dependencies:
oniguruma "^7.0.0"
vscode-uri@1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-1.0.5.tgz#3b899a8ef71c37f3054d79bdbdda31c7bf36f20d"
vscode-xterm@3.6.0-beta5:
version "3.6.0-beta5"
resolved "https://registry.yarnpkg.com/vscode-xterm/-/vscode-xterm-3.6.0-beta5.tgz#b44fd70451944624f148bd9f0be4925b52b7a7e0"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册