From 92230c9a97dc9ce9df3313d11d26999c04bb6b26 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 15 七月 2025 13:12:48 +0800
Subject: [PATCH] 项目初始化

---
 src/plugins/modal.ts |   99 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 99 insertions(+), 0 deletions(-)

diff --git a/src/plugins/modal.ts b/src/plugins/modal.ts
new file mode 100644
index 0000000..4a97dd3
--- /dev/null
+++ b/src/plugins/modal.ts
@@ -0,0 +1,99 @@
+export default {
+  /**
+   * 娑堟伅鎻愮ず
+   * @param content 娑堟伅鍐呭
+   */
+  msg(content: string): void {
+    uni.showToast({
+      title: content,
+      icon: 'none'
+    })
+  },
+  /**
+   * 閿欒娑堟伅
+   * @param content 娑堟伅鍐呭
+   */
+  msgError(content: string): void {
+    uni.showToast({
+      title: content,
+      icon: 'error'
+    })
+  },
+  /**
+   * 鎴愬姛娑堟伅
+   * @param content 娑堟伅鍐呭
+   */
+  msgSuccess(content: string): void {
+    uni.showToast({
+      title: content,
+      icon: 'success'
+    })
+  },
+  /**
+   * 闅愯棌娑堟伅
+   */
+  hideMsg(): void {
+    uni.hideToast()
+  },
+  /**
+   * 寮瑰嚭鎻愮ず
+   * @param content 鎻愮ず鍐呭
+   */
+  alert(content: string): void {
+    uni.showModal({
+      title: '鎻愮ず',
+      content: content,
+      showCancel: false
+    })
+  },
+  /**
+   * 纭绐椾綋
+   * @param content 鎻愮ず鍐呭
+   * @returns 
+   */
+  confirm(content: string): Promise<unknown> {
+    return new Promise((resolve: Function, reject: Function) => {
+      uni.showModal({
+        title: '绯荤粺鎻愮ず',
+        content: content,
+        cancelText: '鍙栨秷',
+        confirmText: '纭畾',
+        success: function (res) {
+          if (res.confirm) {
+            resolve(res.confirm)
+          }
+        }
+      })
+    })
+  },
+  /**
+   * 鎻愮ず淇℃伅
+   * @param option 鎻愮ず鍐呭鎴栬�呮彁绀烘閰嶇疆
+   */
+  showToast(option: string | object): void {
+    if (typeof option === "object") {
+      uni.showToast(option)
+    } else {
+      uni.showToast({
+        title: option,
+        icon: "none",
+        duration: 2500
+      })
+    }
+  },
+  /**
+   * 鎵撳紑閬僵灞傦紝闇�瑕佹墜鍔ㄥ叧闂伄缃╁眰
+   * @param content 閬僵灞傚唴瀹�
+   */
+  loading(content: string): void {
+    uni.showLoading({
+      title: content
+    })
+  },
+  /**
+   * 鍏抽棴閬僵灞�
+   */
+  closeLoading(): void {
+    uni.hideLoading()
+  }
+}

--
Gitblit v1.9.3