Skip to content

Commit

Permalink
fix: attempt to fix unable to run login-canvas.js issue
Browse files Browse the repository at this point in the history
  • Loading branch information
tikazyq committed Dec 3, 2022
1 parent 17daf88 commit 59754ae
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<link href="font-awesome.min.css" rel="stylesheet">
<title>Crawlab</title>
<script src="js/vue3-sfc-loader.js"></script>
<script src="js/login-canvas.js"></script>
<script src="simplemde/simplemde.js"></script>
<style>
#loading-placeholder {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "crawlab-ui",
"version": "0.6.0-22",
"version": "0.6.0-23",
"private": false,
"author": {
"name": "Marvin Zhang",
Expand Down
5 changes: 3 additions & 2 deletions src/views/login/loginCanvas.js → public/js/login-canvas.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export function initCanvas() {
function initCanvas() {
let canvas, ctx, circ, nodes, mouse, SENSITIVITY, SIBLINGS_LIMIT, DENSITY, NODES_QTY, ANCHOR_LENGTH, MOUSE_RADIUS,
TURBULENCE, MOUSE_MOVING_TURBULENCE, MOUSE_ANGLE_TURBULENCE, MOUSE_MOVING_RADIUS, BASE_BRIGHTNESS, RADIUS_DEGRADE,
SAMPLE_SIZE
Expand Down Expand Up @@ -37,7 +37,8 @@ export function initCanvas() {
circ = 2 * Math.PI
nodes = []

canvas = document.querySelector('canvas')
canvas = document.querySelector('#canvas')
if (!canvas) return;
resizeWindow()
ctx = canvas.getContext('2d')
if (!ctx) {
Expand Down
9 changes: 2 additions & 7 deletions src/views/login/Login.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="login-container">
<canvas id="canvas"/>
<canvas id="canvas" class="login-canvas"/>
<el-form
ref="loginFormRef"
:model="loginForm"
Expand Down Expand Up @@ -125,7 +125,6 @@ import {useStore} from 'vuex';
import {setGlobalLang} from '@/utils/i18n';
import {useI18n} from 'vue-i18n';
import {LOCAL_STORAGE_KEY_TOKEN} from '@/constants/localStorage';
import {initCanvas} from './loginCanvas.js';
const {
post,
Expand Down Expand Up @@ -278,11 +277,7 @@ export default defineComponent({
onMounted(() => {
// initialize canvas
if (window.innerWidth >= 1024) {
if (!window.initCanvas) {
initCanvas();
} else {
window.initCanvas();
}
window?.initCanvas?.();
} else {
isShowMobileWarning.value = true;
}
Expand Down

0 comments on commit 59754ae

Please sign in to comment.