Skip to content

Commit

Permalink
Merge pull request #26 from IceWhaleTech/v0.2.1
Browse files Browse the repository at this point in the history
add sync function
  • Loading branch information
LinkLeong authored Nov 25, 2021
2 parents fcc57bb + 9057290 commit 796c25b
Show file tree
Hide file tree
Showing 45 changed files with 1,346 additions and 169 deletions.
2 changes: 1 addition & 1 deletion UI
Submodule UI updated 48 files
+1 −0 package.json
+3 −4 src/App.vue
+1 −0 src/assets/ani/sync.json
+25 −0 src/assets/img/android.svg
+ src/assets/img/computer.png
+ src/assets/img/device.png
+ src/assets/img/folder1.png
+159 −0 src/assets/img/macos.svg
+ src/assets/img/smart_icon.png
+ src/assets/img/sync_icon.png
+54 −0 src/assets/img/syncthing-logo.svg
+1 −0 src/assets/img/syncthing.svg
+1 −0 src/assets/img/windows.svg
+43 −0 src/assets/scss/_buttons.scss
+10 −0 src/assets/scss/_images.scss
+7 −0 src/assets/scss/_widgets.scss
+195 −10 src/assets/scss/app.scss
+ src/assets/syncthing_tutorials/Android-DeviceID.png
+ src/assets/syncthing_tutorials/Android-Menu.png
+ src/assets/syncthing_tutorials/Android-NewDevice.png
+ src/assets/syncthing_tutorials/Android-NewDeviceAdd.png
+ src/assets/syncthing_tutorials/Android-NewFolder.png
+ src/assets/syncthing_tutorials/Android-NewFolderCreate.png
+ src/assets/syncthing_tutorials/Android-ShowDeviceID.png
+ src/assets/syncthing_tutorials/Windows-DeviceID.png
+ src/assets/syncthing_tutorials/Windows-NewDevice.png
+ src/assets/syncthing_tutorials/Windows-NewDeviceSave.png
+ src/assets/syncthing_tutorials/Windows-NewFolder.png
+ src/assets/syncthing_tutorials/Windows-NewFolderSave.png
+ src/assets/syncthing_tutorials/Windows-ShowID.png
+ src/assets/syncthing_tutorials/macOS-Config.png
+ src/assets/syncthing_tutorials/macOS-DeviceID.png
+ src/assets/syncthing_tutorials/macOS-NewFolder.png
+ src/assets/syncthing_tutorials/macOS-NewFolderSave.png
+ src/assets/syncthing_tutorials/macOS-Settings.png
+ src/assets/syncthing_tutorials/macOS-ShowID.png
+ src/assets/syncthing_tutorials/macOS-icon.png
+45 −0 src/components/CoreService.vue
+10 −2 src/components/Settings.vue
+57 −0 src/components/SmartBlock.vue
+301 −0 src/components/SyncBlock.vue
+499 −0 src/components/SyncPanel.vue
+5 −0 src/components/forms/ImportPanel.vue
+4 −2 src/service/api.js
+18 −0 src/service/sync.js
+8 −2 src/store/index.js
+9 −4 src/views/Home.vue
+15 −1 yarn.lock
9 changes: 6 additions & 3 deletions pkg/utils/httper/httper.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,13 @@ func Get(url string, head map[string]string) (response string) {
//发送POST请求
//url:请求地址,data:POST请求提交的数据,contentType:请求体格式,如:application/json
//content:请求放回的内容
func Post(url string, data interface{}, contentType string) (content string) {
jsonStr, _ := json.Marshal(data)
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr))
func Post(url string, data []byte, contentType string, head map[string]string) (content string) {

req, err := http.NewRequest("POST", url, bytes.NewBuffer(data))
req.Header.Add("content-type", contentType)
for k, v := range head {
req.Header.Add(k, v)
}
if err != nil {
panic(err)
}
Expand Down
6 changes: 4 additions & 2 deletions route/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func InitRouter() *gin.Engine {
v1AppGroup.GET("/rely/:id/info", v1.ContainerRelyInfo)
v1AppGroup.GET("/install/config", v1.GetDockerInstallConfig)
//v1AppGroup.POST("/custom/install", v1.CustomInstallApp)

v1AppGroup.POST("/share", v1.ShareAppFile)
}

v1SysGroup := v1Group.Group("/sys")
Expand Down Expand Up @@ -266,7 +266,9 @@ func InitRouter() *gin.Engine {
{
v1SearchGroup.GET("/search", v1.GetSearchList)
}
v1Group.Any("/sync/*url", v1.SyncToSyncthing)
v1Group.GET("/sync/config", v1.GetSyncConfig)
v1Group.Any("/syncthing/*url", v1.SyncToSyncthing)

}
return r
}
15 changes: 15 additions & 0 deletions route/v1/app.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package v1

