Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复二维码不显示的问题 #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"markdown-loader": "4.0.0",
"monaco-editor": "^0.14.3",
"monaco-editor-webpack-plugin": "^1.5.2",
"qrcode": "^1.4.4",
"qs": "^6.3.1",
"title-notify": "^1.0.13",
"vue": "^2.5.16",
Expand Down
15 changes: 12 additions & 3 deletions src/pages/dashboard/featured.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<i class="eqf-QRcode"></i>
</div>
<a :title="item.desc" style="display: inline-block; cursor: pointer;" :href="getUrl(item,true)" target="_blank" class="erCode" >
<img class="qrcode" :src="getqrUrl(item)" alt="">
<img class="qrcode" :src="item.qrUrl" alt="">
</a>
</a>
<p class="editButton" @click="useTemp(item)">立即使用</p>
Expand Down Expand Up @@ -257,6 +257,7 @@
</style>

<script type="text/ecmascript-6">
import QRCode from 'qrcode'
import BasePage from 'src/extend/BasePage'
import Server from 'src/extend/Server'
import config from 'src/config/index'
Expand Down Expand Up @@ -350,6 +351,7 @@
}
}).then((res) => {
this.productList = res.data.data || []
this.setQRUrls(this.productList)
})
},
getUrl: function (item, isClient) {
Expand All @@ -362,8 +364,15 @@
return `${config.EDITOR_PATH}?key=${item.key}`
}
},
getqrUrl: function (item) {
return `https://www.liantu.com/api.php?text=${encodeURIComponent(this.getUrl(item, 1))}`
setQRUrls (list) {
list.forEach(item => {
const url = this.getUrl(item, 1)
try {
QRCode.toDataURL(url).then(value => { this.$set(item, 'qrUrl', value) })
} catch {
console.error('生成二维码出错')
}
})
},
}
}
Expand Down
15 changes: 12 additions & 3 deletions src/pages/dashboard/featuring.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<i class="eqf-QRcode"></i>
</div>
<a :title="item.desc" style="display: inline-block; cursor: pointer;" :href="getUrl(item,true)" target="_blank" class="erCode" >
<img class="qrcode" :src="getqrUrl(item)" alt="">
<img class="qrcode" :src="item.qrUrl" alt="">
</a>
</a>
<el-button class="control-item" size="mini" @click="updateItem(item, 1)">设为精选</el-button>
Expand Down Expand Up @@ -266,6 +266,7 @@
</style>

<script type="text/ecmascript-6">
import QRCode from 'qrcode'
import BasePage from 'src/extend/BasePage'
import Server from 'src/extend/Server'
import config from 'src/config/index'
Expand Down Expand Up @@ -338,6 +339,7 @@
}
}).then((res) => {
this.pages = res.data.data || []
this.setQRUrls(this.pages)
})
},
getUrl: function (item, isClient) {
Expand All @@ -350,8 +352,15 @@
return `${config.EDITOR_PATH}?key=${item.key}`
}
},
getqrUrl: function (item) {
return `https://www.liantu.com/api.php?text=${encodeURIComponent(this.getUrl(item, 1))}`
setQRUrls (list) {
list.forEach(item => {
const url = this.getUrl(item, 1)
try {
QRCode.toDataURL(url).then(value => { this.$set(item, 'qrUrl', value) })
} catch {
console.error('生成二维码出错')
}
})
},
}
}
Expand Down
17 changes: 13 additions & 4 deletions src/pages/dashboard/pages.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<img :src="item.image||'https://ymm-maliang.oss-cn-hangzhou.aliyuncs.com/ymm-maliang/access/ymm1562307855048.png'" alt="">
</div>
<a :title="item.desc" style="display: inline-block; cursor: pointer;" :href="getUrl(item,true)" target="_blank">
<img class="qrcode" :src="getqrUrl(item)" alt="">
<img class="qrcode" :src="item.qrUrl" alt="">
</a>
<div class="sourceButton">
<a class="editButton" @click='setting(item)'>设置</a>
Expand Down Expand Up @@ -227,6 +227,7 @@
</style>

