重构:全局自定义弹窗系统 window.chatDialog
- 新增 chat/partials/global-dialog.blade.php(全局弹窗 HTML + JS) - 提供 chatDialog.alert() 和 chatDialog.confirm() 两个异步 API - Alpine.js userCardComponent 的 $alert/$confirm 代理到全局 API - toolbar 离开按钮统一改用 chatDialog.confirm(),移除独立 leave-confirm-modal - 支持动态标题颜色、淡入动画,兼容 Chrome/Edge/Firefox
This commit is contained in:
@@ -103,6 +103,10 @@
|
||||
showPositionHistory: false, // 职务履历
|
||||
showAdminPanel: false, // 管理操作(管理操作+职务操作合并)
|
||||
|
||||
// 自定义弹窗:直接代理到全局 window.chatDialog
|
||||
$alert: (...args) => window.chatDialog.alert(...args),
|
||||
$confirm: (...args) => window.chatDialog.confirm(...args),
|
||||
|
||||
/** 获取用户资料 */
|
||||
async fetchUser(username) {
|
||||
try {
|
||||
@@ -176,19 +180,28 @@
|
||||
})
|
||||
});
|
||||
const data = await res.json();
|
||||
alert(data.message);
|
||||
if (data.status === 'success') {
|
||||
const ok = data.status === 'success';
|
||||
this.$alert(
|
||||
data.message,
|
||||
ok ? '任命成功 ✨' : '操作失败',
|
||||
ok ? '#16a34a' : '#cc4444'
|
||||
);
|
||||
if (ok) {
|
||||
this.showUserModal = false;
|
||||
}
|
||||
} catch (e) {
|
||||
alert('网络异常');
|
||||
this.$alert('网络异常,请稍后重试', '错误', '#cc4444');
|
||||
}
|
||||
this.appointLoading = false;
|
||||
},
|
||||
|
||||
/** 快速撤销 */
|
||||
async doRevoke() {
|
||||
if (!confirm('确定要撤销 ' + this.userInfo.username + ' 的职务吗?')) return;
|
||||
const ok = await this.$confirm(
|
||||
'确定要撤销 「' + this.userInfo.username + '」 的职务吗?撤销后将不再拥有相关权限。',
|
||||
'撤销职务'
|
||||
);
|
||||
if (!ok) return;
|
||||
this.appointLoading = true;
|
||||
try {
|
||||
const res = await fetch(window.chatContext.revokeUrl, {
|
||||
@@ -201,12 +214,17 @@
|
||||
})
|
||||
});
|
||||
const data = await res.json();
|
||||
alert(data.message);
|
||||
if (data.status === 'success') {
|
||||
const revOk = data.status === 'success';
|
||||
this.$alert(
|
||||
data.message,
|
||||
revOk ? '撤销成功' : '操作失败',
|
||||
revOk ? '#6b7280' : '#cc4444'
|
||||
);
|
||||
if (revOk) {
|
||||
this.showUserModal = false;
|
||||
}
|
||||
} catch (e) {
|
||||
alert('网络异常');
|
||||
this.$alert('网络异常', '错误', '#cc4444');
|
||||
}
|
||||
this.appointLoading = false;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user