Skip to content

Commit

Permalink
chore: update swal
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehco1996 committed Aug 28, 2024
1 parent d5ae762 commit b2a7976
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion apps/sspanel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ def send_first_visit_msg(cls, request):
if not anno or request.session.get("first_visit"):
return
request.session["first_visit"] = True
messages.warning(request, anno.plain_text, extra_tags="最新通知!")
messages.warning(request, anno.body, extra_tags="最新通知!")


class Ticket(models.Model):
Expand Down
8 changes: 7 additions & 1 deletion templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,13 @@ <h1 class="subtitle">{% settings_value "SITE_SUBTITLE" %}</h1>
<!--整站消息提醒功能 -->
{% if messages %}
<script>
{% for message in messages %}swal("{{ message.extra_tags }}", '{{ message }}', '{{ message.level_tag }}');
{% for message in messages %}
Swal.fire({
title: "{{ message.extra_tags|escapejs }}",
html: '{{ message|safe|escapejs }}',
icon: '{{ message.level_tag }}',
confirmButtonText: 'OK'
});
{% endfor %}
</script>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion templates/basehead.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
{% endif %}
<!-- js -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/sweetalert.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="{% static 'sspanel/js/sspanel.js' %}"></script>
{% if not simple_extra_static or user.is_authenticated %}
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/clipboard.min.js"></script>
Expand Down
10 changes: 5 additions & 5 deletions templates/web/charge_center.html
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ <h2 class="subtitle">捐赠的钱会自动打进你的账号余额....</h2>
requestButton.attr("disabled", "disabled")
$.post(url, data, function(results) {
info = results.info
swal(info.title, info.subtitle, info.status)
Swal.fire(info.title, info.subtitle, info.status)
if (info.status == "success") {
// 追加二维码图片
codeBox.attr('class', '')
Expand All @@ -185,7 +185,7 @@ <h2 class="subtitle">捐赠的钱会自动打进你的账号余额....</h2>
}
})
} else {
swal('抱歉~', '最少捐赠一元', 'error')
Swal.fire('抱歉~', '最少捐赠一元', 'error')
}
}
requestButton.click(payrequest)
Expand All @@ -195,18 +195,18 @@ <h2 class="subtitle">捐赠的钱会自动打进你的账号余额....</h2>
$.getJSON(url, function(results) {
info = results.info;
if (byTicker == false) {
swal(info.title, info.subtitle, info.status);
Swal.fire(info.title, info.subtitle, info.status);
} else {
repetitionCount++;
if (repetitionCount >= maxRepetitions) {
clearInterval(queryTimer);
swal("自动查询超时", "请点击按钮手动查询", "error");
Swal.fire("自动查询超时", "请点击按钮手动查询", "error");
}
// only show msg when success
if (info.status == "success") {
// 停止定时器
clearInterval(queryTimer);
swal(info.title, info.subtitle, info.status);
Swal.fire(info.title, info.subtitle, info.status);
} else {
console.log("repetitionCount", repetitionCount)
console.log("api return", info)
Expand Down
2 changes: 1 addition & 1 deletion templates/web/shop.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ <h2 class="subtitle">还没有买过东西呢....</h2>
}
url = "{% url 'api:purchase' %}"
$.post(url, data, function(results) {
swal(results.title, results.subtitle, results.status)
Swal.fire(results.title, results.subtitle, results.status)
})
})
</script>
Expand Down
14 changes: 7 additions & 7 deletions templates/web/user_info.html
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ <h2 class="subtitle">根据您的客户端一键选择</h2>
}
$.post(url, data, function(results) {
info = results
swal(info.title, info.subtitle, info.status).then(function() {
Swal.fire(info.title, info.subtitle, info.status).then(function() {
location.reload();
})
})
Expand All @@ -320,12 +320,12 @@ <h2 class="subtitle">根据您的客户端一键选择</h2>
url = "{% url 'api:change_theme' %}"
$.post(url, data, function(results) {
info = results
swal(info.title, info.subtitle, info.status).then(function() {
Swal.fire(info.title, info.subtitle, info.status).then(function() {
location.reload();
})
})
} else {
swal('错误!', '请选择你要更换的主题', 'error')
Swal.fire('错误!', '请选择你要更换的主题', 'error')
}
}
ThemeButton.click(changeTheme)
Expand All @@ -341,10 +341,10 @@ <h2 class="subtitle">根据您的客户端一键选择</h2>
url = "{% url 'api:user_settings' %}"
$.post(url, data, function(results) {
info = results
swal(info.title, info.subtitle, info.status)
Swal.fire(info.title, info.subtitle, info.status)
})
} else {
swal('错误!', '请输入密码', 'error')
Swal.fire('错误!', '请输入密码', 'error')
}
}
PasswordButton.click(changePassword)
Expand Down Expand Up @@ -373,7 +373,7 @@ <h2 class="subtitle">根据您的客户端一键选择</h2>
// 复制订阅地址
var clip = new Clipboard('#id-button-clip');
clip.on('success', function(e) {
swal("复制成功", "订阅地址已复制到剪贴板", "success");
Swal.fire("复制成功", "订阅地址已复制到剪贴板", "success");
});

// 重置订阅连接
Expand All @@ -385,7 +385,7 @@ <h2 class="subtitle">根据您的客户端一键选择</h2>
}
$.post(url, data, function(results) {
info = results
swal(info.title, info.subtitle, info.status).then(function() {
Swal.fire(info.title, info.subtitle, info.status).then(function() {
location.reload();
})
})
Expand Down

0 comments on commit b2a7976

Please sign in to comment.