ewnewq commited on
Commit
1d2d740
·
verified ·
1 Parent(s): 574e27c

https://mybatis-flex.com/zh/others/codegen.html#%E7%AE%80%E4%BB%8B 开发纯前端 代码生成器

Browse files
Files changed (6) hide show
  1. README.md +7 -4
  2. components/footer.js +58 -0
  3. components/navbar.js +82 -0
  4. index.html +159 -19
  5. script.js +124 -0
  6. style.css +32 -18
README.md CHANGED
@@ -1,10 +1,13 @@
1
  ---
2
- title: Flexgen Studio
3
- emoji: 🏢
4
- colorFrom: yellow
5
  colorTo: yellow
 
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
1
  ---
2
+ title: FlexGen Studio 🚀
3
+ colorFrom: blue
 
4
  colorTo: yellow
5
+ emoji: 🐳
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite-v3
10
  ---
11
 
12
+ # Welcome to your new DeepSite project!
13
+ This project was created with [DeepSite](https://huggingface.co/deepsite).
components/footer.js ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class CustomFooter extends HTMLElement {
2
+ connectedCallback() {
3
+ this.attachShadow({ mode: 'open' });
4
+ this.shadowRoot.innerHTML = `
5
+ <style>
6
+ footer {
7
+ background: #1f2937;
8
+ color: #f9fafb;
9
+ padding: 3rem 2rem;
10
+ text-align: center;
11
+ margin-top: auto;
12
+ }
13
+ .footer-content {
14
+ max-width: 6xl;
15
+ margin: 0 auto;
16
+ }
17
+ .footer-links {
18
+ display: flex;
19
+ justify-content: center;
20
+ gap: 2rem;
21
+ margin-bottom: 2rem;
22
+ flex-wrap: wrap;
23
+ }
24
+ .footer-links a {
25
+ color: #d1d5db;
26
+ text-decoration: none;
27
+ transition: color 0.2s ease;
28
+ }
29
+ .footer-links a:hover {
30
+ color: #3b82f6;
31
+ }
32
+ .copyright {
33
+ color: #9ca3af;
34
+ font-size: 0.875rem;
35
+ }
36
+ @media (max-width: 768px) {
37
+ .footer-links {
38
+ flex-direction: column;
39
+ gap: 1rem;
40
+ }
41
+ }
42
+ </style>
43
+ <footer>
44
+ <div class="footer-content">
45
+ <div class="footer-links">
46
+ <a href="#hero">Home</a>
47
+ <a href="#features">Features</a>
48
+ <a href="#generator">Generator</a>
49
+ <a href="https://mybatis-flex.com" target="_blank">Documentation</a>
50
+ <a href="https://github.com/mybatis-flex" target="_blank">GitHub</a>
51
+ </div>
52
+ <p class="copyright">&copy; 2024 FlexGen Studio. Powered by MyBatis Flex. All rights reserved.</p>
53
+ </div>
54
+ </footer>
55
+ `;
56
+ }
57
+ }
58
+ customElements.define('custom-footer', CustomFooter);
components/navbar.js ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class CustomNavbar extends HTMLElement {
2
+ connectedCallback() {
3
+ this.attachShadow({ mode: 'open' });
4
+ this.shadowRoot.innerHTML = `
5
+ <style>
6
+ nav {
7
+ background: rgba(255, 255, 255, 0.95);
8
+ backdrop-filter: blur(10px);
9
+ border-bottom: 1px solid rgba(229, 231, 235, 0.5);
10
+ padding: 1rem 2rem;
11
+ display: flex;
12
+ justify-content: space-between;
13
+ align-items: center;
14
+ position: fixed;
15
+ top: 0;
16
+ left: 0;
17
+ right: 0;
18
+ z-index: 1000;
19
+ transition: all 0.3s ease;
20
+ }
21
+ .logo {
22
+ color: #1f2937;
23
+ font-weight: 800;
24
+ font-size: 1.5rem;
25
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
26
+ -webkit-background-clip: text;
27
+ -webkit-text-fill-color: transparent;
28
+ }
29
+ ul {
30
+ display: flex;
31
+ gap: 2rem;
32
+ list-style: none;
33
+ margin: 0;
34
+ padding: 0;
35
+ }
36
+ a {
37
+ color: #4b5563;
38
+ text-decoration: none;
39
+ font-weight: 500;
40
+ transition: all 0.2s ease;
41
+ position: relative;
42
+ }
43
+ a:hover {
44
+ color: #3b82f6;
45
+ }
46
+ a::after {
47
+ content: '';
48
+ position: absolute;
49
+ width: 0;
50
+ height: 2px;
51
+ bottom: -4px;
52
+ left: 0;
53
+ background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
54
+ transition: width 0.3s ease;
55
+ }
56
+ a:hover::after {
57
+ width: 100%;
58
+ }
59
+ @media (max-width: 768px) {
60
+ nav {
61
+ padding: 1rem;
62
+ flex-direction: column;
63
+ gap: 1rem;
64
+ }
65
+ ul {
66
+ gap: 1rem;
67
+ }
68
+ }
69
+ </style>
70
+ <nav>
71
+ <div class="logo">FlexGen Studio</div>
72
+ <ul>
73
+ <li><a href="#hero">Home</a></li>
74
+ <li><a href="#features">Features</a></li>
75
+ <li><a href="#generator">Generator</a></li>
76
+ <li><a href="https://mybatis-flex.com" target="_blank">Docs</a></li>
77
+ </ul>
78
+ </nav>
79
+ `;
80
+ }
81
+ }
82
+ customElements.define('custom-navbar', CustomNavbar);
index.html CHANGED
@@ -1,19 +1,159 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>FlexGen Studio - MyBatis Flex Code Generator</title>
7
+ <link rel="icon" type="image/x-icon" href="/static/favicon.ico">
8
+ <link rel="stylesheet" href="style.css">
9
+ <script src="https://cdn.tailwindcss.com"></script>
10
+ <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
11
+ <script src="https://unpkg.com/feather-icons"></script>
12
+ <script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.globe.min.js"></script>
13
+ </head>
14
+ <body class="min-h-screen bg-gradient-to-br from-blue-50 to-indigo-100">
15
+ <custom-navbar></custom-navbar>
16
+
17
+ <!-- Hero Section -->
18
+ <section id="hero" class="relative min-h-screen flex items-center justify-center overflow-hidden">
19
+ <div class="absolute inset-0 z-0" id="vanta-bg"></div>
20
+ <div class="relative z-10 max-w-6xl mx-auto px-4 text-center">
21
+ <h1 class="text-5xl md:text-7xl font-bold text-gray-800 mb-6">
22
+ FlexGen Studio
23
+ </h1>
24
+ <p class="text-xl md:text-2xl text-gray-600 mb-8">
25
+ Generate MyBatis Flex Code with Ease 🎯
26
+ </p>
27
+ <div class="flex flex-col sm:flex-row gap-4 justify-center">
28
+ <a href="#generator" class="bg-blue-600 hover:bg-blue-700 text-white px-8 py-4 rounded-lg font-semibold text-lg transition-all duration-300 transform hover:scale-105 shadow-lg">
29
+ Start Generating
30
+ </a>
31
+ <a href="#features" class="border-2 border-blue-600 text-blue-600 hover:bg-blue-600 hover:text-white px-8 py-4 rounded-lg font-semibold text-lg transition-all duration-300">
32
+ Learn More
33
+ </a>
34
+ </div>
35
+ </div>
36
+ </section>
37
+
38
+ <!-- Features Section -->
39
+ <section id="features" class="py-20 bg-white">
40
+ <div class="max-w-6xl mx-auto px-4">
41
+ <h2 class="text-4xl font-bold text-center text-gray-800 mb-16">Why Choose FlexGen Studio?</h2>
42
+ <div class="grid md:grid-cols-3 gap-8">
43
+ <div class="text-center p-6">
44
+ <div class="w-16 h-16 bg-blue-100 rounded-full flex items-center justify-center mx-auto mb-4">
45
+ <i data-feather="zap" class="text-blue-600"></i>
46
+ </div>
47
+ <h3 class="text-xl font-semibold mb-4">Lightning Fast</h3>
48
+ <p class="text-gray-600">Generate optimized MyBatis Flex code in seconds with our intelligent templates.</p>
49
+ </div>
50
+ <div class="text-center p-6">
51
+ <div class="w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-4">
52
+ <i data-feather="code" class="text-green-600"></i>
53
+ </div>
54
+ <h3 class="text-xl font-semibold mb-4">Clean Code</h3>
55
+ <p class="text-gray-600">Production-ready, well-structured code following best practices and conventions.</p>
56
+ </div>
57
+ <div class="text-center p-6">
58
+ <div class="w-16 h-16 bg-purple-100 rounded-full flex items-center justify-center mx-auto mb-4">
59
+ <i data-feather="settings" class="text-purple-600"></i>
60
+ </div>
61
+ <h3 class="text-xl font-semibold mb-4">Customizable</h3>
62
+ <p class="text-gray-600">Tailor the generated code to your specific project requirements and preferences.</p>
63
+ </div>
64
+ </div>
65
+ </div>
66
+ </section>
67
+
68
+ <!-- Code Generator Section -->
69
+ <section id="generator" class="py-20 bg-gray-50">
70
+ <div class="max-w-6xl mx-auto px-4">
71
+ <h2 class="text-4xl font-bold text-center text-gray-800 mb-16">Code Generator</h2>
72
+ <div class="bg-white rounded-2xl shadow-xl p-8">
73
+ <div class="grid lg:grid-cols-2 gap-8">
74
+ <!-- Input Section -->
75
+ <div class="space-y-6">
76
+ <div>
77
+ <label class="block text-sm font-medium text-gray-700 mb-2">Database Configuration</label>
78
+ <div class="grid grid-cols-2 gap-4">
79
+ <input type="text" placeholder="Database URL" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent">
80
+ <input type="text" placeholder="Username" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent">
81
+ </div>
82
+ </div>
83
+ <div>
84
+ <label class="block text-sm font-medium text-gray-700 mb-2">Table Selection</label>
85
+ <select class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent">
86
+ <option>Select tables to generate...</option>
87
+ <option>All tables</option>
88
+ <option>Custom selection</option>
89
+ </select>
90
+ </div>
91
+ <div>
92
+ <label class="block text-sm font-medium text-gray-700 mb-2">Output Configuration</label>
93
+ <div class="space-y-3">
94
+ <label class="flex items-center">
95
+ <input type="checkbox" class="rounded border-gray-300 text-blue-600 focus:ring-blue-500">
96
+ <span class="ml-2">Generate Entity Classes</span>
97
+ </label>
98
+ <label class="flex items-center">
99
+ <input type="checkbox" class="rounded border-gray-300 text-blue-600 focus:ring-blue-500" checked>
100
+ <span class="ml-2">Generate Mapper Interfaces</span>
101
+ </label>
102
+ <label class="flex items-center">
103
+ <input type="checkbox" class="rounded border-gray-300 text-blue-600 focus:ring-blue-500">
104
+ <span class="ml-2">Generate Service Classes</span>
105
+ </label>
106
+ </div>
107
+ </div>
108
+ <button onclick="generateCode()" class="w-full bg-blue-600 hover:bg-blue-700 text-white py-4 px-6 rounded-lg font-semibold text-lg transition-all duration-300 transform hover:scale-105">
109
+ Generate Code
110
+ </button>
111
+ </div>
112
+
113
+ <!-- Output Preview -->
114
+ <div>
115
+ <label class="block text-sm font-medium text-gray-700 mb-2">Generated Code Preview</label>
116
+ <div class="bg-gray-900 rounded-lg p-4 h-96 overflow-auto">
117
+ <pre id="code-output" class="text-green-400 text-sm font-mono">// Generated code will appear here...</pre>
118
+ </div>
119
+ <div class="mt-4 flex gap-3">
120
+ <button onclick="copyCode()" class="flex-1 bg-gray-600 hover:bg-gray-700 text-white py-3 px-4 rounded-lg font-medium transition-colors">
121
+ <i data-feather="copy" class="inline w-4 h-4 mr-2"></i>
122
+ Copy Code
123
+ </button>
124
+ <button onclick="downloadCode()" class="flex-1 bg-green-600 hover:bg-green-700 text-white py-3 px-4 rounded-lg font-medium transition-colors">
125
+ <i data-feather="download" class="inline w-4 h-4 mr-2"></i>
126
+ Download
127
+ </button>
128
+ </div>
129
+ </div>
130
+ </div>
131
+ </div>
132
+ </div>
133
+ </section>
134
+
135
+ <custom-footer></custom-footer>
136
+
137
+ <!-- Scripts -->
138
+ <script src="components/navbar.js"></script>
139
+ <script src="components/footer.js"></script>
140
+ <script src="script.js"></script>
141
+ <script>
142
+ feather.replace();
143
+ // Initialize Vanta.js background
144
+ VANTA.GLOBE({
145
+ el: "#vanta-bg",
146
+ mouseControls: true,
147
+ touchControls: true,
148
+ gyroControls: false,
149
+ minHeight: 200.00,
150
+ minWidth: 200.00,
151
+ scale: 1.00,
152
+ scaleMobile: 1.00,
153
+ color: 0x3b82f6,
154
+ backgroundColor: 0xf8fafc
155
+ });
156
+ </script>
157
+ <script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
158
+ </body>
159
+ </html>
script.js ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Shared JavaScript across all pages
2
+
3
+ // Code generation function
4
+ function generateCode() {
5
+ const codeOutput = document.getElementById('code-output');
6
+
7
+ // Sample generated code (in real implementation, this would come from API)
8
+ const sampleCode = `package com.example.entity;
9
+
10
+ import com.mybatisflex.annotation.Id;
11
+ import com.mybatisflex.annotation.Table;
12
+ import java.time.LocalDateTime;
13
+
14
+ @Table("user")
15
+ public class User {
16
+
17
+ @Id
18
+ private Long id;
19
+ private String username;
20
+ private String email;
21
+ private LocalDateTime createTime;
22
+ private LocalDateTime updateTime;
23
+
24
+ // Getters and Setters
25
+ public Long getId() { return id; }
26
+ public void setId(Long id) { this.id = id; }
27
+
28
+ public String getUsername() { return username; }
29
+ public void setUsername(String username) { this.username = username; }
30
+
31
+ public String getEmail() { return email; }
32
+ public void setEmail(String email) { this.email = email; }
33
+
34
+ public LocalDateTime getCreateTime() { return createTime; }
35
+ public void setCreateTime(LocalDateTime createTime) { this.createTime = createTime; }
36
+
37
+ public LocalDateTime getUpdateTime() { return updateTime; }
38
+ public void setUpdateTime(LocalDateTime updateTime) { this.updateTime = updateTime; }
39
+ }`;
40
+
41
+ codeOutput.textContent = sampleCode;
42
+ codeOutput.classList.add('code-highlight');
43
+ setTimeout(() => codeOutput.classList.remove('code-highlight'), 2000);
44
+
45
+ // Show success notification
46
+ showNotification('Code generated successfully!', 'success');
47
+ }
48
+
49
+ // Copy code to clipboard
50
+ function copyCode() {
51
+ const codeOutput = document.getElementById('code-output');
52
+ const textArea = document.createElement('textarea');
53
+ textArea.value = codeOutput.textContent;
54
+ document.body.appendChild(textArea);
55
+ textArea.select();
56
+ document.execCommand('copy');
57
+ document.body.removeChild(textArea);
58
+
59
+ showNotification('Code copied to clipboard!', 'success');
60
+ }
61
+
62
+ // Download generated code
63
+ function downloadCode() {
64
+ const codeOutput = document.getElementById('code-output');
65
+ const blob = new Blob([codeOutput.textContent], { type: 'text/plain' });
66
+ const url = URL.createObjectURL(blob);
67
+ const a = document.createElement('a');
68
+ a.href = url;
69
+ a.download = 'MyBatisFlexGeneratedCode.java';
70
+ document.body.appendChild(a);
71
+ a.click();
72
+ document.body.removeChild(a);
73
+ URL.revokeObjectURL(url);
74
+
75
+ showNotification('Code downloaded successfully!', 'success');
76
+ }
77
+
78
+ // Notification system
79
+ function showNotification(message, type = 'info') {
80
+ const notification = document.createElement('div');
81
+ notification.className = `fixed top-4 right-4 z-50 px-6 py-4 rounded-lg shadow-lg transform transition-all duration-300 ${
82
+ type === 'success' ? 'bg-green-500 text-white' :
83
+ type === 'error' ? 'bg-red-500 text-white' :
84
+ 'bg-blue-500 text-white'
85
+ }`;
86
+ notification.textContent = message;
87
+
88
+ document.body.appendChild(notification);
89
+
90
+ // Animate in
91
+ setTimeout(() => {
92
+ notification.classList.add('translate-x-0', 'opacity-100');
93
+ notification.classList.remove('translate-x-full', 'opacity-0');
94
+ }, 100);
95
+
96
+ // Auto remove after 3 seconds
97
+ setTimeout(() => {
98
+ notification.classList.add('translate-x-full', 'opacity-0');
99
+ setTimeout(() => {
100
+ if (notification.parentNode) {
101
+ notification.parentNode.removeChild(notification);
102
+ }
103
+ }, 300);
104
+ }, 3000);
105
+ }
106
+
107
+ // Initialize app when DOM is loaded
108
+ document.addEventListener('DOMContentLoaded', function() {
109
+ console.log('FlexGen Studio loaded successfully!');
110
+
111
+ // Add smooth scrolling for anchor links
112
+ document.querySelectorAll('a[href^="#"]').forEach(anchor => {
113
+ anchor.addEventListener('click', function (e) {
114
+ e.preventDefault();
115
+ const target = document.querySelector(this.getAttribute('href'));
116
+ if (target) {
117
+ target.scrollIntoView({
118
+ behavior: 'smooth',
119
+ block: 'start'
120
+ });
121
+ }
122
+ });
123
+ });
124
+ });
style.css CHANGED
@@ -1,28 +1,42 @@
 
 
 
1
  body {
2
- padding: 2rem;
3
- font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
 
 
 
 
 
4
  }
5
 
6
- h1 {
7
- font-size: 16px;
8
- margin-top: 0;
9
  }
10
 
11
- p {
12
- color: rgb(107, 114, 128);
13
- font-size: 15px;
14
- margin-bottom: 10px;
15
- margin-top: 5px;
16
  }
17
 
18
- .card {
19
- max-width: 620px;
20
- margin: 0 auto;
21
- padding: 16px;
22
- border: 1px solid lightgray;
23
- border-radius: 16px;
24
  }
25
 
26
- .card p:last-child {
27
- margin-bottom: 0;
 
 
28
  }
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Shared styles across all pages */
2
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');
3
+
4
  body {
5
+ font-family: 'Inter', sans-serif;
6
+ scroll-behavior: smooth;
7
+ }
8
+
9
+ /* Custom scrollbar for code preview */
10
+ #code-output::-webkit-scrollbar {
11
+ width: 8px;
12
  }
13
 
14
+ #code-output::-webkit-scrollbar-track {
15
+ background: #1f2937;
 
16
  }
17
 
18
+ #code-output::-webkit-scrollbar-thumb {
19
+ background: #4b5563;
20
+ border-radius: 4px;
 
 
21
  }
22
 
23
+ #code-output::-webkit-scrollbar-thumb:hover {
24
+ background: #6b7280;
 
 
 
 
25
  }
26
 
27
+ /* Animation for generated code */
28
+ @keyframes codeHighlight {
29
+ 0% { background-color: rgba(34, 197, 94, 0.3); }
30
+ 100% { background-color: transparent; }
31
  }
32
+
33
+ .code-highlight {
34
+ animation: codeHighlight 2s ease-in-out;
35
+ }
36
+
37
+ /* Responsive design enhancements */
38
+ @media (max-width: 768px) {
39
+ .hero-text {
40
+ font-size: 2.5rem;
41
+ }
42
+ }