Skip to content

Commit 3c74f15

Browse files
committed
fix: Open dashboard, UI in config tab
1 parent a9f36d5 commit 3c74f15

File tree

4 files changed

+35
-29
lines changed

4 files changed

+35
-29
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
include $(TOPDIR)/rules.mk
55

66
PKG_NAME:=luci-app-ssclash
7-
PKG_VERSION:=2.9.0
7+
PKG_VERSION:=2.9.1
88
PKG_RELEASE:=1
99
PKG_MAINTAINER:=ZeroChaos <[email protected]>
1010

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ For iptables (if you have OpenWrt version < 22.03.x) – `iptables-mod-tproxy`.
3232
Download the SSClash package and install it.
3333

3434
```bash
35-
curl -L https://github.com/zerolabnet/ssclash/releases/download/v2.9.0/luci-app-ssclash_2.9.0-r1_all.ipk -o /tmp/luci-app-ssclash_2.9.0-r1_all.ipk
36-
opkg install /tmp/luci-app-ssclash_2.9.0-r1_all.ipk
35+
curl -L https://github.com/zerolabnet/ssclash/releases/download/v2.9.1/luci-app-ssclash_2.9.1-r1_all.ipk -o /tmp/luci-app-ssclash_2.9.1-r1_all.ipk
36+
opkg install /tmp/luci-app-ssclash_2.9.1-r1_all.ipk
3737
rm /tmp/*.ipk
3838
```
3939

README.ru.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ opkg install kmod-nft-tproxy
3030
Загрузите пакет SSClash и установите его.
3131

3232
```bash
33-
curl -L https://github.com/zerolabnet/ssclash/releases/download/v2.9.0/luci-app-ssclash_2.9.0-r1_all.ipk -o /tmp/luci-app-ssclash_2.9.0-r1_all.ipk
34-
opkg install /tmp/luci-app-ssclash_2.9.0-r1_all.ipk
33+
curl -L https://github.com/zerolabnet/ssclash/releases/download/v2.9.1/luci-app-ssclash_2.9.1-r1_all.ipk -o /tmp/luci-app-ssclash_2.9.1-r1_all.ipk
34+
opkg install /tmp/luci-app-ssclash_2.9.1-r1_all.ipk
3535
rm /tmp/*.ipk
3636
```
3737

rootfs/www/luci-static/resources/view/ssclash/config.js

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -103,37 +103,38 @@ function computeUiPath(externalUiName, externalUi) {
103103
}
104104

105105
async function openDashboard() {
106-
const newWindow = window.open('about:blank', '_blank');
107-
if (!newWindow) {
108-
ui.addNotification(null, E('p', _('Popup was blocked. Please allow popups for this site.')), 'warning');
109-
return;
110-
}
111106
try {
112107
if (!(await getServiceStatus())) {
113-
newWindow.close();
114108
ui.addNotification(null, E('p', _('Service is not running.')), 'error');
115109
return;
116110
}
111+
117112
const config = await fs.read('/opt/clash/config.yaml');
118113
const ec = parseYamlValue(config, 'external-controller');
119114
const ecTls = parseYamlValue(config, 'external-controller-tls');
120115
const secret = parseYamlValue(config, 'secret');
121116
const externalUi = parseYamlValue(config, 'external-ui');
122117
const externalUiName = parseYamlValue(config, 'external-ui-name');
118+
123119
const baseHost = window.location.hostname;
124120
const basePort = '9090';
125121
const useTls = !!ecTls;
122+
126123
const { host, port } = normalizeHostPortFromAddr(useTls ? ecTls : ec, baseHost, basePort);
127124
const scheme = useTls ? 'https:' : 'http:';
128125
const uiPath = computeUiPath(externalUiName, externalUi);
126+
129127
const qp = new URLSearchParams();
130128
if (secret) qp.set('secret', secret);
131129
qp.set('hostname', host);
132130
qp.set('port', port);
133131
const url = `${scheme}//${host}:${port}${uiPath}?${qp.toString()}`;
134-
newWindow.location.replace(url);
132+
133+
const newWindow = window.open(url, '_blank');
134+
if (!newWindow) {
135+
ui.addNotification(null, E('p', _('Popup was blocked. Please allow popups for this site.')), 'warning');
136+
}
135137
} catch (error) {
136-
newWindow.close();
137138
console.error(_('Error opening dashboard:'), error);
138139
ui.addNotification(null, E('p', _('Failed to open dashboard: %s').format(error.message)), 'error');
139140
}
@@ -186,23 +187,27 @@ return view.extend({
186187
if (startStopButton) startStopButton.disabled = false;
187188
}
188189
};
190+
189191
const view = E([
190-
E('div', { 'style': 'margin-bottom: 20px;' }, [
191-
E('div', {
192-
'style': 'margin-bottom: 10px; display: flex; flex-wrap: wrap; gap: 10px;'
193-
}, [
194-
E('button', { 'class': 'btn', 'click': openDashboard }, _('Open Dashboard')),
195-
(startStopButton = E('button', {
196-
'class': 'btn',
197-
'click': toggleService
198-
}, running ? _('Stop Service') : _('Start Service')))
199-
]),
200-
E('div', { 'style': 'display: flex; justify-content: flex-start;' }, [
201-
E('span', {
202-
'class': 'label',
203-
'style': `padding: 6px 12px; border-radius: 3px; font-size: 12px; color: white; background-color: ${running ? '#5cb85c' : '#d9534f'}; display: inline-block;`
204-
}, running ? _('Clash is running') : _('Clash stopped'))
205-
])
192+
E('div', {
193+
'style': 'margin-bottom: 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px;'
194+
}, [
195+
E('button', {
196+
'class': 'btn',
197+
'click': openDashboard,
198+
'style': 'margin: 0;'
199+
}, _('Open Dashboard')),
200+
201+
(startStopButton = E('button', {
202+
'class': 'btn',
203+
'click': toggleService,
204+
'style': 'margin: 0;'
205+
}, running ? _('Stop Service') : _('Start Service'))),
206+
207+
E('span', {
208+
'class': 'label',
209+
'style': `padding: 4px 10px; border-radius: 3px; font-size: 12px; color: white; background-color: ${running ? '#5cb85c' : '#d9534f'}; margin: 0;`
210+
}, running ? _('Clash is running') : _('Clash stopped'))
206211
]),
207212
E('h2', _('Clash Configuration')),
208213
E('p', { 'class': 'cbi-section-descr' }, _('Your current Clash config. When applied, the changes will be saved and the service will be restarted.')),
@@ -217,6 +222,7 @@ return view.extend({
217222
}, _('Save & Apply Configuration'))
218223
])
219224
]);
225+
220226
initializeAceEditor(config);
221227
return view;
222228
},

0 commit comments

Comments
 (0)