update components

This commit is contained in:
Chen, Tai-Lin committed 2024-03-04 23:35:05 +08:00
1 parent ead321cd62
commit 63a57aa2cf
14 files changed
+70 -70

No files matched your search

+4 -4
View File
@@ -1,5 +1,5 @@
<script setup>
import { computed, onMounted, ref } from 'vue'
<script setup lang="ts">
import { computed, onMounted, Ref, ref } from 'vue'
import { RouterLink, useRouter } from 'vue-router'
import { useToast } from 'vue-toastification'
import api from '../utils/api'
@@ -27,7 +27,7 @@ const password = ref('')
const errorMessage = ref('')
const toast = useToast()
const availableMethods = ref({})
const availableMethods: Ref<any> = ref({})
onMounted(async () => {
const res = await api.get('/auth/available-methods')
availableMethods.value = res.data
@@ -44,7 +44,7 @@ const success = () => {
router.push({ name: 'map' })
}
const error = (err) => {
const error = (err: string) => {
errorMessage.value = err
}
+1 -1
View File
@@ -1,4 +1,4 @@
<script setup>
<script setup lang="ts">
import { useRouter } from 'vue-router'
import { useToast } from 'vue-toastification'
import { ref } from 'vue'
+22 -22
View File
@@ -1,3 +1,25 @@
<script setup lang="ts">
import { useRouter } from 'vue-router'
import { useToast } from 'vue-toastification'
import { createSession } from '../store/session'
import { surveyUrl } from '../config'
const router = useRouter()
const reset = async () => {
console.log('resetting...')
await createSession()
}
const continuePlay = async () => {
try {
router.push({ name: 'map' })
} catch (err) {
// useToast().error('Failed to load map')
useToast().error('無法讀取地圖')
console.error(err)
}
}
</script>
<template>
<section class="h-[10%] p-3 grid grid-cols-4 gap-4 place-content-between">
<button id="survey" class="bg-bg-secondary rounded-lg p-2">
@@ -48,25 +70,3 @@
</button>
</section>
</template>
<script setup>
import { useRouter } from 'vue-router'
import { useToast } from 'vue-toastification'
import { createSession } from '../store/session'
import { surveyUrl } from '../config'
const router = useRouter()
const reset = async () => {
console.log('resetting...')
await createSession()
}
const continuePlay = async () => {
try {
router.push({ name: 'map' })
} catch (err) {
// useToast().error('Failed to load map')
useToast().error('無法讀取地圖')
console.error(err)
}
}
</script>
+8 -8
View File
@@ -1,23 +1,23 @@
<script setup>
import { ref, onMounted } from 'vue'
<script setup lang="ts">
import { ref, onMounted, Ref } from 'vue'
const cw = ref(0)
const ch = ref(0)
const fallingCharArr = ref([])
const fallingCharArr: any = ref([])
const fontSize = ref(16)
const maxColums = ref(0)
const charArr = ['0', '1', '', '', '']
const ctx = ref(null)
const ctx: Ref<any> = ref(null)
const randomInt = (min, max) => {
const randomInt = (min: number, max: number) => {
return Math.floor(Math.random() * (max - min) + min)
}
const randomFloat = (min, max) => {
const randomFloat = (min: number, max: number) => {
return Math.random() * (max - min) + min
}
const draw = (point) => {
const draw = (point: any) => {
point.value = charArr[randomInt(0, charArr.length)].toUpperCase()
if (point.y < 0) point.speed = randomFloat(10, 20)
@@ -48,7 +48,7 @@ onMounted(() => {
ch.value = document.documentElement.clientHeight
maxColums.value = cw.value / fontSize.value
const canvas = document.querySelector('canvas')
const canvas: any = document.querySelector('canvas')
ctx.value = canvas.getContext('2d')
canvas.width = cw.value
+1 -1
View File
@@ -1,4 +1,4 @@
<script setup>
<script setup lang="ts">
const props = defineProps({
node: {
type: Object,
+1 -1
View File
@@ -1,4 +1,4 @@
<script setup>
<script setup lang="ts">
import { defineProps, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { useToast } from 'vue-toastification'
+1 -1
View File
@@ -1,4 +1,4 @@
<script setup>
<script setup lang="ts">
import { ref, watch } from 'vue'
import sessionStore from '../store/session'
import MarkdownText from './MarkdownText.vue'
+1 -1
View File
@@ -1,4 +1,4 @@
<script setup>
<script setup lang="ts">
import { computed, defineProps } from 'vue'
import markdown2HTML from '../utils/markdown'
+9 -9
View File
@@ -1,5 +1,5 @@
<!-- eslint-disable no-console -->
<script setup>
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { useToast } from 'vue-toastification'
@@ -50,7 +50,7 @@ async function getProgress() {
}
}
const genOption = (nodes, edges) => ({
const genOption = (nodes: any, edges: any) => ({
renderer: 'svg',
tooltip: {},
animationDurationUpdate: 1500,
@@ -94,7 +94,7 @@ const genOption = (nodes, edges) => ({
curveness: 0.08,
},
itemStyle: {
color: (params) => {
color: (params: any) => {
const {
data: { completed, unlocked },
} = params
@@ -111,7 +111,7 @@ const genOption = (nodes, edges) => ({
],
})
function getOption(quests, progress) {
function getOption(quests: any, progress: any) {
const dag = new DAG(quests)
const nodes = dag.getNodes().map((node) => ({
@@ -120,9 +120,9 @@ function getOption(quests, progress) {
y: marginX * node.index - (marginX * dag.getLayer(node._id)) / 2,
x: marginY * node.layer * 2,
completed: progress[node._id]?.completed || false,
unlocked: node.requirements.every((req) => progress[req]?.completed),
unlocked: node.requirements.every((req: any) => progress[req]?.completed),
}))
const lineAppearence = (node) => {
const lineAppearence = (node: any) => {
try {
const { unlocked } = node
return {
@@ -134,7 +134,7 @@ function getOption(quests, progress) {
throw err
}
}
const edges = dag.getEdgesArray().map((edge) => ({
const edges = dag.getEdgesArray().map((edge: any) => ({
source: edge[0],
target: edge[1],
lineStyle: lineAppearence(nodes.find((node) => node.id === edge[1])),
@@ -145,10 +145,10 @@ function getOption(quests, progress) {
const router = useRouter()
const toast = useToast()
function initChart(option) {
function initChart(option: any) {
chartInstance = init(chartContainer.value)
chartInstance.setOption(option)
chartInstance.on('click', (params) => {
chartInstance.on('click', (params: any) => {
const {
data: { id, unlocked },
} = params
+2 -2
View File
@@ -1,10 +1,10 @@
<script setup>
<script setup lang="ts">
import { computed } from 'vue'
import MarkdownText from './MarkdownText.vue'
import sessionStore from '../store/session'
const tasks = computed(() => {
return sessionStore.session.tasks.map((task) => {
return sessionStore.session.tasks.map((task: any) => {
const prefix = task.completed ? '✓' : '➤'
const color = task.completed ? 'text-text-primary' : 'text-text'
return {
+13 -13
View File
@@ -1,3 +1,16 @@
<script setup lang="ts">
import { Ref, onMounted, ref } from 'vue'
import { useTerminal } from '../store/session'
const terminal: Ref<any> = ref(null)
onMounted(() => {
const term = useTerminal()
term.mount(terminal.value)
window.addEventListener('resize', () => term.resizeScreen())
})
</script>
<template>
<font-awesome-icon :icon="['fas', 'terminal']" class="text-text p-1" />
<button id="Terminal" class="text-text h-[5%]">
@@ -10,16 +23,3 @@
class="bg-bg-secondary h-[calc(100%-5%)] p-0.5"
></div>
</template>
<script setup>
import { onMounted, ref } from 'vue'
import { useTerminal } from '../store/session'
const terminal = ref(null)
onMounted(() => {
const term = useTerminal()
term.mount(terminal.value)
window.addEventListener('resize', () => term.resizeScreen())
})
</script>
+1 -1
View File
@@ -1,4 +1,4 @@
<script setup>
<script setup lang="ts">
import FileNode from './FileNode.vue'
import sessionStore from '../store/session'
</script>
+5 -5
View File
@@ -1,11 +1,11 @@
<script setup>
import { ref, onMounted, onUnmounted } from 'vue'
<script setup lang="ts">
import { Ref, ref, onMounted, onUnmounted } from 'vue'
import TreeChart from './TreeChart.vue'
const treeRef = ref(null)
const treeRef: Ref<any> = ref(null)
let pos = { top: 0, left: 0, x: 0, y: 0 }
function mouseMoveHandler(e) {
function mouseMoveHandler(e: any) {
const dx = e.clientX - pos.x
const dy = e.clientY - pos.y
@@ -21,7 +21,7 @@ function mouseUpHandler() {
document.removeEventListener('mouseup', mouseUpHandler)
}
function mouseDownHandler(e) {
function mouseDownHandler(e: any) {
treeRef.value.style.cursor = 'grabbing'
treeRef.value.style.userSelect = 'none'
+1 -1
View File
@@ -24,7 +24,7 @@ function newSession() {
}
}
const store = reactive({
const store: any = reactive({
session: newSession(),
questId: '',
quest: null,