Compare commits
18 Commits
main
...
a7e569d9b4
| Author | SHA1 | Date | |
|---|---|---|---|
| a7e569d9b4 | |||
| 3bc7c8a160 | |||
| 9fae6afaac | |||
| 614054f35d | |||
| 796487ef76 | |||
| 813b41933b | |||
| 59153cffc2 | |||
| 4ee46371fa | |||
| 400a3d098d | |||
| 5f49070a98 | |||
| accda67b22 | |||
| fee2aed2e6 | |||
| ee42bfcefa | |||
| b5b6082d26 | |||
| d8bbb22dbd | |||
| 4da00b222f | |||
| cfb97d976f | |||
| 6d90a47c24 |
@@ -0,0 +1,14 @@
|
||||
DATABASE_URL="postgresql://postgres:password@localhost:5432/travel_db?schema=public"
|
||||
PORT=3001
|
||||
REDIS_URL=redis://localhost:6379
|
||||
SMTP_HOST=smtp.gmail.com
|
||||
SMTP_PORT=587
|
||||
SMTP_SECURE=false
|
||||
SMTP_USER=yotripadmin@gmail.com
|
||||
SMTP_PASS="ahhh suif kfcp waie"
|
||||
GOOGLE_CLIENT_ID=639044397050-7hair384u6lle941h033trut1s3q47l4.apps.googleusercontent.com
|
||||
FRONTEND_URL=https://yotrip.labz.io.vn
|
||||
ADMIN_SECRET_KEY=Yotrip@Bitabub1
|
||||
# Development: Backend URL for vite dev server proxy (only used with npm run dev)
|
||||
# For production: Nginx handles proxying, this is not used
|
||||
VITE_BACKEND_URL=http://localhost:3001
|
||||
@@ -1,4 +1,3 @@
|
||||
.env
|
||||
node_modules
|
||||
server/dist
|
||||
dist
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
# To AI Agent: Fix Mobile Dropdown Layout Displacement and Eliminate `.filter is not a function` Runtime Crashes
|
||||
|
||||
## 1. Bug Analysis & Context
|
||||
We are resolving three critical layout and runtime bugs observed during Android Simulator testing (`image.png`):
|
||||
|
||||
1. **Dropdown Menu Displacement:** The menu drawer/dropdown container is losing its absolute coordinate anchor pool. Instead of floating gracefully on top of the map layer as a neat dropdown card, it wraps below the viewport grid, conflicting with the lower navigation action buttons ("Khám phá", "Chụp ảnh") and community photo streams.
|
||||
2. **`g.filter is not a function` (Friends List Crash):** Triggering the Friend List components crashes the UI thread into a White Screen of Death (WSoD).
|
||||
3. **`Error fetching connections: TypeError: ...filter is not a function` (LiveChat Crash):** Opening the Live Chat view displays the exact same array mutation failure.
|
||||
- *Root Cause for 2 & 3:* The asynchronous API network response payload or socket stream data returned from the server backend is **not a clean Array structure**. It is likely either wrapped inside an object wrapper (e.g., `{ success: true, friends: [] }`) or returns `null`/`undefined` due to network delays. Invoking `.filter()` directly on a non-array object instantly freezes the React rendering lifecycle.
|
||||
|
||||
---
|
||||
|
||||
## 2. Refactoring Strategy
|
||||
|
||||
### 2.1. Fix Dropdown Layout Context for Mobile/Android Viewports
|
||||
On mobile viewports, traditional hover/click absolute dropdown boxes overflow or clip out. We must force the dropdown menu container inside `MapProfileDropdown.tsx` to act as a structured **Sticky Floating Overlay** or a dedicated **Mobile Bottom-Sheet Box** with a precise `z-index`.
|
||||
|
||||
### 2.2. Implement Defensive Array Architecture (Fix Crashes 2 & 3)
|
||||
We must implement a protective array fallback guard across all data mapping blocks (`friends.filter`, `connections.filter`) using **`Array.isArray()`** validation, coupled with unified error boundaries.
|
||||
|
||||
---
|
||||
|
||||
## 3. Code Refactoring Blueprint
|
||||
|
||||
### Step 1: Overhaul Dropdown Styling for Mobile Boundaries (`MapProfileDropdown.tsx`)
|
||||
Ensure the menu card isolates itself perfectly above the underlying view map layout and handles sizing dimensions cleanly:
|
||||
|
||||
```jsx
|
||||
{/* ✅ RESPONSIVE FIX: Mobile-optimized absolute floating panel structure */}
|
||||
<div
|
||||
className="absolute right-0 top-14 w-[280px] bg-slate-900/95 backdrop-blur-md border border-slate-800 rounded-2xl p-2 shadow-2xl flex flex-col space-y-0.5 text-xs text-slate-200 z-[999999]"
|
||||
style={{
|
||||
/* Tight mobile screen safety rails layout positioning guards */
|
||||
maxHeight: '80vh',
|
||||
overflowY: 'auto',
|
||||
boxShadow: '0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.5)'
|
||||
}}
|
||||
>
|
||||
{/* Menu list rows (Tạo tour, Hành trình, Thư viện ảnh...) populate cleanly here */}
|
||||
<button className="flex items-center gap-3 w-full px-4 py-3 hover:bg-slate-800/80 rounded-xl text-left">...</button>
|
||||
</div>
|
||||
|
||||
### Step 2: Fix Friend List Array Mutation Crash (FriendsManagerModal.tsx)
|
||||
Locate where the backend data hook is consumed. Inject an explicit defensive array verification check:
|
||||
|
||||
// ❌ OLD CRASH-PRONE CODE:
|
||||
// const activeFriends = data.filter(f => f.status === 'active');
|
||||
|
||||
// ✅ NEW DEFENSIVE RAY WRAPPER:
|
||||
const [friendsList, setFriendsList] = useState<any[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
api.get('/friends/connections')
|
||||
.then((res) => {
|
||||
// Deconstruct and verify input type carefully before committing to state
|
||||
const rawPayload = res.data;
|
||||
|
||||
if (rawPayload && Array.isArray(rawPayload)) {
|
||||
setFriendsList(rawPayload);
|
||||
} else if (rawPayload && Array.isArray(rawPayload.data)) {
|
||||
setFriendsList(rawPayload.data); // Fallback unpacker matching nested API responses
|
||||
} else {
|
||||
console.error("⚠️ Expected array structure but received:", rawPayload);
|
||||
setFriendsList([]); // Secure fallback to empty array initialization to protect .filter loops
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error("Failed to compile connections list stream safely:", err);
|
||||
setFriendsList([]); // Fallback safety initialization
|
||||
});
|
||||
}, []);
|
||||
|
||||
// Secure conditional processing guard rail
|
||||
const activeFriends = Array.isArray(friendsList)
|
||||
? friendsList.filter((f: any) => f && f.status === 'active')
|
||||
: [];
|
||||
|
||||
### Step 3: Fix Live Chat Connections Filtering Failure (LiveChatModal.tsx)
|
||||
Locate the data fetcher inside your real-time socket listener or chat state parser module and re-engineer it with identical fallback shields:
|
||||
|
||||
const fetchUserConnections = async () => {
|
||||
try {
|
||||
const response = await api.get('/chat/connections');
|
||||
const resultData = response.data;
|
||||
|
||||
// Direct defensive validation shield check
|
||||
const verifiedConnectionsArray = Array.isArray(resultData)
|
||||
? resultData
|
||||
: (resultData && Array.isArray(resultData.connections) ? resultData.connections : []);
|
||||
|
||||
/* ✅ CRITICAL FIX: Running .filter on verified guaranteed array structure only */
|
||||
const onlineConnections = verifiedConnectionsArray.filter((conn: any) => conn && conn.isOnline === true);
|
||||
|
||||
setConnections(verifiedConnectionsArray);
|
||||
|
||||
} catch (error) {
|
||||
console.error("[LiveChatModal] Error fetching connections cleanly:", error);
|
||||
setConnections([]); // Force secure array context initialization on intercepting crash exceptions
|
||||
}
|
||||
};
|
||||
|
||||
## 4. Verification & Quality Acceptance Criteria for AI Agent
|
||||
[ ] Dropdown Layout Verification: Open the avatar menu on the Android Simulator. The profile dropdown modal panel must lock floating positions right below the top header profile cluster, without displacing the community images ribbon or bleeding into the screen bottom.
|
||||
|
||||
[ ] WSoD Prevention Validation: Simulate an empty or broken server endpoint response (500 or blank text). Confirm that the component prints the error safely to the console tracker log while the screen continues to render placeholder empty-states beautifully without turning into a white void.
|
||||
|
||||
[ ] Array Guard Robustness: Run a global textual scan over modified view sheets. Confirm all custom list operations on fetched database schemas verify array validity using Array.isArray() wrappers prior to calling processing filters.
|
||||
@@ -1,126 +0,0 @@
|
||||
# To AI Agent: Implement Smart Date-Based Accordion Auto-Expansion and Smooth Viewport Auto-Scroll
|
||||
|
||||
## 1. Context & UI/UX Requirements
|
||||
We are enhancing the routing UX between `MemberDashboard.tsx` and `ItineraryTimeline.tsx` based on `image_cc31a4.png`.
|
||||
|
||||
### Functional Specifications:
|
||||
1. **Date-Matching Evaluation:** When a user clicks "Chi tiết hành trình" on a tour card, calculate if the current user system local date falls inside any Stage/Leg timeline block.
|
||||
2. **Auto-Expansion State:** On timeline page load, the matched Leg accordion must be expanded by default (`expandedStageId === leg.id`).
|
||||
3. **Smart Auto-Scroll Layout:** The viewport must smoothly auto-scroll so that the expanded Leg's title bar lands **exactly below the sticky navigation tab bar** ("Lộ trình", "Chi phí", etc.), making it fully visible at the top of the viewport without layout clipping.
|
||||
|
||||
---
|
||||
|
||||
## 2. Technical Architecture & Layout Constraints
|
||||
|
||||
- **The Sticky Header Challenge:** Since the top navigation tab bar uses sticky/fixed positioning, a naive `scrollIntoView({ block: 'start' })` will cause the Leg's title to crawl *underneath* the tabs, hiding it.
|
||||
- **The Solution:** We will inject a dynamic CSS scroll-margin-top parameter (`scroll-mt-[70px]` or matching header height) on each Leg container, and trigger a minor delayed layout effect pool using a React `setTimeout` to wait for the DOM accordion expansion reflow before pulling the scroll trigger.
|
||||
|
||||
---
|
||||
|
||||
## 3. Code Refactoring Blueprint
|
||||
|
||||
### Step 1: Update Navigation Payload Handler in Dashboard Component
|
||||
Ensure the `MemberDashboard.tsx` accurately packages the matched target identifier into the client route state bucket:
|
||||
|
||||
```typescript
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
const navigate = useNavigate();
|
||||
|
||||
const handleNavigateToItinerary = (tour: any) => {
|
||||
let targetLegId = null;
|
||||
|
||||
if (tour?.legs && tour.legs.length > 0) {
|
||||
const today = new Date();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
|
||||
for (const leg of tour.legs) {
|
||||
const rawStart = leg.startDate || leg.plannedStart || leg.date;
|
||||
const rawEnd = leg.endDate || leg.plannedEnd || leg.date;
|
||||
|
||||
if (rawStart) {
|
||||
const startBound = new Date(rawStart);
|
||||
startBound.setHours(0, 0, 0, 0);
|
||||
|
||||
const endBound = rawEnd ? new Date(rawEnd) : new Date(rawStart);
|
||||
endBound.setHours(23, 59, 59, 999);
|
||||
|
||||
if (today >= startBound && today <= endBound) {
|
||||
targetLegId = leg.id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!targetLegId) {
|
||||
targetLegId = tour.legs[0].id; // Fallback to Chặng 1 if out of tour bounds
|
||||
}
|
||||
}
|
||||
|
||||
navigate(`/tour/${tour.id}`, {
|
||||
state: { defaultExpandedLegId: targetLegId, shouldScrollToTarget: true }
|
||||
});
|
||||
};
|
||||
|
||||
### Step 2: Inject Safe Identifiers and Scroll Margin inside ItineraryTimeline
|
||||
Locate the top-level outer container div of each Leg item inside the timeline loop (currentTour.legs.map). Assign a unique id and a scroll margin class utility:
|
||||
|
||||
{currentTour.legs.map((leg: any, legIdx: number) => (
|
||||
<div
|
||||
key={leg.id}
|
||||
id={`leg-anchor-node-${leg.id}`}
|
||||
/* CRITICAL: scroll-mt-[70px] leaves a 70px buffer space at the top.
|
||||
Adjust '70px' to match the exact height of your white Tour Navigation Tabs bar!
|
||||
*/
|
||||
className="scroll-mt-[70px] transition-all w-full mb-4"
|
||||
>
|
||||
{/* Accordion Header Title ("Chặng 2: Dạo chơi ở xứ hoa vàng...") */}
|
||||
<div className="flex items-center justify-between ...">
|
||||
...
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
|
||||
### Step 3: Implement Lifecycle Interaction Trigger Engine
|
||||
Inside ItineraryTimeline.tsx, listen to the passed history route parameters. Set the state, then handle the async smooth scrolling action:
|
||||
|
||||
import { useLocation } from 'react-router-dom';
|
||||
|
||||
const location = useLocation();
|
||||
const [expandedStageId, setExpandedStageId] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (location.state?.defaultExpandedLegId) {
|
||||
const targetId = location.state.defaultExpandedLegId;
|
||||
|
||||
// 1. Instantly trigger the accordion state layout expansion
|
||||
setExpandedStageId(targetId);
|
||||
|
||||
// 2. Schedule a deferred macro-task callback to allow DOM re-renders to finish
|
||||
if (location.state?.shouldScrollToTarget) {
|
||||
const scrollTimer = setTimeout(() => {
|
||||
const targetElement = document.getElementById(`leg-anchor-node-${targetId}`);
|
||||
if (targetElement) {
|
||||
targetElement.scrollIntoView({
|
||||
behavior: 'smooth',
|
||||
block: 'start'
|
||||
});
|
||||
}
|
||||
|
||||
// Clear history router state token flags to prevent repeating scroll on subsequent reload shifts
|
||||
window.history.replaceState({}, document.title);
|
||||
}, 150); // 150ms ensures smooth accordion height deployment transition finishes
|
||||
|
||||
return () => clearTimeout(scrollTimer);
|
||||
}
|
||||
} else if (currentTour?.legs && currentTour.legs.length > 0 && !expandedStageId) {
|
||||
setExpandedStageId(currentTour.legs[0].id);
|
||||
}
|
||||
}, [location.state, currentTour]);
|
||||
|
||||
## 4. Quality Control & Acceptance Verification
|
||||
[ ] Date Matching Accuracy: Set today's date context matching a target Leg configuration profile. Tap the transition interface button from dashboard. The page must route directly and expand the target container block node.
|
||||
|
||||
[ ] Flush Viewport Ceiling Test: The animated target header segment node must slide upwards smoothly. It must lock positions cleanly right below the lowest baseline layer shadow boundary of the Tab Controller without passing behind it.
|
||||
|
||||
[ ] State Cleanliness Check: Refreshing or navigating back and forth within the active Timeline panel after the initial landing should not lock or force layout views to keep jumping scroll heights automatically.
|
||||
@@ -0,0 +1,69 @@
|
||||
# To AI Agent: Implement Smart Runtime Environment Detection for Backend URL (Eliminate Dynamic .env Conflicts)
|
||||
|
||||
## 1. Context & Objective
|
||||
We want to modify the frontend backend-URL resolution engine **exactly once** so that pulling code to the Linux Debian Server (Docker build) or a Windows PC (Android build) requires zero manual `.env` updates.
|
||||
|
||||
- **The Strategy:** Instead of hardcoding `VITE_BACKEND_URL` in a static `.env` file, we will write a smart runtime detector inside the code.
|
||||
- **The Logic:**
|
||||
- If the app runs on a standard web browser (Docker Server), `window.location.origin` automatically resolves to `https://yotrip.labz.io.vn`.
|
||||
- If the app runs inside an Android APK wrapper, the origin defaults to `http://localhost`, `capacitor://`, or `file://`. The code will detect this and automatically inject the absolute server production URL.
|
||||
|
||||
---
|
||||
|
||||
## 2. Refactoring Blueprint
|
||||
|
||||
### Step 1: Overhaul `socketService.ts` (or your central API configuration file)
|
||||
Replace the current environment variable lookup with this smart dynamic runtime resolver:
|
||||
|
||||
```typescript
|
||||
import { io, Socket } from 'socket.io-client';
|
||||
|
||||
const resolveBackendEndpoint = (): string => {
|
||||
// 1. Keep a fallback for explicit env overrides if deliberately set
|
||||
if (import.meta.env.VITE_BACKEND_URL) {
|
||||
return import.meta.env.VITE_BACKEND_URL;
|
||||
}
|
||||
|
||||
const origin = window.location.origin;
|
||||
const userAgent = navigator.userAgent.toLowerCase();
|
||||
|
||||
/* 2. DETECT ANDROID APK WRAPPER ENVIRONMENT
|
||||
Android webviews/hybrid shells run on custom local hosts or file protocols
|
||||
*/
|
||||
const isAndroidApp =
|
||||
origin.includes('localhost') ||
|
||||
origin.includes('capacitor://') ||
|
||||
origin.startsWith('file://') ||
|
||||
(userAgent.includes('android') && !origin.includes('yotrip.labz.io.vn'));
|
||||
|
||||
if (isAndroidApp) {
|
||||
console.log("📱 Android App environment detected. Forcing absolute production domain mapping.");
|
||||
return '[https://yotrip.labz.io.vn](https://yotrip.labz.io.vn)';
|
||||
}
|
||||
|
||||
// 3. Default fallback for Production Web (Docker server automatically yields its own domain)
|
||||
return origin;
|
||||
};
|
||||
|
||||
export const SOCKET_URL = resolveBackendEndpoint();
|
||||
console.log(`🌐 Active Network Base Endpoint: ${SOCKET_URL}`);
|
||||
|
||||
### Step 2: Sync API Axios Client Configuration (api.ts / axiosClient.ts)
|
||||
Ensure your API client hooks directly into the newly created SOCKET_URL variable to keep them unified:
|
||||
|
||||
import axios from 'axios';
|
||||
import { SOCKET_URL } from './socketService';
|
||||
|
||||
export const api = axios.create({
|
||||
baseURL: SOCKET_URL, // Dynamically synchronizes across both Docker and Android build pipelines
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
## 3. Verification Checklist for AI Agent
|
||||
[ ] Eradicate .env Dependency: Ensure that clearing out VITE_BACKEND_URL from local .env files does not cause code compilation failures.
|
||||
|
||||
[ ] Web Browser Verification: When deployed via Docker on the server, verify the network tab calls requests relatively to the running host origin.
|
||||
|
||||
[ ] Android Simulation Success: When compiled into an APK on Windows, confirm all API/Socket requests direct straight to https://yotrip.labz.io.vn, avoiding any localhost 404 blockages.
|
||||
@@ -1,104 +0,0 @@
|
||||
# To AI Agent: Fix Infinite Re-render Loop and Flickering "ĐANG TÌM ĐƯỜNG TỐI ƯU..." Label
|
||||
|
||||
## 1. Context & Layout Bug Analysis
|
||||
We are resolving a critical performance and UI bug inside the Map routing engine interface (`image.png`):
|
||||
- **The Issue:** The floating loading indicator badge reading `"ĐANG TÌM ĐƯỜNG TỐI ƯU..."` keeps flashing, flickering, or appearing and disappearing in an infinite execution loop.
|
||||
- **Root Cause:** This is caused by a broken React lifecycle loop. Every time the map triggers a directions route query, it toggles a loading state variable (`isSearching: true`). Once the route loads, the state updates (`isSearching: false`), forcing a component re-render. If the coordinates object (`origin`, `destination`) or the map instance ref inside the `useEffect` dependency array changes its reference pointer on every render, the hook fires *again*, creating an endless loop of API fetching and component flashing.
|
||||
|
||||
---
|
||||
|
||||
## 2. Technical Execution Strategy
|
||||
To terminate this flickering cycle, we must enforce a strict guard rail on the network/calculation trigger pipeline:
|
||||
1. **Coordinate Reference Stability:** Deconstruct the input latitude/longitude objects into raw primitive string values (e.g., `origin.lat`, `origin.lng`) inside the hook dependency array to avoid object reference mutations triggering re-renders.
|
||||
2. **Locking Ref Mechanism:** Implement a mutable React tracking reference (`const queryInProgress = useRef(false)`) to lock the execution window. If a fetch operation is active, block subsequent duplicate queries from firing.
|
||||
3. **Clean Loading State Termination:** Turn off the search state flag explicitly only *after* the route geometry polyline has completely finished rendering onto the map viewport layout.
|
||||
|
||||
---
|
||||
|
||||
## 3. Code Refactoring Blueprint
|
||||
|
||||
Locate your map navigation layer or modal component (e.g., `LocationNavigationModal.tsx`) and refactor the execution lifecycle loop as defined below:
|
||||
|
||||
```typescript
|
||||
import React, { useEffect, useState, useRef } from 'react';
|
||||
|
||||
// Inside your Map Navigation Modal / Layer component wrapper:
|
||||
export const LocationNavigationModal = ({ isOpen, routeData }) => {
|
||||
const [isSearchingRoute, setIsSearchingRoute] = useState(false);
|
||||
const mapInstanceRef = useRef<any>(null);
|
||||
|
||||
// CRITICAL FIX 2: Guard mechanism to block concurrent duplicated queries
|
||||
const fetchLockRef = useRef(false);
|
||||
|
||||
// Deconstruct coordinate primitives to secure a stable dependency array
|
||||
const originLat = routeData?.origin?.lat;
|
||||
const originLng = routeData?.origin?.lng;
|
||||
const destLat = routeData?.destination?.lat;
|
||||
const destLng = routeData?.destination?.lng;
|
||||
|
||||
useEffect(() => {
|
||||
if (!isOpen || !originLat || !originLng || !destLat || !destLng) return;
|
||||
|
||||
// If an operation is already locked and active, bail out immediately to prevent loops
|
||||
if (fetchLockRef.current) return;
|
||||
|
||||
const calculateOptimalRoute = async () => {
|
||||
try {
|
||||
// 1. Activate loading feedback banner
|
||||
setIsSearchingRoute(true);
|
||||
fetchLockRef.current = true; // Engage execution lock
|
||||
|
||||
console.log("Fetching route coordinates exactly once...");
|
||||
|
||||
// --- YOUR MAP COMPONENT ROUTING LOGIC START ---
|
||||
// Example: const response = await directionsService.route({...});
|
||||
// await mapInstanceRef.current.drawPolyline(response);
|
||||
// --- YOUR MAP COMPONENT ROUTING LOGIC END ---
|
||||
|
||||
} catch (error) {
|
||||
console.error("Failed to compile route optimization maps:", error);
|
||||
} finally {
|
||||
// 2. Safe, definitive termination of the tracking states
|
||||
setIsSearchingRoute(false);
|
||||
fetchLockRef.current = false; // Disengage execution lock
|
||||
}
|
||||
};
|
||||
|
||||
calculateOptimalRoute();
|
||||
|
||||
// Cleanup phase: Reset execution parameters when inputs dismantle or modal closes
|
||||
return () => {
|
||||
fetchLockRef.current = false;
|
||||
setIsSearchingRoute(false);
|
||||
};
|
||||
|
||||
/* CRITICAL FIX 1: Explicitly tracking primitives only.
|
||||
Do NOT pass full 'routeData', 'mapInstanceRef' or object literals here!
|
||||
*/
|
||||
}, [isOpen, originLat, originLng, destLat, destLng]);
|
||||
|
||||
return (
|
||||
<div className="relative w-full h-full">
|
||||
{/* Map Content Target Canvas */}
|
||||
<div id="navigation-viewport-map-canvas" className="w-full h-full" />
|
||||
|
||||
{/* RENDER CONTROLLER: Only mount the label if routing calculations are actively processing */}
|
||||
{isSearchingRoute && (
|
||||
<div className="absolute top-16 left-4 z-30 bg-white/95 dark:bg-slate-900/95 border border-slate-200 dark:border-slate-800 px-3 py-1.5 rounded-full shadow-lg flex items-center gap-2 animate-pulse">
|
||||
{/* Circular Loading Spinner Element */}
|
||||
<div className="w-3.5 h-3.5 border-2 border-blue-500 border-t-transparent rounded-full animate-spin" />
|
||||
<span className="text-[11px] font-bold text-slate-700 dark:text-slate-200 uppercase tracking-wider">
|
||||
ĐANG TÌM ĐƯỜNG TỐI ƯU...
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
## 4. Verification & Quality Acceptance Criteria
|
||||
[ ] Single Instance Trigger: Check console telemetry outputs. When the map modal mounts, the route compilation routine must print its trace log exactly once.
|
||||
|
||||
[ ] Flicker Nullification: The "ĐANG TÌM ĐƯỜNG TỐI ƯU..." badge must display smoothly with an animation pulse. It must not shake, blink, flash, or rapid-cycle on and off.
|
||||
|
||||
[ ] Deterministic Hiding: As soon as the blue route line draws completely across the map terrain grid layout, the loading badge must cleanly unmount and disappear from view without reappearing unless a new destination node button is clicked.
|
||||
@@ -0,0 +1,83 @@
|
||||
# To AI Agent: Global Mobile Viewport Optimization Plan for `frontend/src/pages`
|
||||
|
||||
## 1. Context & Architectural Objective
|
||||
We are launching a comprehensive mobile responsive refactoring across all core application pages inside `frontend/src/pages/`. Currently, several layouts suffer from desktop-first design assumptions, leading to sideways horizontal scrolling, squished sidebars, text wrapping collisions, and clipped viewports on mobile browsers.
|
||||
|
||||
**Objective:** Inspect and refactor all page-level layout components to guarantee an impeccable, fluid mobile UX (screen widths under 640px) while preserving the current widescreen layout using Tailwind CSS responsive breakpoints (`sm:`, `md:`, `lg:`).
|
||||
|
||||
---
|
||||
|
||||
## 2. Core Mobile-Responsive Design Rules for Pages
|
||||
|
||||
When auditing and refactoring page containers, strictly enforce these implementation guardrails:
|
||||
|
||||
1. **Fluid Heights over Sticky Viewports:** Avoid hardcoding page heights to `h-screen`. On mobile browsers, the address bar dynamically expands and collapses, causing layout jumps. Use **`h-auto`** or the new dynamic viewport utilities **`h-dvh`** / **`min-h-dvh`** instead.
|
||||
2. **Horizontal Overflow Elimination:** Ensure the root wrapper of every page enforces `w-full overflow-x-hidden`. Any element causing a horizontal scrollbar must be converted to a flex-wrap, horizontal scroll grid, or dynamic stack.
|
||||
3. **Flex/Grid Stacking:** Multi-column dashboard layouts must stack vertically on mobile and separate into side-by-side structures on desktop:
|
||||
- Use `flex flex-col md:flex-row`
|
||||
- Use `grid grid-cols-1 md:grid-cols-3`
|
||||
4. **Touch Target & Spacing Downscaling:** Mobile views require higher breathing margins but smaller typography. Reduce text sizes (`text-base` ➔ `text-xs/sm`) and scale down paddings (`p-6` ➔ `p-3/4`) on mobile screens.
|
||||
|
||||
---
|
||||
|
||||
## 3. Targeted Page-by-Page Refactoring Guide
|
||||
|
||||
### 3.1. `MemberDashboard.tsx` (Trang chính / Danh sách Tour)
|
||||
- **The Issue:** The grid grid-cols-2 or grid-cols-3 arrangement squishes Tour Card components on small viewports.
|
||||
- **Refactor Spec:** - Change main wrapper grid to `grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4`.
|
||||
- Force individual Tour Cards to occupy 100% width on mobile, stacking all actions ("Trò chuyện", "Chi tiết hành trình") into standard full-width rows or equal flex pairs (`flex-1`).
|
||||
|
||||
### 3.2. `ItineraryTimeline.tsx` (Trang quản lý Lộ trình Chi tiết)
|
||||
- **The Issue:** The sub-navigation tabs ribbon ("Lộ trình, Chi phí, Ảnh...") gets compressed, causing word overlapping. Timeline lines and node circles clip when left padding is too wide.
|
||||
- **Refactor Spec:**
|
||||
- Convert the sub-navigation menu container into a smooth horizontally scrollable ribbon on mobile:
|
||||
```jsx
|
||||
className="flex items-center gap-2 overflow-x-auto whitespace-nowrap scrollbar-none pb-2 md:overflow-x-visible md:whitespace-normal"
|
||||
```
|
||||
- Reduce the absolute left offset tracking of the timeline vertical axis indicator from `left-[32px]` down to a safe margin fitting tight spaces.
|
||||
|
||||
### 3.3. `PhotoGallery.tsx` / `GalleryPage.tsx` (Thư viện ảnh Tour)
|
||||
- **The Issue:** Widescreen image matrices cause layout bleeding or weird masonry columns.
|
||||
- **Refactor Spec:**
|
||||
- Force image grid wrappers to adopt `grid-cols-2` or `grid-cols-3` on mobile browsers instead of desktop 4-5 structures.
|
||||
- Ensure the modal lightboxes or floating overlays use full-width settings (`w-screen h-screen`) with zero perimeter radius limits.
|
||||
|
||||
---
|
||||
|
||||
## 4. Code Refactoring Reference Standard
|
||||
|
||||
### Layout Component Conversion Pattern:
|
||||
Apply this fluid adaptation standard on your root page return templates:
|
||||
|
||||
```jsx
|
||||
{/* ❌ BEFORE: RIGID DESKTOP-FIRST PAGE WRAPPER */}
|
||||
<div className="w-screen h-screen bg-slate-950 flex p-6 gap-6">
|
||||
<aside className="w-64 bg-slate-900">Sidebar</aside>
|
||||
<main className="flex-1 overflow-y-auto">Main Dashboard Content</main>
|
||||
</div>
|
||||
|
||||
{/* ✅ AFTER: MOBILE-FIRST FULLY RESPONSIVE LAYOUT SHEET */}
|
||||
<div className="w-full min-h-dvh bg-slate-950 flex flex-col md:flex-row p-3 sm:p-6 gap-4 sm:gap-6 overflow-x-hidden">
|
||||
|
||||
{/* Sticky Navigation or Drawer Menu on Mobile, Fixed Sidebar on Desktop */}
|
||||
<aside className="w-full md:w-64 shrink-0 bg-slate-900 rounded-xl p-4 md:sticky md:top-6 md:h-[calc(100vh-3rem)]">
|
||||
Sidebar/Menu Content
|
||||
</aside>
|
||||
|
||||
{/* Main Scrollable Core Content Space */}
|
||||
<main className="w-full flex-1 overflow-y-visible md:overflow-y-auto">
|
||||
<div className="space-y-4 max-w-7xl mx-auto">
|
||||
{/* Grid elements stack on mobile (1 col) and expand on desktop */}
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
{/* Card components populate here */}
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
</div>
|
||||
|
||||
## 5. Automated Verification Checklist for AI Agent
|
||||
|
||||
[ ] Zero Pixel Width Hardcodes: Scan all code blocks in frontend/src/pages/. Ensure no outer boundaries utilize structural fixed layouts like w-[1200px] or w-[800px] without a breakpoint utility prefix (e.g., lg:w-[1200px]).
|
||||
[ ] Viewport Axis Lock: Simulate viewport checks at 360px, 390px, and 412px widths. Verify that horizontal browser layout shifting is fully neutralized (window.scrollX === 0).
|
||||
[ ] Dynamic Viewport Heights Verification: Confirm that full-page dashboards replace static h-screen classes with h-auto or dynamic min-h-dvh settings to avoid layout bugs when the mobile address bar shifts.
|
||||
@@ -0,0 +1,129 @@
|
||||
# To AI Agent: Deprecate MemberDashboard Page and Re-architect All User Features into Dedicated Modals on LandingPage
|
||||
|
||||
## 1. Architectural Strategy & Goal
|
||||
We are completely removing the standalone `MemberDashboard` route/page. When a user logs in successfully, they must **remain directly on the `LandingPage`** (or `ExplorerMap`), with their authentication state shifting cleanly to display the member avatar dropdown menu in the top-bar header.
|
||||
|
||||
Every core feature previously hosted on the dashboard page must now be converted into a high-performance, responsive **Modal Overlay Component**. Clicking an item in the avatar dropdown menu will toggle the visibility state of its respective modal over the current viewport, ensuring zero page-redirection disruption.
|
||||
|
||||
---
|
||||
|
||||
## 2. Route Deletion & Auth Redirection Clean-up
|
||||
### 1. **Route Removal:** Open your router configuration (`App.tsx` or `routes.tsx`) and permanently delete the `<Route path="/dashboard" ... />` node.
|
||||
### 2. **Auth Hook Modification:** Inside the login handler lifecycle (e.g., `LoginModal.tsx` or `AuthContext.tsx`), replace `Maps('/dashboard')` with a simple state closer that preserves the current page instance:
|
||||
```typescript
|
||||
// ❌ OLD: navigate('/dashboard');
|
||||
// ✅ NEW: Keep user on context page, close login overlay, update profile states
|
||||
setIsLoginModalOpen(false);
|
||||
|
||||
## 3. Technical Specifications for Each Target Modal
|
||||
Implement the following modal architectures inside frontend/src/components/modals/:
|
||||
|
||||
### 3.1. Modal Chat Trực Tiếp (LiveChatModal.tsx)
|
||||
Layout Architecture: A wide responsive viewport split into two main functional vertical columns (flex flex-col md:flex-row h-[80vh]).
|
||||
|
||||
Left Column (w-full md:w-80 border-r border-slate-800): Interactive scrollable contact strip displaying the User's Friend List with online status indicators and latest message snippets.
|
||||
|
||||
Right Column (flex-1 flex flex-col bg-slate-950): Active conversation window.
|
||||
|
||||
Bottom Input Tray Wrapper: A rich-text typing container bar fixed at the baseline containing:
|
||||
|
||||
Text input area field.
|
||||
|
||||
Attachment Trigger buttons: Icon for Image uploads (accept="image/*") and an Icon for transmitting spatial GPS Coordinates/Locations directly into the text stream.
|
||||
|
||||
### 3.2. Modal Hành Trình Của Tôi (MyToursModal.tsx)
|
||||
Layout Architecture: A dynamic card explorer view featuring structural chronological timeline tabs at the top:
|
||||
|
||||
Tabs Grid: Đang thực hiện (Ongoing), Sắp khởi hành (Upcoming), and Đã hoàn thành (Past).
|
||||
|
||||
Core Content Panel: Clicking a tab renders a fluid inner grid loop of compact trip tiles. Each tile houses a banner photo, progress indicators, and quick action links to open the standalone TourNavigationPage or route maps directly.
|
||||
|
||||
### 3.3. Modal Thư Viện Ảnh (PhotoGalleryModal.tsx)
|
||||
Layout Architecture: A dedicated media repository browser displaying all images uploaded by the member.
|
||||
|
||||
Filtering Header Matrix: Dual filter select boxes pinned at the top:
|
||||
|
||||
Filter 1: Filter by Itinerary/Trip (Theo hành trình).
|
||||
|
||||
Filter 2: Filter by Media Hashtags (Theo tags).
|
||||
|
||||
Core Workspace: A masonry-style gallery layout grid with hover micro-interactions enabling the user to view full resolution views, edit asset tagging descriptions, or delete pictures directly.
|
||||
|
||||
### 3.4. Modal Danh Sách Bạn Bè (FriendsManagerModal.tsx)
|
||||
Layout Architecture: A centralized social dashboard layout built to handle user connections.
|
||||
|
||||
Functional Subsections:
|
||||
|
||||
Search engine bar to lookup new profiles via display name or telephone metrics.
|
||||
|
||||
Tab views separating Danh sách bạn bè (Active Friends) and Lời mời kết bạn (Pending Requests).
|
||||
|
||||
Row items equipped with direct context action triggers: Hủy kết bạn (Unfriend), Chấp nhận (Accept), or Nhắn tin (Quick Message - which bridges states to auto-toggle the Chat Modal).
|
||||
|
||||
## 4. Top-Bar Profile Dropdown Structure Integration
|
||||
Refactor the items list container within MapProfileDropdown.tsx to match the localized modal toggles state logic:
|
||||
|
||||
TypeScript
|
||||
import React, { useState } from 'react';
|
||||
import { Compass, Map, Image, Settings, ShieldAlert, Users, LogOut } from 'lucide-react';
|
||||
|
||||
export const HeaderMemberDropdown = ({ openModal }) => {
|
||||
return (
|
||||
<div className="absolute right-0 top-14 w-64 bg-slate-900 border border-slate-800 rounded-xl p-1.5 shadow-2xl flex flex-col space-y-0.5 text-xs text-slate-200 z-[999999]">
|
||||
|
||||
{/* 1. Nút "Tạo tour" */}
|
||||
<button onClick={() => openModal('create_tour')} className="flex items-center gap-3 w-full px-4 py-2.5 hover:bg-slate-800 rounded-lg text-left transition-colors">
|
||||
<Compass className="w-4 h-4 text-amber-400" />
|
||||
<span className="font-medium">Tạo tour</span>
|
||||
</button>
|
||||
|
||||
{/* 2. Nút "Hành trình của tôi" */}
|
||||
<button onClick={() => openModal('my_tours')} className="flex items-center gap-3 w-full px-4 py-2.5 hover:bg-slate-800 rounded-lg text-left transition-colors">
|
||||
<Map className="w-4 h-4 text-blue-400" />
|
||||
<span className="font-medium">Hành trình của tôi</span>
|
||||
</button>
|
||||
|
||||
{/* 3. Nút "Thư viện ảnh" */}
|
||||
<button onClick={() => openModal('gallery')} className="flex items-center gap-3 w-full px-4 py-2.5 hover:bg-slate-800 rounded-lg text-left transition-colors">
|
||||
<Image className="w-4 h-4 text-emerald-400" />
|
||||
<span className="font-medium">Thư viện ảnh</span>
|
||||
</button>
|
||||
|
||||
{/* 4. Nút "Cài đặt" */}
|
||||
<button onClick={() => openModal('settings')} className="flex items-center gap-3 w-full px-4 py-2.5 hover:bg-slate-800 rounded-lg text-left transition-colors">
|
||||
<Settings className="w-4 h-4 text-slate-400" />
|
||||
<span className="font-medium">Cài đặt</span>
|
||||
</button>
|
||||
|
||||
{/* 5. Nút "Báo cáo vi phạm" */}
|
||||
<button onClick={() => openModal('reports')} className="flex items-center gap-3 w-full px-4 py-2.5 hover:bg-slate-800 rounded-lg text-left transition-colors">
|
||||
<ShieldAlert className="w-4 h-4 text-rose-400" />
|
||||
<span className="font-medium">Báo cáo vi phạm</span>
|
||||
</button>
|
||||
|
||||
<div className="h-[1px] bg-slate-800/80 my-1 mx-2" />
|
||||
|
||||
{/* 6. Nút "Danh sách bạn bè" */}
|
||||
<button onClick={() => openModal('friends')} className="flex items-center gap-3 w-full px-4 py-2.5 hover:bg-slate-800 rounded-lg text-left transition-colors">
|
||||
<Users className="w-4 h-4 text-indigo-400" />
|
||||
<span className="font-medium">Danh sách bạn bè</span>
|
||||
</button>
|
||||
|
||||
{/* 7. Nút "Đăng xuất" */}
|
||||
<button onClick={() => openModal('logout')} className="flex items-center gap-3 w-full px-4 py-2.5 text-rose-400 hover:bg-slate-800 rounded-lg text-left font-bold transition-colors">
|
||||
<LogOut className="w-4 h-4 text-rose-500" />
|
||||
<span>Đăng xuất</span>
|
||||
</button>
|
||||
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
## 5. Automation Checklists for Quality Verification
|
||||
[ ] Redirection Invalidation Check: Perform a successful user login sweep. Verify the active URL hash parameter remains exactly / or /map, completely dropping dashboard transitions.
|
||||
|
||||
[ ] Chat Modal Layout Sizing: Trigger the Live Chat button. Ensure the workspace scales to an explicit split-view pane framework (Left: Contacts / Right: Dialog Thread) with working attachment trays.
|
||||
|
||||
[ ] Gallery Filter Interception: Confirm that filtering options inside the Photo modal dynamically re-index asset cards based on itinerary tags or custom upload parameters.
|
||||
|
||||
[ ] Global Z-Index Verification: All new modals must enforce a strict z-[999999] utility layer rule to pop up cleanly above the underlying map viewport layer without clip cutting.
|
||||
@@ -0,0 +1,518 @@
|
||||
# Plan: Build ứng dụng Android 11+ từ Codebase hiện tại
|
||||
|
||||
## Tổng quan
|
||||
|
||||
Codebase hiện tại là một **web app React + Vite** (frontend) và **NestJS** (backend) theo mô hình monorepo. Chiến lược được đề xuất là dùng **Capacitor.js** để đóng gói web app thành native Android APK/AAB mà **không cần viết lại code**, đồng thời bổ sung các tính năng native (camera, GPS, notifications...) qua Capacitor plugins.
|
||||
|
||||
---
|
||||
|
||||
## So sánh các lựa chọn
|
||||
|
||||
| Phương pháp | Ưu điểm | Nhược điểm | Phù hợp? |
|
||||
|---|---|---|---|
|
||||
| **Capacitor.js** | Tái sử dụng 100% React code, hỗ trợ Vite, ít học thêm | Cần build native mỗi lần release | ✅ **Phù hợp nhất** |
|
||||
| React Native | Performance tốt hơn, native feel | Phải viết lại toàn bộ UI/components | ❌ Tốn quá nhiều công |
|
||||
| PWA (Add to Home Screen) | Không cần build APK | Bị giới hạn API trình duyệt, không lên Google Play | ❌ Không phù hợp |
|
||||
| Cordova/PhoneGap | Tương tự Capacitor | Cũ hơn, ít được duy trì | ❌ Không nên dùng |
|
||||
|
||||
**→ Quyết định: Sử dụng [Capacitor.js](https://capacitorjs.com/)** (do Ionic team phát triển), hỗ trợ Android API 30+ (Android 11).
|
||||
|
||||
---
|
||||
|
||||
## Kiến trúc triển khai
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────┐
|
||||
│ Android APK / AAB │
|
||||
│ ┌─────────────────────────────────────────────┐ │
|
||||
│ │ Capacitor WebView │ │
|
||||
│ │ (Chứa toàn bộ frontend React/Vite) │ │
|
||||
│ └──────────────────┬──────────────────────────┘ │
|
||||
│ │ HTTPS API calls │
|
||||
└─────────────────────┼───────────────────────────────┘
|
||||
▼
|
||||
┌────────────────────────┐
|
||||
│ NestJS Backend │
|
||||
│ (Deployed server / │
|
||||
│ localhost dev) │
|
||||
└────────────────────────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Thông tin đã xác nhận
|
||||
|
||||
| Hạng mục | Quyết định |
|
||||
|---|---|
|
||||
| **Tên app** | YoTrip |
|
||||
| **App ID** | `com.yotrip.app` |
|
||||
| **Phát hành** | Google Play Store |
|
||||
| **Camera** | Native (chụp ảnh trực tiếp từ app) |
|
||||
| **Backend** | Docker trên Debian Homelab, proxy qua Nginx |
|
||||
| **Domain** | `yotrip.labz.io.vn` |
|
||||
| **DNS động** | Cloudflare DDNS |
|
||||
|
||||
---
|
||||
|
||||
## Điều kiện tiên quyết
|
||||
|
||||
> [!IMPORTANT]
|
||||
> Trước khi thực hiện, cần chuẩn bị:
|
||||
> 1. **Java JDK 17+** — Android build tool yêu cầu
|
||||
> 2. **Android Studio** — để build APK, quản lý Android SDK và tạo/chạy Emulator
|
||||
> 3. **Android SDK** với API Level 30+ (Android 11 / API 30)
|
||||
> 4. **Android Virtual Device (AVD)** — tạo trong Android Studio AVD Manager
|
||||
> 5. **Domain + HTTPS cho Homelab** — bắt buộc cho Google Play (xem Phần Bên dưới)
|
||||
|
||||
> [!WARNING]
|
||||
> **Google Play bắt buộc HTTPS** — Android 9+ chặn HTTP rõ ràng mặc định. Homelab phải có SSL certificate hợp lệ (Let's Encrypt qua Nginx) và domain name trỏ vào homelab server.
|
||||
|
||||
> [!NOTE]
|
||||
> Trên emulator, `localhost` của **emulator** khác với `localhost` của máy tính. Phải dùng địa chỉ đặc biệt `10.0.2.2` thay thế khi test emulator (xem Phase 5b).
|
||||
|
||||
---
|
||||
|
||||
## Proposed Changes
|
||||
|
||||
### Phase 1a: Cấu hình Backend Homelab (Docker + Nginx)
|
||||
|
||||
---
|
||||
|
||||
> [!IMPORTANT]
|
||||
> Đây là điều kiện tiên quyết của toàn bộ kế hoạch. App không thể gửi lên Google Play nếu API chưa có HTTPS.
|
||||
|
||||
Homelab của bạn chạy Docker + Nginx là **đủ điều kiện kết nối**, nhưng cần đảm bảo:
|
||||
|
||||
#### Checklist Homelab/Nginx
|
||||
|
||||
| Yêu cầu | Mô tả |
|
||||
|---|---|
|
||||
| **Domain name** | `yotrip.labz.io.vn` — đã xác nhận |
|
||||
| **Port forwarding** | Router cài đặt forward port 80 và 443 vào Nginx server |
|
||||
| **SSL Certificate** | Let's Encrypt (miễn phí) qua Certbot: `certbot --nginx -d yotrip.labz.io.vn` |
|
||||
| **Nginx reverse proxy** | Forward HTTPS → NestJS container port 3001 |
|
||||
| **Docker Compose** | Backend container luôn restart khi Debian reboot |
|
||||
| **CORS** | Backend phải cho phép origin từ app Capacitor (có thể mở rộng `*` ban đầu) |
|
||||
| **IP động** | Dùng **Cloudflare DDNS** để giữ domain `yotrip.labz.io.vn` luôn trỏ đúng IP |
|
||||
|
||||
#### Mẫu cấu hình Nginx reverse proxy
|
||||
|
||||
```nginx
|
||||
# /etc/nginx/sites-available/yotrip-api
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name yotrip.labz.io.vn;
|
||||
|
||||
ssl_certificate /etc/letsencrypt/live/yotrip.labz.io.vn/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/yotrip.labz.io.vn/privkey.pem;
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:3001;
|
||||
proxy_http_version 1.1;
|
||||
# Cần thiết cho WebSocket (Socket.IO)
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
}
|
||||
}
|
||||
|
||||
# Redirect HTTP sang HTTPS
|
||||
server {
|
||||
listen 80;
|
||||
server_name yotrip.labz.io.vn;
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
```
|
||||
|
||||
#### File cấu hình môi trường sẽ dùng
|
||||
|
||||
```env
|
||||
# frontend/.env.production
|
||||
VITE_API_BASE_URL=https://yotrip.labz.io.vn
|
||||
|
||||
# frontend/.env.emulator (test local)
|
||||
VITE_API_BASE_URL=http://10.0.2.2:3001
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 1b: Tập trung API URL trong Frontend
|
||||
|
||||
#### [MODIFY] [vite.config.ts](file:///home/locpham/travelplanning/frontend/vite.config.ts)
|
||||
- Dev proxy hiện tại trỏ về `http://localhost:3001` — chỉ hoạt động khi chạy trên browser máy tính.
|
||||
- Tạo biến môi trường `VITE_API_BASE_URL` để frontend biết trỏ đến đâu.
|
||||
|
||||
#### [NEW] `.env.production` trong `frontend/`
|
||||
```env
|
||||
VITE_API_BASE_URL=https://your-backend-server.com
|
||||
```
|
||||
|
||||
#### [NEW] `.env.development` trong `frontend/`
|
||||
```env
|
||||
# Dùng ngrok hoặc IP máy tính cho mobile dev
|
||||
VITE_API_BASE_URL=http://192.168.x.x:3001
|
||||
```
|
||||
|
||||
#### [MODIFY] Toàn bộ các file gọi `/api/v1/...`
|
||||
- Thay `fetch('/api/v1/...')` bằng `fetch(\`${import.meta.env.VITE_API_BASE_URL}/api/v1/...\`)`
|
||||
- **Ưu tiên**: Tạo một file `src/lib/api.ts` (helper) để tập trung URL, tránh sửa từng file.
|
||||
|
||||
```typescript
|
||||
// src/lib/api.ts
|
||||
export const API_BASE = import.meta.env.VITE_API_BASE_URL || '';
|
||||
|
||||
export const apiFetch = (path: string, options?: RequestInit) =>
|
||||
fetch(`${API_BASE}${path}`, options);
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Tích hợp Capacitor
|
||||
|
||||
---
|
||||
|
||||
#### Cài đặt Capacitor vào frontend
|
||||
|
||||
```bash
|
||||
# Trong thư mục frontend/
|
||||
npm install @capacitor/core @capacitor/cli
|
||||
npx cap init "YoTrip" "com.yotrip.app" --web-dir dist
|
||||
npm install @capacitor/android
|
||||
npx cap add android
|
||||
```
|
||||
|
||||
#### [NEW] `frontend/capacitor.config.ts`
|
||||
```typescript
|
||||
import { CapacitorConfig } from '@capacitor/cli';
|
||||
|
||||
const config: CapacitorConfig = {
|
||||
appId: 'com.yotrip.app', // ✅ App ID chính thức
|
||||
appName: 'YoTrip', // ✅ Tên app
|
||||
webDir: 'dist',
|
||||
server: {
|
||||
// Production: không cần cấu hình, dùng VITE_API_BASE_URL trong build
|
||||
// Dev/Emulator: uncomment dòng dưới
|
||||
// url: 'http://10.0.2.2:3002',
|
||||
// cleartext: true,
|
||||
},
|
||||
android: {
|
||||
minSdkVersion: 30, // Android 11 (API 30)
|
||||
targetSdkVersion: 34, // Android 14
|
||||
buildOptions: {
|
||||
keystorePath: 'release-key.keystore',
|
||||
keystoreAlias: 'yotrip',
|
||||
}
|
||||
},
|
||||
plugins: {
|
||||
SplashScreen: {
|
||||
launchAutoHide: false,
|
||||
backgroundColor: '#0f172a',
|
||||
androidSplashResourceName: 'splash',
|
||||
},
|
||||
// Camera plugin config (bắt buộc vì app cần chụp ảnh)
|
||||
Camera: {
|
||||
presentationStyle: 'fullscreen',
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default config;
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: Android Project Setup
|
||||
|
||||
---
|
||||
|
||||
#### Build flow
|
||||
|
||||
```bash
|
||||
# Bước 1: Build React app thành static files
|
||||
npm run build -w frontend
|
||||
|
||||
# Bước 2: Copy static files vào Android project
|
||||
npx cap copy android
|
||||
|
||||
# Bước 3: Sync plugins và dependencies
|
||||
npx cap sync android
|
||||
|
||||
# Bước 4: Mở Android Studio để build APK/AAB
|
||||
npx cap open android
|
||||
```
|
||||
|
||||
#### [MODIFY] `android/app/src/main/AndroidManifest.xml` (tự sinh bởi Capacitor)
|
||||
Thêm các permissions cần thiết:
|
||||
```xml
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
|
||||
<!-- Android 11+ scoped storage -->
|
||||
<uses-permission android:name="android.permission.MANAGE_MEDIA" />
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 4: Native Plugins (**Bắt buộc**)
|
||||
|
||||
| Plugin | Mức độ | Mục đích | Package |
|
||||
|---|---|---|---|
|
||||
| `@capacitor/camera` | ✅ **Bắt buộc** | Chụp ảnh trực tiếp từ camera + gallery | `@capacitor/camera` |
|
||||
| `@capacitor/geolocation` | ✅ **Bắt buộc** | GPS thiết bị cho bản đồ | `@capacitor/geolocation` |
|
||||
| `@capacitor/splash-screen` | ✅ **Bắt buộc** | Màn hình khởi động | `@capacitor/splash-screen` |
|
||||
| `@capacitor/status-bar` | ✅ **Bắt buộc** | Màu status bar đồng bộ UI | `@capacitor/status-bar` |
|
||||
| `@capacitor/push-notifications` | 🔲 Tùy chọn | Thông báo bình luận, tour | `@capacitor/push-notifications` |
|
||||
| `@capacitor/network` | 🔲 Tùy chọn | Kiểm tra kết nối mạng | `@capacitor/network` |
|
||||
|
||||
#### Cách dùng Camera plugin trong code (thay thế input file)
|
||||
|
||||
```typescript
|
||||
// Thay thế <input type="file"> bằng Capacitor Camera API
|
||||
import { Camera, CameraResultType, CameraSource } from '@capacitor/camera';
|
||||
|
||||
const takePhoto = async () => {
|
||||
const photo = await Camera.getPhoto({
|
||||
resultType: CameraResultType.DataUrl, // Hoặc Uri cho hiệu năng tốt hơn
|
||||
source: CameraSource.Prompt, // Hỏi: Camera hay Gallery?
|
||||
quality: 85,
|
||||
});
|
||||
// photo.dataUrl → upload lên backend
|
||||
};
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 5: Điều chỉnh UI cho Mobile
|
||||
|
||||
Một số thành phần hiện tại đã có responsive CSS, nhưng cần kiểm tra thêm:
|
||||
|
||||
- **`PublicPhotoModal.tsx`**: Đã có kế hoạch fix mobile layout (từ plan cũ), cần implement trước khi build.
|
||||
- **`ExploreMap.tsx`**: Leaflet map cần đảm bảo touch events hoạt động (thường OK trên mobile).
|
||||
- **`TourDetailPage.tsx`**: Kiểm tra scroll behavior, fixed headers.
|
||||
- **Safe Area Insets**: Dùng `env(safe-area-inset-*)` cho các thiết bị có notch/dynamic island.
|
||||
|
||||
```css
|
||||
/* Thêm vào index.css */
|
||||
:root {
|
||||
--safe-top: env(safe-area-inset-top, 0px);
|
||||
--safe-bottom: env(safe-area-inset-bottom, 0px);
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 5b: Test trên Android Emulator (AVD)
|
||||
|
||||
> [!IMPORTANT]
|
||||
> Đây là bước bắt buộc trước khi test trên thiết bị thật. Emulator giúp phát hiện lỗi layout, API call, và native permissions mà không cần thiết bị vật lý.
|
||||
|
||||
#### Tạo Android Virtual Device (AVD)
|
||||
1. Mở **Android Studio → Tools → Device Manager → Create Device**
|
||||
2. Chọn **Pixel 6** (hoặc tương đương) → chọn hệ thống **Android 11.0 (API 30)**
|
||||
3. Cấp RAM 2GB+, Storage 4GB+ cho emulator
|
||||
4. Khởi động emulator, đảm bảo hiện **"Emulator is running"**
|
||||
|
||||
#### Địa chỉ đặc biệt trong Emulator
|
||||
|
||||
```
|
||||
10.0.2.2 → Trỏ đến localhost (127.0.0.1) của máy tính host
|
||||
```
|
||||
|
||||
Khi chạy trong emulator, backend ở `localhost:3001` của máy tính phải được gọi bằng `10.0.2.2:3001`.
|
||||
|
||||
#### Cấu hình `capacitor.config.ts` cho Emulator Dev
|
||||
```typescript
|
||||
// Tạm thời uncomment khi test trên emulator
|
||||
server: {
|
||||
url: 'http://10.0.2.2:3002', // Trỏ đến Vite dev server trên máy host
|
||||
cleartext: true, // Cho phép HTTP (không dùng trong production)
|
||||
},
|
||||
```
|
||||
|
||||
Hoặc dùng biến môi trường `.env.emulator`:
|
||||
```env
|
||||
VITE_API_BASE_URL=http://10.0.2.2:3001
|
||||
```
|
||||
|
||||
#### Chạy app trên Emulator
|
||||
```bash
|
||||
# Bước 1: Đảm bảo emulator đang chạy
|
||||
adb devices
|
||||
# Phải thấy: emulator-5554 device
|
||||
|
||||
# Bước 2: Build & sync
|
||||
npm run build -w frontend
|
||||
npx cap copy android && npx cap sync android
|
||||
|
||||
# Bước 3: Chạy trực tiếp trên emulator
|
||||
npx cap run android
|
||||
# hoặc trong Android Studio: Run ▶ chọn emulator
|
||||
```
|
||||
|
||||
#### Checklist kiểm tra trên Emulator
|
||||
|
||||
| Chức năng | Test case | Kết quả mong đợi |
|
||||
|---|---|---|
|
||||
| Khởi động | Mở app | Splash screen → Landing page |
|
||||
| Đăng nhập | Nhập email/password | Vào ExploreMap |
|
||||
| Bản đồ | Zoom/pan trên emulator | Leaflet map hoạt động |
|
||||
| Upload ảnh | Chọn ảnh từ gallery giả lập | Ảnh được upload thành công |
|
||||
| Bình luận | Nhập & gửi bình luận | Hiện real-time qua WebSocket |
|
||||
| Safe area | Xoay màn hình | Layout không bị che |
|
||||
| Responsive | Portrait/Landscape | UI không bị vỡ |
|
||||
|
||||
---
|
||||
|
||||
### Phase 6: Test trên thiết bị Android thật
|
||||
|
||||
> [!NOTE]
|
||||
> Chỉ tiến hành Phase này sau khi toàn bộ Phase 5b đã pass. Thiết bị thật giúp phát hiện lỗi về hiệu năng, cảm biến thực tế, và hành vi network.
|
||||
|
||||
#### Kết nối thiết bị
|
||||
```bash
|
||||
# Bật Developer Mode + USB Debugging trên điện thoại
|
||||
# Cắm cáp USB → xác nhận "Allow USB Debugging"
|
||||
adb devices
|
||||
# Phải thấy: <serial_number> device
|
||||
```
|
||||
|
||||
#### Cấu hình backend cho thiết bị thật
|
||||
Thiết bị thật phải dùng IP LAN hoặc ngrok (không thể dùng `10.0.2.2`):
|
||||
```bash
|
||||
# Tùy chọn A: Dùng IP LAN (điện thoại và máy tính cùng WiFi)
|
||||
VITE_API_BASE_URL=http://192.168.x.x:3001
|
||||
|
||||
# Tùy chọn B: Dùng ngrok (tiện hơn, không cần cùng mạng)
|
||||
ngrok http 3001
|
||||
# → VITE_API_BASE_URL=https://xxxx.ngrok-free.app
|
||||
```
|
||||
|
||||
#### Cài debug APK lên thiết bị thật
|
||||
```bash
|
||||
# Build debug APK
|
||||
cd frontend/android && ./gradlew assembleDebug
|
||||
|
||||
# Cài APK lên thiết bị
|
||||
adb install app/build/outputs/apk/debug/app-debug.apk
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 7: Ký APK và phát hành
|
||||
|
||||
#### Debug build (dev testing)
|
||||
```bash
|
||||
cd android && ./gradlew assembleDebug
|
||||
# Output: android/app/build/outputs/apk/debug/app-debug.apk
|
||||
```
|
||||
|
||||
#### Release build (production)
|
||||
```bash
|
||||
# Tạo keystore lần đầu
|
||||
keytool -genkey -v -keystore release-key.keystore -alias yotrip \
|
||||
-keyalg RSA -keysize 2048 -validity 10000
|
||||
|
||||
# Build release
|
||||
cd android && ./gradlew bundleRelease
|
||||
# Output: .aab file để upload Google Play
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Checklist thực hiện
|
||||
|
||||
```
|
||||
Phase 1 - Backend URL
|
||||
[ ] Tạo file src/lib/api.ts (centralised fetch helper)
|
||||
[ ] Refactor tất cả fetch('/api/v1/...) sang apiFetch()
|
||||
[ ] Tạo .env.production với VITE_API_BASE_URL
|
||||
[ ] Tạo .env.emulator với VITE_API_BASE_URL=http://10.0.2.2:3001
|
||||
|
||||
Phase 2 - Capacitor Setup
|
||||
[ ] npm install @capacitor/core @capacitor/cli @capacitor/android
|
||||
[ ] npx cap init với App ID và tên app
|
||||
[ ] Tạo capacitor.config.ts
|
||||
[ ] npx cap add android
|
||||
|
||||
Phase 3 - Build & Sync
|
||||
[ ] npm run build -w frontend (kiểm tra không có lỗi TypeScript)
|
||||
[ ] npx cap copy android && npx cap sync android
|
||||
[ ] Cấu hình AndroidManifest.xml với permissions
|
||||
|
||||
Phase 4 - Native Plugins
|
||||
[ ] Cài @capacitor/geolocation (thay navigator.geolocation)
|
||||
[ ] Cài @capacitor/camera (upload ảnh từ điện thoại)
|
||||
[ ] Cài @capacitor/splash-screen, @capacitor/status-bar
|
||||
|
||||
Phase 5 - Mobile UI Polish
|
||||
[ ] Implement mobile layout fixes cho PublicPhotoModal.tsx
|
||||
[ ] Kiểm tra safe-area-inset cho Android
|
||||
|
||||
Phase 5b - Test trên Android Emulator (AVD)
|
||||
[ ] Tạo AVD Android 11 (API 30) trong Android Studio
|
||||
[ ] Cấu hình capacitor.config.ts server.url = http://10.0.2.2:3002
|
||||
[ ] Khởi động emulator → adb devices xác nhận kết nối
|
||||
[ ] npx cap run android → kiểm tra app khởi động
|
||||
[ ] Kiểm tra toàn bộ checklist: Login, Map, Upload, Comment, SafeArea
|
||||
[ ] Sửa tất cả lỗi phát sinh trên emulator
|
||||
|
||||
Phase 6 - Test trên thiết bị Android 11 thật
|
||||
[ ] Bật Developer Mode + USB Debugging trên điện thoại
|
||||
[ ] adb devices xác nhận thiết bị kết nối
|
||||
[ ] Cấu hình VITE_API_BASE_URL = IP LAN hoặc ngrok
|
||||
[ ] Build debug APK → adb install
|
||||
[ ] Kiểm tra lại toàn bộ checklist trên thiết bị thật
|
||||
[ ] Kiểm tra performance, pin, cảm biến GPS thực tế
|
||||
|
||||
Phase 7 - Build Release
|
||||
[ ] Build debug APK để test
|
||||
[ ] Tạo keystore và build release AAB
|
||||
[ ] Chuẩn bị lên Google Play (nếu cần)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Verification Plan
|
||||
|
||||
### Automated
|
||||
- `npm run build -w frontend` — không có lỗi TypeScript/build
|
||||
- `adb devices` — xác nhận emulator/thiết bị thật đang kết nối
|
||||
|
||||
### Stage 1: Test trên Android Emulator
|
||||
1. App khởi động không crash, hiện Landing page đúng.
|
||||
2. Đăng nhập / Đăng ký hoạt động (kết nối `10.0.2.2:3001`).
|
||||
3. Bản đồ Leaflet zoom/pan bằng cảm ứng mô phỏng.
|
||||
4. Upload ảnh từ gallery giả lập của emulator.
|
||||
5. Bình luận real-time qua WebSocket hoạt động.
|
||||
6. Layout không bị vỡ khi xoay màn hình (portrait/landscape).
|
||||
7. Safe-area-inset không bị che bởi status bar.
|
||||
|
||||
### Stage 2: Test trên thiết bị Android 11 thật
|
||||
1. Lặp lại toàn bộ Stage 1 trên thiết bị thật.
|
||||
2. GPS thực tế hoạt động và hiện đúng vị trí trên bản đồ.
|
||||
3. Camera native chụp và upload ảnh thành công.
|
||||
4. Performance mượt mà (scroll, animation không giật).
|
||||
5. WebSocket giữ kết nối ổn định trên mobile network (4G/WiFi).
|
||||
6. Kiểm tra pin consumption không bất thường.
|
||||
|
||||
---
|
||||
|
||||
## Các quyết định đã xác nhận
|
||||
|
||||
| Câu hỏi | Trả lời |
|
||||
|---|---|
|
||||
| Backend deploy ở đâu? | Docker trên Debian homelab, proxy qua Nginx |
|
||||
| Tên app và App ID? | `YoTrip` — `com.yotrip.app` |
|
||||
| Domain? | `yotrip.labz.io.vn` (Cloudflare DDNS) |
|
||||
| Phát hành? | Đưa lên **Google Play Store** |
|
||||
| Camera? | **Native camera** — chụp ảnh trực tiếp từ app |
|
||||
|
||||
> [!NOTE]
|
||||
> **Lưu ý quan trọng về Homelab + Google Play:**
|
||||
> - Homelab + Docker + Nginx là **đủ điều kiện kết nối** cho app Android.
|
||||
> - Domain `yotrip.labz.io.vn` dùng **Cloudflare DDNS** — IP homelab thay đổi sẽ được cập nhật tự động.
|
||||
> - **WebSocket (Socket.IO)** cần Nginx được cấu hình `proxy_set_header Upgrade` (xem Phase 1a).
|
||||
> - Certbot cấp SSL cho `yotrip.labz.io.vn`: `certbot --nginx -d yotrip.labz.io.vn`
|
||||
@@ -0,0 +1 @@
|
||||
../.env
|
||||
@@ -154,6 +154,17 @@ async function bootstrap() {
|
||||
app.useStaticAssets(UPLOAD_ROOT, {
|
||||
prefix: '/uploads/',
|
||||
});
|
||||
const downloadsDir = path.join(process.cwd(), 'public/downloads');
|
||||
if (!fs.existsSync(downloadsDir)) {
|
||||
fs.mkdirSync(downloadsDir, { recursive: true });
|
||||
}
|
||||
app.useStaticAssets(downloadsDir, {
|
||||
prefix: '/downloads/',
|
||||
setHeaders: (res) => {
|
||||
res.set('Content-Type', 'application/vnd.android.package-archive');
|
||||
res.set('Content-Disposition', 'attachment; filename="yotrip-latest.apk"');
|
||||
}
|
||||
});
|
||||
const prisma = app.get(prisma_service_1.PrismaService);
|
||||
startAutoCleanup(prisma);
|
||||
await app.listen(3001);
|
||||
|
||||
@@ -114,6 +114,21 @@ async function bootstrap() {
|
||||
prefix: '/uploads/',
|
||||
});
|
||||
|
||||
// Tự động tạo thư mục downloads nếu chưa tồn tại
|
||||
const downloadsDir = path.join(process.cwd(), 'public/downloads');
|
||||
if (!fs.existsSync(downloadsDir)) {
|
||||
fs.mkdirSync(downloadsDir, { recursive: true });
|
||||
}
|
||||
|
||||
// Khai báo thư mục lưu trữ APK tải về
|
||||
app.useStaticAssets(downloadsDir, {
|
||||
prefix: '/downloads/',
|
||||
setHeaders: (res) => {
|
||||
res.set('Content-Type', 'application/vnd.android.package-archive');
|
||||
res.set('Content-Disposition', 'attachment; filename="yotrip-latest.apk"');
|
||||
}
|
||||
});
|
||||
|
||||
const prisma = app.get(PrismaService);
|
||||
startAutoCleanup(prisma);
|
||||
|
||||
@@ -2169,12 +2184,7 @@ class PhotoController {
|
||||
}
|
||||
|
||||
const uploaderId = req.user.id;
|
||||
const isAnonymous = req.user.isAnonymous;
|
||||
|
||||
// Chỉ người dùng ẩn danh mới được dùng endpoint này
|
||||
if (!isAnonymous) {
|
||||
throw new ForbiddenException('Chỉ người dùng khách mới có thể sử dụng tính năng này.');
|
||||
}
|
||||
// Cả người dùng đã đăng ký và khách ẩn danh đều được dùng endpoint này để chia sẻ ảnh công khai lên bản đồ
|
||||
|
||||
const file = files[0];
|
||||
const uniqueSuffix = Date.now() + '-' + Math.round(Math.random() * 1e9);
|
||||
@@ -2309,7 +2319,7 @@ class PhotoController {
|
||||
@Patch(':id')
|
||||
async updatePhoto(
|
||||
@Param('id', ParseUUIDPipe) id: string,
|
||||
@Body() body: { title?: string; description?: string; latitude?: number; longitude?: number },
|
||||
@Body() body: { title?: string; description?: string; latitude?: number; longitude?: number; tags?: string[] },
|
||||
@Req() req: any
|
||||
) {
|
||||
const photo = await this.prisma.photo.findUnique({
|
||||
@@ -2332,6 +2342,7 @@ class PhotoController {
|
||||
lng: body.longitude !== undefined ? body.longitude : currentMetadata.lng,
|
||||
title: body.title !== undefined ? body.title : currentMetadata.title,
|
||||
description: body.description !== undefined ? body.description : currentMetadata.description,
|
||||
tags: body.tags !== undefined ? body.tags : currentMetadata.tags,
|
||||
};
|
||||
|
||||
return this.prisma.photo.update({
|
||||
@@ -2463,7 +2474,7 @@ class UserController {
|
||||
return this.prisma.user.update({
|
||||
where: { id },
|
||||
data,
|
||||
select: { id: true, email: true, name: true, isAdmin: true, isBlocked: true }
|
||||
select: { id: true, email: true, name: true, isAdmin: true, isBlocked: true, avatar: true, phone: true, address: true }
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 868 KiB |
|
Before Width: | Height: | Size: 148 KiB |
|
Before Width: | Height: | Size: 120 KiB |
|
Before Width: | Height: | Size: 844 KiB |
|
Before Width: | Height: | Size: 408 KiB |
|
Before Width: | Height: | Size: 422 KiB |
@@ -0,0 +1 @@
|
||||
{"web":{"client_id":"639044397050-7hair384u6lle941h033trut1s3q47l4.apps.googleusercontent.com","project_id":"yotrip-web","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"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"}}
|
||||
@@ -31,7 +31,7 @@ services:
|
||||
ports:
|
||||
- "3001:3001"
|
||||
volumes:
|
||||
- ./backend/uploads:/usr/src/app/uploads
|
||||
- /mnt/storage/yotrip/uploads:/usr/src/app/uploads
|
||||
environment:
|
||||
DATABASE_URL: "postgresql://postgres:password@postgres:5432/travel_db?schema=public"
|
||||
REDIS_URL: "redis://redis:6379"
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
# Kế hoạch triển khai: Cấu hình Docker để Chạy Server & Phát triển (Hot-reload)
|
||||
|
||||
Kế hoạch này phác thảo cách cấu hình Docker và Docker Compose cho dự án YoTrip. Cấu hình này sẽ đáp ứng đồng thời hai nhu cầu:
|
||||
1. **Môi trường Phát triển (Development)**: Đồng bộ mã nguồn trực tiếp (bind mounts) từ máy local vào container, hỗ trợ hot-reload cho cả backend (NestJS watch) và frontend (Vite HMR).
|
||||
2. **Môi trường Triển khai (Production)**: Đóng gói tối ưu thành các image độc lập, sử dụng Nginx để phục vụ frontend tĩnh và tối ưu hóa hiệu năng NestJS backend.
|
||||
|
||||
---
|
||||
|
||||
## User Review Required
|
||||
|
||||
> [!IMPORTANT]
|
||||
> - **Biến môi trường trong Docker**: Khi chạy trong Docker Compose, địa chỉ kết nối cơ sở dữ liệu (`DATABASE_URL`) và Redis (`REDIS_URL`) phải trỏ đến tên các service của container (ví dụ: `postgres` thay vì `localhost`). Chúng tôi sẽ cấu hình Docker Compose ghi đè (override) các biến này một cách tự động để tránh làm hỏng cấu hình chạy trực tiếp bằng `npm run start:dev` trên máy local của bạn.
|
||||
> - **Cổng mạng (Ports)**:
|
||||
> - Backend: Cổng `3001` được mở ra ngoài.
|
||||
> - Frontend: Cổng `5173` (cho Dev) và cổng `3002` (cho Production thông qua Nginx).
|
||||
> - Database: Cổng `5432` (mở để truy cập quản trị nếu cần).
|
||||
> - Redis: Cổng `6379`.
|
||||
|
||||
---
|
||||
|
||||
## Proposed Changes
|
||||
|
||||
### 1. Dockerfile cho Backend
|
||||
|
||||
#### [NEW] [Dockerfile](file:///home/locpham/travelplanning/backend/Dockerfile)
|
||||
- Thiết lập môi trường chạy Node.js (phiên bản `20-alpine`).
|
||||
- Cài đặt các gói phụ thuộc hệ thống cần thiết (như openssl cho Prisma).
|
||||
- Cấu hình chạy chế độ phát triển (sử dụng volume mounts để hot-reload) và chế độ production (build code JS).
|
||||
- Chạy Prisma client generation lúc build.
|
||||
|
||||
---
|
||||
|
||||
### 2. Dockerfile cho Frontend
|
||||
|
||||
#### [NEW] [Dockerfile](file:///home/locpham/travelplanning/frontend/Dockerfile)
|
||||
- Sử dụng chiến lược Multi-stage build để tối ưu hóa dung lượng:
|
||||
- **Stage 1 (Build)**: Cài đặt dependencies và build mã nguồn React/Vite thành thư mục tĩnh `dist`.
|
||||
- **Stage 2 (Nginx)**: Copy thư mục `dist` vào container chạy Nginx để phục vụ các file tĩnh ở cổng `80` (phục vụ môi trường production).
|
||||
- Hỗ trợ chạy Node.js trực tiếp cho môi trường phát triển để dùng Vite dev server và HMR.
|
||||
|
||||
---
|
||||
|
||||
### 3. Docker Compose cho Phát triển & Sửa Code (Hot-reload)
|
||||
|
||||
#### [NEW] [docker-compose.yml](file:///home/locpham/travelplanning/docker-compose.yml)
|
||||
- Khởi tạo 4 services chính:
|
||||
1. `postgres`: Cơ sở dữ liệu PostgreSQL 15, lưu trữ dữ liệu bền vững qua volume `pg_data`.
|
||||
2. `redis`: Caching và WebSockets.
|
||||
3. `backend`: Mount thư mục `backend/` vào container, chạy lệnh `npm run start:dev` để tự động reload khi sửa code trên máy host.
|
||||
4. `frontend`: Mount thư mục `frontend/` vào container, chạy lệnh `npm run dev -- --host` để phục vụ Vite dev server hỗ trợ HMR (Hot Module Replacement).
|
||||
- Đồng bộ hóa các volume ẩn `node_modules` để tránh xung đột hệ điều hành giữa máy host và container.
|
||||
|
||||
---
|
||||
|
||||
### 4. Docker Compose cho Triển khai lên Server (Production)
|
||||
|
||||
#### [NEW] [docker-compose.prod.yml](file:///home/locpham/travelplanning/docker-compose.prod.yml)
|
||||
- Cấu hình tối ưu để triển khai lên server cloud:
|
||||
- Builds production image cho `backend` và chạy trực tiếp file JS đã build (`dist/src/main.js`).
|
||||
- Builds production image cho `frontend` sử dụng Nginx để phục vụ client, tối ưu hóa tốc độ tải trang và bảo mật.
|
||||
- Tự động restart dịch vụ nếu gặp sự cố (`restart: always`).
|
||||
|
||||
---
|
||||
|
||||
## Verification Plan
|
||||
|
||||
### Automated Tests
|
||||
- Kiểm tra tính hợp lệ của cấu hình docker-compose:
|
||||
```bash
|
||||
docker compose config
|
||||
```
|
||||
|
||||
### Manual Verification
|
||||
1. **Kiểm tra Môi trường Phát triển (Sửa code trực tiếp)**:
|
||||
- Chạy lệnh khởi động môi trường dev:
|
||||
```bash
|
||||
docker compose up --build
|
||||
```
|
||||
- Truy cập giao diện tại `http://localhost:5173`.
|
||||
- Sửa đổi một dòng văn bản trong frontend (ví dụ: nhãn nút ở `LandingPage.tsx`) hoặc backend và kiểm tra xem container có tự động tải lại (hot-reload) tức thì hay không.
|
||||
2. **Kiểm tra Môi trường Production (Triển khai server)**:
|
||||
- Chạy lệnh khởi động môi trường prod:
|
||||
```bash
|
||||
docker compose -f docker-compose.prod.yml up --build -d
|
||||
```
|
||||
- Xác nhận mọi service khởi chạy ngầm thành công.
|
||||
- Truy cập ứng dụng qua cổng `80` (http://localhost) và xác nhận hoạt động bình thường.
|
||||
@@ -0,0 +1,2 @@
|
||||
VITE_BACKEND_URL=https://yotrip.labz.io.vn
|
||||
VITE_GOOGLE_CLIENT_ID=639044397050-7hair384u6lle941h033trut1s3q47l4.apps.googleusercontent.com
|
||||
@@ -0,0 +1,2 @@
|
||||
VITE_BACKEND_URL=https://yotrip.labz.io.vn
|
||||
VITE_GOOGLE_CLIENT_ID=639044397050-7hair384u6lle941h033trut1s3q47l4.apps.googleusercontent.com
|
||||
@@ -15,7 +15,7 @@ CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"]
|
||||
FROM base AS build
|
||||
ARG VITE_GOOGLE_CLIENT_ID
|
||||
ENV VITE_GOOGLE_CLIENT_ID=$VITE_GOOGLE_CLIENT_ID
|
||||
RUN npm install
|
||||
RUN npm install --legacy-peer-deps
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
# Using Android gitignore template: https://github.com/github/gitignore/blob/HEAD/Android.gitignore
|
||||
|
||||
# Built application files
|
||||
*.apk
|
||||
*.aar
|
||||
*.ap_
|
||||
*.aab
|
||||
|
||||
# Files for the ART/Dalvik VM
|
||||
*.dex
|
||||
|
||||
# Java class files
|
||||
*.class
|
||||
|
||||
# Generated files
|
||||
bin/
|
||||
gen/
|
||||
out/
|
||||
# Uncomment the following line in case you need and you don't have the release build type files in your app
|
||||
# release/
|
||||
|
||||
# Gradle files
|
||||
.gradle/
|
||||
build/
|
||||
|
||||
# Local configuration file (sdk path, etc)
|
||||
local.properties
|
||||
|
||||
# Proguard folder generated by Eclipse
|
||||
proguard/
|
||||
|
||||
# Log Files
|
||||
*.log
|
||||
|
||||
# Android Studio Navigation editor temp files
|
||||
.navigation/
|
||||
|
||||
# Android Studio captures folder
|
||||
captures/
|
||||
|
||||
# IntelliJ
|
||||
*.iml
|
||||
.idea/workspace.xml
|
||||
.idea/tasks.xml
|
||||
.idea/gradle.xml
|
||||
.idea/assetWizardSettings.xml
|
||||
.idea/dictionaries
|
||||
.idea/libraries
|
||||
# Android Studio 3 in .gitignore file.
|
||||
.idea/caches
|
||||
.idea/modules.xml
|
||||
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
|
||||
.idea/navEditor.xml
|
||||
|
||||
# Keystore files
|
||||
# Uncomment the following lines if you do not want to check your keystore files in.
|
||||
#*.jks
|
||||
#*.keystore
|
||||
|
||||
# External native build folder generated in Android Studio 2.2 and later
|
||||
.externalNativeBuild
|
||||
.cxx/
|
||||
|
||||
# Google Services (e.g. APIs or Firebase)
|
||||
# google-services.json
|
||||
|
||||
# Freeline
|
||||
freeline.py
|
||||
freeline/
|
||||
freeline_project_description.json
|
||||
|
||||
# fastlane
|
||||
fastlane/report.xml
|
||||
fastlane/Preview.html
|
||||
fastlane/screenshots
|
||||
fastlane/test_output
|
||||
fastlane/readme.md
|
||||
|
||||
# Version control
|
||||
vcs.xml
|
||||
|
||||
# lint
|
||||
lint/intermediates/
|
||||
lint/generated/
|
||||
lint/outputs/
|
||||
lint/tmp/
|
||||
# lint/reports/
|
||||
|
||||
# Android Profiling
|
||||
*.hprof
|
||||
|
||||
# Cordova plugins for Capacitor
|
||||
capacitor-cordova-android-plugins
|
||||
|
||||
# Copied web assets
|
||||
app/src/main/assets/public
|
||||
|
||||
# Generated Config files
|
||||
app/src/main/assets/capacitor.config.json
|
||||
app/src/main/assets/capacitor.plugins.json
|
||||
app/src/main/res/xml/config.xml
|
||||
@@ -0,0 +1,2 @@
|
||||
/build/*
|
||||
!/build/.npmkeep
|
||||
@@ -0,0 +1,54 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
namespace "com.yotrip.app"
|
||||
compileSdk rootProject.ext.compileSdkVersion
|
||||
defaultConfig {
|
||||
applicationId "com.yotrip.app"
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
aaptOptions {
|
||||
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
|
||||
// Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61
|
||||
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
flatDir{
|
||||
dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
||||
implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
|
||||
implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion"
|
||||
implementation project(':capacitor-android')
|
||||
testImplementation "junit:junit:$junitVersion"
|
||||
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
||||
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
||||
implementation project(':capacitor-cordova-android-plugins')
|
||||
}
|
||||
|
||||
apply from: 'capacitor.build.gradle'
|
||||
|
||||
try {
|
||||
def servicesJSON = file('google-services.json')
|
||||
if (servicesJSON.text) {
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
}
|
||||
} catch(Exception e) {
|
||||
logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
|
||||
|
||||
android {
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_21
|
||||
targetCompatibility JavaVersion.VERSION_21
|
||||
}
|
||||
}
|
||||
|
||||
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
|
||||
dependencies {
|
||||
implementation project(':capacitor-camera')
|
||||
implementation project(':capacitor-geolocation')
|
||||
implementation project(':capacitor-local-notifications')
|
||||
implementation project(':codetrix-studio-capacitor-google-auth')
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (hasProperty('postBuildExtras')) {
|
||||
postBuildExtras()
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.getcapacitor.myapp;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
|
||||
@Test
|
||||
public void useAppContext() throws Exception {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
|
||||
assertEquals("com.getcapacitor.app", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme"
|
||||
android:usesCleartextTraffic="true">
|
||||
<activity
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode|navigation"
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/title_activity_main"
|
||||
android:theme="@style/AppTheme.NoActionBarLaunch"
|
||||
android:launchMode="singleTask"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}.fileprovider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
</application>
|
||||
|
||||
<!-- Permissions -->
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-feature android:name="android.hardware.location.gps" />
|
||||
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
|
||||
<queries>
|
||||
<intent>
|
||||
<action android:name="android.media.action.IMAGE_CAPTURE" />
|
||||
</intent>
|
||||
</queries>
|
||||
</manifest>
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.yotrip.app;
|
||||
|
||||
import com.getcapacitor.BridgeActivity;
|
||||
|
||||
public class MainActivity extends BridgeActivity {}
|
||||
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 60 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 128 KiB |
|
After Width: | Height: | Size: 182 KiB |
|
After Width: | Height: | Size: 235 KiB |
|
After Width: | Height: | Size: 118 KiB |
|
After Width: | Height: | Size: 164 KiB |
|
After Width: | Height: | Size: 207 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 59 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 129 KiB |
|
After Width: | Height: | Size: 179 KiB |
|
After Width: | Height: | Size: 228 KiB |
|
After Width: | Height: | Size: 116 KiB |
|
After Width: | Height: | Size: 161 KiB |
|
After Width: | Height: | Size: 202 KiB |
@@ -0,0 +1,34 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportHeight="108"
|
||||
android:viewportWidth="108">
|
||||
<path
|
||||
android:fillType="evenOdd"
|
||||
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
|
||||
android:strokeColor="#00000000"
|
||||
android:strokeWidth="1">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="78.5885"
|
||||
android:endY="90.9159"
|
||||
android:startX="48.7653"
|
||||
android:startY="61.0927"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
|
||||
android:strokeColor="#00000000"
|
||||
android:strokeWidth="1" />
|
||||
</vector>
|
||||
@@ -0,0 +1,170 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportHeight="108"
|
||||
android:viewportWidth="108">
|
||||
<path
|
||||
android:fillColor="#26A69A"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
</vector>
|
||||
|
After Width: | Height: | Size: 23 KiB |
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<WebView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background>
|
||||
<inset android:drawable="@mipmap/ic_launcher_background" android:inset="16.7%" />
|
||||
</background>
|
||||
<foreground>
|
||||
<inset android:drawable="@mipmap/ic_launcher_foreground" android:inset="16.7%" />
|
||||
</foreground>
|
||||
</adaptive-icon>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background>
|
||||
<inset android:drawable="@mipmap/ic_launcher_background" android:inset="16.7%" />
|
||||
</background>
|
||||
<foreground>
|
||||
<inset android:drawable="@mipmap/ic_launcher_foreground" android:inset="16.7%" />
|
||||
</foreground>
|
||||
</adaptive-icon>
|
||||
|
After Width: | Height: | Size: 5.5 KiB |
|
After Width: | Height: | Size: 212 B |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 8.0 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 147 B |
|
After Width: | Height: | Size: 8.7 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 175 B |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 285 B |
|
After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 431 B |
|
After Width: | Height: | Size: 89 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 558 B |
|
After Width: | Height: | Size: 137 KiB |
|
After Width: | Height: | Size: 39 KiB |
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="ic_launcher_background">#FFFFFF</color>
|
||||
</resources>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<resources>
|
||||
<string name="app_name">YoTrip</string>
|
||||
<string name="title_activity_main">YoTrip</string>
|
||||
<string name="package_name">com.yotrip.app</string>
|
||||
<string name="custom_url_scheme">com.yotrip.app</string>
|
||||
<string name="server_client_id">639044397050-7hair384u6lle941h033trut1s3q47l4.apps.googleusercontent.com</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.DayNight.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
<item name="android:background">@null</item>
|
||||
</style>
|
||||
|
||||
|
||||
<style name="AppTheme.NoActionBarLaunch" parent="Theme.SplashScreen">
|
||||
<item name="android:background">@drawable/splash</item>
|
||||
</style>
|
||||
</resources>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<external-path name="my_images" path="." />
|
||||
<cache-path name="my_cache_images" path="." />
|
||||
</paths>
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.getcapacitor.myapp;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
|
||||
@Test
|
||||
public void addition_isCorrect() throws Exception {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:8.7.2'
|
||||
classpath 'com.google.gms:google-services:4.4.2'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
}
|
||||
|
||||
apply from: "variables.gradle"
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
subprojects {
|
||||
configurations.all {
|
||||
resolutionStrategy {
|
||||
force "androidx.core:core-ktx:${rootProject.ext.androidxCoreVersion}"
|
||||
force "androidx.core:core:${rootProject.ext.androidxCoreVersion}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
|
||||
include ':capacitor-android'
|
||||
project(':capacitor-android').projectDir = new File('../../node_modules/@capacitor/android/capacitor')
|
||||
|
||||
include ':capacitor-camera'
|
||||
project(':capacitor-camera').projectDir = new File('../../node_modules/@capacitor/camera/android')
|
||||
|
||||
include ':capacitor-geolocation'
|
||||
project(':capacitor-geolocation').projectDir = new File('../../node_modules/@capacitor/geolocation/android')
|
||||
|
||||
include ':capacitor-local-notifications'
|
||||
project(':capacitor-local-notifications').projectDir = new File('../../node_modules/@capacitor/local-notifications/android')
|
||||
|
||||
include ':codetrix-studio-capacitor-google-auth'
|
||||
project(':codetrix-studio-capacitor-google-auth').projectDir = new File('../../node_modules/@codetrix-studio/capacitor-google-auth/android')
|
||||
@@ -0,0 +1,22 @@
|
||||
# Project-wide Gradle settings.
|
||||
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx1536m
|
||||
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
|
||||
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||
# Android operating system, and which are packaged with your app's APK
|
||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||
android.useAndroidX=true
|
||||
@@ -0,0 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -0,0 +1,252 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
||||
' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||