mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 03:20:12 +08:00
update components
This commit is contained in:
1 parent
ead321cd62
commit
63a57aa2cf
14 files changed
+70
-70
No files matched your search
@@ -1,5 +1,5 @@
|
|||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, ref } from 'vue'
|
import { computed, onMounted, Ref, ref } from 'vue'
|
||||||
import { RouterLink, useRouter } from 'vue-router'
|
import { RouterLink, useRouter } from 'vue-router'
|
||||||
import { useToast } from 'vue-toastification'
|
import { useToast } from 'vue-toastification'
|
||||||
import api from '../utils/api'
|
import api from '../utils/api'
|
||||||
@@ -27,7 +27,7 @@ const password = ref('')
|
|||||||
const errorMessage = ref('')
|
const errorMessage = ref('')
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
|
|
||||||
const availableMethods = ref({})
|
const availableMethods: Ref<any> = ref({})
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const res = await api.get('/auth/available-methods')
|
const res = await api.get('/auth/available-methods')
|
||||||
availableMethods.value = res.data
|
availableMethods.value = res.data
|
||||||
@@ -44,7 +44,7 @@ const success = () => {
|
|||||||
router.push({ name: 'map' })
|
router.push({ name: 'map' })
|
||||||
}
|
}
|
||||||
|
|
||||||
const error = (err) => {
|
const error = (err: string) => {
|
||||||
errorMessage.value = err
|
errorMessage.value = err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { useToast } from 'vue-toastification'
|
import { useToast } from 'vue-toastification'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
|||||||
@@ -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>
|
<template>
|
||||||
<section class="h-[10%] p-3 grid grid-cols-4 gap-4 place-content-between">
|
<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">
|
<button id="survey" class="bg-bg-secondary rounded-lg p-2">
|
||||||
@@ -48,25 +70,3 @@
|
|||||||
</button>
|
</button>
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</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>
|
|
||||||
@@ -1,23 +1,23 @@
|
|||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import { ref, onMounted } from 'vue'
|
import { ref, onMounted, Ref } from 'vue'
|
||||||
|
|
||||||
const cw = ref(0)
|
const cw = ref(0)
|
||||||
const ch = ref(0)
|
const ch = ref(0)
|
||||||
const fallingCharArr = ref([])
|
const fallingCharArr: any = ref([])
|
||||||
const fontSize = ref(16)
|
const fontSize = ref(16)
|
||||||
const maxColums = ref(0)
|
const maxColums = ref(0)
|
||||||
const charArr = ['0', '1', '', '', '']
|
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)
|
return Math.floor(Math.random() * (max - min) + min)
|
||||||
}
|
}
|
||||||
|
|
||||||
const randomFloat = (min, max) => {
|
const randomFloat = (min: number, max: number) => {
|
||||||
return Math.random() * (max - min) + min
|
return Math.random() * (max - min) + min
|
||||||
}
|
}
|
||||||
|
|
||||||
const draw = (point) => {
|
const draw = (point: any) => {
|
||||||
point.value = charArr[randomInt(0, charArr.length)].toUpperCase()
|
point.value = charArr[randomInt(0, charArr.length)].toUpperCase()
|
||||||
if (point.y < 0) point.speed = randomFloat(10, 20)
|
if (point.y < 0) point.speed = randomFloat(10, 20)
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ onMounted(() => {
|
|||||||
ch.value = document.documentElement.clientHeight
|
ch.value = document.documentElement.clientHeight
|
||||||
maxColums.value = cw.value / fontSize.value
|
maxColums.value = cw.value / fontSize.value
|
||||||
|
|
||||||
const canvas = document.querySelector('canvas')
|
const canvas: any = document.querySelector('canvas')
|
||||||
ctx.value = canvas.getContext('2d')
|
ctx.value = canvas.getContext('2d')
|
||||||
|
|
||||||
canvas.width = cw.value
|
canvas.width = cw.value
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<script setup>
|
<script setup lang="ts">
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
node: {
|
node: {
|
||||||
type: Object,
|
type: Object,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import { defineProps, onMounted } from 'vue'
|
import { defineProps, onMounted } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { useToast } from 'vue-toastification'
|
import { useToast } from 'vue-toastification'
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import { ref, watch } from 'vue'
|
import { ref, watch } from 'vue'
|
||||||
import sessionStore from '../store/session'
|
import sessionStore from '../store/session'
|
||||||
import MarkdownText from './MarkdownText.vue'
|
import MarkdownText from './MarkdownText.vue'
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import { computed, defineProps } from 'vue'
|
import { computed, defineProps } from 'vue'
|
||||||
import markdown2HTML from '../utils/markdown'
|
import markdown2HTML from '../utils/markdown'
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<!-- eslint-disable no-console -->
|
<!-- eslint-disable no-console -->
|
||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import { ref, onMounted } from 'vue'
|
import { ref, onMounted } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { useToast } from 'vue-toastification'
|
import { useToast } from 'vue-toastification'
|
||||||
@@ -50,7 +50,7 @@ async function getProgress() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const genOption = (nodes, edges) => ({
|
const genOption = (nodes: any, edges: any) => ({
|
||||||
renderer: 'svg',
|
renderer: 'svg',
|
||||||
tooltip: {},
|
tooltip: {},
|
||||||
animationDurationUpdate: 1500,
|
animationDurationUpdate: 1500,
|
||||||
@@ -94,7 +94,7 @@ const genOption = (nodes, edges) => ({
|
|||||||
curveness: 0.08,
|
curveness: 0.08,
|
||||||
},
|
},
|
||||||
itemStyle: {
|
itemStyle: {
|
||||||
color: (params) => {
|
color: (params: any) => {
|
||||||
const {
|
const {
|
||||||
data: { completed, unlocked },
|
data: { completed, unlocked },
|
||||||
} = params
|
} = 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 dag = new DAG(quests)
|
||||||
|
|
||||||
const nodes = dag.getNodes().map((node) => ({
|
const nodes = dag.getNodes().map((node) => ({
|
||||||
@@ -120,9 +120,9 @@ function getOption(quests, progress) {
|
|||||||
y: marginX * node.index - (marginX * dag.getLayer(node._id)) / 2,
|
y: marginX * node.index - (marginX * dag.getLayer(node._id)) / 2,
|
||||||
x: marginY * node.layer * 2,
|
x: marginY * node.layer * 2,
|
||||||
completed: progress[node._id]?.completed || false,
|
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 {
|
try {
|
||||||
const { unlocked } = node
|
const { unlocked } = node
|
||||||
return {
|
return {
|
||||||
@@ -134,7 +134,7 @@ function getOption(quests, progress) {
|
|||||||
throw err
|
throw err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const edges = dag.getEdgesArray().map((edge) => ({
|
const edges = dag.getEdgesArray().map((edge: any) => ({
|
||||||
source: edge[0],
|
source: edge[0],
|
||||||
target: edge[1],
|
target: edge[1],
|
||||||
lineStyle: lineAppearence(nodes.find((node) => node.id === edge[1])),
|
lineStyle: lineAppearence(nodes.find((node) => node.id === edge[1])),
|
||||||
@@ -145,10 +145,10 @@ function getOption(quests, progress) {
|
|||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
|
|
||||||
function initChart(option) {
|
function initChart(option: any) {
|
||||||
chartInstance = init(chartContainer.value)
|
chartInstance = init(chartContainer.value)
|
||||||
chartInstance.setOption(option)
|
chartInstance.setOption(option)
|
||||||
chartInstance.on('click', (params) => {
|
chartInstance.on('click', (params: any) => {
|
||||||
const {
|
const {
|
||||||
data: { id, unlocked },
|
data: { id, unlocked },
|
||||||
} = params
|
} = params
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import MarkdownText from './MarkdownText.vue'
|
import MarkdownText from './MarkdownText.vue'
|
||||||
import sessionStore from '../store/session'
|
import sessionStore from '../store/session'
|
||||||
|
|
||||||
const tasks = computed(() => {
|
const tasks = computed(() => {
|
||||||
return sessionStore.session.tasks.map((task) => {
|
return sessionStore.session.tasks.map((task: any) => {
|
||||||
const prefix = task.completed ? '✓' : '➤'
|
const prefix = task.completed ? '✓' : '➤'
|
||||||
const color = task.completed ? 'text-text-primary' : 'text-text'
|
const color = task.completed ? 'text-text-primary' : 'text-text'
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -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>
|
<template>
|
||||||
<font-awesome-icon :icon="['fas', 'terminal']" class="text-text p-1" />
|
<font-awesome-icon :icon="['fas', 'terminal']" class="text-text p-1" />
|
||||||
<button id="Terminal" class="text-text h-[5%]">
|
<button id="Terminal" class="text-text h-[5%]">
|
||||||
@@ -10,16 +23,3 @@
|
|||||||
class="bg-bg-secondary h-[calc(100%-5%)] p-0.5"
|
class="bg-bg-secondary h-[calc(100%-5%)] p-0.5"
|
||||||
></div>
|
></div>
|
||||||
</template>
|
</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,4 +1,4 @@
|
|||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import FileNode from './FileNode.vue'
|
import FileNode from './FileNode.vue'
|
||||||
import sessionStore from '../store/session'
|
import sessionStore from '../store/session'
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, onUnmounted } from 'vue'
|
import { Ref, ref, onMounted, onUnmounted } from 'vue'
|
||||||
import TreeChart from './TreeChart.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 }
|
let pos = { top: 0, left: 0, x: 0, y: 0 }
|
||||||
|
|
||||||
function mouseMoveHandler(e) {
|
function mouseMoveHandler(e: any) {
|
||||||
const dx = e.clientX - pos.x
|
const dx = e.clientX - pos.x
|
||||||
const dy = e.clientY - pos.y
|
const dy = e.clientY - pos.y
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ function mouseUpHandler() {
|
|||||||
document.removeEventListener('mouseup', mouseUpHandler)
|
document.removeEventListener('mouseup', mouseUpHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
function mouseDownHandler(e) {
|
function mouseDownHandler(e: any) {
|
||||||
treeRef.value.style.cursor = 'grabbing'
|
treeRef.value.style.cursor = 'grabbing'
|
||||||
treeRef.value.style.userSelect = 'none'
|
treeRef.value.style.userSelect = 'none'
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ function newSession() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const store = reactive({
|
const store: any = reactive({
|
||||||
session: newSession(),
|
session: newSession(),
|
||||||
questId: '',
|
questId: '',
|
||||||
quest: null,
|
quest: null,
|
||||||
|
|||||||
Reference in new issue
Block a user