From 4d1ca8ffaf9ddee851f754d414802ad556db8124 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=8F=E4=B8=9C=E4=BA=AE?= Date: Thu, 23 Jul 2026 17:31:42 +0800 Subject: [PATCH] add backend dir --- app.go => backend/app.go | 8 ++---- types.go => backend/types.go | 2 +- frontend/src/components/Navbar.tsx | 2 +- frontend/wailsjs/go/backend/App.d.ts | 18 ++++++++++++ frontend/wailsjs/go/backend/App.js | 31 ++++++++++++++++++++ frontend/wailsjs/go/main/App.d.ts | 20 ------------- frontend/wailsjs/go/main/App.js | 35 ----------------------- frontend/wailsjs/go/models.ts | 42 ++++++++++++++-------------- go.mod | 2 +- main.go | 7 +++-- 10 files changed, 79 insertions(+), 88 deletions(-) rename app.go => backend/app.go (96%) rename types.go => backend/types.go (98%) create mode 100644 frontend/wailsjs/go/backend/App.d.ts create mode 100644 frontend/wailsjs/go/backend/App.js delete mode 100644 frontend/wailsjs/go/main/App.d.ts delete mode 100644 frontend/wailsjs/go/main/App.js diff --git a/app.go b/backend/app.go similarity index 96% rename from app.go rename to backend/app.go index 5fc5119..af77d9c 100644 --- a/app.go +++ b/backend/app.go @@ -1,4 +1,4 @@ -package main +package backend import ( "context" @@ -20,14 +20,10 @@ func NewApp() *App { return &App{} } -func (a *App) startup(ctx context.Context) { +func (a *App) Startup(ctx context.Context) { a.ctx = ctx } -func (a *App) Greet(name string) string { - return fmt.Sprintf("Hello %s, It's show time!", name) -} - func (a *App) GormDB() (*gorm.DB, error) { db, err := gorm.Open(sqlite.Open("app.db"), &gorm.Config{}) if err != nil { diff --git a/types.go b/backend/types.go similarity index 98% rename from types.go rename to backend/types.go index bea5971..fefbcf8 100644 --- a/types.go +++ b/backend/types.go @@ -1,4 +1,4 @@ -package main +package backend import ( "context" diff --git a/frontend/src/components/Navbar.tsx b/frontend/src/components/Navbar.tsx index 3fafcfb..508fbfc 100644 --- a/frontend/src/components/Navbar.tsx +++ b/frontend/src/components/Navbar.tsx @@ -1,7 +1,7 @@ const Navbar = () => { const svgPath = "M12 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-4.5 4c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm9 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-9.5 3.5c-1.38 0-2.5 1.12-2.5 2.5s1.12 2.5 2.5 2.5 2.5-1.12 2.5-2.5-1.12-2.5-2.5-2.5zm11 0c-1.38 0-2.5 1.12-2.5 2.5s1.12 2.5 2.5 2.5 2.5-1.12 2.5-2.5-1.12-2.5-2.5-2.5zM12 18c-2.21 0-4 1.79-4 4h8c0-2.21-1.79-4-4-4z" - const handleClick = () => window.open('https://git.leonstack.com/owner/Collage-Images', '_blank') + const handleClick = () => window.open('https://git.leonstack.com/owner/SortMeow', '_blank') const handleNavColor = (e: Event) => { const current = e.currentTarget as HTMLElement diff --git a/frontend/wailsjs/go/backend/App.d.ts b/frontend/wailsjs/go/backend/App.d.ts new file mode 100644 index 0000000..2479777 --- /dev/null +++ b/frontend/wailsjs/go/backend/App.d.ts @@ -0,0 +1,18 @@ +// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL +// This file is automatically generated. DO NOT EDIT +import {backend} from '../models'; +import {gorm} from '../models'; + +export function ClearHistory():Promise; + +export function DeleteOneHistory(arg1:number):Promise; + +export function Detect(arg1:string):Promise; + +export function GetHistory(arg1:number,arg2:number):Promise; + +export function GetImage(arg1:string):Promise; + +export function GormDB():Promise; + +export function UploadImage(arg1:Array,arg2:string):Promise; diff --git a/frontend/wailsjs/go/backend/App.js b/frontend/wailsjs/go/backend/App.js new file mode 100644 index 0000000..1c4e437 --- /dev/null +++ b/frontend/wailsjs/go/backend/App.js @@ -0,0 +1,31 @@ +// @ts-check +// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL +// This file is automatically generated. DO NOT EDIT + +export function ClearHistory() { + return window['go']['backend']['App']['ClearHistory'](); +} + +export function DeleteOneHistory(arg1) { + return window['go']['backend']['App']['DeleteOneHistory'](arg1); +} + +export function Detect(arg1) { + return window['go']['backend']['App']['Detect'](arg1); +} + +export function GetHistory(arg1, arg2) { + return window['go']['backend']['App']['GetHistory'](arg1, arg2); +} + +export function GetImage(arg1) { + return window['go']['backend']['App']['GetImage'](arg1); +} + +export function GormDB() { + return window['go']['backend']['App']['GormDB'](); +} + +export function UploadImage(arg1, arg2) { + return window['go']['backend']['App']['UploadImage'](arg1, arg2); +} diff --git a/frontend/wailsjs/go/main/App.d.ts b/frontend/wailsjs/go/main/App.d.ts deleted file mode 100644 index 22e9028..0000000 --- a/frontend/wailsjs/go/main/App.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL -// This file is automatically generated. DO NOT EDIT -import {main} from '../models'; -import {gorm} from '../models'; - -export function ClearHistory():Promise; - -export function DeleteOneHistory(arg1:number):Promise; - -export function Detect(arg1:string):Promise; - -export function GetHistory(arg1:number,arg2:number):Promise; - -export function GetImage(arg1:string):Promise; - -export function GormDB():Promise; - -export function Greet(arg1:string):Promise; - -export function UploadImage(arg1:Array,arg2:string):Promise; diff --git a/frontend/wailsjs/go/main/App.js b/frontend/wailsjs/go/main/App.js deleted file mode 100644 index 398a6ba..0000000 --- a/frontend/wailsjs/go/main/App.js +++ /dev/null @@ -1,35 +0,0 @@ -// @ts-check -// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL -// This file is automatically generated. DO NOT EDIT - -export function ClearHistory() { - return window['go']['main']['App']['ClearHistory'](); -} - -export function DeleteOneHistory(arg1) { - return window['go']['main']['App']['DeleteOneHistory'](arg1); -} - -export function Detect(arg1) { - return window['go']['main']['App']['Detect'](arg1); -} - -export function GetHistory(arg1, arg2) { - return window['go']['main']['App']['GetHistory'](arg1, arg2); -} - -export function GetImage(arg1) { - return window['go']['main']['App']['GetImage'](arg1); -} - -export function GormDB() { - return window['go']['main']['App']['GormDB'](); -} - -export function Greet(arg1) { - return window['go']['main']['App']['Greet'](arg1); -} - -export function UploadImage(arg1, arg2) { - return window['go']['main']['App']['UploadImage'](arg1, arg2); -} diff --git a/frontend/wailsjs/go/models.ts b/frontend/wailsjs/go/models.ts index 6c63e7a..58bd183 100644 --- a/frontend/wailsjs/go/models.ts +++ b/frontend/wailsjs/go/models.ts @@ -1,3 +1,24 @@ +export namespace backend { + + export class Response { + code: number; + message: string; + data?: any; + + static createFrom(source: any = {}) { + return new Response(source); + } + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.code = source["code"]; + this.message = source["message"]; + this.data = source["data"]; + } + } + +} + export namespace clause { export class Clause { @@ -327,27 +348,6 @@ export namespace gorm { -} - -export namespace main { - - export class Response { - code: number; - message: string; - data?: any; - - static createFrom(source: any = {}) { - return new Response(source); - } - - constructor(source: any = {}) { - if ('string' === typeof source) source = JSON.parse(source); - this.code = source["code"]; - this.message = source["message"]; - this.data = source["data"]; - } - } - } export namespace reflect { diff --git a/go.mod b/go.mod index a5a0134..b1fc58f 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module dissertation +module sortmeow go 1.25.0 diff --git a/main.go b/main.go index ba21798..26f5db9 100644 --- a/main.go +++ b/main.go @@ -6,14 +6,15 @@ import ( "github.com/wailsapp/wails/v2" "github.com/wailsapp/wails/v2/pkg/options" "github.com/wailsapp/wails/v2/pkg/options/assetserver" + + "sortmeow/backend" ) -//go:embed all:frontend/dist var assets embed.FS func main() { // Create an instance of the app structure - app := NewApp() + app := backend.NewApp() // Create application with options err := wails.Run(&options.App{ @@ -25,7 +26,7 @@ func main() { Assets: assets, }, BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1}, - OnStartup: app.startup, + OnStartup: app.Startup, Bind: []interface{}{ app, },