From 8048ce5751b2ed2bc07aeba484ccb51406613ebc Mon Sep 17 00:00:00 2001 From: yutent Date: Fri, 21 Apr 2023 10:53:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BE=9D=E8=B5=96;=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vue.live.js => fite.config.js | 3 ++- index.html | 2 +- package.json | 2 +- src/app.vue | 17 ++++++++++++++++- src/lib/fetch.js | 2 +- src/main.js | 10 ++++++---- src/views/request.vue | 5 ++--- 7 files changed, 29 insertions(+), 12 deletions(-) rename vue.live.js => fite.config.js (90%) diff --git a/vue.live.js b/fite.config.js similarity index 90% rename from vue.live.js rename to fite.config.js index 71336e3..f2d9e77 100644 --- a/vue.live.js +++ b/fite.config.js @@ -29,6 +29,7 @@ export default { 'vue-router': '//jscdn.ink/@bytedo/vue-router/4.1.6/vue-router.js', // 这个库被vue-router依赖, 可以注释掉vue-router代码中的 @vue/devtools-api 的引入 // 以达到减少不必须的体积的效果 - fetch: '//jscdn.ink/@bytedo/fetch/2.1.1/next.js' + fetch: '//jscdn.ink/@bytedo/fetch/latest/next.js', + '@bd/core': '//jscdn.ink/@bd/core/latest/index.js' } } diff --git a/index.html b/index.html index 5a0a518..a9ab5ae 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,7 @@ {{title}} - + diff --git a/package.json b/package.json index e08360f..c74dc4d 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,6 @@ "build": "fite build" }, "devDependencies": { - "fite": "^0.3.3" + "fite": "^0.6.0" } } diff --git a/src/app.vue b/src/app.vue index 5768984..8927487 100644 --- a/src/app.vue +++ b/src/app.vue @@ -8,14 +8,29 @@ import Header from './components/header.vue' import Footer from './components/footer.vue' +import fetch from '@/lib/fetch.js' + export default { components: { Header, Footer }, mounted() { var user = localStorage.getItem('user') + var checked = sessionStorage.getItem('session_checked') if (user) { - this.$store.user = JSON.parse(user) + if (checked) { + return (this.$store.user = JSON.parse(user)) + } + fetch('/login/check') + .then(r => { + localStorage.setItem('token', r.data.token) + sessionStorage.setItem('session_checked', 1) + this.$store.user = JSON.parse(user) + }) + .catch(r => { + localStorage.removeItem('token') + localStorage.removeItem('user') + }) } } } diff --git a/src/lib/fetch.js b/src/lib/fetch.js index 3d63521..03dd34a 100644 --- a/src/lib/fetch.js +++ b/src/lib/fetch.js @@ -1,6 +1,6 @@ import fetch from 'fetch' -fetch.BASE_URL = 'https://api.jscdn.ink' +fetch.BASE_URL = '//api.jscdn.ink' fetch.inject.request(function (conf) { var token = localStorage.getItem('token') diff --git a/src/main.js b/src/main.js index 7c68002..5057482 100644 --- a/src/main.js +++ b/src/main.js @@ -1,11 +1,13 @@ import { createApp } from 'vue' import '//jscdn.ink/es.shim/2.1.0/index.js' -import '//jscdn.ink/@bytedo/wcui/1.0.12/form/input.js' +import '//jscdn.ink/@bd/ui/latest/form/input.js' +import '//jscdn.ink/@bd/ui/latest/form/button.js' +import '//jscdn.ink/@bd/ui/latest/form/switch.js' +import '//jscdn.ink/@bd/ui/latest/form/link.js' +import '//jscdn.ink/@bd/ui/latest/layer/index.js' +import '//jscdn.ink/@bd/ui/latest/pager/index.js' import '//jscdn.ink/@bytedo/wcui/1.0.12/form/dropdown.js' -import '//jscdn.ink/@bytedo/wcui/1.0.12/form/button.js' -import '//jscdn.ink/@bytedo/wcui/1.0.12/form/link.js' -import '//jscdn.ink/@bytedo/wcui/1.0.12/layer/index.js' import App from './app.vue' diff --git a/src/views/request.vue b/src/views/request.vue index 088a4b4..a507733 100644 --- a/src/views/request.vue +++ b/src/views/request.vue @@ -55,7 +55,7 @@ import '//jscdn.ink/@bytedo/wcui/1.0.12/table/index.js' -import '//jscdn.ink/@bytedo/wcui/1.0.12/form/switch.js' -import '//jscdn.ink/@bytedo/wcui/1.0.12/pager/index.js' import fetch from '@/lib/fetch.js' export default { @@ -344,6 +342,7 @@ export default { .request-form { width: 640px; + background: #fff; .title { display: flex;