转ts,解决bug

This commit is contained in:
dftre 2024-07-23 12:04:33 +08:00
parent 000dd462ab
commit 40cb9fd70c
8 changed files with 116 additions and 37 deletions

View File

@ -15,7 +15,7 @@
* http://ext.dcloud.net.cn/plugin?id=271
*
-->
<template>
<template>
<view class="chartsview" :id="'ChartBoxId'+cid">
<view v-if="mixinDatacomLoading">
<!-- 自定义加载状态请改这里 -->
@ -1251,13 +1251,13 @@ export default {
},
mounted() {
rootdom = {top:0,left:0}
// #ifdef H5
let dm = document.querySelectorAll('uni-main')[0]
if(dm === undefined){
dm = document.querySelectorAll('uni-page-wrapper')[0]
}
rootdom = {top:dm.offsetTop,left:dm.offsetLeft}
// #endif
if(dm !== undefined){
rootdom = {top:dm.offsetTop,left:dm.offsetLeft}
}
setTimeout(()=>{
if(this.rid === null){
this.$ownerInstance && this.$ownerInstance.callMethod('getRenderType')
@ -1305,14 +1305,10 @@ export default {
this.newEChart()
}else{
const script = document.createElement('script')
// #ifdef APP-VUE
script.src = './uni_modules/qiun-data-charts/static/app-plus/echarts.min.js'
// #endif
// #ifdef H5
const rooturl = window.location.origin
const directory = instance.getDataset().directory
script.src = rooturl + directory + 'uni_modules/qiun-data-charts/static/h5/echarts.min.js'
// #endif
script.onload = this.newEChart
document.head.appendChild(script)
}

View File

@ -1,14 +1,24 @@
// #ifdef APP-VUE || H5
/**
* v-copyText
* Copyright (c) 2022 ruoyi
* v-copyText="要复制的文本内容"
* v-copyText:callback="复制成功后的回调函数"
*
*/
export default {
beforeMount(el, { value, arg }) {
if (arg === "callback") {
el.$copyCallback = value;
import type { Directive, DirectiveBinding } from "vue";
interface ElType extends HTMLElement {
$copyValue: string;
$copyCallback: Function;
$destroyCopy:Function;
}
const vCopyText:Directive = {
beforeMount(el:ElType , binding:DirectiveBinding) {
if (binding.arg === "callback") {
el.$copyCallback = binding.value;
} else {
el.$copyValue = value;
el.$copyValue = binding.value;
const handler = () => {
copyTextToClipboard(el.$copyValue);
if (el.$copyCallback) {
@ -20,10 +30,11 @@ export default {
}
}
}
export default vCopyText;
function copyTextToClipboard(input, { target = document.body } = {}) {
function copyTextToClipboard(input:string, { target = document.body } = {}) {
const element = document.createElement('textarea');
const previouslyFocusedElement = document.activeElement;
const previouslyFocusedElement = document.activeElement as HTMLElement;
element.value = input;
@ -36,6 +47,7 @@ function copyTextToClipboard(input, { target = document.body } = {}) {
element.style.fontSize = '12pt'; // Prevent zooming on iOS
const selection = document.getSelection();
if(!selection)return
const originalRange = selection.rangeCount > 0 && selection.getRangeAt(0);
target.append(element);
@ -64,3 +76,4 @@ function copyTextToClipboard(input, { target = document.body } = {}) {
return isSuccess;
}
// #endif

View File

@ -0,0 +1,7 @@
import type { Directive } from "vue";
const vFocus: Directive = {
mounted: (el) => el.focus()
}
export default vFocus

View File

@ -0,0 +1,50 @@
import type { Directive } from "vue";
interface ElType extends HTMLElement {
$oldStyle: CSSStyleDeclaration;
$fullStyle: CSSStyleDeclaration;
}
const vFull: Directive = {
mounted: (el: ElType, binding) => {
el.$oldStyle = { ...el.style }
if (binding.arg === 'screen') {
el.$fullStyle = {
...el.style,
left: '0',
top: '0',
zIndex: '8',
position: 'fixed',
height: '100vh',
width: '100vw',
}
} else {
el.$fullStyle = {
...el.style,
left: '0',
top: '0',
zIndex: '8',
position: 'absolute',
height: '100%',
width: '100%',
}
}
},
updated: (el: ElType, binding) => {
function setStyle(el: CSSStyleDeclaration, style: CSSStyleDeclaration) {
el.position = style.position
el.left = style.left
el.top = style.top
el.zIndex = style.zIndex
el.height = style.height
el.width = style.width
}
if (binding.value) {
setStyle(el.style, el.$fullStyle)
} else {
setStyle(el.style, el.$oldStyle)
}
}
}
export default vFull

View File

@ -1,9 +0,0 @@
import hasRole from './permission/hasRole'
import hasPermi from './permission/hasPermi'
import copyText from './common/copyText'
export default function directive(app){
app.directive('hasRole', hasRole)
app.directive('hasPermi', hasPermi)
app.directive('copyText', copyText)
}

18
src/directive/index.ts Normal file
View File

@ -0,0 +1,18 @@
// #ifdef APP-VUE || H5
import copyText from './common/copyText'
// #endif
import hasRole from './permission/hasRole'
import hasPermi from './permission/hasPermi'
import focus from './common/focus'
import full from './common/full'
import { App } from 'vue'
export default function directive(app: App) {
// #ifdef APP-VUE || H5
app.directive('copyText', copyText)
// #endif
app.directive('hasRole', hasRole)
app.directive('hasPermi', hasPermi)
app.directive('focus', focus)
app.directive('full', full)
}

View File

@ -1,11 +1,12 @@
/**
* v-hasPermi
* Copyright (c) 2019 ruoyi
*/
/**
* v-hasPermi
* Copyright (c) 2019 ruoyi
*/
import useUserStore from '@/store/modules/user'
export default {
import type { Directive } from "vue";
const vHasPermi: Directive = {
mounted(el, binding, vnode) {
const { value } = binding
const all_permission = "*:*:*";
@ -26,3 +27,4 @@ export default {
}
}
}
export default vHasPermi

View File

@ -1,11 +1,11 @@
/**
* v-hasRole
* Copyright (c) 2019 ruoyi
*/
/**
* v-hasRole
* Copyright (c) 2019 ruoyi
*/
import useUserStore from '@/store/modules/user'
export default {
import type { Directive } from "vue";
const vHasRole: Directive = {
mounted(el, binding, vnode) {
const { value } = binding
const super_admin = "admin";
@ -26,3 +26,5 @@ export default {
}
}
}
export default vHasRole;