add local dev mode
This commit is contained in:
parent
566de4066b
commit
36475c0a9b
@ -37,9 +37,9 @@ const toggleDark = useToggle(dark);
|
||||
const theme = computed(() => dark.value ? 'dark' : 'light');
|
||||
const themeIcon = computed(() => dark.value ? 'mdi-moon-waxing-crescent' : 'mdi-white-balance-sunny');
|
||||
|
||||
const { status, data, send, open, close } = useWebSocket<string>(`wss://${window.location.host}/queue`, {
|
||||
immediate: false,
|
||||
});
|
||||
const local = window.location.hostname === 'localhost';
|
||||
|
||||
const { status, data, send, open, close } = useWebSocket<string>(`wss://${window.location.host}/queue`, {immediate: false});
|
||||
const game = ref<Game | null>(null);
|
||||
const dealer = ref<boolean | null>(null);
|
||||
watchEffect(() => {
|
||||
@ -66,11 +66,31 @@ const playing = computed(() => game.value != null);
|
||||
const loading = computed(() => status.value === 'CONNECTING' || status.value === 'OPEN' && !playing.value);
|
||||
|
||||
function clickPlay() {
|
||||
if (local) {
|
||||
data.value = JSON.stringify({
|
||||
action: "Start",
|
||||
damage: 1,
|
||||
dealer: false,
|
||||
players: [
|
||||
{hp: 4, items: ['', '', '', '', '', '', '', '']},
|
||||
{hp: 4, items: ['', '', '', '', '', '', '', '']},
|
||||
],
|
||||
previous: null,
|
||||
round: 1,
|
||||
blank: 3,
|
||||
live: 2,
|
||||
});
|
||||
return;
|
||||
}
|
||||
open();
|
||||
send('{"action":"ping"}');
|
||||
}
|
||||
|
||||
function action(evt: Action) {
|
||||
if (local && game.value != null) {
|
||||
game.value.dealer = !game.value.dealer;
|
||||
return;
|
||||
}
|
||||
if (evt.action === 'quit') {
|
||||
// Just close the connection. The server knows what to do.
|
||||
data.value = null;
|
||||
@ -85,6 +105,11 @@ function action(evt: Action) {
|
||||
const loadingMe = ref(true);
|
||||
const me = ref<string | null>(null);
|
||||
onMounted(async () => {
|
||||
if (local) {
|
||||
loadingMe.value = false;
|
||||
me.value = 'a';
|
||||
return;
|
||||
}
|
||||
loadingMe.value = true;
|
||||
try {
|
||||
const resp = await fetch('/user/me', {
|
||||
|
Loading…
Reference in New Issue
Block a user