|
@@ -44,6 +44,7 @@ const colors = [ '⚫️', '🔵', '🟢', '🟣', '🔴', '🟤', '🟠', '🟡
|
|
|
let canvas: HTMLCanvasElement | null = null
|
|
let canvas: HTMLCanvasElement | null = null
|
|
|
let context: CanvasRenderingContext2D | null = null
|
|
let context: CanvasRenderingContext2D | null = null
|
|
|
const resetStyle = ref('')
|
|
const resetStyle = ref('')
|
|
|
|
|
+
|
|
|
// canvas fn
|
|
// canvas fn
|
|
|
const onPointerMove = (event: PointerEvent) => {
|
|
const onPointerMove = (event: PointerEvent) => {
|
|
|
if (event.isPrimary) {
|
|
if (event.isPrimary) {
|
|
@@ -77,7 +78,9 @@ const onPointerUp = (event: PointerEvent) => {
|
|
|
|
|
|
|
|
const restColor = (i: number) => {
|
|
const restColor = (i: number) => {
|
|
|
recorder.color(i)
|
|
recorder.color(i)
|
|
|
- resetStyle.value = `cursor: url(/pen/${i}.cur) 0 17, crosshair;`
|
|
|
|
|
|
|
+ const w = canvas?.width
|
|
|
|
|
+ const h = canvas?.height
|
|
|
|
|
+ resetStyle.value = `width:${w}px;height:${h}px; cursor: url(/pen/${i}.cur) 0 17, crosshair;`
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// socket init
|
|
// socket init
|
|
@@ -103,8 +106,8 @@ socket.on('connect_error', () => {
|
|
|
status.value = colors[4]
|
|
status.value = colors[4]
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-onMounted(() => {
|
|
|
|
|
- // init canvas
|
|
|
|
|
|
|
+// init canvas
|
|
|
|
|
+const intCanvas = () => {
|
|
|
canvas = document.getElementById('canvas') as HTMLCanvasElement
|
|
canvas = document.getElementById('canvas') as HTMLCanvasElement
|
|
|
canvas.width = window.innerWidth * window.devicePixelRatio
|
|
canvas.width = window.innerWidth * window.devicePixelRatio
|
|
|
canvas.height = window.innerHeight * window.devicePixelRatio
|
|
canvas.height = window.innerHeight * window.devicePixelRatio
|
|
@@ -114,19 +117,20 @@ onMounted(() => {
|
|
|
context.lineWidth = 0.7 * window.devicePixelRatio
|
|
context.lineWidth = 0.7 * window.devicePixelRatio
|
|
|
context.fillStyle = 'rgb(238, 238, 238)'
|
|
context.fillStyle = 'rgb(238, 238, 238)'
|
|
|
context.fillRect(0, 0, canvas.width, canvas.height)
|
|
context.fillRect(0, 0, canvas.width, canvas.height)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+onMounted(() => {
|
|
|
|
|
+ intCanvas()
|
|
|
nextTick(() => {
|
|
nextTick(() => {
|
|
|
socket.connect()
|
|
socket.connect()
|
|
|
})
|
|
})
|
|
|
- const isIOS = !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
|
|
|
|
|
- const isAndroid = navigator.userAgent.includes('Android') || navigator.userAgent.includes('Linux') // g
|
|
|
|
|
- if (isIOS || isAndroid) {
|
|
|
|
|
- alert('建议用电脑打开')
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ window.addEventListener('resize', intCanvas)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
onUnmounted(() => {
|
|
onUnmounted(() => {
|
|
|
if (!socket) return
|
|
if (!socket) return
|
|
|
socket.disconnect()
|
|
socket.disconnect()
|
|
|
|
|
+ window.removeEventListener('resize', intCanvas)
|
|
|
context = null
|
|
context = null
|
|
|
canvas = null
|
|
canvas = null
|
|
|
recorder = null
|
|
recorder = null
|
|
@@ -139,7 +143,6 @@ onUnmounted(() => {
|
|
|
font-family: sans-serif;
|
|
font-family: sans-serif;
|
|
|
margin: 0;
|
|
margin: 0;
|
|
|
overflow: hidden;
|
|
overflow: hidden;
|
|
|
-
|
|
|
|
|
#canvas {
|
|
#canvas {
|
|
|
display: block;
|
|
display: block;
|
|
|
cursor: url('/pen/0.cur') 0 17, crosshair;
|
|
cursor: url('/pen/0.cur') 0 17, crosshair;
|
|
@@ -171,9 +174,11 @@ onUnmounted(() => {
|
|
|
border-radius: 25px;
|
|
border-radius: 25px;
|
|
|
user-select: none;
|
|
user-select: none;
|
|
|
pointer-events: auto;
|
|
pointer-events: auto;
|
|
|
- &:last-child{
|
|
|
|
|
|
|
+
|
|
|
|
|
+ &:last-child {
|
|
|
margin-left: 5px;
|
|
margin-left: 5px;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
&>span {
|
|
&>span {
|
|
|
span {
|
|
span {
|
|
|
margin: 0 3px;
|
|
margin: 0 3px;
|