mirror of
https://github.com/Macrame-App/Macrame
synced 2025-12-29 07:19:26 +00:00
Update to UIX.
This commit is contained in:
parent
d373237127
commit
c9850dcbf8
10 changed files with 38 additions and 16 deletions
|
|
@ -9,7 +9,8 @@
|
||||||
href="https://fonts.bunny.net/css?family=fira-code:300,500,700|roboto:100,300,700"
|
href="https://fonts.bunny.net/css?family=fira-code:300,500,700|roboto:100,300,700"
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
/>
|
/>
|
||||||
<title>Vite + Vue</title>
|
<title>Macrame</title>
|
||||||
|
<script src="config.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
|
|
||||||
|
|
@ -23,24 +23,32 @@ import { RouterView, useRoute } from 'vue-router'
|
||||||
import { useDeviceStore } from './stores/device'
|
import { useDeviceStore } from './stores/device'
|
||||||
import { isLocal } from './services/ApiService'
|
import { isLocal } from './services/ApiService'
|
||||||
import AlertComp from './components/base/AlertComp.vue'
|
import AlertComp from './components/base/AlertComp.vue'
|
||||||
|
import { ConfigGet } from './services/ConfigService'
|
||||||
|
|
||||||
const device = useDeviceStore()
|
const device = useDeviceStore()
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const handshake = ref(false)
|
const handshake = ref(false)
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(() => {
|
||||||
|
// const port = await ConfigGet('MCRM__PORT')
|
||||||
|
// console.log(port)
|
||||||
|
|
||||||
// Setting device uuid from localstorage
|
// Setting device uuid from localstorage
|
||||||
// If not present in LocalStorage a new uuidV4 will be generated
|
// If not present in LocalStorage a new uuidV4 will be generated
|
||||||
device.uuid()
|
device.uuid()
|
||||||
|
|
||||||
const hsReq = await device.remoteHandshake()
|
// appHandshake()
|
||||||
handshake.value = hsReq
|
|
||||||
|
|
||||||
device.$subscribe(() => {
|
device.$subscribe(() => {
|
||||||
if (device.key()) handshake.value = true
|
if (device.key()) handshake.value = true
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
async function appHandshake() {
|
||||||
|
const hsReq = await device.remoteHandshake()
|
||||||
|
handshake.value = hsReq
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ const linkPinInput = ref()
|
||||||
|
|
||||||
const server = reactive({
|
const server = reactive({
|
||||||
host: '',
|
host: '',
|
||||||
port: import.meta.env.VITE_MCRM__PORT,
|
port: window.__CONFIG__.MCRM__PORT,
|
||||||
status: false,
|
status: false,
|
||||||
link: false,
|
link: false,
|
||||||
inputPin: '',
|
inputPin: '',
|
||||||
|
|
@ -172,6 +172,7 @@ function pingLink() {
|
||||||
|
|
||||||
async function decryptKey() {
|
async function decryptKey() {
|
||||||
const decryptedKey = decryptAES(server.inputPin, server.encryptedKey)
|
const decryptedKey = decryptAES(server.inputPin, server.encryptedKey)
|
||||||
|
|
||||||
const handshake = await device.remoteHandshake(decryptedKey)
|
const handshake = await device.remoteHandshake(decryptedKey)
|
||||||
|
|
||||||
if (handshake) {
|
if (handshake) {
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ onMounted(async () => {
|
||||||
const serverIP = await device.serverGetIP()
|
const serverIP = await device.serverGetIP()
|
||||||
server.ip = serverIP
|
server.ip = serverIP
|
||||||
|
|
||||||
server.port = import.meta.env.VITE_MCRM__PORT
|
server.port = window.__CONFIG__.MCRM__PORT
|
||||||
})
|
})
|
||||||
|
|
||||||
async function startLink(deviceUuid) {
|
async function startLink(deviceUuid) {
|
||||||
|
|
@ -184,7 +184,9 @@ function resetPinLink() {
|
||||||
|
|
||||||
function unlinkDevice(id) {
|
function unlinkDevice(id) {
|
||||||
axios.post(appUrl() + '/device/link/remove', { uuid: id }).then((data) => {
|
axios.post(appUrl() + '/device/link/remove', { uuid: id }).then((data) => {
|
||||||
if (data.data) device.serverGetRemotes()
|
if (data.data) {
|
||||||
|
device.serverGetRemotes()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { useDeviceStore } from '@/stores/device'
|
||||||
import CryptoJS from 'crypto-js'
|
import CryptoJS from 'crypto-js'
|
||||||
|
|
||||||
export const appUrl = () => {
|
export const appUrl = () => {
|
||||||
const port = window.location.port == 5173 ? import.meta.env.VITE_MCRM__PORT : window.location.port
|
const port = window.location.port == 5173 ? window.__CONFIG__.MCRM__PORT : window.location.port
|
||||||
|
|
||||||
return `http://${window.location.hostname}:${port}`
|
return `http://${window.location.hostname}:${port}`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
12
fe/src/services/ConfigService.js
Normal file
12
fe/src/services/ConfigService.js
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
import axios from 'axios'
|
||||||
|
import { appUrl } from './ApiService'
|
||||||
|
|
||||||
|
export const ConfigGet = async (key) => {
|
||||||
|
console.log(window.__CONFIG__)
|
||||||
|
|
||||||
|
const config = await axios.get(appUrl() + '/config.json')
|
||||||
|
|
||||||
|
if (!config.data) return false
|
||||||
|
|
||||||
|
return config.data[key]
|
||||||
|
}
|
||||||
|
|
@ -5,7 +5,7 @@ import { isLocal } from './ApiService'
|
||||||
export const encryptAES = (key, str) => {
|
export const encryptAES = (key, str) => {
|
||||||
key = keyPad(key)
|
key = keyPad(key)
|
||||||
|
|
||||||
let iv = enc.Utf8.parse(import.meta.env.VITE_MCRM__IV)
|
let iv = enc.Utf8.parse(window.__CONFIG__.MCRM__IV)
|
||||||
let encrypted = AES.encrypt(str, key, {
|
let encrypted = AES.encrypt(str, key, {
|
||||||
iv: iv,
|
iv: iv,
|
||||||
padding: pad.Pkcs7,
|
padding: pad.Pkcs7,
|
||||||
|
|
@ -16,7 +16,7 @@ export const encryptAES = (key, str) => {
|
||||||
export const decryptAES = (key, str) => {
|
export const decryptAES = (key, str) => {
|
||||||
key = keyPad(key)
|
key = keyPad(key)
|
||||||
|
|
||||||
let iv = enc.Utf8.parse(import.meta.env.VITE_MCRM__IV)
|
let iv = enc.Utf8.parse(window.__CONFIG__.MCRM__IV)
|
||||||
let encrypted = AES.decrypt(str.toString(), key, {
|
let encrypted = AES.decrypt(str.toString(), key, {
|
||||||
iv: iv,
|
iv: iv,
|
||||||
padding: pad.Pkcs7,
|
padding: pad.Pkcs7,
|
||||||
|
|
@ -39,7 +39,7 @@ function keyPad(key) {
|
||||||
let returnKey = key
|
let returnKey = key
|
||||||
|
|
||||||
if (key.length == 4) {
|
if (key.length == 4) {
|
||||||
returnKey = key + import.meta.env.VITE_MCRM__SALT
|
returnKey = key + window.__CONFIG__.MCRM__SALT
|
||||||
}
|
}
|
||||||
|
|
||||||
return enc.Utf8.parse(returnKey)
|
return enc.Utf8.parse(returnKey)
|
||||||
|
|
|
||||||
|
|
@ -85,8 +85,6 @@ export const useDeviceStore = defineStore('device', () => {
|
||||||
return request
|
return request
|
||||||
}
|
}
|
||||||
const remotePingLink = async (cb) => {
|
const remotePingLink = async (cb) => {
|
||||||
// const linkRequest = await axios.post(appUrl() + '/device/link/ping', { uuid: deviceUuid })
|
|
||||||
// if (linkRequest.data)
|
|
||||||
const pingInterval = setInterval(() => {
|
const pingInterval = setInterval(() => {
|
||||||
axios.post(appUrl() + '/device/link/ping', { uuid: uuid() }).then((data) => {
|
axios.post(appUrl() + '/device/link/ping', { uuid: uuid() }).then((data) => {
|
||||||
if (data.data) {
|
if (data.data) {
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ export const usePanelStore = defineStore('panel', () => {
|
||||||
|
|
||||||
const get = async (dir) => {
|
const get = async (dir) => {
|
||||||
const data = AuthCall({ dir: dir })
|
const data = AuthCall({ dir: dir })
|
||||||
// alert(JSON.stringify(data))
|
|
||||||
const resp = await axios.post(appUrl() + '/panel/get', data)
|
const resp = await axios.post(appUrl() + '/panel/get', data)
|
||||||
|
|
||||||
if (!resp.data && !current.value.html) return false
|
if (!resp.data && !current.value.html) return false
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@
|
||||||
{{ isLocal() ? 'Remote devices' : 'Server' }}
|
{{ isLocal() ? 'Remote devices' : 'Server' }}
|
||||||
</h1>
|
</h1>
|
||||||
<div class="grid gap-8 pr-2 panel__content">
|
<div class="grid gap-8 pr-2 panel__content">
|
||||||
<ServerView />
|
<ServerView v-if="isLocal()" />
|
||||||
<RemoteView />
|
<RemoteView v-else />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue