Создание шифрованного API

This commit is contained in:
2024-06-25 13:11:51 +07:00
parent 4345ddc645
commit 26d973a1a7
14 changed files with 776 additions and 66 deletions
+35
View File
@@ -0,0 +1,35 @@
<script setup>
</script>
<template>
<div id="create-task-modal" tabindex="-1" aria-hidden="true" class="absolute left-[50%] translate-x-[-50%] overflow-y-auto overflow-x-hidden w-50 top-20 lg:top-32 z-50">
<div class="relative p-4 max-h-full">
<!-- Modal content -->
<div class="relative bg-white rounded-lg shadow dark:bg-[rgb(50,50,50)]">
<!-- Modal header -->
<div class="flex items-center justify-between px-5 py-2 md:py-3 border-b rounded-t">
<h3 class="text-xl font-semibold text-gray-700 dark:text-gray-100 mr-2">
Вы уверены?
</h3>
<button type="button" @click="$emit('close')" class="transition-colors text-gray-400 dark:text-gray-300 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 ms-auto inline-flex justify-center items-center" data-modal-hide="default-modal">
<svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
</svg>
</button>
</div>
<!-- Modal body
<div class="p-4 md:p-5 space-y-4"></div>
Modal footer -->
<div class="flex items-center py-3 px-5 md:p-3 border-t border-gray-200 rounded-b">
<button @click="$emit('yes')" class="text-white bg-red-500 hover:bg-red-600 transition-colors font-medium rounded-lg text-sm px-5 py-2.5 text-center">Да</button>
<button @click="$emit('close')" class="ml-2 bg-zinc-200 hover:bg-zinc-300 text-black transition-colors font-medium rounded-lg text-sm px-5 py-2.5 text-center">Нет</button>
</div>
</div>
</div>
</div>
</template>
<style scoped>
</style>
+81
View File
@@ -0,0 +1,81 @@
<script setup>
import {ref} from "vue";
import {invoke} from "@tauri-apps/api";
const props = defineProps({
port: Number,
autostart: Boolean
})
const emit = defineEmits(['close'])
let port = ref(props.port);
let autostart = ref(props.autostart);
let error = ref(" ");
async function save_settings(){
if (port.value < 1 || port.value > 65536){
error.value = "Номер порта не может быть меньше 1 или больше 65536"
} else {
await invoke('edit_settings', {
port: port.value,
autostart: autostart.value
}).then(() => {
emit('close');
})
}
}
</script>
<template>
<div id="create-task-modal" tabindex="-1" aria-hidden="true" class="px-[5vw] md:px-[10vw] lg:px-[15vw] absolute overflow-y-auto overflow-x-hidden w-full top-20 lg:top-24 z-50">
<div class="relative p-4 max-h-full">
<!-- Modal content -->
<form class="relative bg-white rounded-lg shadow dark:bg-[rgb(50,50,50)]" @submit.prevent="save_settings">
<!-- Modal header -->
<div class="flex items-center justify-between px-5 py-2 md:py-3 border-b rounded-t">
<h3 class="text-xl font-semibold text-gray-700 dark:text-gray-100">
Настройки
</h3>
<button type="button" @click="$emit('close')" class="transition-colors text-gray-400 dark:text-gray-300 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 ms-auto inline-flex justify-center items-center" data-modal-hide="default-modal">
<svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
</svg>
</button>
</div>
<!-- Modal body -->
<div class="px-4 md:px-5 pt-4">
<div>
<div>
<label id="autostart" class="items-center me-5 cursor-pointer">
<p class="text-sm font-medium text-gray-900 dark:text-gray-200 mb-0.5">Запуск при старте</p>
<input v-model="autostart" type="checkbox" value="" class="sr-only peer">
<div class="relative w-11 h-6 bg-gray-200 rounded-full peer dark:bg-gray-700
peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full
peer-checked:after:border-white after:content-[''] after:absolute after:top-0.5 after:start-[2px]
after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5
after:transition-all dark:border-gray-600 peer-checked:bg-green-600"/>
</label>
<div class="flex items-center justify-between">
<label for="port" class="block text-sm font-medium leading-6 text-gray-900 dark:text-gray-200">Порт</label>
</div>
<div class="mb-3">
<input @input="error = ' '" v-model="port" type="number" id="port" name="port" placeholder="1-65536" class="px-2 py-1.5 block w-48 rounded-md border-0 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-inset sm:text-sm sm:leading-6" />
</div>
</div>
</div>
</div>
<!-- Modal footer -->
<div class="flex items-center py-1 px-5 md:p-3 border-t border-gray-200 rounded-b">
<input type="submit" class="text-white bg-green-500 hover:bg-green-600 transition-colors font-medium rounded-lg text-sm px-5 py-2.5 text-center" value="Сохранить">
<p class="ml-3 text-red-500">{{error}}</p>
</div>
</form>
</div>
</div>
</template>
<style scoped>
</style>