mirror of
https://github.com/xtr-dev/rondevu-demo.git
synced 2025-12-10 18:53:24 +00:00
Add version display in footer
- Add version state tracking for demo and server versions - Create loadVersions() function to fetch server version via API - Update footer to display both demo version and server version - Update vite.config.js to inject git commit hash as VITE_VERSION 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
23
src/App.jsx
23
src/App.jsx
@@ -60,6 +60,10 @@ function App() {
|
|||||||
const [channelReady, setChannelReady] = useState(false);
|
const [channelReady, setChannelReady] = useState(false);
|
||||||
const [fileUploadProgress, setFileUploadProgress] = useState(null);
|
const [fileUploadProgress, setFileUploadProgress] = useState(null);
|
||||||
|
|
||||||
|
// Version state
|
||||||
|
const [demoVersion, setDemoVersion] = useState('unknown');
|
||||||
|
const [serverVersion, setServerVersion] = useState('unknown');
|
||||||
|
|
||||||
const connectionRef = useRef(null);
|
const connectionRef = useRef(null);
|
||||||
const dataChannelRef = useRef(null);
|
const dataChannelRef = useRef(null);
|
||||||
const fileTransfersRef = useRef(new Map()); // Track ongoing file transfers
|
const fileTransfersRef = useRef(new Map()); // Track ongoing file transfers
|
||||||
@@ -68,6 +72,7 @@ function App() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
log('Demo initialized', 'info');
|
log('Demo initialized', 'info');
|
||||||
loadTopics();
|
loadTopics();
|
||||||
|
loadVersions();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const log = (message, type = 'info') => {
|
const log = (message, type = 'info') => {
|
||||||
@@ -75,6 +80,19 @@ function App() {
|
|||||||
setLogs(prev => [...prev, { message, type, timestamp }]);
|
setLogs(prev => [...prev, { message, type, timestamp }]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const loadVersions = async () => {
|
||||||
|
// Get demo version from build environment
|
||||||
|
setDemoVersion(import.meta.env.VITE_VERSION || 'unknown');
|
||||||
|
|
||||||
|
// Get server version from API
|
||||||
|
try {
|
||||||
|
const { version } = await client.getVersion();
|
||||||
|
setServerVersion(version);
|
||||||
|
} catch (error) {
|
||||||
|
log(`Error loading server version: ${error.message}`, 'error');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const loadTopics = async () => {
|
const loadTopics = async () => {
|
||||||
try {
|
try {
|
||||||
const { topics } = await client.listTopics();
|
const { topics } = await client.listTopics();
|
||||||
@@ -518,9 +536,14 @@ function App() {
|
|||||||
</main>
|
</main>
|
||||||
|
|
||||||
<footer className="footer">
|
<footer className="footer">
|
||||||
|
<div style={{ display: 'flex', flexDirection: 'column', gap: '0.25rem', alignItems: 'center' }}>
|
||||||
<a href="https://ronde.vu" target="_blank" rel="noopener noreferrer">
|
<a href="https://ronde.vu" target="_blank" rel="noopener noreferrer">
|
||||||
ronde.vu
|
ronde.vu
|
||||||
</a>
|
</a>
|
||||||
|
<div style={{ fontSize: '0.75rem', color: '#888' }}>
|
||||||
|
Demo: {demoVersion} | Server: {serverVersion}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,5 +1,14 @@
|
|||||||
import { defineConfig } from 'vite';
|
import { defineConfig } from 'vite';
|
||||||
import react from '@vitejs/plugin-react';
|
import react from '@vitejs/plugin-react';
|
||||||
|
import { execSync } from 'child_process';
|
||||||
|
|
||||||
|
// Get git commit hash
|
||||||
|
let version = 'unknown';
|
||||||
|
try {
|
||||||
|
version = execSync('git rev-parse --short HEAD', { encoding: 'utf8' }).trim();
|
||||||
|
} catch (err) {
|
||||||
|
console.warn('Could not get git commit hash, using "unknown"');
|
||||||
|
}
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react()],
|
plugins: [react()],
|
||||||
@@ -10,5 +19,8 @@ export default defineConfig({
|
|||||||
build: {
|
build: {
|
||||||
outDir: 'dist',
|
outDir: 'dist',
|
||||||
sourcemap: true
|
sourcemap: true
|
||||||
|
},
|
||||||
|
define: {
|
||||||
|
'import.meta.env.VITE_VERSION': JSON.stringify(version)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user