-
Notifications
You must be signed in to change notification settings - Fork 195
Expand file tree
/
Copy pathnav.component.ts
More file actions
223 lines (215 loc) · 6.06 KB
/
Copy pathnav.component.ts
File metadata and controls
223 lines (215 loc) · 6.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
import { Nav, View } from '@app/model';
import { DataStore } from '@app/globals';
import { themes } from '@src/sass/theme/main';
import { useTheme } from '@src/sass/theme/util';
import { I18nService } from '@app/services/i18n';
import { Component, OnInit } from '@angular/core';
import { NzModalService } from 'ng-zorro-antd/modal';
import { ElementSettingComponent } from '@app/elements/nav/setting/setting.component';
import {
IframeCommunicationService,
HttpService,
SettingService,
ViewService
} from '@app/services';
import { withSitePrefix, withUIBase } from '@app/utils/path';
@Component({
standalone: false,
selector: 'elements-nav',
templateUrl: 'nav.component.html',
styleUrls: ['nav.component.scss']
})
export class ElementNavComponent implements OnInit {
DataStore = DataStore;
navs: Array<Nav>;
viewList: Array<View>;
viewIds: Array<string>;
HELP_DOCUMENT_URL: string;
HELP_SUPPORT_URL: string;
constructor(
private _i18n: I18nService,
public _viewSrv: ViewService,
private _dialog: NzModalService,
private _settingSvc: SettingService,
private _http: HttpService,
private _iframeSvc: IframeCommunicationService
) {}
get viewListSorted() {
const viewList = [];
this.viewIds.forEach((id, index) => {
viewList[index] = this.viewList.find(i => i.id === id);
});
return viewList;
}
ngOnInit() {
this.navs = this.getNav();
this.viewList = this._viewSrv.viewList;
this.viewIds = this._viewSrv.viewIds;
}
getNav() {
return [
{
id: 'FileManager',
name: 'File Manager',
children: [
{
id: 'Connect',
click: () => {
window.open(withSitePrefix('/koko/elfinder/sftp/'));
},
name: 'Connect'
}
]
},
{
id: 'View',
name: 'View',
children: [
// 此处直接使用空串的话,在渲染时会被 nif 判断为 false 从而只有禁用效果而不展示文字内容
{
id: 'FullScreen',
click: () => {
const ele: any = document.getElementsByClassName('window active')[0];
if (!ele) {
return;
}
if (ele.requestFullscreen) {
ele.requestFullscreen();
} else if (ele.mozRequestFullScreen) {
ele.mozRequestFullScreen();
} else if (ele.msRequestFullscreen) {
ele.msRequestFullscreen();
} else if (ele.webkitRequestFullscreen) {
ele.webkitRequestFullScreen();
} else {
throw new Error('不支持全屏api');
}
window.dispatchEvent(new Event('resize'));
},
name: 'Full Screen'
}
]
},
{
id: 'Language',
name: 'Language',
children: this.getLanguageOptions()
},
{
id: 'Setting',
name: 'Setting',
children: [
{
id: 'General',
name: this._i18n.instant('General'),
click: () => {
this.showSettingDialog('general', 'General');
}
},
{
id: 'GUI',
name: this._i18n.instant('GUI'),
click: () => {
this.showSettingDialog('gui', 'GUI');
}
},
{
id: 'CLI',
name: this._i18n.instant('CLI'),
click: () => {
this.showSettingDialog('cli', 'CLI');
}
}
]
},
{
id: 'Tabs',
name: this._i18n.instant('Tabs'),
children: []
},
{
id: 'Theme',
name: this._i18n.instant('Theme'),
children: themes.map(theme => ({
id: theme.name,
click: () => {
(this._settingSvc.setting.basic as any).themes = theme.name;
useTheme().switchTheme(theme.name);
this._iframeSvc.sendMessage({
name: 'CHANGE_MAIN_THEME',
data: theme.name
});
this._settingSvc.save();
},
name: this._i18n.instant(theme.label)
}))
},
{
id: 'Help',
name: 'Help',
children: [
{
id: 'Document',
click: () => {
this.HELP_DOCUMENT_URL = this._settingSvc.globalSetting.HELP_DOCUMENT_URL;
window.open(this.HELP_DOCUMENT_URL);
},
name: 'Document'
},
{
id: 'Support',
click: () => {
this.HELP_SUPPORT_URL = this._settingSvc.globalSetting.HELP_SUPPORT_URL;
window.open(this.HELP_SUPPORT_URL);
},
name: 'Support'
},
{
id: 'Download',
click: () => {
window.open(withSitePrefix('/core/download/'), '_blank');
},
name: 'Download'
}
]
}
];
}
showSettingDialog(type: string, name: string) {
this._dialog.create({
nzTitle: this._i18n.instant(name),
nzContent: ElementSettingComponent,
nzClassName: 'setting-dialog',
nzWidth: '600px',
nzCentered: true,
nzData: { type, name },
nzOnOk: cmp => cmp.onSubmit(),
nzCancelText: this._i18n.instant('Cancel'),
nzOkText: this._i18n.instant('Confirm')
});
}
getLanguageOptions() {
const langOptions = [];
this._settingSvc.afterInited().then(state => {
const languages = this._settingSvc.globalSetting.LANGUAGES;
for (const langObj of languages) {
langOptions.push({
id: langObj.code,
click: () => {
this._i18n.use(langObj.code);
this._http
.get(`/core/i18n/${langObj.code}/`, { responseType: 'text' })
.subscribe(resp => {
window.location.reload();
});
},
name: langObj.name
});
}
});
return langOptions;
}
onJumpUi() {
window.open(withUIBase(), '_blank');
}
}