import (
"encoding/json"
"io/ioutil"
"net/http"
"strconv"

Expand Down Expand Up @@ -197,3 +199,16 @@ func CategoryList(c *gin.Context) {
list = append(list, rear...)
c.JSON(http.StatusOK, &model.Result{Success: oasis_err2.SUCCESS, Message: oasis_err2.GetMsg(oasis_err2.SUCCESS), Data: list})
}

// @Summary 分享该应用配置
// @Produce application/json
// @Accept application/json
// @Tags app
// @Security ApiKeyAuth
// @Success 200 {string} string "ok"
// @Router /app/share [post]
func ShareAppFile(c *gin.Context) {
str, _ := ioutil.ReadAll(c.Request.Body)
content := service.MyService.OAPI().ShareAppFile(str)
c.JSON(http.StatusOK, json.RawMessage(content))
}
15 changes: 14 additions & 1 deletion route/v1/sync.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
package v1

import (
"net/http"
"net/http/httputil"
"net/url"
"strings"

"github.com/IceWhaleTech/CasaOS/model"
"github.com/IceWhaleTech/CasaOS/pkg/config"
"github.com/IceWhaleTech/CasaOS/pkg/utils/oasis_err"
"github.com/gin-gonic/gin"
)

func SyncToSyncthing(c *gin.Context) {
u := c.Param("url")
target := "http://127.0.0.1:" + config.SystemConfigInfo.SyncPort
target := "http://" + strings.Split(c.Request.Host, ":")[0] + ":" + config.SystemConfigInfo.SyncPort
remote, err := url.Parse(target)
if err != nil {
return
}
proxy := httputil.NewSingleHostReverseProxy(remote)
c.Request.Header.Add("X-API-Key", config.SystemConfigInfo.SyncKey)
//c.Request.Header.Add("X-API-Key", config.SystemConfigInfo.SyncKey)
c.Request.URL.Path = u

proxy.ServeHTTP(c.Writer, c.Request)
}

func GetSyncConfig(c *gin.Context) {
data := make(map[string]string)
data["key"] = config.SystemConfigInfo.SyncKey
data["port"] = config.SystemConfigInfo.SyncPort
c.JSON(http.StatusOK, model.Result{Success: oasis_err.SUCCESS, Message: oasis_err.GetMsg(oasis_err.SUCCESS), Data: data})
}
10 changes: 10 additions & 0 deletions service/casa.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,21 @@ type CasaService interface {
GetServerCategoryList() []model.ServerCategoryList
GetTaskList(size int) []model2.TaskDBModel
GetServerAppInfo(id string) model.ServerAppList
ShareAppFile(body []byte) string
}

type casaService struct {
}

func (o *casaService) ShareAppFile(body []byte) string {
head := make(map[string]string)

head["Authorization"] = GetToken()

content := httper2.Post(config.ServerInfo.ServerApi+"/v1/community/add", body, "application/json", head)
return content
}

func (o *casaService) GetTaskList(size int) []model2.TaskDBModel {
head := make(map[string]string)

Expand Down
4 changes: 2 additions & 2 deletions types/system.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package types

const CURRENTVERSION = "0.1.11"
const BODY = "<li>Resolve application installation path errors</li><li>Mobile Adaptation</li><li>Optimize user experience</li>"
const CURRENTVERSION = "0.2.0"
const BODY = "<li>add sync function</li><li>fixed some error</li>"
Binary file added web/img/Account.1bc4a418.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 72 additions & 0 deletions web/img/Account.bde47fba.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/Android-DeviceID.b57fefc8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/Android-Menu.ed4df0da.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/Android-NewDevice.f00af2cb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/Android-NewDeviceAdd.784d2f18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/Android-NewFolder.d71dc444.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/Android-NewFolderCreate.b3521b45.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/Android-ShowDeviceID.f7e46fb8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/Windows-DeviceID.2e929f75.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/Windows-NewDevice.c9f2471d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/Windows-NewDeviceSave.fe1078b1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/Windows-NewFolder.5305cc41.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/Windows-NewFolderSave.9ce2312f.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/Windows-ShowID.1000f319.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions web/img/android.48a6cf16.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed web/img/bg.afedbc0b.jpeg
Binary file not shown.
Binary file added web/img/bg3.1e0d0d23.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/macOS-Config.f419628a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/macOS-DeviceID.968cc84d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/macOS-NewFolder.fa9e37d0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/macOS-NewFolderSave.6f3f247d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/macOS-ShowID.c822acc3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/macOS-icon.ae9e0906.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
159 changes: 159 additions & 0 deletions web/img/macos.da8469ce.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/smart_icon.7cc8510a.png
Binary file added web/img/sync_icon.ae659b01.png
Loading

0 comments on commit 796c25b

Please sign in to comment.