File size: 2,757 Bytes
7bff52e
2d7fc97
7bff52e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<template>
  <Header/>
  <router-view class="content" />
  <!-- <Footer/> -->

  <!-- <a-layout>
    <a-layout-sider :style="siderStyle" width="300" :collapsed-width="0" :collapsed="!sider_open" >
      Sider
      <a-button @click="toggleSider">close</a-button>
    </a-layout-sider>
    <a-layout>
      <router-view class="content" />
    </a-layout>
  </a-layout> -->

</template>

<script setup lang="ts">
import Header from "@/views/Header.vue";
import Footer from "@/views/Footer.vue";

// import * as api from "@/client";
import { onBeforeMount, onMounted, watch, CSSProperties, ref} from "vue";
import {useSettingsStore} from "@/stores/config.ts";

import axios from "axios";
import {getRandomNumInt} from "@/utils/size.ts";

const base_url = axios.defaults.baseURL

const settingsStore = useSettingsStore();

const sider_open = ref(settingsStore.$state.sider_open);
const siderStyle: CSSProperties = {
  textAlign: 'center',
  lineHeight: '90px',
  color: '#fff',
  backgroundColor: '#3ba0e9',
};

watch(() => settingsStore.$state.sider_open, (newVal) => {
  sider_open.value = newVal;
  console.log('sider open changed: ', sider_open.value);
});

const toggleSider = () => {
  sider_open.value = !sider_open.value;
  settingsStore.$patch({sider_open: sider_open.value});
  console.log('sider open: ', sider_open.value);
}

// const registerSession = async () => {
//   console.log('register ...')
//   const role = settingsStore.$state.role_name

//   const response = await fetch(`${base_url}/register?role=${role}`)
//   const res = await response.json()
//   console.log('res: ', res)
//   return res['session_id']
// }

// watch(() => settingsStore.$state.role_name, async (role_name: any) => {
//   console.log('>>>>> role updated', role_name)
//   let session_id = await registerSession()
//   if (!session_id) {
//     console.log('register session failed')
//     session_id = getRandomNumInt(100000, 999999)
//   }
//   // @ts-ignore
//   sessionsStore.$patch({current_session_id: session_id + ''})
//   console.log('session id: ', sessionsStore.$state.current_session_id)
// })

onMounted(async () => {
  // console.log('app mounted', settingsStore.$state)

  // let session_id = await registerSession()
  // if (!session_id) {
  //   console.log('register session failed')
  //   session_id = getRandomNumInt(100000, 999999)
  // }
  // // @ts-ignore
  // sessionsStore.$patch({current_session_id: session_id + ''})
  // console.log('session id: ', sessionsStore.$state.current_session_id)
})

</script>

<style scoped>
.content {
  background-color: white;
  /* max-width: 1280px;
  min-height: 720px; */
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}
</style>