jinnrry 1 жил өмнө
parent
commit
49de86fd75

+ 4 - 0
fe/src/main.js

@@ -5,7 +5,11 @@ import { createPinia } from 'pinia'
 import App from './App.vue'
 import {router} from './router'
 
+import ElementPlus from 'element-plus'
+import 'element-plus/dist/index.css'
+
 const app = createApp(App)
 app.use(router)
 app.use(createPinia())
+app.use(ElementPlus) 
 app.mount('#app')

+ 63 - 46
fe/src/views/ListView.vue

@@ -19,35 +19,35 @@
         <template #dropdown>
           <el-dropdown-menu>
             <el-dropdown-item @click="move(group.id)" v-for="group in groupList" :key="group.id">{{
-                group.name
-              }}
+              group.name
+            }}
             </el-dropdown-item>
           </el-dropdown-menu>
         </template>
       </el-dropdown>
     </div>
     <div id="table">
-      <el-table ref="taskTableDataRef" :data="data" :show-header="true"
-                :border="false" @row-click="rowClick" :row-style="rowStyle">
-        <el-table-column type="selection" width="30"/>
+      <el-table ref="taskTableDataRef" :data="data" :show-header="true" :border="false" @row-click="rowClick"
+        :row-style="rowStyle">
+        <el-table-column type="selection" width="30" />
         <el-table-column prop="is_read" label="" width="50">
           <template #default="scope">
             <div>
-                            <span v-if="!scope.row.is_read">
-                                {{ lang.new }}
-                            </span>
+              <span v-if="!scope.row.is_read">
+                {{ lang.new }}
+              </span>
               <span style="font-weight: 900;color: #FF0000;" v-if="scope.row.dangerous">
-                                <el-tooltip effect="dark" :content="lang.dangerous" placement="top-start">
-                                    !
-                                </el-tooltip>
+                <el-tooltip effect="dark" :content="lang.dangerous" placement="top-start">
+                  !
+                </el-tooltip>
 
-                            </span>
+              </span>
               <span style="font-weight: 900;color: #FF0000;" v-if="scope.row.error !== ''">
-                                <el-tooltip effect="dark" :content="scope.row.error" placement="top-start">
-                                    !
-                                </el-tooltip>
+                <el-tooltip effect="dark" :content="scope.row.error" placement="top-start">
+                  !
+                </el-tooltip>
 
-                            </span>
+              </span>
             </div>
           </template>
         </el-table-column>
@@ -63,8 +63,8 @@
 
         <el-table-column prop="title" :label="lang.to" width="150">
           <template #default="scope">
-            <el-tooltip v-for="toInfo in scope.row.to" :key="toInfo" class="box-item" effect="dark" :content="toInfo.EmailAddress"
-                        placement="top">
+            <el-tooltip v-for="toInfo in scope.row.to" :key="toInfo" class="box-item" effect="dark"
+              :content="toInfo.EmailAddress" placement="top">
               <el-tag size="small" type="info">{{ toInfo.Name !== '' ? toInfo.Name : toInfo.EmailAddress }}</el-tag>
             </el-tooltip>
           </template>
@@ -88,7 +88,7 @@
       </el-table>
     </div>
     <div id="pagination">
-      <el-pagination background layout="prev, pager, next" :page-count="totalPage" @current-change="pageChange"/>
+      <el-pagination background layout="prev, pager, next" :page-count="totalPage" @current-change="pageChange" />
     </div>
   </div>
 </template>
@@ -96,13 +96,13 @@
 
 <script setup>
 
-import {EpArrowDownBold} from "vue-icons-plus/ep";
-import {RouterLink, useRouter} from 'vue-router'
-import {ref, watch} from 'vue'
+import { EpArrowDownBold } from "vue-icons-plus/ep";
+import { RouterLink, useRouter } from 'vue-router'
+import { ref, watch } from 'vue'
 import useGroupStore from '../stores/group'
 import lang from '../i18n/i18n';
-import {http} from "@/utils/axios";
-import {ElMessage, ElMessageBox} from "element-plus";
+import { http } from "@/utils/axios";
+import { ElMessage, ElMessageBox } from "element-plus";
 
 
 const router = useRouter();
