@@ -4,86 +4,112 @@ import { IAppInstance, EditorRenderer } from '../../editor';
44import * as Alex from '../../editor' ;
55import '../startup/languages' ;
66
7- import Button from 'antd/lib/button' ;
8- import 'antd/lib/button/style/index.css' ;
7+ import 'antd/dist/antd.css' ;
98import Select from 'antd/lib/select' ;
10- import 'antd/lib/select/style/index.css' ;
11- import Spin from 'antd/lib/spin' ;
12- import 'antd/lib/spin/style/index.css' ;
9+ import Cascader from 'antd/lib/cascader' ;
1310import './style.less' ;
1411
1512( window as any ) . alex = Alex ;
1613
17- const owner = 'kaitian' ;
18- const name = 'ide-framework' ;
19- const project = encodeURIComponent ( `${ owner } /${ name } ` ) ;
14+ const fileOptions = [
15+ {
16+ value : 'chaxuan.wh/qiankun-mirror' ,
17+ label : 'chaxuan.wh/qiankun-mirror' ,
18+ children : [
19+ {
20+ value : 'master' ,
21+ label : 'master' ,
22+ children : [
23+ {
24+ value : 'src/globalState.ts' ,
25+ label : 'src/globalState.ts' ,
26+ } ,
27+ ] ,
28+ } ,
29+ ] ,
30+ } ,
31+ {
32+ value : 'wealth_release/finstrategy' ,
33+ label : 'wealth_release/finstrategy' ,
34+ children : [
35+ {
36+ value : 'f577528518c7c0279f8cdf3de59ae24a80a16607' ,
37+ label : 'f577528518c7c0279f8cdf3de59ae24a80a16607' ,
38+ children : [
39+ {
40+ value :
41+ 'app/biz/service-impl/src/main/java/com/alipay/finstrategy/biz/service/impl/portfolio/msg/TradeMessageListener.java' ,
42+ label :
43+ 'app/biz/service-impl/src/main/java/com/alipay/finstrategy/biz/service/impl/portfolio/msg/TradeMessageListener.java' ,
44+ } ,
45+ ] ,
46+ } ,
47+ ] ,
48+ } ,
49+ {
50+ value : 'kaitian/ide-framework' ,
51+ label : 'kaitian/ide-framework' ,
52+ children : [
53+ {
54+ value : 'develop' ,
55+ label : 'develop' ,
56+ children : [
57+ {
58+ value : 'packages/addons/src/browser/file-drop.service.ts' ,
59+ label : 'packages/addons/src/browser/file-drop.service.ts' ,
60+ } ,
61+ {
62+ value : 'packages/addons/src/common/index.ts' ,
63+ label : 'packages/addons/src/common/index.ts' ,
64+ } ,
65+ {
66+ value : 'OWNERS' ,
67+ label : 'OWNERS' ,
68+ } ,
69+ ] ,
70+ } ,
71+ ] ,
72+ } ,
73+ ] ;
2074
2175const App = ( ) => {
22- const [ key , setKey ] = useState ( 0 ) ;
76+ const [ project , setProject ] = useState ( '' ) ;
2377 const [ ref , setRef ] = useState ( '' ) ;
2478 const [ filepath , setFilePath ] = useState ( '' ) ;
2579 const [ encoding , setEncoding ] = useState < 'utf8' | 'gbk' | undefined > ( 'utf8' ) ;
2680 const [ lineNumber , setLineNumber ] = useState < number | [ number , number ] | undefined > ( ) ;
2781
28- const setContent = ( ) => {
29- setRef ( 'develop' ) ;
30- setFilePath ( 'packages/addons/src/browser/file-drop.service.ts' ) ;
31- setLineNumber ( [ 30 , 32 ] ) ;
32- } ;
33-
3482 const readFile = async ( filepath : string ) => {
3583 const res = await fetch (
36- `/code-service/api/v3/projects/${ project } /repository/blobs/ ${ encodeURIComponent (
37- ref
38- ) } ?filepath=${ filepath } `
84+ `/code-service/api/v3/projects/${ encodeURIComponent (
85+ project
86+ ) } /repository/blobs/ ${ encodeURIComponent ( ref ) } ?filepath=${ filepath } `
3987 ) ;
4088 if ( res . status >= 200 && res . status < 300 ) {
4189 return res . arrayBuffer ( ) ;
4290 }
4391 throw new Error ( `${ res . status } - ${ res . statusText } ` ) ;
4492 } ;
4593
94+ const onFileChange = ( [ project , ref , filepath ] ) => {
95+ setProject ( project ) ;
96+ setRef ( ref ) ;
97+ setFilePath ( filepath ) ;
98+ } ;
99+ console . log ( 123 ) ;
100+
46101 return (
47102 < div style = { { padding : 8 } } >
48103 < div style = { { display : 'flex' , marginBottom : 8 } } >
49- < Select
50- value = { ref || undefined }
51- onChange = { setRef }
104+ < Cascader
105+ style = { { width : '100%' } }
52106 size = "small"
53- style = { { width : 400 , marginRight : 8 } }
54- placeholder = "选择分支"
55- >
56- { [ 'develop' ] . map ( ( path ) => (
57- < Select . Option key = { path } value = { path } >
58- { path }
59- </ Select . Option >
60- ) ) }
61- </ Select >
62- < Select
63- value = { filepath || undefined }
64- onChange = { setFilePath }
65- size = "small"
66- style = { { width : 600 , marginRight : 8 } }
67- placeholder = "选择文件"
68- >
69- { [
70- 'packages/addons/src/browser/file-drop.service.ts' ,
71- 'packages/addons/src/common/index.ts' ,
72- 'OWNERS' ,
73- ] . map ( ( path ) => (
74- < Select . Option key = { path } value = { path } >
75- { path }
76- </ Select . Option >
77- ) ) }
78- </ Select >
107+ options = { fileOptions }
108+ onChange = { onFileChange }
109+ placeholder = "Please select"
110+ />
79111 </ div >
80112 < div style = { { display : 'flex' , marginBottom : 8 } } >
81- < Button size = "small" onClick = { ( ) => setKey ( ( k ) => k + 1 ) } style = { { marginRight : 8 } } >
82- 重置
83- </ Button >
84- < Button size = "small" onClick = { ( ) => setContent ( ) } style = { { marginRight : 8 } } >
85- 一键设置文件
86- </ Button >
87113 < Select
88114 value = { encoding }
89115 onChange = { setEncoding }
@@ -114,7 +140,7 @@ const App = () => {
114140 < div style = { { display : 'flex' } } >
115141 < div style = { { width : '50%' , minHeight : 300 } } >
116142 < EditorRenderer
117- key = { key }
143+ key = { project }
118144 onLoad = { ( app ) => {
119145 window . app = app ;
120146 } }
@@ -138,13 +164,13 @@ const App = () => {
138164 } }
139165 editorConfig = { {
140166 disableEditorSearch : true ,
141- stretchHeight : true ,
167+ // stretchHeight: true,
142168 } }
143169 documentModel = { {
144170 type : 'code' ,
145171 ref,
146- owner,
147- name,
172+ owner : project . split ( '/' ) [ 0 ] ,
173+ name : project . split ( '/' ) [ 1 ] ,
148174 filepath,
149175 onFilepathChange ( newFilepath ) {
150176 setFilePath ( newFilepath ) ;
0 commit comments