From aed692cffe4373c0f6a821b3d21318a3ed1575e4 Mon Sep 17 00:00:00 2001 From: PhuocNTB Date: Mon, 20 Jul 2026 06:01:51 +0700 Subject: [PATCH] fix push --- client/INSTALL_LINUX.md | 8 +- client/app.go | 98 +++++++++++----------- client/frontend/package-lock.json | 4 +- client/frontend/package.json | 2 +- client/frontend/package.json.md5 | 2 +- client/frontend/src/main.js | 2 +- client/internal/blocker/blocker_darwin.go | 1 + client/internal/blocker/blocker_linux.go | 1 + client/internal/blocker/blocker_windows.go | 1 + client/internal/screen/screen_other.go | 8 +- client/main.go | 2 +- client/wails.json | 2 +- 12 files changed, 67 insertions(+), 64 deletions(-) diff --git a/client/INSTALL_LINUX.md b/client/INSTALL_LINUX.md index ca73cf0..c511bcc 100644 --- a/client/INSTALL_LINUX.md +++ b/client/INSTALL_LINUX.md @@ -46,13 +46,13 @@ cd client chmod +x build.sh ./build.sh ``` -Sau khi build xong, file thực thi sẽ nằm tại: `client/build/bin/simple_care_v1.2` +Sau khi build xong, file thực thi sẽ nằm tại: `client/build/bin/simple_care_v1.3` --- ## 2. Cho Người dùng cuối (End-user - Chỉ chạy ứng dụng) -Người dùng cuối **không cần** cài đặt Go, Node hay trình biên dịch C. Họ chỉ cần tệp thực thi `simple_care_v1.2` và cài đặt các thư viện đồ họa cơ bản của hệ thống: +Người dùng cuối **không cần** cài đặt Go, Node hay trình biên dịch C. Họ chỉ cần tệp thực thi `simple_care_v1.3` và cài đặt các thư viện đồ họa cơ bản của hệ thống: * **Ubuntu / Debian / Linux Mint:** ```bash @@ -73,8 +73,8 @@ Người dùng cuối **không cần** cài đặt Go, Node hay trình biên d ### Lệnh chạy ứng dụng: Cấp quyền chạy cho file và khởi chạy: ```bash -chmod +x simple_care_v1.2 -./simple_care_v1.2 +chmod +x simple_care_v1.3 +./simple_care_v1.3 ``` --- diff --git a/client/app.go b/client/app.go index 8d9a0a6..6f05cb7 100644 --- a/client/app.go +++ b/client/app.go @@ -8,8 +8,8 @@ import ( "crypto/cipher" "crypto/rand" "crypto/sha256" - "encoding/json" "encoding/base64" + "encoding/json" "errors" "fmt" "html" @@ -59,7 +59,7 @@ func getWsUrl(apiBase string) string { return "ws://" + apiBase } -var wifiReportLast sync.Map // ssidKey -> time.Time +var wifiReportLast sync.Map // ssidKey -> time.Time func getDynamicEncryptionKey() []byte { base := "simple-care-proctor-secretkey32!" @@ -120,45 +120,45 @@ type StudentData struct { } type App struct { - ctx context.Context - student *StudentData - mu sync.Mutex - sessionPath string - statsPath string - webviewDataPath string - pendingViolPath string - runLockPath string - wsConn *websocket.Conn - wsConnected bool - wsConnecting bool - wsBackoff time.Duration - wsWriteMu sync.Mutex - wifiSSID string - wifiBSSID string - allowedApps string - onlineSecs int - offlineSecs int - unsyncedOn int - unsyncedOff int - lastSyncTime time.Time - isStreamingSc bool - streamScStop chan struct{} - isStreamingCam bool - streamCamStop chan struct{} + ctx context.Context + student *StudentData + mu sync.Mutex + sessionPath string + statsPath string + webviewDataPath string + pendingViolPath string + runLockPath string + wsConn *websocket.Conn + wsConnected bool + wsConnecting bool + wsBackoff time.Duration + wsWriteMu sync.Mutex + wifiSSID string + wifiBSSID string + allowedApps string + onlineSecs int + offlineSecs int + unsyncedOn int + unsyncedOff int + lastSyncTime time.Time + isStreamingSc bool + streamScStop chan struct{} + isStreamingCam bool + streamCamStop chan struct{} statusMsg string expectingLogin bool needsClearPortalStorage bool backendOnline bool - dashboard StudentDashboardSnapshot - wifiEnforce bool - acceptedWifi map[string]bool - wifiRejected bool - quitDialogShown bool - monitoringTornDown bool - localBrowserActive bool // trình duyệt local — chỉ cho phép localhost - chatUnread int - replyStaffID uint - fetchAppsMu sync.Mutex + dashboard StudentDashboardSnapshot + wifiEnforce bool + acceptedWifi map[string]bool + wifiRejected bool + quitDialogShown bool + monitoringTornDown bool + localBrowserActive bool // trình duyệt local — chỉ cho phép localhost + chatUnread int + replyStaffID uint + fetchAppsMu sync.Mutex } type LocalStats struct { @@ -219,13 +219,13 @@ func NewApp() *App { _ = os.MkdirAll(webviewDir, 0755) return &App{ - sessionPath: filepath.Join(appDir, "student_session.json"), - statsPath: filepath.Join(appDir, "student_stats.json"), - webviewDataPath: webviewDir, - pendingViolPath: filepath.Join(appDir, "pending_violations.json"), - runLockPath: filepath.Join(appDir, "monitoring.lock"), - lastSyncTime: time.Now(), - expectingLogin: false, + sessionPath: filepath.Join(appDir, "student_session.json"), + statsPath: filepath.Join(appDir, "student_stats.json"), + webviewDataPath: webviewDir, + pendingViolPath: filepath.Join(appDir, "pending_violations.json"), + runLockPath: filepath.Join(appDir, "monitoring.lock"), + lastSyncTime: time.Now(), + expectingLogin: false, } } @@ -1473,12 +1473,12 @@ func (a *App) fetchAllowedApps(classId int64) { reason = "Không đáp ứng điều kiện học tập (chưa cấu hình ứng dụng được phép hoặc ngoài giờ học)." } log.Printf("[CLIENT] Conditions not met: %s. Blocker suspended.", reason) - + a.mu.Lock() a.allowedApps = "" a.statusMsg = reason a.mu.Unlock() - + blocker.Instance.Stop() return } @@ -1490,7 +1490,7 @@ func (a *App) fetchAllowedApps(classId int64) { a.statusMsg = "Đang trong giờ học" } a.mu.Unlock() - + log.Printf("[CLIENT] Allowed apps fetched from server: %s", res.Keywords) blocker.Instance.SetKeywords(res.Keywords) blocker.Instance.Start() @@ -2401,7 +2401,7 @@ func (a *App) DownloadExamResource(fileID uint) (string, error) { // LoadExamViewFile tải file đề/tài nguyên qua Go (không mở URL trực tiếp trong WebView). func (a *App) LoadExamViewFile(fileURL string) (map[string]any, error) { fileURL = strings.TrimSpace(fileURL) - if !strings.HasPrefix(fileURL, API_BASE + "/api/student/exam/download") { + if !strings.HasPrefix(fileURL, API_BASE+"/api/student/exam/download") { return nil, errors.New("URL không hợp lệ") } if _, _, err := a.examStudentContext(); err != nil { @@ -2477,7 +2477,7 @@ func (a *App) SubmitExamWork() (string, error) { } _ = w.Close() - req, err := http.NewRequest("POST", API_BASE + "/api/student/exam/submit", &body) + req, err := http.NewRequest("POST", API_BASE+"/api/student/exam/submit", &body) if err != nil { return "", err } diff --git a/client/frontend/package-lock.json b/client/frontend/package-lock.json index bee0857..5df92cb 100644 --- a/client/frontend/package-lock.json +++ b/client/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "frontend", - "version": "1.2.0", + "version": "1.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "frontend", - "version": "1.2.0", + "version": "1.3.0", "dependencies": { "pdfjs-dist": "^3.11.174" }, diff --git a/client/frontend/package.json b/client/frontend/package.json index 2eb20ba..a08408c 100644 --- a/client/frontend/package.json +++ b/client/frontend/package.json @@ -1,7 +1,7 @@ { "name": "frontend", "private": true, - "version": "1.2.0", + "version": "1.3.0", "scripts": { "dev": "vite", "build": "vite build", diff --git a/client/frontend/package.json.md5 b/client/frontend/package.json.md5 index be93c51..3d9c48e 100644 --- a/client/frontend/package.json.md5 +++ b/client/frontend/package.json.md5 @@ -1 +1 @@ -06a16f2c007333cdf273a92d4914c63b \ No newline at end of file +792441f7861d7badf1335f3778fcdebd \ No newline at end of file diff --git a/client/frontend/src/main.js b/client/frontend/src/main.js index 7dd2a17..1fc3adb 100644 --- a/client/frontend/src/main.js +++ b/client/frontend/src/main.js @@ -19,7 +19,7 @@ if (typeof window.go.main.App === 'undefined') { } const brandLogoHtml = `Simple Care`; -const APP_VERSION = '1.2'; +const APP_VERSION = '1.3'; // Trạng thái cục bộ let loggedIn = false; diff --git a/client/internal/blocker/blocker_darwin.go b/client/internal/blocker/blocker_darwin.go index a4e8413..e4290fe 100644 --- a/client/internal/blocker/blocker_darwin.go +++ b/client/internal/blocker/blocker_darwin.go @@ -173,6 +173,7 @@ var systemAllowed = map[string]bool{ "simple_care_v1.0": true, "simple_care_v1.1": true, "simple_care_v1.2": true, + "simple_care_v1.3": true, "simple_care": true, "wails": true, "code": true, // VSCode diff --git a/client/internal/blocker/blocker_linux.go b/client/internal/blocker/blocker_linux.go index 8ee84bf..12f007c 100644 --- a/client/internal/blocker/blocker_linux.go +++ b/client/internal/blocker/blocker_linux.go @@ -238,6 +238,7 @@ var systemAllowed = map[string]bool{ "simple_care_v1.0": true, "simple_care_v1.1": true, "simple_care_v1.2": true, + "simple_care_v1.3": true, "simple_care": true, } diff --git a/client/internal/blocker/blocker_windows.go b/client/internal/blocker/blocker_windows.go index 06c70ca..aae08da 100644 --- a/client/internal/blocker/blocker_windows.go +++ b/client/internal/blocker/blocker_windows.go @@ -331,6 +331,7 @@ var systemAllowed = map[string]bool{ "simple_care_v1.0.exe": true, "simple_care_v1.1.exe": true, "simple_care_v1.2.exe": true, + "simple_care_v1.3.exe": true, "simple_care.exe": true, "wails.exe": true, "msedgewebview2.exe": true, // WebView2 runtime (Wails renderer) diff --git a/client/internal/screen/screen_other.go b/client/internal/screen/screen_other.go index 8f3a1e4..b103208 100644 --- a/client/internal/screen/screen_other.go +++ b/client/internal/screen/screen_other.go @@ -22,13 +22,13 @@ func resizeRGBA(src *image.RGBA, width, height int) *image.RGBA { minY := srcBounds.Min.Y for y := 0; y < height; y++ { - srcY := minY + (y * dy) / height + srcY := minY + (y*dy)/height for x := 0; x < width; x++ { - srcX := minX + (x * dx) / width - + srcX := minX + (x*dx)/width + srcOffset := src.PixOffset(srcX, srcY) dstOffset := dst.PixOffset(x, y) - + copy(dst.Pix[dstOffset:dstOffset+4], src.Pix[srcOffset:srcOffset+4]) } } diff --git a/client/main.go b/client/main.go index a76ff85..851b346 100644 --- a/client/main.go +++ b/client/main.go @@ -62,7 +62,7 @@ func main() { // Create application with options err := wails.Run(&options.App{ - Title: "Simple Care v1.2 — Rikkei Education", + Title: "Simple Care v1.3 — Rikkei Education", Width: 1024, Height: 768, Menu: appMenu, diff --git a/client/wails.json b/client/wails.json index a1b8d1a..279699c 100644 --- a/client/wails.json +++ b/client/wails.json @@ -1,7 +1,7 @@ { "$schema": "https://wails.io/schemas/config.v2.json", "name": "Simple Care by Rikkei Edu", - "outputfilename": "simple_care_v1.2", + "outputfilename": "simple_care_v1.3", "frontend:install": "npm install", "frontend:build": "npm run build", "frontend:dev:watcher": "npm run dev",