diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000..062c4ce Binary files /dev/null and b/public/favicon.ico differ diff --git a/public/index-m.html b/public/index-m.html deleted file mode 100644 index 34fe0fe..0000000 --- a/public/index-m.html +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - - MyUrls - - - - - - - - -
- - - -
- - - - - -
-
-
-
- - - - - - - \ No newline at end of file diff --git a/public/index.html b/public/index.html index c1b76b9..893f627 100644 --- a/public/index.html +++ b/public/index.html @@ -10,6 +10,7 @@ + @@ -17,13 +18,15 @@ -
+
- + + + + -
@@ -37,11 +40,19 @@ el: "#app", data() { return { + isPc: true, + loading: false, longUrl: '', shortUrl: '' } }, + created() { + const os = this.getOS() + if (os.isPc !== true) { + this.isPc = false + } + }, mounted() { this.$refs.long.focus() }, @@ -53,7 +64,7 @@ let re = new RegExp('http(s*)://[^\s]*') if (re.exec(this.longUrl) === null) { this.$message.warning('请输入正确格式的长链接') - return + return } this.loading = true @@ -68,6 +79,8 @@ .then(res => { if (res.data.Code === 1 && res.data.ShortUrl !== "") { this.shortUrl = res.data.ShortUrl; + this.$copyText(this.shortUrl) + this.$message.success("短链接已复制到剪贴板"); } else { this.$message.error("短链接获取失败:" + res.data.Message); } @@ -81,7 +94,31 @@ }, goToGayHub() { window.open(repo) - } + }, + getOS() { + let ua = navigator.userAgent, + isWindowsPhone = /(?:Windows Phone)/.test(ua), + isSymbian = /(?:SymbianOS)/.test(ua) || isWindowsPhone, + isAndroid = /(?:Android)/.test(ua), + isFireFox = /(?:Firefox)/.test(ua), + isChrome = /(?:Chrome|CriOS)/.test(ua), + isTablet = /(?:iPad|PlayBook)/.test(ua) || (isAndroid && !/(?:Mobile)/.test(ua)) || (isFireFox && /(?:Tablet)/.test(ua)), + isPhone = /(?:iPhone)/.test(ua) && !isTablet, + isPc = !isPhone && !isAndroid && !isSymbian; + + return { + isTablet: isTablet, + isPhone: isPhone, + isAndroid: isAndroid, + isPc: isPc + }; + }, + getBodyClass() { + return this.isPc ? 'body-center body-width-pc' : 'body-center' + }, + onCopy() { + this.$message.success("Copied!"); + }, }, }) @@ -91,11 +128,19 @@ width: 40%; position: absolute; left: 50%; - top: 40%; + top: 30%; transform: translate(-50%, -50%); text-align: center; } + .body-width-pc { + width: 40%; + } + + .body-width-mb { + width: 90%; + } + .el-input { margin-top: 20px; }