From 0b9f38436a02d9516ea4252127484097a6ad10b1 Mon Sep 17 00:00:00 2001 From: fanxb Date: Sun, 12 Jul 2020 20:46:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E7=99=BB=E5=BD=95=E9=A1=B5=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bookmark_front/.editorconfig | 2 +- bookmark_front/babel.config.js | 6 +- bookmark_front/package.json | 2 +- .../src/components/public/Switch.vue | 51 +++++++++++++ .../layout => layout/main}/Bottom.vue | 0 .../layout => layout/main}/Content.vue | 0 .../layout => layout/main}/Top.vue | 0 bookmark_front/src/main.js | 10 ++- bookmark_front/src/router/index.js | 1 - bookmark_front/src/util/HttpUtil.js | 7 +- bookmark_front/src/views/main/Main.vue | 6 +- .../src/views/public/pages/Login.vue | 76 ++++++++++++++++++- bookmark_front/vue.config.js | 17 +++++ 13 files changed, 161 insertions(+), 17 deletions(-) create mode 100644 bookmark_front/src/components/public/Switch.vue rename bookmark_front/src/{components/layout => layout/main}/Bottom.vue (100%) rename bookmark_front/src/{components/layout => layout/main}/Content.vue (100%) rename bookmark_front/src/{components/layout => layout/main}/Top.vue (100%) create mode 100644 bookmark_front/vue.config.js diff --git a/bookmark_front/.editorconfig b/bookmark_front/.editorconfig index c24743d..5c5a774 100644 --- a/bookmark_front/.editorconfig +++ b/bookmark_front/.editorconfig @@ -4,4 +4,4 @@ indent_size = 2 end_of_line = lf trim_trailing_whitespace = true insert_final_newline = true -max_line_length = 100 +max_line_length = 150 diff --git a/bookmark_front/babel.config.js b/bookmark_front/babel.config.js index c6d82ab..d6bc123 100644 --- a/bookmark_front/babel.config.js +++ b/bookmark_front/babel.config.js @@ -1,6 +1,4 @@ module.exports = { - presets: ["@vue/cli-plugin-babel/preset"], - plugins: [ - ["import", { libraryName: "ant-design-vue", libraryDirectory: "es", style: "css" }] // `style: true` 会加载 less 文件 - ] + presets: ["@vue/app"], + plugins: [["import", { libraryName: "ant-design-vue", libraryDirectory: "es", style: "css" }]] }; diff --git a/bookmark_front/package.json b/bookmark_front/package.json index aa62bf2..b849f71 100644 --- a/bookmark_front/package.json +++ b/bookmark_front/package.json @@ -8,7 +8,7 @@ "lint": "vue-cli-service lint" }, "dependencies": { - "ant-design-vue": "^1.6.2", + "ant-design-vue": "^1.6.3", "axios": "^0.19.2", "babel-plugin-import": "^1.13.0", "core-js": "^3.6.5", diff --git a/bookmark_front/src/components/public/Switch.vue b/bookmark_front/src/components/public/Switch.vue new file mode 100644 index 0000000..540900e --- /dev/null +++ b/bookmark_front/src/components/public/Switch.vue @@ -0,0 +1,51 @@ + + + + + diff --git a/bookmark_front/src/components/layout/Bottom.vue b/bookmark_front/src/layout/main/Bottom.vue similarity index 100% rename from bookmark_front/src/components/layout/Bottom.vue rename to bookmark_front/src/layout/main/Bottom.vue diff --git a/bookmark_front/src/components/layout/Content.vue b/bookmark_front/src/layout/main/Content.vue similarity index 100% rename from bookmark_front/src/components/layout/Content.vue rename to bookmark_front/src/layout/main/Content.vue diff --git a/bookmark_front/src/components/layout/Top.vue b/bookmark_front/src/layout/main/Top.vue similarity index 100% rename from bookmark_front/src/components/layout/Top.vue rename to bookmark_front/src/layout/main/Top.vue diff --git a/bookmark_front/src/main.js b/bookmark_front/src/main.js index 3a47006..0c3d1b0 100644 --- a/bookmark_front/src/main.js +++ b/bookmark_front/src/main.js @@ -1,11 +1,19 @@ import Vue from "vue"; +import { Button, FormModel, Input, Icon, message, Checkbox } from "ant-design-vue"; import App from "./App.vue"; import router from "./router"; import store from "./store"; +Vue.component(Button.name, Button); +Vue.use(FormModel); +Vue.component(Input.name, Input); +Vue.component(Icon.name, Icon); +Vue.use(Checkbox); + +Vue.prototype.$message = message; Vue.config.productionTip = false; -new Vue({ +window.vueInstance = new Vue({ router, store, render: h => h(App) diff --git a/bookmark_front/src/router/index.js b/bookmark_front/src/router/index.js index d1b6a0c..cc18d0b 100644 --- a/bookmark_front/src/router/index.js +++ b/bookmark_front/src/router/index.js @@ -12,7 +12,6 @@ Vue.use(VueRouter); const routes = [ { path: "/", - name: "Main", component: Main, children: [ { diff --git a/bookmark_front/src/util/HttpUtil.js b/bookmark_front/src/util/HttpUtil.js index 0d1aab7..0734b34 100644 --- a/bookmark_front/src/util/HttpUtil.js +++ b/bookmark_front/src/util/HttpUtil.js @@ -20,13 +20,15 @@ async function request(url, method, params, body, isForm, redirect) { headers["Content-Type"] = "multipart/form-data"; } try { - const { code, data, message } = await http.default.request({ + const res = await http.default.request({ url, baseURL: "/bookmark/api", + method, params, data: body, headers }); + const { code, data, message } = res.data; if (code === 1) { return data; } @@ -35,10 +37,9 @@ async function request(url, method, params, body, isForm, redirect) { router.replace(`/public/login?redirect=${encodeURIComponent(router.currentRoute.fullPath)}`); return null; } - console.log(`请求异常:${message}`); + window.vueInstance.$message.error(message); throw new Error(message); } catch (err) { - console.error(err); throw new Error(err); } } diff --git a/bookmark_front/src/views/main/Main.vue b/bookmark_front/src/views/main/Main.vue index 6bbc027..0aa7f17 100644 --- a/bookmark_front/src/views/main/Main.vue +++ b/bookmark_front/src/views/main/Main.vue @@ -9,9 +9,9 @@ - + diff --git a/bookmark_front/vue.config.js b/bookmark_front/vue.config.js new file mode 100644 index 0000000..7ed59d0 --- /dev/null +++ b/bookmark_front/vue.config.js @@ -0,0 +1,17 @@ +module.exports = { + lintOnSave: false, + devServer: { + proxy: { + "/bookmark/api": { + //这里最好有一个 / + target: "http://localhost:8088", // 服务器端接口地址 + ws: true, //如果要代理 websockets,配置这个参数 + // 如果是https接口,需要配置这个参数 + changeOrigin: true, //是否跨域 + pathRewrite: { + "^/bookmark/api": "/bookmark/api" + } + } + } + } +};