mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 21:50:28 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			43 lines
		
	
	
		
			832 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			832 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package ui
 | 
						|
 | 
						|
import (
 | 
						|
	"bytes"
 | 
						|
	"github.com/iwind/TeaGo/Tea"
 | 
						|
	"github.com/iwind/TeaGo/actions"
 | 
						|
	"github.com/iwind/TeaGo/files"
 | 
						|
	"github.com/iwind/TeaGo/logs"
 | 
						|
)
 | 
						|
 | 
						|
type ComponentsAction actions.Action
 | 
						|
 | 
						|
func (this *ComponentsAction) RunGet(params struct{}) {
 | 
						|
	this.AddHeader("Content-Type", "text/javascript; charset=utf-8")
 | 
						|
 | 
						|
	var webRoot string
 | 
						|
	if Tea.IsTesting() {
 | 
						|
		webRoot = Tea.Root + "/../web/public/js/components/"
 | 
						|
	} else {
 | 
						|
		webRoot = Tea.Root + "/web/public/js/components/"
 | 
						|
	}
 | 
						|
	f := files.NewFile(webRoot)
 | 
						|
 | 
						|
	buf := bytes.NewBuffer([]byte{})
 | 
						|
	f.Range(func(file *files.File) {
 | 
						|
		if !file.IsFile() {
 | 
						|
			return
 | 
						|
		}
 | 
						|
		if file.Ext() != ".js" {
 | 
						|
			return
 | 
						|
		}
 | 
						|
		data, err := file.ReadAll()
 | 
						|
		if err != nil {
 | 
						|
			logs.Error(err)
 | 
						|
			return
 | 
						|
		}
 | 
						|
		buf.Write(data)
 | 
						|
		buf.WriteByte('\n')
 | 
						|
		buf.WriteByte('\n')
 | 
						|
	})
 | 
						|
	this.Write(buf.Bytes())
 | 
						|
}
 |