diff --git a/浏览器插件/bookmark-chrome/src/background.js b/浏览器插件/bookmark-chrome/src/background.js index 95d9314..7428a6c 100644 --- a/浏览器插件/bookmark-chrome/src/background.js +++ b/浏览器插件/bookmark-chrome/src/background.js @@ -7,6 +7,7 @@ chrome.extension.onConnect.addListener(port => { switch (msg.type) { case 'sendToken': localStorage.setItem('token', msg.data); + window.token = msg.data; break; default: console.error('未知的数据', msg); diff --git a/浏览器插件/bookmark-chrome/src/manifest.json b/浏览器插件/bookmark-chrome/src/manifest.json index 53f65d2..0e48aac 100644 --- a/浏览器插件/bookmark-chrome/src/manifest.json +++ b/浏览器插件/bookmark-chrome/src/manifest.json @@ -22,7 +22,7 @@ }, "content_scripts": [{ "matches": ["http://west.tapme.top/*", "http://bookmark.tapme.top/*","http://localhost:3000/*"], - "js": ["popup/static/sso.js"] + "js": ["static/sso.js"] } ] diff --git a/浏览器插件/bookmark-chrome/src/popup/popup.js b/浏览器插件/bookmark-chrome/src/popup/popup.js index 08fd669..7ed5591 100644 --- a/浏览器插件/bookmark-chrome/src/popup/popup.js +++ b/浏览器插件/bookmark-chrome/src/popup/popup.js @@ -4,31 +4,24 @@ import store from '../store'; import router from './router'; import ElementUI from 'element-ui'; import 'element-ui/lib/theme-chalk/index.css'; +import config from '../util/config'; import axios from 'axios'; global.browser = require('webextension-polyfill'); Vue.prototype.$browser = global.browser; Vue.use(ElementUI); -/* eslint-disable no-new */ -window.vueInstance = new Vue({ - el: '#app', - store, - router, - render: h => h(App), -}); - /** * 配置axios */ axios.defaults.timeout = 15000; - +axios.defaults.baseURL = config.baseUrl; /** * 请求拦截器 */ axios.interceptors.request.use( function(config) { - console.log(config); + config.headers['jwt-token'] = window.token; return config; }, function(error) { @@ -39,10 +32,23 @@ axios.interceptors.request.use( axios.interceptors.response.use( res => { - console.log(res); - return res.data; + if (res.data.code === -1) { + window.vueInstance.$router.replace('/public/login'); + } else if (res.data.code === 1) { + return res.data.data; + } else { + Promise.reject(res); + } }, error => { return Promise.reject(error); } ); + +/* eslint-disable no-new */ +window.vueInstance = new Vue({ + el: '#app', + store, + router, + render: h => h(App), +}); diff --git a/浏览器插件/bookmark-chrome/src/popup/router/pages/Index.vue b/浏览器插件/bookmark-chrome/src/popup/router/pages/Index.vue index d10d49e..33c0e24 100644 --- a/浏览器插件/bookmark-chrome/src/popup/router/pages/Index.vue +++ b/浏览器插件/bookmark-chrome/src/popup/router/pages/Index.vue @@ -1,20 +1,71 @@ diff --git a/浏览器插件/bookmark-chrome/src/popup/router/pages/public/Login.vue b/浏览器插件/bookmark-chrome/src/popup/router/pages/public/Login.vue index 1ffcd02..bc24588 100644 --- a/浏览器插件/bookmark-chrome/src/popup/router/pages/public/Login.vue +++ b/浏览器插件/bookmark-chrome/src/popup/router/pages/public/Login.vue @@ -1,14 +1,15 @@ diff --git a/浏览器插件/bookmark-chrome/src/static/fonts/element-icons.ttf b/浏览器插件/bookmark-chrome/src/static/fonts/element-icons.ttf new file mode 100644 index 0000000..91b74de Binary files /dev/null and b/浏览器插件/bookmark-chrome/src/static/fonts/element-icons.ttf differ diff --git a/浏览器插件/bookmark-chrome/src/static/fonts/element-icons.woff b/浏览器插件/bookmark-chrome/src/static/fonts/element-icons.woff new file mode 100644 index 0000000..02b9a25 Binary files /dev/null and b/浏览器插件/bookmark-chrome/src/static/fonts/element-icons.woff differ diff --git a/浏览器插件/bookmark-chrome/src/static/img/bookmarkLogo.png b/浏览器插件/bookmark-chrome/src/static/img/bookmarkLogo.png new file mode 100644 index 0000000..d77cc9a Binary files /dev/null and b/浏览器插件/bookmark-chrome/src/static/img/bookmarkLogo.png differ diff --git a/浏览器插件/bookmark-chrome/src/util/config.js b/浏览器插件/bookmark-chrome/src/util/config.js new file mode 100644 index 0000000..ce9a820 --- /dev/null +++ b/浏览器插件/bookmark-chrome/src/util/config.js @@ -0,0 +1,9 @@ +// const baseUri = 'https://bm.tapme.top'; +const baseUri = 'http://localhost:3000'; + +const config = { + baseUrl: baseUri + '/bookmark/api', + ssoUrl: baseUri + '/userSpace/ssoAuth', +}; + +export default config; diff --git a/浏览器插件/bookmark-chrome/webpack.config.js b/浏览器插件/bookmark-chrome/webpack.config.js index 7ccecd3..d7d835f 100644 --- a/浏览器插件/bookmark-chrome/webpack.config.js +++ b/浏览器插件/bookmark-chrome/webpack.config.js @@ -74,7 +74,8 @@ const config = { }), new CopyWebpackPlugin([ { from: 'icons', to: 'icons', ignore: ['icon.xcf'] }, - { from: 'static', to: 'popup/static' }, + { from: 'static', to: 'static' }, + { from: 'static/fonts', to: 'fonts' }, { from: 'popup/popup.html', to: 'popup/popup.html', transform: transformHtml }, { from: 'options/options.html', to: 'options/options.html', transform: transformHtml }, {