File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * @deprecated 此文件已弃用,请使用新的模块化系统 (main-new.js)
3+ *
4+ * 为保证向下兼容性,此文件仍然可用,但建议使用新的模块化系统
5+ */
6+
7+ console . warn ( '[DEPRECATED] main.js 已弃用,请使用新的模块化系统 (main-new.js)' ) ;
8+
9+ // 尝试加载新的模块化系统
10+ ( function ( ) {
11+ try {
12+ const script = document . createElement ( 'script' ) ;
13+ script . type = 'module' ;
14+
15+ // 尝试确定正确的路径
16+ const currentPath = window . location . pathname ;
17+
18+ if ( currentPath . includes ( '/cases/' ) ) {
19+ script . src = '../js/main-new.js' ;
20+ } else if ( currentPath . includes ( '/test-cases/' ) ) {
21+ const pathParts = currentPath . split ( '/' ) ;
22+ // 计算需要回退的目录层级
23+ const depth = pathParts . length - pathParts . indexOf ( 'test-cases' ) - 1 ;
24+ script . src = '../' . repeat ( depth ) + 'js/main-new.js' ;
25+ } else {
26+ script . src = 'js/main-new.js' ;
27+ }
28+
29+ document . head . appendChild ( script ) ;
30+ console . log ( '已自动加载新的模块化系统:' , script . src ) ;
31+ } catch ( e ) {
32+ console . error ( '加载新的模块化系统失败' , e ) ;
33+ }
34+ } ) ( ) ;
35+
136// 通用功能
237document . addEventListener ( 'DOMContentLoaded' , ( ) => {
338 // 为所有代码块添加复制功能
You can’t perform that action at this time.
0 commit comments