fix: SPA routing and prompts table handling

- Add clean URL routing: /dashboard -> dashboard.html, /settings -> settings.html
- Add EnsurePromptsTable for dev environments where prompts table may not exist
- Fix nav links to use clean URLs instead of .html paths

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-06-26 15:08:12 +08:00
parent f456cdb565
commit b7008afd29
4 changed files with 57 additions and 5 deletions
+18
View File
@@ -109,6 +109,24 @@ func AutoMigrate() error {
return nil
}
// EnsurePromptsTable creates the prompts table if it doesn't exist (for dev environments)
func EnsurePromptsTable() {
_, err := DB.Exec(`CREATE TABLE IF NOT EXISTS prompts (
id bigint NOT NULL AUTO_INCREMENT,
session_id varchar(128) NOT NULL,
project_name varchar(255) NOT NULL DEFAULT '',
prompt text NOT NULL,
created_at datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id),
KEY idx_session_id (session_id),
KEY idx_project_name (project_name),
KEY idx_created_at (created_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4`)
if err != nil {
log.Printf("Warning: failed to ensure prompts table: %v", err)
}
}
func SeedData() error {
// Check if system tags already exist
var count int