@@ -122,7 +122,7 @@ watch(groupStore, async (newV) => {
     tag = '{"type":0,"status":-1}'
   }
   data.value = []
-  http.post("/api/email/list", {tag: tag, page_size: 10}).then(res => {
+  http.post("/api/email/list", { tag: tag, page_size: 10 }).then(res => {
     data.value = res.data.list
     totalPage.value = res.data.total_page
   })
@@ -133,7 +133,7 @@ const data = ref([])
 const totalPage = ref(0)
 
 const updateList = function () {
-  http.post("/api/email/list", {tag: tag, page_size: 10}).then(res => {
+  http.post("/api/email/list", { tag: tag, page_size: 10 }).then(res => {
     data.value = res.data.list
     totalPage.value = res.data.total_page
   })
@@ -158,17 +158,22 @@ const markRead = function () {
   rows.forEach(element => {
     ids.push(element.id)
   });
-
-  http.post("/api/email/read", {"ids": ids}).then(res => {
-    if (res.errorNo === 0) {
-      updateList()
-    } else {
-      ElMessage({
-        type: 'error',
-        message: res.errorMsg,
-      })
-    }
-  })
+  if (ids.length == 0) {
+    ElMessageBox.alert('Unselected content', 'Notice', {
+      confirmButtonText: 'OK',
+    })
+  } else {
+    http.post("/api/email/read", { "ids": ids }).then(res => {
+      if (res.errorNo === 0) {
+        updateList()
+      } else {
+        ElMessage({
+          type: 'error',
+          message: res.errorMsg,
+        })
+      }
+    })
+  }
 }
 
 
@@ -179,7 +184,13 @@ const move = function (group_id) {
     ids.push(element.id)
   });
 
-  ElMessageBox.confirm(
+
+  if (ids.length == 0) {
+    ElMessageBox.alert('Unselected content', 'Notice', {
+      confirmButtonText: 'OK',
+    })
+  } else {
+    ElMessageBox.confirm(
       lang.move_email_confirm,
       'Warning',
       {
@@ -187,9 +198,9 @@ const move = function (group_id) {
         cancelButtonText: 'Cancel',
         type: 'warning',
       }
-  )
+    )
       .then(() => {
-        http.post("/api/email/move", {"group_id": group_id, "ids": ids}).then(res => {
+        http.post("/api/email/move", { "group_id": group_id, "ids": ids }).then(res => {
           if (res.errorNo === 0) {
             updateList()
             ElMessage({
@@ -206,6 +217,7 @@ const move = function (group_id) {
 
 
       })
+  }
 }
 
 
@@ -217,9 +229,13 @@ const del = function () {
   });
 
   let groupTag = JSON.parse(tag)
+  if (ids.length == 0) {
+    ElMessageBox.alert('Unselected content', 'Notice', {
+      confirmButtonText: 'OK',
+    })
+  } else {
 
-
-  ElMessageBox.confirm(
+    ElMessageBox.confirm(
       lang.del_email_confirm,
       'Warning',
       {
@@ -227,9 +243,9 @@ const del = function () {
         cancelButtonText: 'Cancel',
         type: 'warning',
       }
-  )
+    )
       .then(() => {
-        http.post("/api/email/del", {"ids": ids, "forcedDel": groupTag.status === 3}).then(res => {
+        http.post("/api/email/del", { "ids": ids, "forcedDel": groupTag.status === 3 }).then(res => {
           if (res.errorNo === 0) {
             updateList()
             ElMessage({
@@ -246,15 +262,16 @@ const del = function () {
 
 
       })
+  }
 }
 
 
 const rowStyle = function () {
-  return {'cursor': 'pointer'}
+  return { 'cursor': 'pointer' }
 }
 
 const pageChange = function (p) {
-  http.post("/api/email/list", {tag: tag, page_size: 10, current_page: p}).then(res => {
+  http.post("/api/email/list", { tag: tag, page_size: 10, current_page: p }).then(res => {
     data.value = res.data.list
   })
 }

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 373 - 382
fe/yarn.lock


+ 2 - 0
server/db/init.go

@@ -10,6 +10,7 @@ import (
 	_ "github.com/lib/pq"
 	log "github.com/sirupsen/logrus"
 	_ "modernc.org/sqlite"
+	"time"
 	"xorm.io/xorm"
 )
 
@@ -40,6 +41,7 @@ func Init(version string) error {
 		return errors.Wrap(err)
 	}
 
+	Instance.SetConnMaxLifetime(30 * time.Minute)
 	Instance.ShowSQL(false)
 	// 同步表结构
 	syncTables()

+ 1 - 1
server/hooks/spam_block/spam_block.go

@@ -188,7 +188,7 @@ func NewSpamBlockHook() *SpamBlock {
 	}
 
 	if pluginConfig.Threshold == 0 {
-		pluginConfig.Threshold = 80
+		pluginConfig.Threshold = 20
 	}
 
 	hc := &http.Client{

+ 1 - 1
server/services/list/list.go

@@ -50,7 +50,7 @@ func genSQL(ctx *context.Context, count bool, tagInfo dto.SearchTag, keyword str
 	if tagInfo.Status != -1 {
 		sql += " and ue.status =? "
 		sqlParams = append(sqlParams, tagInfo.Status)
-	} else if tagInfo.GroupId == -1 {
+	} else {
 		sql += " and ue.status != 3"
 	}
 

+ 17 - 13
server/services/rule/match/base.go

@@ -1,7 +1,6 @@
 package match
 
 import (
-	"encoding/json"
 	"github.com/Jinnrry/pmail/dto/parsemail"
 	"github.com/Jinnrry/pmail/utils/context"
 )
@@ -16,32 +15,37 @@ type Match interface {
 	Match(ctx *context.Context, email *parsemail.Email) bool
 }
 
+func buildUsers(users []*parsemail.User) string {
+	ret := ""
+	for i, u := range users {
+		if i != 0 {
+			ret += ","
+		}
+		ret += u.EmailAddress
+	}
+	return ret
+}
+
 func getFieldContent(field string, email *parsemail.Email) string {
 	switch field {
 	case "ReplyTo":
-		b, _ := json.Marshal(email.ReplyTo)
-		return string(b)
+		return buildUsers(email.ReplyTo)
 	case "From":
-		b, _ := json.Marshal(email.From)
-		return string(b)
+		return email.From.EmailAddress
 	case "Subject":
 		return email.Subject
 	case "To":
-		b, _ := json.Marshal(email.To)
-		return string(b)
+		return buildUsers(email.To)
 	case "Bcc":
-		b, _ := json.Marshal(email.Bcc)
-		return string(b)
+		return buildUsers(email.Bcc)
 	case "Cc":
-		b, _ := json.Marshal(email.Cc)
-		return string(b)
+		return buildUsers(email.Cc)
 	case "Text":
 		return string(email.Text)
 	case "Html":
 		return string(email.HTML)
 	case "Sender":
-		b, _ := json.Marshal(email.Sender)
-		return string(b)
+		return email.Sender.EmailAddress
 	case "Content":
 		b := string(email.HTML)
 		b2 := string(email.Text)

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно