88 lines
2.3 KiB
Vue
88 lines
2.3 KiB
Vue
|
<script setup>
|
||
|
import {Greet} from 'frontend/wailsjs/go/main/App';
|
||
|
import {reactive} from "vue";
|
||
|
import {useWebNotification} from '@vueuse/core'
|
||
|
import {GetAllEnv} from "frontend/wailsjs/go/env/Env";
|
||
|
import {hideDebugger, showDebugger} from "src/utils/debugger/eruda";
|
||
|
|
||
|
const controller = reactive({
|
||
|
input: ""
|
||
|
})
|
||
|
|
||
|
function greet() {
|
||
|
let resultElement = document.getElementById("result");
|
||
|
|
||
|
// Get name
|
||
|
let name = controller.input
|
||
|
|
||
|
// Check if the input is empty
|
||
|
if (name === "") return;
|
||
|
|
||
|
// Call App.Greet(name)
|
||
|
try {
|
||
|
Greet(name)
|
||
|
.then((result) => {
|
||
|
// Update result with data back from App.Greet()
|
||
|
resultElement.innerText = result;
|
||
|
})
|
||
|
.catch((err) => {
|
||
|
console.error(err);
|
||
|
});
|
||
|
} catch (err) {
|
||
|
console.error(err);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function sendNotify() {
|
||
|
Greet(controller.input)
|
||
|
.then((result) => {
|
||
|
/**
|
||
|
*
|
||
|
* @type {UseWebNotificationOptions}
|
||
|
*/
|
||
|
const options = {
|
||
|
title: '通知测试',
|
||
|
dir: 'auto',
|
||
|
body: result,
|
||
|
lang: 'zh-CN',
|
||
|
renotify: true,
|
||
|
tag: 'notify',
|
||
|
};
|
||
|
|
||
|
const notification = useWebNotification(options);
|
||
|
setTimeout(()=>{
|
||
|
notification.close()
|
||
|
}, 5 * 1000)
|
||
|
notification.show()
|
||
|
})
|
||
|
.catch((err) => {
|
||
|
console.error(err);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function getAllEnv(){
|
||
|
GetAllEnv().then(allEnv => {
|
||
|
console.log(allEnv)
|
||
|
})
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<template>
|
||
|
<div class="result w-full text-center" id="result">Please enter your name below 👇</div>
|
||
|
<div class="input-box w-full text-center" id="input">
|
||
|
<el-input v-model="controller.input" type="text" autocomplete="off"></el-input>
|
||
|
<el-button class="btn" @click="greet()">Greet</el-button>
|
||
|
<el-button class="btn" @click="sendNotify()">通知</el-button>
|
||
|
</div>
|
||
|
<el-button @click="getAllEnv()">获取所有环境变量</el-button>
|
||
|
|
||
|
<div>
|
||
|
<el-button @click="showDebugger()">显示 debugger</el-button>
|
||
|
<el-button @click="hideDebugger()">隐藏 debugger</el-button>
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<style scoped>
|
||
|
|
||
|
</style>
|