默认允许发送统计信息

This commit is contained in:
marvzhang
2020-02-08 09:32:42 +08:00
parent 1144186816
commit a24058013d
3 changed files with 51 additions and 29 deletions

View File

@@ -35,32 +35,32 @@ export default {
},
methods: {},
async mounted () {
window.setUseStats = (value) => {
document.querySelector('.el-message__closeBtn').click()
if (value === 1) {
this.$st.sendPv('/allow_stats')
this.$st.sendEv('全局', '允许/禁止统计', '允许')
} else {
this.$st.sendPv('/disallow_stats')
this.$st.sendEv('全局', '允许/禁止统计', '禁止')
}
localStorage.setItem('useStats', value)
}
// window.setUseStats = (value) => {
// document.querySelector('.el-message__closeBtn').click()
// if (value === 1) {
// this.$st.sendPv('/allow_stats')
// this.$st.sendEv('全局', '允许/禁止统计', '允许')
// } else {
// this.$st.sendPv('/disallow_stats')
// this.$st.sendEv('全局', '允许/禁止统计', '禁止')
// }
// localStorage.setItem('useStats', value)
// }
// first-time user
if (this.useStats === undefined || this.useStats === null) {
this.$message({
type: 'info',
dangerouslyUseHTMLString: true,
showClose: true,
duration: 0,
message: '<p>' + this.$t('Do you allow us to collect some statistics to improve Crawlab?') + '</p>' +
'<div style="text-align: center;margin-top: 10px;">' +
'<button class="message-btn" onclick="setUseStats(1)">' + this.$t('Yes') + '</button>' +
'<button class="message-btn" onclick="setUseStats(0)">' + this.$t('No') + '</button>' +
'</div>'
})
}
// if (this.useStats === undefined || this.useStats === null) {
// this.$message({
// type: 'info',
// dangerouslyUseHTMLString: true,
// showClose: true,
// duration: 0,
// message: '<p>' + this.$t('Do you allow us to collect some statistics to improve Crawlab?') + '</p>' +
// '<div style="text-align: center;margin-top: 10px;">' +
// '<button class="message-btn" onclick="setUseStats(1)">' + this.$t('Yes') + '</button>' +
// '<button class="message-btn" onclick="setUseStats(0)">' + this.$t('No') + '</button>' +
// '</div>'
// })
// }
// set uid if first visit
if (this.uid === undefined || this.uid === null) {

View File

@@ -380,11 +380,13 @@ export default {
'DingTalk Robot Webhook': '钉钉机器人 Webhook',
'Wechat Robot Webhook': '微信机器人 Webhook',
'Password Settings': '密码设置',
'Notify Settings': '通知设置',
'Notifications': '消息通知',
'Global Variable': '全局变量',
'Add Global Variable': '新增全局变量',
'Are you sure to delete this global variable': '确定删除该全局变量',
'Key': '设置',
'Allow Sending Statistics': '允许发送统计信息',
'General': '通用',
// 其他
tagsView: {

View File

@@ -32,7 +32,7 @@
</el-dialog>
<el-tabs v-model="activeName" @tab-click="tabActiveHandle">
<el-tab-pane :label="$t('Password Settings')" name="password">
<el-tab-pane :label="$t('General')" name="general">
<el-form :model="userInfo" class="setting-form" ref="setting-form" label-width="200px" :rules="rules"
inline-message>
<el-form-item prop="username" :label="$t('Username')">
@@ -41,6 +41,14 @@
<el-form-item prop="password" :label="$t('Password')">
<el-input v-model="userInfo.password" type="password" :placeholder="$t('Password')"></el-input>
</el-form-item>
<el-form-item :label="$t('Allow Sending Statistics')">
<el-switch
v-model="isAllowSendingStatistics"
@change="onAllowSendingStatisticsChange"
active-color="#67C23A"
inactive-color="#909399"
/>
</el-form-item>
<el-form-item>
<div style="text-align: right">
<el-button type="success" size="small" @click="saveUserInfo">
@@ -50,7 +58,7 @@
</el-form-item>
</el-form>
</el-tab-pane>
<el-tab-pane :label="$t('Notify Settings')" name="notify">
<el-tab-pane :label="$t('Notifications')" name="notify">
<el-form :model="userInfo" class="setting-form" ref="setting-form" label-width="200px" :rules="rules"
inline-message>
<el-form-item :label="$t('Notification Trigger Timing')">
@@ -165,7 +173,7 @@ export default {
'setting.wechat_robot_webhook': [{ trigger: 'blur', validator: validateWechatRobotWebhook }]
},
isShowDingTalkAppSecret: false,
activeName: 'password',
activeName: 'general',
addDialogVisible: false,
tourSteps: [
{
@@ -204,7 +212,8 @@ export default {
}
this.$utils.tour.nextStep('setting', currentStep)
}
}
},
isAllowSendingStatistics: localStorage.getItem('useStats') === '1'
}
},
computed: {
@@ -271,6 +280,17 @@ export default {
this.$st.sendEv('设置', '保存')
},
tabActiveHandle () {
},
onAllowSendingStatisticsChange (value) {
if (value) {
this.$st.sendPv('/allow_stats')
this.$st.sendEv('全局', '允许/禁止统计', '允许')
} else {
this.$st.sendPv('/disallow_stats')
this.$st.sendEv('全局', '允许/禁止统计', '禁止')
}
this.$message.success(this.$t('Saved successfully'))
localStorage.setItem('useStats', value ? '1' : '0')
}
},
async created () {