add backend dir

This commit is contained in:
2026-07-23 17:31:42 +08:00
parent bc269f91eb
commit 4d1ca8ffaf
10 changed files with 79 additions and 88 deletions
+2 -6
View File
@@ -1,4 +1,4 @@
package main package backend
import ( import (
"context" "context"
@@ -20,14 +20,10 @@ func NewApp() *App {
return &App{} return &App{}
} }
func (a *App) startup(ctx context.Context) { func (a *App) Startup(ctx context.Context) {
a.ctx = ctx 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) { func (a *App) GormDB() (*gorm.DB, error) {
db, err := gorm.Open(sqlite.Open("app.db"), &gorm.Config{}) db, err := gorm.Open(sqlite.Open("app.db"), &gorm.Config{})
if err != nil { if err != nil {
+1 -1
View File
@@ -1,4 +1,4 @@
package main package backend
import ( import (
"context" "context"
+1 -1
View File
@@ -1,7 +1,7 @@
const Navbar = () => { 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 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 handleNavColor = (e: Event) => {
const current = e.currentTarget as HTMLElement const current = e.currentTarget as HTMLElement
+18
View File
@@ -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<backend.Response>;
export function DeleteOneHistory(arg1:number):Promise<backend.Response>;
export function Detect(arg1:string):Promise<backend.Response>;
export function GetHistory(arg1:number,arg2:number):Promise<backend.Response>;
export function GetImage(arg1:string):Promise<backend.Response>;
export function GormDB():Promise<gorm.DB>;
export function UploadImage(arg1:Array<number>,arg2:string):Promise<backend.Response>;
+31
View File
@@ -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);
}
-20
View File
@@ -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<main.Response>;
export function DeleteOneHistory(arg1:number):Promise<main.Response>;
export function Detect(arg1:string):Promise<main.Response>;
export function GetHistory(arg1:number,arg2:number):Promise<main.Response>;
export function GetImage(arg1:string):Promise<main.Response>;
export function GormDB():Promise<gorm.DB>;
export function Greet(arg1:string):Promise<string>;
export function UploadImage(arg1:Array<number>,arg2:string):Promise<main.Response>;
-35
View File
@@ -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);
}
+21 -21
View File
@@ -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 namespace clause {
export class 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 { export namespace reflect {
+1 -1
View File
@@ -1,4 +1,4 @@
module dissertation module sortmeow
go 1.25.0 go 1.25.0
+4 -3
View File
@@ -6,14 +6,15 @@ import (
"github.com/wailsapp/wails/v2" "github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/options" "github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver" "github.com/wailsapp/wails/v2/pkg/options/assetserver"
"sortmeow/backend"
) )
//go:embed all:frontend/dist
var assets embed.FS var assets embed.FS
func main() { func main() {
// Create an instance of the app structure // Create an instance of the app structure
app := NewApp() app := backend.NewApp()
// Create application with options // Create application with options
err := wails.Run(&options.App{ err := wails.Run(&options.App{
@@ -25,7 +26,7 @@ func main() {
Assets: assets, Assets: assets,
}, },
BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1}, BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1},
OnStartup: app.startup, OnStartup: app.Startup,
Bind: []interface{}{ Bind: []interface{}{
app, app,
}, },