x
This commit is contained in:
@@ -8,6 +8,6 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
<script src="/admin/umi.4cb92728.js"></script>
|
<script src="/admin/umi.f36f16c6.js"></script>
|
||||||
|
|
||||||
</body></html>
|
</body></html>
|
||||||
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+10
-4
@@ -17,13 +17,19 @@ import (
|
|||||||
|
|
||||||
func checkFilePlugin(key string, value *string) {
|
func checkFilePlugin(key string, value *string) {
|
||||||
if isNameUuid(key) {
|
if isNameUuid(key) {
|
||||||
if v, ok := plugins_id.Load(key); ok {
|
for _, f := range Functions {
|
||||||
data, _ := os.ReadFile(v.(string))
|
if f.UUID == key {
|
||||||
|
data, _ := os.ReadFile(f.Path)
|
||||||
*value = string(data)
|
*value = string(data)
|
||||||
} else {
|
return
|
||||||
*value = "非法操作,请勿乱动。"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// if v, ok := plugins_id.Load(key); ok {
|
||||||
|
|
||||||
|
// } else {
|
||||||
|
*value = "非法操作,请勿乱动。"
|
||||||
|
// }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ type Function struct {
|
|||||||
Messages interface{} `json:"messages"`
|
Messages interface{} `json:"messages"`
|
||||||
Classes []string `json:"classes"`
|
Classes []string `json:"classes"`
|
||||||
Debug bool `json:"debug"`
|
Debug bool `json:"debug"`
|
||||||
|
Path string `json:"-"`
|
||||||
}
|
}
|
||||||
type Filter struct {
|
type Filter struct {
|
||||||
BlackMode bool
|
BlackMode bool
|
||||||
|
|||||||
+14
-1
@@ -41,6 +41,12 @@ var languages = []Language{
|
|||||||
Arch: "arm64",
|
Arch: "arm64",
|
||||||
Links: []string{"https://gitee.com/sillybot/binary/releases/download/" + release + "/node_darwin_arm64.zip"},
|
Links: []string{"https://gitee.com/sillybot/binary/releases/download/" + release + "/node_darwin_arm64.zip"},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "node",
|
||||||
|
Version: release,
|
||||||
|
Os: "windows",
|
||||||
|
Arch: "amd64",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func initLanguage() {
|
func initLanguage() {
|
||||||
@@ -59,7 +65,11 @@ func initLanguage() {
|
|||||||
newPath = node_dir
|
newPath = node_dir
|
||||||
}
|
}
|
||||||
os.Setenv("PATH", newPath)
|
os.Setenv("PATH", newPath)
|
||||||
|
if len(item.Links) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if _, err := os.Stat(node_dir + "/yarn"); err != nil {
|
if _, err := os.Stat(node_dir + "/yarn"); err != nil {
|
||||||
|
fmt.Println(err, 1)
|
||||||
resp, err := http.Get("https://gitee.com/sillybot/binary/releases/download/yarn/yarn.zip")
|
resp, err := http.Get("https://gitee.com/sillybot/binary/releases/download/yarn/yarn.zip")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
go func() {
|
go func() {
|
||||||
@@ -67,15 +77,18 @@ func initLanguage() {
|
|||||||
zipfile := node_dir + "/yarn.zip"
|
zipfile := node_dir + "/yarn.zip"
|
||||||
f, err := os.OpenFile(zipfile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0755)
|
f, err := os.OpenFile(zipfile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println(err, 2)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
_, err = io.Copy(f, resp.Body)
|
_, err = io.Copy(f, resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println(err, 3)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer os.Remove(zipfile)
|
defer os.Remove(zipfile)
|
||||||
unzip(zipfile, 0777, false)
|
err = unzip(zipfile, 0777, false)
|
||||||
|
fmt.Println(err, 4)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ func RemNodePlugin(name string) error {
|
|||||||
pluginLock.Lock()
|
pluginLock.Lock()
|
||||||
defer pluginLock.Unlock()
|
defer pluginLock.Unlock()
|
||||||
key := nameUuid(name)
|
key := nameUuid(name)
|
||||||
plugins_id.Delete(key)
|
// plugins_id.Delete(key)
|
||||||
// fmt.Println("rem", key, name)
|
// fmt.Println("rem", key, name)
|
||||||
for i := range Functions {
|
for i := range Functions {
|
||||||
if Functions[i].UUID == key {
|
if Functions[i].UUID == key {
|
||||||
@@ -223,7 +223,7 @@ func isNameUuid(uuid string) bool {
|
|||||||
return strings.Contains(uuid, "_")
|
return strings.Contains(uuid, "_")
|
||||||
}
|
}
|
||||||
|
|
||||||
var plugins_id sync.Map
|
// var plugins_id sync.Map
|
||||||
|
|
||||||
func AddNodePlugin(path, name string) error {
|
func AddNodePlugin(path, name string) error {
|
||||||
if name == "" {
|
if name == "" {
|
||||||
@@ -246,12 +246,12 @@ func AddNodePlugin(path, name string) error {
|
|||||||
if script == "" {
|
if script == "" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
// plugins_id.Store(uuid, path)
|
||||||
plugins_id.Store(uuid, path)
|
|
||||||
// fmt.Println("add,", uuid, name)
|
// fmt.Println("add,", uuid, name)
|
||||||
f, cbs := pluginParse(script, uuid)
|
f, cbs := pluginParse(script, uuid)
|
||||||
f.Suffix = ".js"
|
f.Suffix = ".js"
|
||||||
f.Type = "typescript"
|
f.Type = "node"
|
||||||
|
f.Path = path
|
||||||
f.Handle = func(s common.Sender, f func(vm *goja.Runtime)) interface{} {
|
f.Handle = func(s common.Sender, f func(vm *goja.Runtime)) interface{} {
|
||||||
s.SetPluginID(uuid)
|
s.SetPluginID(uuid)
|
||||||
plt := s.GetImType()
|
plt := s.GetImType()
|
||||||
|
|||||||
+26
-9
@@ -111,8 +111,13 @@ func initPlugins() {
|
|||||||
storage.Watch(plugins, nil, func(old, new, key string) (fin *storage.Final) {
|
storage.Watch(plugins, nil, func(old, new, key string) (fin *storage.Final) {
|
||||||
pluginLock.Lock()
|
pluginLock.Lock()
|
||||||
defer pluginLock.Unlock()
|
defer pluginLock.Unlock()
|
||||||
// fmt.Println("new", new, key)
|
// fmt.Println(old, new, key, "===")
|
||||||
|
if new == "uninstall" {
|
||||||
|
new = ""
|
||||||
|
fin = &storage.Final{
|
||||||
|
Now: storage.EMPTY,
|
||||||
|
}
|
||||||
|
}
|
||||||
if isNameUuid(key) {
|
if isNameUuid(key) {
|
||||||
if new == "install" {
|
if new == "install" {
|
||||||
for _, p := range plugin_list {
|
for _, p := range plugin_list {
|
||||||
@@ -162,10 +167,18 @@ func initPlugins() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if vv, ok := plugins_id.Load(key); ok {
|
// if vv, ok := plugins_id.Load(key); ok {
|
||||||
filename := vv.(string)
|
for _, f := range Functions {
|
||||||
|
if f.UUID == key {
|
||||||
|
filename := f.Path
|
||||||
if new == "" {
|
if new == "" {
|
||||||
|
ss := strings.Split(filename, "/")
|
||||||
os.RemoveAll(filepath.Dir(filename))
|
os.RemoveAll(filepath.Dir(filename))
|
||||||
|
// fmt.Println(strings.Join(ss, " "))
|
||||||
|
if len(ss) > 2 {
|
||||||
|
go RemNodePlugin(ss[len(ss)-2])
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
err := os.WriteFile(filename, []byte(new), 0755)
|
err := os.WriteFile(filename, []byte(new), 0755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -174,13 +187,18 @@ func initPlugins() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if fin != nil {
|
||||||
|
return fin
|
||||||
|
}
|
||||||
return &storage.Final{
|
return &storage.Final{
|
||||||
Now: "",
|
Now: "",
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
return &storage.Final{
|
// return &storage.Final{
|
||||||
Error: errors.New("安装失败!!!"),
|
// Error: errors.New("安装失败!!!"),
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
if new == "install" {
|
if new == "install" {
|
||||||
@@ -206,7 +224,6 @@ func initPlugins() {
|
|||||||
Error: errors.New("订阅源异常"),
|
Error: errors.New("订阅源异常"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -180,8 +180,12 @@ func (bucket *Bucket) Set(key interface{}, value interface{}) (string, bool, err
|
|||||||
return msg, changed, fin.Error
|
return msg, changed, fin.Error
|
||||||
}
|
}
|
||||||
if fin.Now != "" {
|
if fin.Now != "" {
|
||||||
|
if new == storage.EMPTY {
|
||||||
|
new = ""
|
||||||
|
} else {
|
||||||
new = fin.Now
|
new = fin.Now
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if fin.EndFunc != nil {
|
if fin.EndFunc != nil {
|
||||||
endFuncs = append(endFuncs, fin.EndFunc)
|
endFuncs = append(endFuncs, fin.EndFunc)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ type Listen struct {
|
|||||||
Handle func(old string, new string, key string) *Final
|
Handle func(old string, new string, key string) *Final
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const EMPTY = "__EMPTY__"
|
||||||
|
|
||||||
var Listens []Listen
|
var Listens []Listen
|
||||||
|
|
||||||
var DisableHandle = func(uuid string) {
|
var DisableHandle = func(uuid string) {
|
||||||
|
|||||||
@@ -239,8 +239,12 @@ func (bucket *Bucket) Set(key interface{}, value interface{}) (string, bool, err
|
|||||||
return msg, changed, fin.Error
|
return msg, changed, fin.Error
|
||||||
}
|
}
|
||||||
if fin.Now != "" {
|
if fin.Now != "" {
|
||||||
|
if new == storage.EMPTY {
|
||||||
|
new = ""
|
||||||
|
} else {
|
||||||
new = fin.Now
|
new = fin.Now
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if fin.EndFunc != nil {
|
if fin.EndFunc != nil {
|
||||||
endFuncs = append(endFuncs, fin.EndFunc)
|
endFuncs = append(endFuncs, fin.EndFunc)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-6
@@ -76,15 +76,11 @@ func initWeb() {
|
|||||||
for _, f := range Functions {
|
for _, f := range Functions {
|
||||||
if f.UUID == uuid && f.Public {
|
if f.UUID == uuid && f.Public {
|
||||||
plugin_downloads.Set(f.UUID, plugin_downloads.GetInt(f.UUID)+1)
|
plugin_downloads.Set(f.UUID, plugin_downloads.GetInt(f.UUID)+1)
|
||||||
if f.Type == "goja" {
|
if !isNameUuid(f.UUID) {
|
||||||
c.String(200, publicScript(plugins.GetString(f.UUID)))
|
c.String(200, publicScript(plugins.GetString(f.UUID)))
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
v, ok := plugins_id.Load(f.UUID)
|
dir := filepath.Dir(f.Path)
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
dir := filepath.Dir(v.(string))
|
|
||||||
if _, err := os.Stat(dir); err != nil { //执行压缩
|
if _, err := os.Stat(dir); err != nil { //执行压缩
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user