init: v3 init
This commit is contained in:
@@ -1,17 +0,0 @@
|
||||
/**
|
||||
* 配置浏览器本地存储的方式,可直接存储对象数组。
|
||||
*/
|
||||
|
||||
import WebStorageCache from 'web-storage-cache'
|
||||
|
||||
type CacheType = 'sessionStorage' | 'localStorage'
|
||||
|
||||
export function useCache(type: CacheType = 'sessionStorage') {
|
||||
const wsCache: WebStorageCache = new WebStorageCache({
|
||||
storage: type
|
||||
})
|
||||
|
||||
return {
|
||||
wsCache
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
import Clipboard from 'clipboard'
|
||||
import { Message } from '_c/Message'
|
||||
|
||||
export function useClipboard() {
|
||||
function clipboard(text: string, event: MouseEvent) {
|
||||
const clipboard = new Clipboard(event.target as Element, {
|
||||
text: () => text
|
||||
})
|
||||
clipboard.on('success', () => {
|
||||
clipboardSuccess()
|
||||
clipboard.destroy()
|
||||
})
|
||||
clipboard.on('error', () => {
|
||||
clipboardError()
|
||||
clipboard.destroy()
|
||||
})
|
||||
;(clipboard as any).onClick(event)
|
||||
}
|
||||
|
||||
function clipboardSuccess() {
|
||||
Message.success('复制成功')
|
||||
}
|
||||
|
||||
function clipboardError() {
|
||||
Message.error('复制失败')
|
||||
}
|
||||
|
||||
return {
|
||||
clipboard
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
import screenfull from 'screenfull'
|
||||
|
||||
export function useFullscreen() {
|
||||
const sf = screenfull as any
|
||||
|
||||
return {
|
||||
sf
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
import IntroJs from 'intro.js'
|
||||
import 'intro.js/introjs.css'
|
||||
|
||||
export function useIntro() {
|
||||
const intro: IntroJs.IntroJs = new (IntroJs as any)()
|
||||
|
||||
return {
|
||||
intro
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import { ref, watch } from 'vue'
|
||||
import { isString } from '@/utils/validate'
|
||||
import { useAppStoreWithOut } from '@/store/modules/app'
|
||||
const appStore = useAppStoreWithOut()
|
||||
|
||||
export function useTitle(newTitle?: string) {
|
||||
const title = ref(newTitle ? `${appStore.getTitle} - ${newTitle}` : appStore.getTitle)
|
||||
|
||||
watch(
|
||||
title,
|
||||
(t, o) => {
|
||||
if (isString(t) && t !== o && document) {
|
||||
document.title = t
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
return title
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
const domSymbol = Symbol('watermark-dom')
|
||||
|
||||
export function useWatermark(appendEl: HTMLElement | null = document.body) {
|
||||
let func: Fn = () => {}
|
||||
const id = domSymbol.toString()
|
||||
const clear = () => {
|
||||
const domId = document.getElementById(id)
|
||||
if (domId) {
|
||||
const el = appendEl
|
||||
el && el.removeChild(domId)
|
||||
}
|
||||
window.removeEventListener('resize', func)
|
||||
}
|
||||
const createWatermark = (str: string) => {
|
||||
clear()
|
||||
|
||||
const can = document.createElement('canvas')
|
||||
can.width = 300
|
||||
can.height = 240
|
||||
|
||||
const cans = can.getContext('2d')
|
||||
if (cans) {
|
||||
cans.rotate((-20 * Math.PI) / 120)
|
||||
cans.font = '15px Vedana'
|
||||
cans.fillStyle = 'rgba(0, 0, 0, 0.15)'
|
||||
cans.textAlign = 'left'
|
||||
cans.textBaseline = 'middle'
|
||||
cans.fillText(str, can.width / 20, can.height)
|
||||
}
|
||||
|
||||
const div = document.createElement('div')
|
||||
div.id = id
|
||||
div.style.pointerEvents = 'none'
|
||||
div.style.top = '0px'
|
||||
div.style.left = '0px'
|
||||
div.style.position = 'absolute'
|
||||
div.style.zIndex = '100000000'
|
||||
div.style.width = document.documentElement.clientWidth + 'px'
|
||||
div.style.height = document.documentElement.clientHeight + 'px'
|
||||
div.style.background = 'url(' + can.toDataURL('image/png') + ') left top repeat'
|
||||
const el = appendEl
|
||||
el && el.appendChild(div)
|
||||
return id
|
||||
}
|
||||
|
||||
function setWatermark(str: string) {
|
||||
createWatermark(str)
|
||||
func = () => {
|
||||
createWatermark(str)
|
||||
}
|
||||
window.addEventListener('resize', func)
|
||||
}
|
||||
|
||||
return { setWatermark, clear }
|
||||
}
|
||||
Reference in New Issue
Block a user