diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml new file mode 100644 index 0000000..cc3da93 --- /dev/null +++ b/.idea/jsLibraryMappings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/wails/frontend/package.json b/app/wails/frontend/package.json index 773beea..f0f0318 100644 --- a/app/wails/frontend/package.json +++ b/app/wails/frontend/package.json @@ -17,6 +17,7 @@ "dependencies": { "@vueuse/core": "^10.2.1", "element-plus": "^2.3.7", + "eruda": "^3.0.0", "pinia": "^2.1.4", "vue": "^3.3.4", "vue-router": "^4.2.2" diff --git a/app/wails/frontend/package.json.md5 b/app/wails/frontend/package.json.md5 index 1536041..daeb509 100644 --- a/app/wails/frontend/package.json.md5 +++ b/app/wails/frontend/package.json.md5 @@ -1 +1 @@ -db4d8f94ebd4b8a52b1af9220d2d1d60 \ No newline at end of file +f642d4d4c90aca4792a079e99b5747bd \ No newline at end of file diff --git a/app/wails/frontend/src/App.vue b/app/wails/frontend/src/App.vue index b18bfa4..94dc27c 100644 --- a/app/wails/frontend/src/App.vue +++ b/app/wails/frontend/src/App.vue @@ -1,74 +1,16 @@ - - - +onMounted(()=>{ + createDebugger() +}) + +onBeforeUnmount(()=>{ + destroyDebugger() +}) + diff --git a/app/wails/frontend/src/main.js b/app/wails/frontend/src/main.js index 25777ad..c02be4a 100644 --- a/app/wails/frontend/src/main.js +++ b/app/wails/frontend/src/main.js @@ -3,8 +3,10 @@ import { createApp } from 'vue' import ElementPlus from 'element-plus' import 'element-plus/dist/index.css' import App from './App.vue' +import Router from "frontend/src/router/router"; const app = createApp(App) +app.use(Router) app.use(ElementPlus) app.mount('#app') diff --git a/app/wails/frontend/src/router/router.js b/app/wails/frontend/src/router/router.js new file mode 100644 index 0000000..158a551 --- /dev/null +++ b/app/wails/frontend/src/router/router.js @@ -0,0 +1,18 @@ +import * as VueRouter from "vue-router" + +/** + * + * @type {Readonly} + */ +const routes = [ + { + path: '/', + component: ()=>import("frontend/src/views/Home.vue"), + } +] + +const Router = VueRouter.createRouter({ + history: VueRouter.createWebHistory(), + routes +}) +export default Router diff --git a/app/wails/frontend/src/utils/debugger/eruda.js b/app/wails/frontend/src/utils/debugger/eruda.js new file mode 100644 index 0000000..87cd40a --- /dev/null +++ b/app/wails/frontend/src/utils/debugger/eruda.js @@ -0,0 +1,44 @@ +import eruda from 'eruda' +let isCreated = false + +export function showDebugger(){ + if(!isCreated){ + return + } + + eruda.show() +} + +export function hideDebugger(){ + if(!isCreated){ + return + } + + eruda.hide() +} + +export function createDebugger(){ + if(!isCreated){ + isCreated = true + eruda.init({ + useShadowDom: true, + autoScale: true, + defaults: { + displaySize: 50, + transparency: 1, + theme: 'Atom One Light' + } + }) + } else { + eruda.show() + } +} + +export function destroyDebugger(){ + if(!isCreated){ + return + } + + eruda.destroy() + isCreated = false +} diff --git a/app/wails/frontend/src/views/Home.vue b/app/wails/frontend/src/views/Home.vue new file mode 100644 index 0000000..0bca6ab --- /dev/null +++ b/app/wails/frontend/src/views/Home.vue @@ -0,0 +1,88 @@ + + + + + diff --git a/app/wails/frontend/tsconfig.json b/app/wails/frontend/tsconfig.json new file mode 100644 index 0000000..2726733 --- /dev/null +++ b/app/wails/frontend/tsconfig.json @@ -0,0 +1,34 @@ +{ + "compilerOptions": { + "target": "ESNext", + "useDefineForClassFields": true, + "module": "ESNext", + "moduleResolution": "Node", + "strict": true, + "jsx": "preserve", + "sourceMap": true, + "resolveJsonModule": true, + "isolatedModules": false, + "esModuleInterop": true, + "lib": [ + "ESNext", + "DOM" + ], + "baseUrl": ".", + "paths": { + "frontend/*": ["*"], + "src/*": ["src/*"], + } + }, + "include": [ + "src/**/*.ts", + "src/**/*.d.ts", + "src/**/*.tsx", + "src/**/*.vue" + ], + "references": [ + { + "path": "./tsconfig.node.json" + } + ] +} diff --git a/app/wails/frontend/tsconfig.node.json b/app/wails/frontend/tsconfig.node.json new file mode 100644 index 0000000..e16b968 --- /dev/null +++ b/app/wails/frontend/tsconfig.node.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "composite": true, + "module": "ESNext", + "moduleResolution": "Node", + "allowSyntheticDefaultImports": true + }, + "include": [ + "wails-plugin.ts", + "vite.config.ts" + ] +} diff --git a/app/wails/frontend/vite.config.js b/app/wails/frontend/vite.config.js index 37d511e..c0a8f8e 100644 --- a/app/wails/frontend/vite.config.js +++ b/app/wails/frontend/vite.config.js @@ -1,8 +1,15 @@ import {defineConfig} from "vite"; import vuePlugin from "@vitejs/plugin-vue"; +import path from "path" export default defineConfig({ plugins: [ vuePlugin() - ] + ], + resolve: { + alias: { + "frontend": path.resolve(__dirname, "./"), + "src": path.resolve(__dirname, "./src") + } + } }) diff --git a/app/wails/frontend/wailsjs/go/env/Env.d.ts b/app/wails/frontend/wailsjs/go/env/Env.d.ts new file mode 100644 index 0000000..6678d68 --- /dev/null +++ b/app/wails/frontend/wailsjs/go/env/Env.d.ts @@ -0,0 +1,4 @@ +// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL +// This file is automatically generated. DO NOT EDIT + +export function GetAllEnv():Promise<{[key: string]: string}>; diff --git a/app/wails/frontend/wailsjs/go/env/Env.js b/app/wails/frontend/wailsjs/go/env/Env.js new file mode 100644 index 0000000..02082fb --- /dev/null +++ b/app/wails/frontend/wailsjs/go/env/Env.js @@ -0,0 +1,7 @@ +// @ts-check +// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL +// This file is automatically generated. DO NOT EDIT + +export function GetAllEnv() { + return window['go']['env']['Env']['GetAllEnv'](); +} diff --git a/app/wails/frontend/yarn.lock b/app/wails/frontend/yarn.lock index 0dab064..0576dfb 100644 --- a/app/wails/frontend/yarn.lock +++ b/app/wails/frontend/yarn.lock @@ -529,6 +529,11 @@ element-plus@^2.3.7: memoize-one "^6.0.0" normalize-wheel-es "^1.2.0" +eruda@^3.0.0: + version "3.0.0" + resolved "https://registry.npmmirror.com/eruda/-/eruda-3.0.0.tgz#d54b2c9c727f1604796a82c4b62975d1e9988ef1" + integrity sha512-6L8A8aBHOQv0rqeBlNdJEl/hl6OAdLVRtJlVmBIlIJ6Fe1a92HFXO58jHLC0vFyuKV0deTjYjRaWwLo9lJ9K9A== + esbuild@^0.17.5: version "0.17.19" resolved "https://registry.npmmirror.com/esbuild/-/esbuild-0.17.19.tgz#087a727e98299f0462a3d0bcdd9cd7ff100bd955" diff --git a/app/wails/lib/env/env.go b/app/wails/lib/env/env.go new file mode 100644 index 0000000..526f689 --- /dev/null +++ b/app/wails/lib/env/env.go @@ -0,0 +1,25 @@ +package env + +import ( + "os" + "strings" +) + +type Env struct { +} + +func (e *Env) GetAllEnv() map[string]string { + m := make(map[string]string, 0) + + for _, e := range os.Environ() { + envs := strings.SplitN(e, "=", 2) + + if len(envs) != 2 { + m[envs[0]] = "" + } else { + m[envs[0]] = envs[1] + } + } + + return m +} diff --git a/app/wails/lib/general_test.go b/app/wails/lib/general_test.go index f05ac11..1605248 100644 --- a/app/wails/lib/general_test.go +++ b/app/wails/lib/general_test.go @@ -4,6 +4,7 @@ import ( "bytes" "fmt" "github.com/gen2brain/beeep" + "os" "os/exec" "strings" "testing" @@ -39,3 +40,20 @@ func TestBeeepNotify(t *testing.T) { time.Sleep(1 * time.Second) } + +func TestEnv(t *testing.T) { + for _, e := range os.Environ() { + parts := strings.SplitN(e, "=", 2) + + if len(parts) != 2 { + continue + } else { + println(parts[0], parts[1]) + } + } +} + +func TestJavaEnv(t *testing.T) { + fmt.Println(os.Getenv("java_home")) + fmt.Println(os.Getenv("JAVA_HOME")) +} diff --git a/app/wails/main.go b/app/wails/main.go index fb3e3cd..337d7f3 100644 --- a/app/wails/main.go +++ b/app/wails/main.go @@ -1,6 +1,7 @@ package main import ( + "changeme/lib/env" "embed" "github.com/wailsapp/wails/v2" @@ -27,6 +28,7 @@ func main() { OnStartup: app.startup, Bind: []interface{}{ app, + &env.Env{}, }, Debug: options.Debug{ OpenInspectorOnStartup: true,