style(editor-app): 移除log信息

This commit is contained in:
yhh
2025-11-20 09:51:29 +08:00
parent 0d2948e60c
commit 8b9616837d
15 changed files with 4 additions and 164 deletions

View File

@@ -5,8 +5,6 @@ import { EditorAppearancePlugin } from '../../plugins/EditorAppearancePlugin';
export class PluginInstaller {
async installBuiltinPlugins(pluginManager: EditorPluginManager): Promise<void> {
console.log('[PluginInstaller] Installing builtin plugins...');
const plugins = [
new SceneInspectorPlugin(),
new ProfilerPlugin(),
@@ -16,12 +14,9 @@ export class PluginInstaller {
for (const plugin of plugins) {
try {
await pluginManager.installEditor(plugin);
console.log(`[PluginInstaller] Installed plugin: ${plugin.name}`);
} catch (error) {
console.error(`[PluginInstaller] Failed to install plugin ${plugin.name}:`, error);
}
}
console.log('[PluginInstaller] All builtin plugins installed');
}
}

View File

@@ -23,24 +23,14 @@ export class EditorBootstrap {
throw new Error('EditorBootstrap has already been initialized');
}
console.log('[EditorBootstrap] Starting editor initialization...');
const scene = await this.createScene();
console.log('[EditorBootstrap] Scene created');
const container = globalContainer;
const eventBus = container.resolve(EditorEventBus);
console.log('[EditorBootstrap] EventBus initialized');
const commands = container.resolve(CommandRegistry);
console.log('[EditorBootstrap] CommandRegistry initialized');
const panels = container.resolve(PanelRegistry);
console.log('[EditorBootstrap] PanelRegistry initialized');
this.initialized = true;
console.log('[EditorBootstrap] Editor initialized successfully');
return {
container,

View File

@@ -16,11 +16,9 @@ export class SceneInspectorPlugin implements IEditorPlugin {
readonly icon = '🔍';
async install(_core: Core, _services: ServiceContainer): Promise<void> {
console.log('[SceneInspectorPlugin] Installed');
}
async uninstall(): Promise<void> {
console.log('[SceneInspectorPlugin] Uninstalled');
}
registerMenuItems(): MenuItem[] {
@@ -30,7 +28,6 @@ export class SceneInspectorPlugin implements IEditorPlugin {
label: 'Scene Inspector',
parentId: 'view',
onClick: () => {
console.log('Toggle Scene Inspector');
},
shortcut: 'Ctrl+Shift+I',
order: 100
@@ -40,7 +37,6 @@ export class SceneInspectorPlugin implements IEditorPlugin {
label: 'Create Entity',
parentId: 'scene',
onClick: () => {
console.log('Create new entity');
},
shortcut: 'Ctrl+N',
order: 10
@@ -56,7 +52,6 @@ export class SceneInspectorPlugin implements IEditorPlugin {
groupId: 'entity-tools',
icon: '',
onClick: () => {
console.log('Create entity from toolbar');
},
order: 10
},
@@ -66,7 +61,6 @@ export class SceneInspectorPlugin implements IEditorPlugin {
groupId: 'entity-tools',
icon: '🗑️',
onClick: () => {
console.log('Delete entity from toolbar');
},
order: 20
}
@@ -117,14 +111,11 @@ export class SceneInspectorPlugin implements IEditorPlugin {
}
async onEditorReady(): Promise<void> {
console.log('[SceneInspectorPlugin] Editor is ready');
}
async onProjectOpen(projectPath: string): Promise<void> {
console.log(`[SceneInspectorPlugin] Project opened: ${projectPath}`);
}
async onProjectClose(): Promise<void> {
console.log('[SceneInspectorPlugin] Project closed');
}
}

View File

@@ -280,9 +280,6 @@ export class GitHubService {
* 返回设备代码信息,包含用户需要访问的 URL 和输入的代码
*/
async requestDeviceCode(): Promise<DeviceCodeResponse> {
console.log('[GitHubService] Requesting device code...');
console.log('[GitHubService] Client ID:', this.CLIENT_ID);
try {
const response = await fetch('https://github.com/login/device/code', {
method: 'POST',
@@ -296,9 +293,6 @@ export class GitHubService {
})
});
console.log('[GitHubService] Response status:', response.status);
console.log('[GitHubService] Response ok:', response.ok);
if (!response.ok) {
const error = await response.text();
console.error('[GitHubService] Request device code failed:', error);
@@ -306,11 +300,6 @@ export class GitHubService {
}
const data = (await response.json()) as DeviceCodeResponse;
console.log('[GitHubService] Device code received:', {
user_code: data.user_code,
verification_uri: data.verification_uri
});
return data;
} catch (error) {
console.error('[GitHubService] Error requesting device code:', error);
@@ -518,14 +507,12 @@ export class GitHubService {
}
async deleteFile(owner: string, repo: string, path: string, message: string, branch: string): Promise<void> {
console.log(`[GitHubService] Getting file SHA for: ${owner}/${repo}/${path}?ref=${branch}`);
const existing = await this.request<GitHubFileContent>(`GET /repos/${owner}/${repo}/contents/${path}?ref=${branch}`);
if (!existing || !existing.sha) {
throw new Error(`Failed to get file SHA for ${path}`);
}
console.log(`[GitHubService] Deleting file with SHA: ${existing.sha}`);
await this.request<void>(`DELETE /repos/${owner}/${repo}/contents/${path}`, {
message: message,
sha: existing.sha,
@@ -631,7 +618,6 @@ export class GitHubService {
if (deletedDate && pr.merged_at) {
const addedDate = new Date(pr.merged_at);
if (deletedDate > addedDate) {
console.log(`[GitHubService] Plugin ${pluginName} was deleted after being added, skipping`);
continue;
}
}
@@ -922,12 +908,10 @@ export class GitHubService {
try {
const stored = localStorage.getItem(this.STORAGE_KEY);
if (stored) {
console.log('[GitHubService] Loading stored token...');
this.accessToken = stored;
this.notifyUserLoadStateChange(true);
this.fetchUser()
.then((user) => {
console.log('[GitHubService] User loaded from stored token:', user.login);
this.user = user;
if (this.retryTimer) {
clearTimeout(this.retryTimer);
@@ -940,19 +924,15 @@ export class GitHubService {
const errorMessage = error instanceof Error ? error.message : String(error);
if (errorMessage.includes('401') || errorMessage.includes('Unauthorized')) {
console.log('[GitHubService] Token is invalid or expired, removing it');
this.accessToken = null;
this.user = null;
localStorage.removeItem(this.STORAGE_KEY);
this.notifyUserLoadStateChange(false);
} else {
console.log('[GitHubService] Temporary error fetching user, will retry in 5 seconds');
this.scheduleRetryLoadUser();
}
});
} else {
console.log('[GitHubService] No stored token found');
}
}
} catch (error) {
console.error('[GitHubService] Failed to load token:', error);
this.notifyUserLoadStateChange(false);
@@ -965,11 +945,9 @@ export class GitHubService {
}
this.retryTimer = window.setTimeout(() => {
console.log('[GitHubService] Retrying to load user...');
if (this.accessToken && !this.user) {
this.fetchUser()
.then((user) => {
console.log('[GitHubService] User loaded successfully on retry:', user.login);
this.user = user;
this.retryTimer = null;
this.notifyUserLoadStateChange(false);
@@ -978,13 +956,11 @@ export class GitHubService {
console.error('[GitHubService] Retry failed:', error);
const errorMessage = error instanceof Error ? error.message : String(error);
if (errorMessage.includes('401') || errorMessage.includes('Unauthorized')) {
console.log('[GitHubService] Token is invalid, removing it');
this.accessToken = null;
this.user = null;
localStorage.removeItem(this.STORAGE_KEY);
this.notifyUserLoadStateChange(false);
} else {
console.log('[GitHubService] Will retry again in 10 seconds');
this.retryTimer = window.setTimeout(() => this.scheduleRetryLoadUser(), 10000);
}
});

View File

@@ -56,7 +56,6 @@ export class PluginBuildService {
pluginFolder
});
console.log('[PluginBuildService] Build completed, zip path:', zipPath);
return zipPath;
} catch (error) {
console.error('[PluginBuildService] Build failed:', error);

View File

@@ -31,13 +31,11 @@ export class PluginLoader {
try {
const exists = await TauriAPI.pathExists(pluginsPath);
if (!exists) {
console.log('[PluginLoader] No plugins directory found');
return;
}
const entries = await TauriAPI.listDirectory(pluginsPath);
const pluginDirs = entries.filter((entry) => entry.is_dir && !entry.name.startsWith('.'));
console.log('[PluginLoader] Found plugin directories:', pluginDirs.map((d) => d.name));
for (const entry of pluginDirs) {
const pluginPath = `${pluginsPath}/${entry.name}`;
@@ -102,13 +100,10 @@ export class PluginLoader {
const timestamp = Date.now();
const moduleUrl = `/@user-project/plugins/${pluginDirName}/${entryPoint}?v=${currentVersion}&t=${timestamp}`;
console.log(`[PluginLoader] Loading plugin from: ${moduleUrl} (version: ${currentVersion})`);
// 清除可能存在的旧模块缓存
this.loadedModuleUrls.add(moduleUrl);
const module = await import(/* @vite-ignore */ moduleUrl);
console.log('[PluginLoader] Module loaded successfully');
let pluginInstance: IEditorPlugin | null = null;
try {
@@ -133,7 +128,6 @@ export class PluginLoader {
const currentLocale = localeService.getCurrentLocale();
if (pluginInstance.setLocale) {
pluginInstance.setLocale(currentLocale);
console.log(`[PluginLoader] Set locale for plugin ${packageJson.name}: ${currentLocale}`);
}
} catch (error) {
console.warn(`[PluginLoader] Failed to set locale for plugin ${packageJson.name}:`, error);
@@ -144,12 +138,9 @@ export class PluginLoader {
const messageHub = Core.services.resolve(MessageHub);
const localeService = Core.services.resolve(LocaleService);
messageHub.publish('locale:changed', { locale: localeService.getCurrentLocale() });
console.log(`[PluginLoader] Published locale:changed event for plugin ${packageJson.name}`);
} catch (error) {
console.warn('[PluginLoader] Failed to publish locale:changed event:', error);
}
console.log(`[PluginLoader] Successfully loaded plugin: ${packageJson.name}`);
} catch (error) {
console.error(`[PluginLoader] Failed to load plugin from ${pluginPath}:`, error);
if (error instanceof Error) {
@@ -159,17 +150,13 @@ export class PluginLoader {
}
private findPluginInstance(module: any): IEditorPlugin | null {
console.log('[PluginLoader] Module exports:', Object.keys(module));
if (module.default && this.isPluginInstance(module.default)) {
console.log('[PluginLoader] Found plugin in default export');
return module.default;
}
for (const key of Object.keys(module)) {
const value = module[key];
if (value && this.isPluginInstance(value)) {
console.log(`[PluginLoader] Found plugin in export: ${key}`);
return value;
}
}
@@ -192,19 +179,6 @@ export class PluginLoader {
typeof obj.install === 'function' &&
typeof obj.uninstall === 'function';
if (!hasRequiredProperties) {
console.log('[PluginLoader] Object is not a valid plugin:', {
hasName: typeof obj.name === 'string',
hasVersion: typeof obj.version === 'string',
hasDisplayName: typeof obj.displayName === 'string',
hasCategory: typeof obj.category === 'string',
hasInstall: typeof obj.install === 'function',
hasUninstall: typeof obj.uninstall === 'function',
objectType: typeof obj,
objectConstructor: obj?.constructor?.name
});
}
return hasRequiredProperties;
} catch (error) {
console.error('[PluginLoader] Error in isPluginInstance:', error);
@@ -213,11 +187,8 @@ export class PluginLoader {
}
async unloadProjectPlugins(pluginManager: EditorPluginManager): Promise<void> {
console.log('[PluginLoader] Unloading all project plugins...');
for (const pluginName of this.loadedPluginNames) {
try {
console.log(`[PluginLoader] Uninstalling plugin: ${pluginName}`);
await pluginManager.uninstallEditor(pluginName);
} catch (error) {
console.error(`[PluginLoader] Failed to unload plugin ${pluginName}:`, error);
@@ -229,22 +200,14 @@ export class PluginLoader {
this.loadedPluginNames.clear();
this.loadedModuleUrls.clear();
console.log('[PluginLoader] All project plugins unloaded');
}
private invalidateModuleCache(): void {
try {
// 尝试使用Vite HMR API无效化模块
if (import.meta.hot) {
console.log('[PluginLoader] Attempting to invalidate module cache via HMR');
import.meta.hot.invalidate();
}
// 清除已加载的模块URL记录
for (const url of this.loadedModuleUrls) {
console.log(`[PluginLoader] Marking module for reload: ${url}`);
}
} catch (error) {
console.warn('[PluginLoader] Failed to invalidate module cache:', error);
}

View File

@@ -1,6 +1,6 @@
import type { EditorPluginManager, IEditorPlugin } from '@esengine/editor-core';
import JSZip from 'jszip';
import type { EditorPluginManager } from '@esengine/editor-core';
import { fetch } from '@tauri-apps/plugin-http';
import { invoke } from '@tauri-apps/api/core';
export interface PluginAuthor {
name: string;
@@ -80,7 +80,6 @@ export class PluginMarketService {
setProjectPath(path: string | null): void {
this.projectPath = path;
console.log(`[PluginMarketService] Project path set to: ${path}`);
}
isUsingDirectSource(): boolean {
@@ -89,14 +88,12 @@ export class PluginMarketService {
setUseDirectSource(useDirect: boolean): void {
localStorage.setItem(this.USE_DIRECT_SOURCE_KEY, String(useDirect));
console.log(`[PluginMarketService] Direct source ${useDirect ? 'enabled' : 'disabled'}`);
}
async fetchPluginList(bypassCache: boolean = false): Promise<PluginMarketMetadata[]> {
const useDirectSource = this.isUsingDirectSource();
if (useDirectSource) {
console.log('[PluginMarketService] Using direct GitHub source (bypass CDN)');
return await this.fetchFromUrl(this.GITHUB_DIRECT_URL, bypassCache);
}
@@ -131,16 +128,9 @@ export class PluginMarketService {
if (bypassCache) {
url += `?t=${Date.now()}`;
if (urlIndex && totalUrls) {
console.log(`[PluginMarketService] Bypassing cache with timestamp (URL ${urlIndex}/${totalUrls})`);
}
}
if (urlIndex && totalUrls) {
console.log(`[PluginMarketService] Trying URL ${urlIndex}/${totalUrls}: ${url}`);
} else {
console.log(`[PluginMarketService] Fetching from: ${url}`);
}
const response = await fetch(url, {
cache: 'no-cache',
headers: {
@@ -154,22 +144,11 @@ export class PluginMarketService {
}
const registry: PluginRegistry = await response.json();
if (urlIndex) {
console.log(`[PluginMarketService] Successfully loaded from URL ${urlIndex}`);
} else {
console.log(`[PluginMarketService] Successfully loaded`);
}
console.log(`[PluginMarketService] Loaded ${registry.plugins.length} plugins from registry`);
console.log(`[PluginMarketService] Registry generated at: ${registry.generatedAt}`);
return registry.plugins;
}
async installPlugin(plugin: PluginMarketMetadata, version?: string, onReload?: () => Promise<void>): Promise<void> {
const targetVersion = version || plugin.latestVersion;
console.log(`[PluginMarketService] Installing plugin: ${plugin.name} v${targetVersion}`);
if (!this.projectPath) {
throw new Error('No project opened. Please open a project first.');
}
@@ -182,11 +161,9 @@ export class PluginMarketService {
}
// 下载 ZIP 文件
console.log(`[PluginMarketService] Downloading ZIP: ${versionInfo.zipUrl}`);
const zipBlob = await this.downloadZip(versionInfo.zipUrl);
// 解压到项目 plugins 目录
console.log(`[PluginMarketService] Extracting plugin to project...`);
await this.extractZipToProject(zipBlob, plugin.id);
// 标记为已安装
@@ -194,11 +171,8 @@ export class PluginMarketService {
// 重新加载项目插件
if (onReload) {
console.log(`[PluginMarketService] Reloading project plugins...`);
await onReload();
}
console.log(`[PluginMarketService] Successfully installed: ${plugin.name} v${targetVersion}`);
} catch (error) {
console.error(`[PluginMarketService] Failed to install plugin ${plugin.name}:`, error);
throw error;
@@ -206,8 +180,6 @@ export class PluginMarketService {
}
async uninstallPlugin(pluginId: string, onReload?: () => Promise<void>): Promise<void> {
console.log(`[PluginMarketService] Uninstalling plugin: ${pluginId}`);
if (!this.projectPath) {
throw new Error('No project opened');
}
@@ -223,19 +195,14 @@ export class PluginMarketService {
pluginId: pluginId
});
console.log(`[PluginMarketService] Successfully removed plugin directory`);
// 从已安装列表移除
this.installedPlugins.delete(pluginId);
this.saveInstalledPlugins();
// 重新加载项目插件
if (onReload) {
console.log(`[PluginMarketService] Reloading project plugins...`);
await onReload();
}
console.log(`[PluginMarketService] Successfully uninstalled: ${pluginId}`);
} catch (error) {
console.error(`[PluginMarketService] Failed to uninstall plugin ${pluginId}:`, error);
throw error;
@@ -286,14 +253,11 @@ export class PluginMarketService {
const base64Data = btoa(binary);
// 调用 Tauri 后端命令进行安装
const { invoke } = await import('@tauri-apps/api/core');
const pluginDir = await invoke<string>('install_marketplace_plugin', {
await invoke<string>('install_marketplace_plugin', {
projectPath: this.projectPath,
pluginId: pluginId,
zipDataBase64: base64Data
});
console.log(`[PluginMarketService] Successfully extracted plugin to ${pluginDir}`);
} catch (error) {
console.error('[PluginMarketService] Failed to extract ZIP:', error);
throw new Error(`Failed to extract plugin: ${error instanceof Error ? error.message : String(error)}`);

View File

@@ -48,7 +48,6 @@ export class PluginPublishService {
}
private notifyProgress(step: PublishStep, message: string, progress: number): void {
console.log(`[PluginPublishService] ${message} (${progress}%)`);
this.progressCallback?.({ step, message, progress });
}
@@ -59,9 +58,6 @@ export class PluginPublishService {
* @returns Pull Request URL
*/
async publishPlugin(publishInfo: PluginPublishInfo, zipPath: string): Promise<string> {
console.log('[PluginPublishService] Publishing plugin with ZIP:', zipPath);
console.log('[PluginPublishService] Plugin info:', publishInfo);
if (!this.githubService.isAuthenticated()) {
throw new Error('Please login to GitHub first');
}
@@ -214,7 +210,6 @@ export class PluginPublishService {
);
return JSON.parse(content);
} catch (error) {
console.log(`[PluginPublishService] No existing manifest found, will create new one`);
return null;
}
}
@@ -543,7 +538,6 @@ ${releaseNotes}
throw new Error(`No files found to delete in ${pluginPath}`);
}
console.log(`[PluginPublishService] Files to delete:`, filesToDelete.map(f => f.path));
this.notifyProgress('uploading-files', `Deleting ${filesToDelete.length} files...`, 40);
let deletedCount = 0;
@@ -551,7 +545,6 @@ ${releaseNotes}
for (const file of filesToDelete) {
try {
console.log(`[PluginPublishService] Deleting file: ${file.path} (SHA: ${file.sha}) from ${user.login}/${this.REGISTRY_REPO}:${branchName}`);
await this.githubService.deleteFileWithSha(
user.login,
this.REGISTRY_REPO,
@@ -561,7 +554,6 @@ ${releaseNotes}
branchName
);
deletedCount++;
console.log(`[PluginPublishService] Successfully deleted: ${file.path}`);
const progress = 40 + Math.floor((deletedCount / filesToDelete.length) * 40);
this.notifyProgress('uploading-files', `Deleted ${deletedCount}/${filesToDelete.length} files`, progress);
} catch (error) {

View File

@@ -47,8 +47,6 @@ export class PluginSourceParser {
const packageJsonContent = await readTextFile(packageJsonPath);
const packageJson = JSON.parse(packageJsonContent) as PluginPackageJson;
console.log('[PluginSourceParser] Parsed package.json from folder:', packageJson);
return {
packageJson,
sourceType: 'folder',
@@ -87,8 +85,6 @@ export class PluginSourceParser {
const packageJsonContent = await packageJsonFile.async('text');
const packageJson = JSON.parse(packageJsonContent) as PluginPackageJson;
console.log('[PluginSourceParser] Parsed package.json from ZIP:', packageJson);
// 验证 ZIP 中必须包含 dist 目录
const distFiles = Object.keys(zip.files).filter(f => f.startsWith('dist/'));
if (distFiles.length === 0) {

View File

@@ -18,11 +18,6 @@ export async function checkForUpdates(silent: boolean = false): Promise<UpdateCh
const update = await check();
if (update?.available) {
console.log(`发现新版本: ${update.version}`);
console.log(`当前版本: ${update.currentVersion}`);
console.log(`更新日期: ${update.date}`);
console.log(`更新说明:\n${update.body}`);
if (!silent) {
// Tauri 会自动显示更新对话框(因为配置了 dialog: true
// 用户点击确认后会自动下载并安装,安装完成后会自动重启
@@ -35,9 +30,6 @@ export async function checkForUpdates(silent: boolean = false): Promise<UpdateCh
currentVersion: update.currentVersion
};
} else {
if (!silent) {
console.log('当前已是最新版本');
}
return { available: false };
}
} catch (error) {