|
2 | 2 | <html>
|
3 | 3 | <head>
|
4 | 4 | <title>Clone ProcessOn</title>
|
| 5 | + <script src="https://cdn.tailwindcss.com"></script> |
5 | 6 | </head>
|
6 |
| - <style> |
7 |
| - :root { |
8 |
| - --primary-color: #067bef; |
9 |
| - --border: #eee; |
10 |
| - --input: #d9d9d9; |
11 |
| - --error: #dc2626; |
12 |
| - } |
13 |
| - * { |
14 |
| - margin: 0; |
15 |
| - padding: 0; |
16 |
| - font-size: 12px; |
17 |
| - box-sizing: border-box; |
18 |
| - } |
19 |
| - a { |
20 |
| - color: var(--primary-color); |
21 |
| - text-decoration: none; |
22 |
| - } |
23 |
| - a:hover { |
24 |
| - text-decoration: underline; |
25 |
| - } |
26 |
| - header { |
27 |
| - margin: 24px 0; |
28 |
| - } |
29 |
| - body { |
30 |
| - font-size: 14px; |
31 |
| - background-color: #f6f7f8; |
32 |
| - } |
33 |
| - input[type="submit"], |
34 |
| - button { |
35 |
| - padding: 8px 24px; |
36 |
| - font-size: 14px; |
37 |
| - border: 1px solid var(--border); |
38 |
| - cursor: pointer; |
39 |
| - border-radius: 4px; |
40 |
| - } |
41 |
| - input[type="password"], |
42 |
| - input[type="email"], |
43 |
| - input[type="text"] { |
44 |
| - padding: 8px 12px; |
45 |
| - border: 1px solid var(--input); |
46 |
| - width: 100%; |
47 |
| - } |
48 |
| - input[type="password"]:focus, |
49 |
| - input[type="email"]:focus, |
50 |
| - input[type="text"]:focus { |
51 |
| - outline-offset: 2px; |
52 |
| - outline: 2px solid var(--primary-color); |
53 |
| - } |
54 |
| - .block { |
55 |
| - display: block; |
56 |
| - } |
57 |
| - .w-full { |
58 |
| - width: 100%; |
59 |
| - } |
60 |
| - .btn:hover { |
61 |
| - color: var(--primary-color); |
62 |
| - border: 1px solid var(--primary-color); |
63 |
| - } |
64 |
| - .btn { |
65 |
| - cursor: pointer; |
66 |
| - padding: 8px 12px; |
67 |
| - background-color: #f1f1f1; |
68 |
| - border: 1px solid var(--border); |
69 |
| - color: #212930; |
70 |
| - text-decoration: none; |
71 |
| - border-radius: 2px; |
72 |
| - text-align: center; |
73 |
| - } |
74 |
| - .btn-primary { |
75 |
| - background: var(--primary-color); |
76 |
| - color: #fff; |
77 |
| - border: 1px solid var(--primary-color); |
78 |
| - } |
79 |
| - .btn-primary:hover { |
80 |
| - color: #fff; |
81 |
| - border: 1px solid var(--primary-color); |
82 |
| - } |
83 |
| - #list { |
84 |
| - margin-top: 16px; |
85 |
| - background: #fff; |
86 |
| - border: 1px solid var(--border); |
87 |
| - padding: 8px; |
88 |
| - } |
89 |
| - form > div { |
90 |
| - margin-top: 24px; |
91 |
| - } |
92 |
| - .empty { |
93 |
| - text-align: center; |
94 |
| - padding: 24px; |
95 |
| - } |
96 |
| - .ml-2 { |
97 |
| - margin-left: 8px; |
98 |
| - } |
99 |
| - .flex { |
100 |
| - display: flex; |
101 |
| - } |
102 |
| - .justify-between { |
103 |
| - justify-content: space-between; |
104 |
| - } |
105 |
| - .items-center { |
106 |
| - align-items: center; |
107 |
| - } |
108 |
| - .mx-auto { |
109 |
| - margin-left: auto; |
110 |
| - margin-right: auto; |
111 |
| - } |
112 |
| - .max-w-5xl { |
113 |
| - max-width: 1024px; |
114 |
| - } |
115 |
| - .w-2\/5 { |
116 |
| - width: 40%; |
117 |
| - border: 1px solid var(--border); |
118 |
| - padding: 24px; |
119 |
| - background: #fff; |
120 |
| - margin: auto; |
121 |
| - } |
122 |
| - h1 { |
123 |
| - font-size: 16px; |
124 |
| - } |
125 |
| - .avatar { |
126 |
| - width: 30px; |
127 |
| - height: 30px; |
128 |
| - border-radius: 100%; |
129 |
| - border: 2px solid var(--border); |
130 |
| - background: rgba(6, 122, 239, 0.2); |
131 |
| - } |
132 |
| - .border-b { |
133 |
| - border-bottom: 1px solid var(--border); |
134 |
| - line-height: 2.5; |
135 |
| - } |
136 |
| - .border-b:last-child { |
137 |
| - border: 0; |
138 |
| - } |
139 |
| - .login-warper { |
140 |
| - display: flex; |
141 |
| - height: 80vh; |
142 |
| - } |
143 |
| - .message { |
144 |
| - border: 1px solid var(--error); |
145 |
| - padding: 8px 12px; |
146 |
| - color: var(--error); |
147 |
| - background-color: #fee2e2; |
148 |
| - border-radius: 2px; |
149 |
| - } |
150 |
| - </style> |
151 |
| - <body> |
152 |
| - <div class="max-w-5xl mx-auto"> |
| 7 | + <body class="bg-gray-100 text-gray-900 text-sm"> |
| 8 | + <div class="max-w-5xl mx-auto bg-white p-6 border mt-6 space-y-4"> |
153 | 9 | <header class="flex justify-between items-center">
|
154 |
| - <h1>Clone ProcessOn</h1> |
155 |
| - <span class="flex items-center" id="user-info"></span> |
| 10 | + <h1 class="text-lg">Clone ProcessOn</h1> |
| 11 | + <span class="flex items-center" id="user-info"> |
| 12 | + <img |
| 13 | + class="w-8 h-8 rounded-full border-2 border-gray-200" |
| 14 | + src="https://api.dicebear.com/7.x/notionists/svg?seed=${res.email}" |
| 15 | + alt="${res.name}" |
| 16 | + /> |
| 17 | + <button |
| 18 | + class="ml-2 text-sm bg-gray-100 px-2 py-1 rounded border" |
| 19 | + id="signout" |
| 20 | + > |
| 21 | + 退出 |
| 22 | + </button> |
| 23 | + </span> |
156 | 24 | </header>
|
157 |
| - <div id="container"></div> |
| 25 | + <div id="container"> |
| 26 | + <div> |
| 27 | + <div> |
| 28 | + <button |
| 29 | + class="text-sm bg-blue-500 text-white px-3 py-2 rounded" |
| 30 | + id="create" |
| 31 | + > |
| 32 | + + 新建流程图 |
| 33 | + </button> |
| 34 | + </div> |
| 35 | + <div class="mt-6 space-y-4" id="list"></div> |
| 36 | + </div> |
| 37 | + </div> |
158 | 38 | </div>
|
159 | 39 | <script src="./scripts_bin/zh/jquery.js"></script>
|
160 | 40 | <script>
|
|
167 | 47 | case 500:
|
168 | 48 | console.log("服务器错误");
|
169 | 49 | case 401:
|
170 |
| - showLogin(); |
| 50 | + window.location.href = "/login"; |
171 | 51 | }
|
172 | 52 | });
|
| 53 | +
|
173 | 54 | $(document).on("submit", "form", function (e) {
|
174 | 55 | $(".js-message").html("");
|
175 | 56 | e.preventDefault();
|
|
204 | 85 | },
|
205 | 86 | });
|
206 | 87 | });
|
207 |
| - function showLogin() { |
208 |
| - $("#user-info").html(""); |
209 |
| - $("#container").html( |
210 |
| - `<div class="login-warper"><div class="w-2/5"> |
211 |
| - <h2>欢迎回来</h2> |
212 |
| - <form method="POST" action="/api/auth/signin"> |
213 |
| - <div><input value="[email protected]" placeholder="邮箱" type="email" name="email" /></div> |
214 |
| - <div><input value="123456" placeholder="密码" minLength="6" maxLength="20" type="password" name="password" /></div> |
215 |
| - <div><button type="submit" class="btn btn-primary block w-full">登录</button></div> |
216 |
| - <div class="js-message"></div> |
217 |
| - <div><a class="btn block w-full" href="/api/github/login">GitHub 账号登录</a></div> |
218 |
| - <div>如果您没有账号,您可以 <a href="javascript:showRegister()">立即注册</a></div> |
219 |
| - </form> |
220 |
| - </div></div>` |
221 |
| - ); |
222 |
| - } |
223 | 88 |
|
224 |
| - function showRegister() { |
225 |
| - $("#container").html(` |
226 |
| - <div class="login-warper"> |
227 |
| - <div class="w-2/5"> |
228 |
| - <h2>创建一个账号</h2> |
229 |
| - <form method="POST" action="/api/auth/register"> |
230 |
| - <div><input placeholder="邮箱" type="email" name="email" /></div> |
231 |
| - <div><input placeholder="昵称" maxLength="20" type="text" name="name" /></div> |
232 |
| - <div><input placeholder="密码" minLength="6" maxLength="20" type="password" name="password" /></div> |
233 |
| - <div><button type="submit" class="btn btn-primary block w-full">注册</button></div> |
234 |
| - <div>已有账号,您可以 <a href="javascript:showLogin()">立即登录</a></div> |
235 |
| - <div class="js-message"></div> |
236 |
| - <div>测试账号:[email protected] 密码 123456</div> |
237 |
| - </form> |
238 |
| - </div></div>`); |
239 |
| - } |
240 | 89 | function getList() {
|
241 | 90 | $.get("/diagraming", (res) => {
|
242 | 91 | const { list = [] } = res;
|
243 | 92 | if (list.length > 0) {
|
244 | 93 | let html = "";
|
245 | 94 | list.forEach((item) => {
|
246 |
| - html += `<div class="flex justify-between border-b"> |
247 |
| - <a href="/diagraming/${item.id}">${item.title}</a> |
| 95 | + html += `<div class="flex justify-between border-b py-2"> |
| 96 | + <a class="text-sm text-blue-500 hover:text-blue-700" href="/diagraming/${ |
| 97 | + item.id |
| 98 | + }">${item.title}</a> |
248 | 99 | <span><span>${new Date(item.lastModify).toLocaleString()}</span>
|
249 |
| - <a class="ml-2" href="/view/${item.id}">查看</a> |
250 |
| - <a class="ml-2 js-remove" href="javascript:;" data-id="${ |
| 100 | + <a class="ml-2 text-blue-500 hover:text-blue-700" href="/view/${ |
| 101 | + item.id |
| 102 | + }">查看</a> |
| 103 | + <a class="ml-2 text-blue-500 hover:text-blue-700 js-remove" href="javascript:;" data-id="${ |
251 | 104 | item.id
|
252 | 105 | }">删除</a></span>
|
253 | 106 | </div>`;
|
|
292 | 145 |
|
293 | 146 | function getUser() {
|
294 | 147 | $.get("/api/user/me", (res) => {
|
295 |
| - $("#user-info").html( |
296 |
| - ` |
297 |
| - <img class="avatar" src="https://api.dicebear.com/7.x/notionists/svg?seed=${res.email}" alt="${res.name}"/> |
298 |
| - <button class="ml-2 btn" id="signout">退出</button> ` |
299 |
| - ); |
300 |
| - $("#container").html( |
301 |
| - `<div> |
302 |
| - <div> <button class="btn btn-primary" id="create">+ 新建流程图</button></div> |
303 |
| - <div id="list"></div> |
304 |
| - </div>` |
305 |
| - ); |
306 | 148 | getList();
|
307 | 149 | bindCreate();
|
308 | 150 | });
|
|
0 commit comments