<script type="text/ecmascript-6">
import QRCode from 'qrcode'
import BasePage from 'src/extend/BasePage'
import Server from 'src/extend/Server'
const config = require('../../config/index.js')
Expand Down Expand Up @@ -274,9 +275,6 @@
return `${config.EDITOR_PATH}?key=${item.key}`
}
},
getqrUrl: function (item) {
return `https://www.liantu.com/api.php?text=${encodeURIComponent(this.getUrl(item, 1))}`
},
tabHandleClick (tab) {
this.activeName = tab.name
if (tab.name == 'public') {
Expand All @@ -294,6 +292,17 @@
}
}).then((res) => {
this.publicPage = res.data.data || []
this.setQRUrls(this.publicPage)
})
},
setQRUrls (list) {
list.forEach(item => {
const url = this.getUrl(item, 1)
try {
QRCode.toDataURL(url).then(value => { this.$set(item, 'qrUrl', value) })
} catch {
console.error('生成二维码出错')
}
})
},
loadStarProject: function () {
Expand Down
29 changes: 19 additions & 10 deletions src/pages/projects/CDoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
<i class="eqf-QRcode"></i>
</div>
<a :title="item.desc" style="display: inline-block; cursor: pointer;" :href="getUrl(item,true)" target="_blank" class="erCode" >
<img class="qrcode" :src="getqrUrl(item)" alt="">
<img class="qrcode" :src="item.qrUrl" alt="">
</a>
</a>
<div class="sourceButton">

<a class="editButton" :href="getUrl(item)" target="_blank">编辑</a>
<a class="editButton act_btn" target="_blank">操作
<div class="actions">
Expand All @@ -57,7 +57,7 @@
<p class="last"></p>
</div>
</a>

</div>
</div>
</div>
Expand Down Expand Up @@ -263,7 +263,7 @@
align-items: center;

.editButton {
text-decoration:none;
text-decoration:none;
color:#333;
margin: 10px 2px;
padding 6px 10px
Expand Down Expand Up @@ -295,12 +295,12 @@
z-index: 999;
.action {
font-family: PingFang-SC-Medium;
text-decoration:none;
text-decoration:none;
color:#333;
font-size: 13px;
cursor: pointer;
transition: background-color 0.4s ease-in-out;
margin 0
margin 0
line-height: 25px;
padding: 4px 10px;
&:hover {
Expand All @@ -310,7 +310,7 @@
.last {
width 100%
height 10px
margin 0
margin 0
padding 0
background-color: rgba(220, 196, 196, 0.2);
}
Expand All @@ -323,6 +323,7 @@
</style>

<script type="text/ecmascript-6">
import QRCode from 'qrcode'
import BasePage from 'src/extend/BasePage'
import Server from 'src/extend/Server'
const config = require('src/config')
Expand Down Expand Up @@ -393,9 +394,6 @@
return `${config.EDITOR_PATH}?key=${item.key}`
}
},
getqrUrl: function (item) {
return `https://www.liantu.com/api.php?text=${encodeURIComponent(this.getUrl(item, 1))}`
},
// 1启用、2禁用 0删除
changeStatus: function (item) {
var me = this
Expand Down Expand Up @@ -462,6 +460,7 @@
}
}).then((res) => {
this.productList = res.data.data || []
this.setQRUrls(this.productList)
})
},
// 详情
Expand Down Expand Up @@ -510,6 +509,16 @@
}
})
})
},
setQRUrls (productList) {
productList.forEach(item => {
const url = this.getUrl(item, 1)
try {
QRCode.toDataURL(url).then(value => {this.$set(item, 'qrUrl', value)})
} catch (e) {
console.log(e)
}
})
}
}
}
Expand Down
Loading