This commit is contained in:
Dftre 2024-09-16 18:45:28 +08:00
commit 4be484d27a
9 changed files with 123 additions and 37 deletions

View File

@ -48,6 +48,13 @@ RuoYi-Vue 与 RuoYi-App 是基于 SpringBoot2+Vue2 打造的企业级开发框
**注意:**node 版本需要 16+ **注意:**node 版本需要 16+
## 迁移到Hbuilder不依赖Hbuilder的项目不需要迁移
1. src路径作为项目根路径
2. 将index.html、package.json、vite.config.js、tsconfig.json粘贴到src目录下
3. 在src目录下运行npm install
## 安装 ## 安装
一下三种方式均可,感觉速度 pnpm > yarn > cnpm > npm 一下三种方式均可,感觉速度 pnpm > yarn > cnpm > npm

View File

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

View File

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

View File

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