demo-version: höchstens 6 projekte
- edition.json (nur im Demo-Build) bzw. DASHBOARD_DEMO=1 schaltet die Demo ein. projectList() gibt dann fest nach Name die ersten 6 Projekte aus; Board, Galerie, Liste, Kennzahlen, Speicher, Aktivität, Details, Aktionen, Löschen und Aufräumen kennen damit nur diese 6. - Backup: robocopy schließt in der Demo alle übrigen Projektordner per /XD aus (auch die automatische Sicherung). - Neu/Klonen: Server lehnt ab Grenze ab, Oberfläche zeigt einen Kauf-Hinweis. - Demo-Banner "Demo – 6 von N Projekten sichtbar" + "Vollversion holen", Demo-Badge und Kauf-Button unter Einstellungen → Über. EN/DE. - build.ps1 -Demo → release\ProjectDashboard-Demo.exe und ProjectDashboard-Demo-Setup.exe; der Installer nutzt dieselbe AppId wie die Vollversion, die ihn später am selben Ort ersetzt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
20
server.js
20
server.js
@@ -50,6 +50,14 @@ const HOST = '127.0.0.1'
|
||||
const PORT = Number(process.env.DASHBOARD_PORT) || 4848
|
||||
const ALLOWED_HOSTS = new Set([`localhost:${PORT}`, `127.0.0.1:${PORT}`])
|
||||
|
||||
// Edition: the demo build ships an edition.json next to this file (build.ps1 -Release -Demo).
|
||||
// The demo shows at most DEMO_LIMIT projects; everything else works. DASHBOARD_DEMO=1 tests it from source.
|
||||
const EDITION = (() => { try { return JSON.parse(fs.readFileSync(path.join(__dirname, 'edition.json'), 'utf8').replace(/^\uFEFF/, '')) } catch { return {} } })()
|
||||
const DEMO = EDITION.demo === true || process.env.DASHBOARD_DEMO === '1'
|
||||
const DEMO_LIMIT = Number(EDITION.limit) > 0 ? Number(EDITION.limit) : 6
|
||||
const BUY_URL = typeof EDITION.buyUrl === 'string' && EDITION.buyUrl ? EDITION.buyUrl : 'https://sn09.itch.io/project-dashboard'
|
||||
let demoTotal = 0 // all project folders found (the demo shows DEMO_LIMIT of them)
|
||||
|
||||
const STATUSES = ['idea', 'active', 'paused', 'done', 'archived']
|
||||
const PRIORITIES = ['low', 'medium', 'high']
|
||||
|
||||
@@ -239,8 +247,13 @@ function projectList() {
|
||||
used.add(key.toLowerCase())
|
||||
return { key, folder: p.folder, root: p.root, parent: p.parent }
|
||||
})
|
||||
projMap = new Map(list.map((p) => [p.key, p]))
|
||||
return list
|
||||
demoTotal = list.length
|
||||
// demo: a fixed set (by name, so touching a project doesn't swap it in) – every view,
|
||||
// action and the backup only know these, since they all go through projMap
|
||||
const shown = DEMO ? [...list].sort((a, b) => a.key.localeCompare(b.key, 'de', { sensitivity: 'base' })).slice(0, DEMO_LIMIT) : list
|
||||
projMap = new Map(shown.map((p) => [p.key, p]))
|
||||
backup.limitTo(DEMO ? shown.map((p) => ({ root: p.root.path, folder: p.folder })) : null)
|
||||
return shown
|
||||
}
|
||||
|
||||
function projectNames() { return projectList().map((p) => p.key) }
|
||||
@@ -415,6 +428,7 @@ app.get('/api/projects', handle(async (req, res) => {
|
||||
setupNeeded: !settings.get().roots.some((r) => fs.existsSync(r.path)),
|
||||
noneShown: !ROOTS.length && !!settings.get().noneShown,
|
||||
projects: list,
|
||||
demo: DEMO ? { limit: DEMO_LIMIT, total: demoTotal, buyUrl: BUY_URL } : null,
|
||||
totals: { ...storage.totals(list.map((p) => ({ root: ROOTS.find((r) => r.id === p.root)?.path, folder: p.folder }))), noBackup: list.filter((p) => p.git.level === 'red').length },
|
||||
scan: storage.state,
|
||||
cleanupAvailable: storage.available(),
|
||||
@@ -523,6 +537,8 @@ app.post('/api/roots/active', (req, res) => {
|
||||
app.post('/api/projects/new', handle(async (req, res) => {
|
||||
const s = settings.get()
|
||||
const b = req.body ?? {}
|
||||
projectList()
|
||||
if (DEMO && demoTotal >= DEMO_LIMIT) return res.status(403).json({ error: `Demo: maximal ${DEMO_LIMIT} Projekte – für mehr die Vollversion holen: ${BUY_URL}` })
|
||||
const root = s.roots.find((r) => r.id === (b.root || s.activeRoot))
|
||||
if (!root || !fs.existsSync(root.path)) return res.status(400).json({ error: 'Projektordner nicht gefunden.' })
|
||||
let from = null
|
||||
|
||||
Reference in New Issue
Block a user