Skip to content
This repository was archived by the owner on Mar 8, 2021. It is now read-only.
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 public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<title>学生事务系统 - 消息推送</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons.min.css">
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10.12.7/dist/sweetalert2.all.min.js"></script>
</head>
<body style="margin: 0;">
<noscript>
Expand Down
15 changes: 6 additions & 9 deletions src/components/Push.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<v-text-field label="链接文字" outlined v-model="linkText"></v-text-field>
<v-text-field label="链接" outlined v-model="link"></v-text-field>
<v-textarea :error-message="error" label="正文(markdown语法)" v-model="text" outlined auto-grow></v-textarea>
<p>{{ tip }}</p>
<v-btn color="primary" large :disabled="!link || !linkText || !text" :loading="loading" @click="submit">推送</v-btn>
</v-form>
</div>
Expand All @@ -29,12 +28,6 @@ export default {
components: {
Group
},
watch: {
text () { this.tip = this.error = '' },
link () { this.tip = this.error = '' },
group () { this.tip = this.error = '' },
linkText () { this.tip = this.error = ''}
},
methods: {
async submit () {
this.loading = true
Expand All @@ -47,10 +40,14 @@ export default {
}
}, { headers: { token: SS.token } })
.then(() => {
this.tip = '推送已发布'
this.$swal.fire('推送已发布', '', 'success')
})
.catch(err => {
this.error = err.response.data
this.$swal.fire(({
icon: 'error',
title: '错误',
html: `<code>${err.response.data}<code>`
}))
})
this.loading = false
}
Expand Down
4 changes: 4 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ Vue.config.productionTip = false
Vue.prototype.$ajax = axios.create({
baseURL: 'https://sas.aauth.link/'
})
Vue.prototype.$swal = window.Swal
Vue.prototype.$swal.catch = err => {
window.Swal.fire('错误', err.response ? err.response.data : '网络错误', 'error')
}

new Vue({
router,
Expand Down
5 changes: 5 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ const router = new VueRouter({
routes
})

router.beforeEach((to, from, next) => {
window.Swal.close()
next()
})

export default router