diff --git a/src/components/Tooltip.vue b/src/components/Tooltip.vue new file mode 100644 index 0000000..15bd51c --- /dev/null +++ b/src/components/Tooltip.vue @@ -0,0 +1,222 @@ + + + + + + + \ No newline at end of file diff --git a/src/main.js b/src/main.js index 90e30ce..b525bd4 100755 --- a/src/main.js +++ b/src/main.js @@ -19,6 +19,7 @@ import clipboard from '@/utils/dirClipBoard'; import { modernCopyToClipboard } from '@/utils/clipboard'; //登陆 import { autoLoginByToken } from '@/utils/login' +import PositionMessage from './utils/tooltip' function filterByPermission(data, targetPermission) { return data.filter(item => { @@ -55,6 +56,10 @@ Vue.config.productionTip = false; Vue.prototype.$http = request; Vue.prototype.$token = '' Vue.use(ElementUI); +Vue.use(PositionMessage) + +Vue.prototype.$Message = GuipMessage + Vue.use(GuipMessage) Vue.use(clipboard); diff --git a/src/utils/tooltip.js b/src/utils/tooltip.js new file mode 100644 index 0000000..e7c5c14 --- /dev/null +++ b/src/utils/tooltip.js @@ -0,0 +1,33 @@ +import Vue from 'vue' +import Tooltip from '@/components/Tooltip.vue' + +const PositionMessageConstructor = Vue.extend(Tooltip) + +// 自动隐藏功能扩展 +function showMessage(options) { + const instance = new PositionMessageConstructor({ + propsData: options + }).$mount() + + document.body.appendChild(instance.$el) + + const showInstance = instance.show() + + // 添加自动隐藏 + if (options.duration !== 0) { + setTimeout(() => { + showInstance.hide() + setTimeout(() => { + document.body.removeChild(instance.$el) + }, 300) // 等待动画结束 + }, options.duration || 2000) + } + + return showInstance + } + +export default { + install(Vue) { + Vue.prototype.$positionMessage = showMessage + } +} \ No newline at end of file diff --git a/src/views/agent/siteTemplate.vue b/src/views/agent/siteTemplate.vue index 9c4d724..ebb111e 100644 --- a/src/views/agent/siteTemplate.vue +++ b/src/views/agent/siteTemplate.vue @@ -5,9 +5,10 @@

模板选择

-
-
+
+
预览 @@ -15,10 +16,11 @@

{{ item.name }}

-
+
- +

自定义模板

@@ -30,20 +32,20 @@ 站点ICO + :limit="Number(1)" ref="avatorUpload" :auto-upload="false" accept=".ico"> 选择文件
浏览器标题前面的图片,必须是ico格式,尺寸32PX*32PX
- - - - - - - + + + + + + +
@@ -84,12 +86,15 @@
+ :limit="Number(1)" ref="avatorUpload2" :auto-upload="false" accept=".zip">
- + 选择文件重新上传 - 导出网页模板 + 导出网页模板
根据开发文档的提示,将内容压缩成zip包上传
@@ -148,18 +153,19 @@ export default { templeteList: [], formData: new FormData(), previewVisible: false, - currentImage: '' + currentImage: '', + itemRefs: {} } }, mounted() { - if(!this.$route.query.uid && !this.$route.query.site_type){ + if (!this.$route.query.uid && !this.$route.query.site_type) { this.$message.error('未知错误'); this.$router.push('/') return false; } //站点不存在 读取本地存储设置的数据 const siteTplInfo = JSON.parse(localStorage.getItem('site_tpl_info')) - if(!this.$route.query.uid && siteTplInfo) { + if (!this.$route.query.uid && siteTplInfo) { this.tpl_id = siteTplInfo.site_tpl this.pictureUrl = siteTplInfo.picture this.previewUrl = siteTplInfo.preview @@ -173,13 +179,13 @@ export default { // 初始化 get_site_tpl_list() { let obj = {} - if(this.$route.query.site_type) obj.site_type = this.$route.query.site_type; - if(this.$route.query.uid) obj.uid = this.$route.query.uid; + if (this.$route.query.site_type) obj.site_type = this.$route.query.site_type; + if (this.$route.query.uid) obj.uid = this.$route.query.uid; this.$http('POST', '/agentnew/ajax_get_site_tpl_list', obj).then(response => { - if(response.status) { + if (response.status) { this.$nextTick(() => { - if(!this.tpl_id) { + if (!this.tpl_id) { this.tpl_id = response.data.tpl_data.tpl_id this.pictureUrl = response.data.tpl_data.picture this.previewUrl = response.data.tpl_data.thumbnail @@ -197,17 +203,17 @@ export default { console.error(error, 'error') }) }, - jumpCancle(){ + jumpCancle() { this.$router.go(-1) }, - jumpDoc(){ + jumpDoc() { window.open(this.$router.resolve({ path: '/customizeDoc', }).href, '_blank') }, update_site_tpl() { //站点不存在只保存选择的模板id到 - if(!this.$route.query.uid){ + if (!this.$route.query.uid) { let site_tpl_info = { site_tpl: this.tpl_id, site_tpl_name: this.tpl_name, @@ -225,7 +231,7 @@ export default { this.formData.set('tpl_id', this.tpl_id) this.formData.set('is_public_tpl', this.is_public_tpl) this.$http('POST', '/agentnew/ajax_update_site_tpl', this.formData).then(response => { - if(response.status){ + if (response.status) { this.$router.go(-1) return true } @@ -235,15 +241,26 @@ export default { }) return true; }, - chooseTemplate(item) { + chooseTemplate(item, index) { + // 获取动态 ref 对应的 DOM 元素 + const targetEl = this.itemRefs[index]; // 注意:$refs 是数组 this.is_public_tpl = 1 this.tpl_id = item.id; this.tpl_name = item.name; this.pictureUrl = item.picture; this.previewUrl = item.thumbnail; - this.$Message.info(item.introduce) + this.openDialog3(targetEl, 'top', item.introduce) + }, + openDialog3(el, pos, introduce) { + // type属性可更换 + this.$positionMessage({ + type: 'info', + message: introduce, + target: el, // 可以是DOM元素或选择器 + position: pos || 'bottom' // 或 'bottom' + }) // 2秒后自动隐藏(可选) }, - choosePrivTemplate(){ + choosePrivTemplate() { this.is_public_tpl = 0 this.tpl_id = '' this.tpl_name = ''; @@ -285,40 +302,46 @@ export default { }