openwrt_helloworld/luci-app-mihomo/htdocs/luci-static/resources/view/mihomo/profile.js
2024-12-17 15:30:26 +08:00

87 lines
2.4 KiB
JavaScript

'use strict';
'require form';
'require view';
'require uci';
'require tools.mihomo as mihomo';
return view.extend({
load: function () {
return Promise.all([
uci.load('mihomo')
]);
},
render: function (data) {
let m, s, o, so;
m = new form.Map('mihomo');
s = m.section(form.NamedSection, 'config', 'config', _('Profile'));
o = s.option(form.FileUpload, '_upload_profile', _('Upload Profile'));
o.browser = true;
o.enable_download = true;
o.root_directory = mihomo.profilesDir;
o.write = function (section_id, formvalue) {
return true;
};
s = m.section(form.GridSection, 'subscription', _('Subscription'));
s.addremove = true;
s.anonymous = true;
s.sortable = true;
s.modaltitle = _('Edit Subscription');
o = s.option(form.Value, 'name', _('Subscription Name'));
o.rmempty = false;
o = s.option(form.Value, 'used', _('Used'));
o.modalonly = false;
o.optional = true;
o.readonly = true;
o = s.option(form.Value, 'total', _('Total'));
o.modalonly = false;
o.optional = true;
o.readonly = true;
o = s.option(form.Value, 'expire', _('Expire At'));
o.modalonly = false;
o.optional = true;
o.readonly = true;
o = s.option(form.Value, 'update', _('Update At'));
o.modalonly = false;
o.optional = true;
o.readonly = true;
o = s.option(form.Button, 'update_subscription');
o.editable = true;
o.inputstyle = 'positive';
o.inputtitle = _('Update');
o.modalonly = false;
o.onclick = function (_, section_id) {
return mihomo.updateSubscription(section_id);
};
o = s.option(form.Value, 'url', _('Subscription Url'));
o.modalonly = true;
o.rmempty = false;
o = s.option(form.Value, 'user_agent', _('User Agent'));
o.default = 'clash';
o.modalonly = true;
o.rmempty = false;
o.value('mihomo');
o.value('clash.meta');
o.value('clash');
o = s.option(form.ListValue, 'prefer', _('Prefer'));
o.default = 'remote';
o.modalonly = true;
o.value('remote', _('Remote'));
o.value('local', _('Local'));
return m.render();
}
});