|
|
就是用ucode开发
我现在有一个问题,我写了一个luci插件,方法都封装到了 /usr/share/rpcd/ucode/luci.myplugin 里
- 'use strict';
- import { cursor } from 'uci';
- import { popen } from 'fs';
- function wget(url) {
- return popen('wget -q --user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0" -t 3 -T 10 -O- ' + url);
- }
- function md5(str) {
- const handle = popen('echo -n "' + str + '" | md5sum');
- if (handle) {
- let content = handle.read(' ');
- handle.close();
- return trim(content);
- }
- }
- const methods = {
- get_conf : {
- call: function () {
- ...
- return conf;
- }
- }
- };
- return { 'luci.myplugin': methods };
复制代码
但是这个方法我其实不只是我luci界面用,我觉得我应该写成这样:
在 /usr/share/myplugin 目录下面有一个 app.uc 他能接受参数,比如 start stop cleanup renew 这种,然后运行不同的逻辑,同时 luci 界面也能调用
我没太理解 openwrt 插件开发的逻辑,因为我本身不是一个 web 开发者,我一般都是写一些桌面程序或者干脆就是控制台程序,所以很困惑。 |
|