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 theme = computed(() => dark.value ? 'dark' : 'light');
|
||||||
const themeIcon = computed(() => dark.value ? 'mdi-moon-waxing-crescent' : 'mdi-white-balance-sunny');
|
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`, {
|
const local = window.location.hostname === 'localhost';
|
||||||
immediate: false,
|
|
||||||
});
|
const { status, data, send, open, close } = useWebSocket<string>(`wss://${window.location.host}/queue`, {immediate: false});
|
||||||
const game = ref<Game | null>(null);
|
const game = ref<Game | null>(null);
|
||||||
const dealer = ref<boolean | null>(null);
|
const dealer = ref<boolean | null>(null);
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
@ -66,11 +66,31 @@ const playing = computed(() => game.value != null);
|
|||||||
const loading = computed(() => status.value === 'CONNECTING' || status.value === 'OPEN' && !playing.value);
|
const loading = computed(() => status.value === 'CONNECTING' || status.value === 'OPEN' && !playing.value);
|
||||||
|
|
||||||
function clickPlay() {
|
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();
|
open();
|
||||||
send('{"action":"ping"}');
|
send('{"action":"ping"}');
|
||||||
}
|
}
|
||||||
|
|
||||||
function action(evt: Action) {
|
function action(evt: Action) {
|
||||||
|
if (local && game.value != null) {
|
||||||
|
game.value.dealer = !game.value.dealer;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (evt.action === 'quit') {
|
if (evt.action === 'quit') {
|
||||||
// Just close the connection. The server knows what to do.
|
// Just close the connection. The server knows what to do.
|
||||||
data.value = null;
|
data.value = null;
|
||||||
@ -85,6 +105,11 @@ function action(evt: Action) {
|
|||||||
const loadingMe = ref(true);
|
const loadingMe = ref(true);
|
||||||
const me = ref<string | null>(null);
|
const me = ref<string | null>(null);
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
if (local) {
|
||||||
|
loadingMe.value = false;
|
||||||
|
me.value = 'a';
|
||||||
|
return;
|
||||||
|
}
|
||||||
loadingMe.value = true;
|
loadingMe.value = true;
|
||||||
try {
|
try {
|
||||||
const resp = await fetch('/user/me', {
|
const resp = await fetch('/user/me', {
|
||||||
|
Loading…
Reference in New Issue
Block a user