Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(category-list): fix icon with vs-seti icon theme #39

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

Merged
laggage merged 1 commit into main from fix-category-icon
Mar 23, 2022
Merged
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
12 changes: 9 additions & 3 deletions src/services/check-workspace.ts
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { commands, workspace } from 'vscode';
import { refreshPostCategoriesList } from '../commands/post-category/refresh-post-categories-list';
import { globalState } from './global-state';
import { PostFileMapManager } from './post-file-map';
import { Settings } from './settings.service';
Expand All @@ -12,9 +13,14 @@ export const isTargetWorkspace = (): boolean => {

export const observeConfigurationChange = () => {
globalState.extensionContext?.subscriptions.push(
workspace.onDidChangeConfiguration(ev =>
ev.affectsConfiguration(Settings.prefix) ? isTargetWorkspace() : false
)
workspace.onDidChangeConfiguration(ev => {
if (ev.affectsConfiguration(Settings.prefix)) {
isTargetWorkspace();
}
if (ev.affectsConfiguration(`${Settings.iconThemePrefix}.${Settings.iconThemeKey}`)) {
refreshPostCategoriesList();
}
})
);
isTargetWorkspace();
};
Expand Down
14 changes: 14 additions & 0 deletions src/services/settings.service.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ export class Settings {
return `cnblogsClientForVSCode`;
}

static get iconThemePrefix() {
return 'workbench';
}

static get iconThemeKey() {
return `iconTheme`;
}

static get iconTheme() {
return <'vs-seti' | 'vs-minimal' | undefined | string>(
workspace.getConfiguration(this.iconThemePrefix).get<string>(this.iconThemeKey)
);
}

static get configuration() {
return workspace.getConfiguration(this.prefix);
}
Expand Down
14 changes: 13 additions & 1 deletion src/tree-view-providers/categories-view-data-provider.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ import { commands, Event, EventEmitter, MessageOptions, ThemeIcon, TreeDataProvi
import { PostCategories, PostCategory } from '../models/post-category';
import { globalState } from '../services/global-state';
import { postCategoryService } from '../services/post-category.service';
import { Settings } from '../services/settings.service';

const categoryIcon = () => {
const iconTheme = Settings.iconTheme;
let iconId = 'folder';
switch (iconTheme) {
case 'vs-seti':
iconId = 'file-directory';
break;
}
return new ThemeIcon(iconId);
};

export class PostCategoriesViewDataProvider implements TreeDataProvider<PostCategory> {
private static _instance: PostCategoriesViewDataProvider;
Expand Down Expand Up @@ -36,7 +48,7 @@ export class PostCategoriesViewDataProvider implements TreeDataProvider<PostCate
getTreeItem(element: PostCategory): TreeItem | Thenable<TreeItem> {
const label = `${element.title}(${element.count})`;
return Object.assign(new TreeItem(label), {
iconPath: new ThemeIcon('folder'),
iconPath: categoryIcon(),
contextValue: 'cnb-post-category',
} as TreeItem);
}
Expand Down

AltStyle によって変換されたページ (->オリジナル) /