feat(sidepanel): 实现基于组件的架构并优化路由管理

- 引入 BaseComponent 基类统一管理事件、定时器和脚本加载
- 重构 timestamp 模块为继承自 BaseComponent 的类组件
- 新增 ScriptManager 工具类用于动态加载和卸载脚本
- 修改路由配置支持按需加载页面对应的 JS 模块
- 路由切换时自动销毁旧组件实例以防止内存泄漏
- 更新文件引用路径适配新的目录结构
- 修复 rollup 配置中的语法问题及端口配置
- 移除无用的日志输出和冗余代码提升性能
This commit is contained in:
雨霖铃
2025-12-12 00:01:00 +08:00
parent 4a76561a85
commit aaefc9c3fc
12 changed files with 281 additions and 245 deletions
+3 -3
View File
@@ -1,4 +1,4 @@
import { defineConfig } from 'rollup';
import {defineConfig} from 'rollup';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
@@ -14,7 +14,7 @@ const devPlugins = [
}),
serve({
open: true,
port: 8082,
port: 3000,
contentBase: ['.', 'sidepanel'],
headers: {
'Access-Control-Allow-Origin': '*',
@@ -42,4 +42,4 @@ export default defineConfig([
},
plugins: [...basePlugins, ...devPlugins],
},
]);
]);