|
4 | 4 | <title>Code Statistic</title> |
5 | 5 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
6 | 6 | <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/element-plus/2.2.32/index.css"> |
| 7 | + <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/element-plus/2.2.32/theme-chalk/base.css"> |
7 | 8 | <style> |
8 | 9 | html, body { |
9 | | - display: grid; |
10 | 10 | padding: 0; |
11 | 11 | margin: 0; |
12 | | - place-items: center; |
| 12 | + display: flex; |
| 13 | + align-items: center; |
| 14 | + justify-content: center; |
| 15 | + gap: 8px; |
13 | 16 | width: 100%; |
14 | 17 | height: 100%; |
15 | 18 | } |
| 19 | + #app { |
| 20 | + display: flex; |
| 21 | + flex-direction: column; |
| 22 | + gap: 8px; |
| 23 | + margin: 30px 0; |
| 24 | + } |
| 25 | + #generate { |
| 26 | + margin: 0 auto; |
| 27 | + transform: translateY(20px); |
| 28 | + } |
16 | 29 | * { |
17 | | - font-family: "Comic Sans MS", Consolas, monospace, Serif; |
| 30 | + font-family: Consolas, Nunito, monospace, Serif; |
18 | 31 | } |
19 | 32 | </style> |
20 | 33 | <script src="https://cdn.bootcdn.net/ajax/libs/vue/3.2.47/vue.global.js"></script> |
|
27 | 40 | <el-form-item label="Username"><el-input v-model="form.username"></el-input></el-form-item> |
28 | 41 | <el-form-item label="Repo" v-if="isRepo"><el-input v-model="form.repo"></el-input></el-form-item> |
29 | 42 | <el-form-item label="Type"><el-radio-group v-model="form.type"><el-radio border label="User"></el-radio><el-radio border label="Repo"></el-radio></el-radio-group></el-form-item> |
30 | | - <el-form-item><el-button type="primary" @click="generate">Generate</el-button></el-form-item> |
| 43 | + <el-form-item label="Dark Mode"><el-switch v-model="form.dark"></el-switch></el-form-item> |
| 44 | + <el-form-item><el-button type="primary" @click="generate" id="generate">Generate</el-button></el-form-item> |
31 | 45 | </el-form> |
32 | | - <code>{{ link }}</code><img :src="link"> |
33 | 46 | </el-card> |
34 | | - <el-card></el-card> |
| 47 | + <el-card> |
| 48 | + <template v-if="! link"><el-empty image-size="80"></el-empty></template> |
| 49 | + <template v-else><el-form-item label="Link"><el-input readonly v-model="link"></el-input></el-form-item><br><img :src="link" alt></template> |
| 50 | + </el-card> |
35 | 51 | </div> |
36 | 52 | <script> |
37 | 53 | const form = Vue.ref({ |
38 | 54 | username: "", |
39 | 55 | repo: "", |
40 | 56 | type: "User", |
| 57 | + dark: false, |
41 | 58 | }) |
42 | 59 | const link = Vue.ref(""); |
43 | 60 | const isRepo = Vue.computed(() => form.value.type !== "User"); |
|
50 | 67 | isRepo: isRepo, |
51 | 68 | generate: () => { |
52 | 69 | const username = form.value.username.trim(), |
53 | | - repo = form.value.repo.trim(); |
| 70 | + repo = form.value.repo.trim(), |
| 71 | + dark = !!form.value.dark; |
54 | 72 |
|
55 | 73 | if (! username) {throwWarning("username is empty."); return } |
56 | 74 | if (isRepo.value && ! repo) {throwWarning("repo is empty."); return } |
57 | | - link.value = location.origin + ((!isRepo.value) ? `/user/${username}/` : `/repo/${username}/${repo}`) |
| 75 | + link.value = location.origin + |
| 76 | + ((!isRepo.value) ? `/user/${username}/` : `/repo/${username}/${repo}`) + |
| 77 | + (dark ? "?theme=dark" : ""); |
58 | 78 | } |
59 | 79 | } |
60 | 80 | } |
|
0 commit comments