Browse Source

代理地址,修改复制方法

master
py 9 months ago
parent
commit
bd43586c4a
  1. 2
      .env.dev.local
  2. 5
      .env.prod
  3. 31
      src/views/Banner/Index.vue

2
.env.dev.local

@ -4,8 +4,8 @@ NODE_ENV=development
VITE_DEV=true
# 请求路径
VITE_BASE_URL='http://192.168.254.110:48080'
VITE_BASE_URL='http://192.168.254.66:48080'
VITE_BASE_URL='http://192.168.254.110:48080'
# 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持 S3 服务
VITE_UPLOAD_TYPE=server

5
.env.prod

@ -4,7 +4,7 @@ NODE_ENV=production
VITE_DEV=false
# 请求路径
VITE_BASE_URL='http://localhost:48080'
VITE_BASE_URL=
# 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持S3服务
VITE_UPLOAD_TYPE=server
@ -31,3 +31,6 @@ VITE_OUT_DIR=dist-prod
# 商城H5会员端域名
VITE_MALL_H5_DOMAIN='http://mall.riiwo.riiwo.cn'
# 验证码的开关
VITE_APP_CAPTCHA_ENABLE=false

31
src/views/Banner/Index.vue

@ -89,7 +89,7 @@
</div>
<template #footer>
<div class="flex-s-c card-footer">
<el-link class="copy" @click="copyUrl(item)" title="点击复制链接">
<el-link class="copy" @click="copyUrl(item.url)" title="点击复制链接">
<Icon :size="16" icon="ep:copy-document" />
<span>访问链接</span>
</el-link>
@ -168,11 +168,32 @@ const getList = async () => {
}
}
getList()
const copyUrl = async ({ url,code }) => {
// router.push({ path: '/board',query:{code} })
// return
const copyUrl = async (textToCopy)=> {
try {
await navigator.clipboard.writeText(url)
// navigator clipboard https
if (navigator.clipboard && window.isSecureContext) {
// navigator clipboard
navigator.clipboard.writeText(textToCopy);
} else {
// textarea
const tempTextArea = document.createElement('textarea');
tempTextArea.value = textToCopy;
document.body.appendChild(tempTextArea);
//
tempTextArea.select();
tempTextArea.setSelectionRange(0, 99999); //
try {
const successful = document.execCommand('copy');
if (!successful) {
alert('复制失败。');
}
} catch (err) {
console.error('无法执行复制操作: ', err);
alert('复制失败。');
}
// textarea
document.body.removeChild(tempTextArea);
}
ElMessage.success('复制成功')
} catch (err) {
ElMessage.error('复制失败')

Loading…
Cancel
Save