Skip to content

Commit

Permalink
update 2024-11-09 20:21:35
Browse files Browse the repository at this point in the history
  • Loading branch information
kenzok8 committed Nov 9, 2024
1 parent a67121a commit 83888a0
Show file tree
Hide file tree
Showing 179 changed files with 31,919 additions and 58,767 deletions.
2 changes: 1 addition & 1 deletion luci-app-mihomo/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include $(TOPDIR)/rules.mk

PKG_VERSION:=1.9.3
PKG_VERSION:=1.10.0

LUCI_TITLE:=LuCI Support for mihomo
LUCI_DEPENDS:=+luci-base +mihomo
Expand Down
10 changes: 8 additions & 2 deletions luci-app-mihomo/htdocs/luci-static/resources/tools/mihomo.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

const homeDir = '/etc/mihomo';
const profilesDir = `${homeDir}/profiles`;
const subscriptionsDir = `${homeDir}/subscriptions`;
const mixinFilePath = `${homeDir}/mixin.yaml`;
const runDir = `${homeDir}/run`;
const runProfilePath = `${runDir}/config.yaml`;
Expand All @@ -19,6 +20,7 @@ const reservedIP6NFT = `${nftDir}/reserved_ip6.nft`;
return baseclass.extend({
homeDir: homeDir,
profilesDir: profilesDir,
subscriptionsDir: subscriptionsDir,
mixinFilePath: mixinFilePath,
runDir: runDir,
appLogPath: appLogPath,
Expand Down Expand Up @@ -54,6 +56,10 @@ return baseclass.extend({
return L.resolveDefault(fs.list(this.profilesDir), []);
},

updateSubscription: function (section_id) {
return fs.exec_direct('/usr/libexec/mihomo-call', ['subscription', 'update', section_id]);
},

status: async function () {
try {
return (await this.callServiceList('mihomo'))['mihomo']['instances']['mihomo']['running'];
Expand All @@ -71,11 +77,11 @@ return baseclass.extend({
},

appVersion: function () {
return L.resolveDefault(fs.exec_direct('/usr/libexec/mihomo-call', ['version', 'app']), 'Unknown');
return L.resolveDefault(fs.exec_direct('/usr/libexec/mihomo-call', ['version', 'app']), _('Unknown'));
},

coreVersion: function () {
return L.resolveDefault(fs.exec_direct('/usr/libexec/mihomo-call', ['version', 'core']), 'Unknown');
return L.resolveDefault(fs.exec_direct('/usr/libexec/mihomo-call', ['version', 'core']), _('Unknown'));
},

callMihomoAPI: async function (method, path, body) {
Expand Down
32 changes: 22 additions & 10 deletions luci-app-mihomo/htdocs/luci-static/resources/view/mihomo/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,20 @@ return view.extend({

o = s.option(form.Value, '_app_version', _('App Version'));
o.readonly = true;
o.load = function (section_id) {
o.load = function () {
return appVersion.trim();
};
o.write = function () { };

o = s.option(form.Value, '_core_version', _('Core Version'));
o.readonly = true;
o.load = function (section_id) {
o.load = function () {
return coreVersion.trim();
};
o.write = function () { };

o = s.option(form.DummyValue, '_core_status', _('Core Status'));
o.cfgvalue = function (section_id) {
o.cfgvalue = function () {
return renderStatus(running);
};
poll.add(function () {
Expand Down Expand Up @@ -119,11 +119,11 @@ return view.extend({

for (const profile of profiles) {
o.value('file:' + profile.name, _('File:') + profile.name);
}
};

for (const subscription of subscriptions) {
o.value('subscription:' + subscription['.name'], _('Subscription:') + subscription.name);
}
};

o = s.option(form.FileUpload, 'upload_profile', _('Upload Profile'));
o.root_directory = mihomo.profilesDir;
Expand Down Expand Up @@ -253,8 +253,20 @@ return view.extend({
o.value('clash.meta');
o.value('clash');

o = s.option(form.ListValue, 'prefer', _('Prefer'));
o.default = 'remote';
o.value('remote', _('Remote'));
o.value('local', _('Local'));

o = s.option(form.Button, 'update_subscription');
o.inputstyle = 'positive';
o.inputtitle = _('Update');
o.onclick = function (_, section_id) {
return mihomo.updateSubscription(section_id);
};

s = m.section(form.NamedSection, 'mixin', 'mixin', _('Mixin Config'));

s.tab('general', _('General Config'));

o = s.taboption('general', form.ListValue, 'log_level', '*' + ' ' + _('Log Level'));
Expand Down Expand Up @@ -295,9 +307,9 @@ return view.extend({

o = s.taboption('external_control', form.Value, 'ui_url', '*' + ' ' + _('UI Url'));
o.rmempty = false;
o.value('https://mirror.ghproxy.com/https://github.com/MetaCubeX/metacubexd/archive/refs/heads/gh-pages.zip', 'MetaCubeXD')
o.value('https://mirror.ghproxy.com/https://github.com/MetaCubeX/Yacd-meta/archive/refs/heads/gh-pages.zip', 'YACD')
o.value('https://mirror.ghproxy.com/https://github.com/MetaCubeX/Razord-meta/archive/refs/heads/gh-pages.zip', 'Razord')
o.value('https://mirror.ghproxy.com/https://github.com/MetaCubeX/metacubexd/archive/refs/heads/gh-pages.zip', 'MetaCubeXD');
o.value('https://mirror.ghproxy.com/https://github.com/MetaCubeX/Yacd-meta/archive/refs/heads/gh-pages.zip', 'YACD');
o.value('https://mirror.ghproxy.com/https://github.com/MetaCubeX/Razord-meta/archive/refs/heads/gh-pages.zip', 'Razord');

o = s.taboption('external_control', form.Value, 'api_port', '*' + ' ' + _('API Port'));
o.datatype = 'port';
Expand Down Expand Up @@ -403,7 +415,7 @@ return view.extend({
o.retain = true;
o.depends({ 'dns_mode': 'fake-ip', 'fake_ip_filter': '1' });

o = s.taboption('dns', form.ListValue, 'fake_ip_filter_mode', _('Fake-IP Filter Mode'))
o = s.taboption('dns', form.ListValue, 'fake_ip_filter_mode', _('Fake-IP Filter Mode'));
o.retain = true;
o.value('blacklist', _('Block Mode'));
o.value('whitelist', _('Allow Mode'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ return view.extend({
]);
},
render: function (data) {
const subscriptions = uci.sections('mihomo', 'subscription');
const profiles = data[1];

let m, s, o;

m = new form.Map('mihomo');

s = m.section(form.NamedSection, 'editor', 'editor');
Expand All @@ -27,6 +28,11 @@ return view.extend({
for (const profile of profiles) {
o.value(mihomo.profilesDir + '/' + profile.name, _('File:') + profile.name);
}

for (const subscription of subscriptions) {
o.value(mihomo.subscriptionsDir + '/' + subscription['.name'] + '.yaml', _('Subscription:') + subscription.name);
}

o.value(mihomo.mixinFilePath, _('File for Mixin'));
o.value(mihomo.runProfilePath, _('Profile for Startup'));
o.value(mihomo.reservedIPNFT, _('File for Reserved IP'));
Expand All @@ -43,6 +49,7 @@ return view.extend({

o = s.option(form.TextValue, '_profile_content',);
o.rows = 25;
o.wrap = false;
o.write = function (section_id, formvalue) {
const path = m.lookupOption('mihomo.editor._profile')[0].formvalue('editor');
return fs.write(path, formvalue);
Expand All @@ -55,7 +62,7 @@ return view.extend({
return m.render();
},
handleSaveApply: function (ev, mode) {
return this.handleSave(ev).finally(function() {
return this.handleSave(ev).finally(function () {
return mode === '0' ? mihomo.reload() : mihomo.restart();
});
},
Expand Down
Loading

0 comments on commit 83888a0

Please sign in to comment.