From 2d3b6ebe4ab1cab82098532eb762e164eb33149e Mon Sep 17 00:00:00 2001 From: actions-user Date: Wed, 27 Nov 2024 11:44:24 +0800 Subject: [PATCH] update 2024-11-27 11:44:24 --- luci-app-design-config/Makefile | 17 ++++++ luci-app-design-config/README.md | 1 + .../luasrc/controller/design-config.lua | 10 ++++ .../luasrc/model/cbi/design-config.lua | 58 +++++++++++++++++++ .../view/design-config/other_button.htm | 7 +++ .../view/design-config/other_dvalue.htm | 8 +++ .../po/zh-cn/design-config.po | 44 ++++++++++++++ luci-app-design-config/po/zh_Hans | 1 + luci-app-design-config/root/etc/config/design | 4 ++ .../root/etc/uci-defaults/luci-design-config | 6 ++ .../rpcd/acl.d/luci-app-design-config.json | 11 ++++ 11 files changed, 167 insertions(+) create mode 100644 luci-app-design-config/Makefile create mode 100644 luci-app-design-config/README.md create mode 100644 luci-app-design-config/luasrc/controller/design-config.lua create mode 100644 luci-app-design-config/luasrc/model/cbi/design-config.lua create mode 100644 luci-app-design-config/luasrc/view/design-config/other_button.htm create mode 100644 luci-app-design-config/luasrc/view/design-config/other_dvalue.htm create mode 100644 luci-app-design-config/po/zh-cn/design-config.po create mode 120000 luci-app-design-config/po/zh_Hans create mode 100644 luci-app-design-config/root/etc/config/design create mode 100644 luci-app-design-config/root/etc/uci-defaults/luci-design-config create mode 100644 luci-app-design-config/root/usr/share/rpcd/acl.d/luci-app-design-config.json diff --git a/luci-app-design-config/Makefile b/luci-app-design-config/Makefile new file mode 100644 index 00000000..029ed20a --- /dev/null +++ b/luci-app-design-config/Makefile @@ -0,0 +1,17 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=luci-app-design-config + +PKG_MAINTAINER:=gngpp + +LUCI_TITLE:=LuCI page for Design Config +LUCI_PKGARCH:=all +LUCI_DEPENDS:=+luci-compat + +define Package/$(PKG_NAME)/conffiles +/etc/config/design +endef + +include $(TOPDIR)/feeds/luci/luci.mk + +# call BuildPackage - OpenWrt buildroot signature diff --git a/luci-app-design-config/README.md b/luci-app-design-config/README.md new file mode 100644 index 00000000..93b7e225 --- /dev/null +++ b/luci-app-design-config/README.md @@ -0,0 +1 @@ +# luci-app-design-config \ No newline at end of file diff --git a/luci-app-design-config/luasrc/controller/design-config.lua b/luci-app-design-config/luasrc/controller/design-config.lua new file mode 100644 index 00000000..f6529fbc --- /dev/null +++ b/luci-app-design-config/luasrc/controller/design-config.lua @@ -0,0 +1,10 @@ +module("luci.controller.design-config", package.seeall) + +function index() + if not nixio.fs.access('/www/luci-static/design/css/style.css') then + return + end + + local page = entry({"admin", "system", "design-config"}, form("design-config"), _("Design Config"), 90) + page.acl_depends = { "luci-app-design-config" } +end diff --git a/luci-app-design-config/luasrc/model/cbi/design-config.lua b/luci-app-design-config/luasrc/model/cbi/design-config.lua new file mode 100644 index 00000000..8ce99fae --- /dev/null +++ b/luci-app-design-config/luasrc/model/cbi/design-config.lua @@ -0,0 +1,58 @@ +local nxfs = require 'nixio.fs' +local nutil = require 'nixio.util' +local name = 'design' +local uci = require 'luci.model.uci'.cursor() + +local mode, navbar, navbar_proxy +if nxfs.access('/etc/config/design') then + mode = uci:get_first('design', 'global', 'mode') + navbar = uci:get_first('design', 'global', 'navbar') + navbar_proxy = uci:get_first('design', 'global', 'navbar_proxy') +end + +-- [[ 设置 ]]-- +br = SimpleForm('config', translate('Design Config'), translate('Here you can set the mode of the theme and change the proxy tool icon in the navigation bar. [Recommend Chrome]')) +br.reset = false +br.submit = false +s = br:section(SimpleSection) + +o = s:option(ListValue, 'mode', translate('Theme mode')) +o:value('normal', translate('Follow System')) +o:value('light', translate('Force Light')) +o:value('dark', translate('Force Dark')) +o.default = mode +o.rmempty = false +o.description = translate('You can choose Theme color mode here') + +o = s:option(ListValue, 'navbar', translate('Navigation bar setting')) +o:value('display', translate('Display navigation bar')) +o:value('close', translate('Close navigation bar')) +o.default = navbar +o.rmempty = false +o.description = translate('The navigation bar is display by default') + +o = s:option(ListValue, 'navbar_proxy', translate('Navigation bar proxy')) +o:value('openclash', 'openclash') +o:value('shadowsocksr', 'shadowsocksr') +o:value('vssr', 'vssr') +o:value('passwall', 'passwall') +o:value('passwall2', 'passwall2') +o.default = navbar_proxy +o.rmempty = false +o.description = translate('OpenClash by default') + +o = s:option(Button, 'save', translate('Save Changes')) +o.inputstyle = 'reload' + +function br.handle(self, state, data) + if (state == FORM_VALID and data.mode ~= nil and data.navbar ~= nil and data.navbar_proxy ~= nil) then + nxfs.writefile('/tmp/aaa', data) + for key, value in pairs(data) do + uci:set('design','@global[0]',key,value) + end + uci:commit('design') + end + return true +end + +return br diff --git a/luci-app-design-config/luasrc/view/design-config/other_button.htm b/luci-app-design-config/luasrc/view/design-config/other_button.htm new file mode 100644 index 00000000..1c391ad9 --- /dev/null +++ b/luci-app-design-config/luasrc/view/design-config/other_button.htm @@ -0,0 +1,7 @@ +<%+cbi/valueheader%> + <% if self:cfgvalue(section) ~= false then %> + " style="display: <%= display %>" type="submit"<%= attr("name", cbid) .. attr("id", cbid) .. attr("value", self.inputtitle or self.title)%> /> + <% else %> + - + <% end %> +<%+cbi/valuefooter%> diff --git a/luci-app-design-config/luasrc/view/design-config/other_dvalue.htm b/luci-app-design-config/luasrc/view/design-config/other_dvalue.htm new file mode 100644 index 00000000..296c61e4 --- /dev/null +++ b/luci-app-design-config/luasrc/view/design-config/other_dvalue.htm @@ -0,0 +1,8 @@ +<%+cbi/valueheader%> + +<% + local val = self:cfgvalue(section) or self.default or "" + write(pcdata(val)) +%> + +<%+cbi/valuefooter%> diff --git a/luci-app-design-config/po/zh-cn/design-config.po b/luci-app-design-config/po/zh-cn/design-config.po new file mode 100644 index 00000000..af48e4c0 --- /dev/null +++ b/luci-app-design-config/po/zh-cn/design-config.po @@ -0,0 +1,44 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8\n" + +msgid "Design Config" +msgstr "Design 主题设置" + +msgid "Here you can set the mode of the theme and change the proxy tool icon in the navigation bar. [Recommend Chrome]" +msgstr "这里可以设置主题的模式和更换导航栏的代理工具图标。[建议使用 Chrome]" + +msgid "Theme mode" +msgstr "主题模式" + +msgid "Follow System" +msgstr "跟随系统" + +msgid "Force Light" +msgstr "强制亮色" + +msgid "Force Dark" +msgstr "强制暗色" + +msgid "You can choose Theme color mode here" +msgstr "你可以选择喜欢的主题模式" + +msgid "Navigation bar setting" +msgstr "导航栏设置" + +msgid "Display navigation bar" +msgstr "显示导航栏" + +msgid "Close navigation bar" +msgstr "关闭导航栏" + +msgid "The navigation bar is display by default" +msgstr "默认显示导航栏" + +msgid "Navigation bar proxy" +msgstr "导航栏代理" + +msgid "OpenClash by default" +msgstr "默认 OpenClash" + +msgid "Save Changes" +msgstr "保存更改" \ No newline at end of file diff --git a/luci-app-design-config/po/zh_Hans b/luci-app-design-config/po/zh_Hans new file mode 120000 index 00000000..41451e4a --- /dev/null +++ b/luci-app-design-config/po/zh_Hans @@ -0,0 +1 @@ +zh-cn \ No newline at end of file diff --git a/luci-app-design-config/root/etc/config/design b/luci-app-design-config/root/etc/config/design new file mode 100644 index 00000000..faa65357 --- /dev/null +++ b/luci-app-design-config/root/etc/config/design @@ -0,0 +1,4 @@ +config global + option mode 'dark' + option navbar 'display' + option navbar_proxy 'openclash' \ No newline at end of file diff --git a/luci-app-design-config/root/etc/uci-defaults/luci-design-config b/luci-app-design-config/root/etc/uci-defaults/luci-design-config new file mode 100644 index 00000000..935d7c8b --- /dev/null +++ b/luci-app-design-config/root/etc/uci-defaults/luci-design-config @@ -0,0 +1,6 @@ +#!/bin/sh + +sed -i 's/cbi.submit\"] = true/cbi.submit\"] = \"1\"/g' /usr/lib/lua/luci/dispatcher.lua + +rm -f /tmp/luci-indexcache +exit 0 diff --git a/luci-app-design-config/root/usr/share/rpcd/acl.d/luci-app-design-config.json b/luci-app-design-config/root/usr/share/rpcd/acl.d/luci-app-design-config.json new file mode 100644 index 00000000..c439886f --- /dev/null +++ b/luci-app-design-config/root/usr/share/rpcd/acl.d/luci-app-design-config.json @@ -0,0 +1,11 @@ +{ + "luci-app-design-config": { + "description": "Grant UCI access for luci-app-design-config", + "read": { + "uci": [ "design" ] + }, + "write": { + "uci": [ "design" ] + } + } +}