diff --git a/README.md b/README.md index 5466ea4..a0dc71f 100644 --- a/README.md +++ b/README.md @@ -21,43 +21,46 @@ Next light-weight,responsive project With Docker,Vue2,Vue CLI 3,webpack4,Java8 and Spring Boot5 -# Important Changes in JVue 4 +## Important Changes in JVue 4 Using [Docker](https://docs.docker.com/develop/dev-best-practices/) for deploy -# Install +## Install The instructions assume that you have already installed [Docker](https://docs.docker.com/installation/) and [Docker Compose](https://docs.docker.com/compose/install/). -# Run +## Run -## install docker +### install docker ``` yum install docker ``` -## install docker-compose +### install docker-compose ``` curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose ``` See [https://docs.docker.com/compose/reference/up/](https://docs.docker.com/compose/reference/up/) -## run jvue +## Run jvue -### via docker(for production) +### docker(for dev) ```bash -docker compose up -d --build +docker compose up --build ``` -### custom(for dev) -~~1. mysql~~ +### docker(for production) ```bash -docker compose -f docker-compose-mysql.yml +docker compose up -d --build ``` -2. Jvue-server +### dev + +1. jvue-mysql + +2. jvue-server ```bash cd ./jvue-server/src/main/java/com/terwergreen/jvueserver @@ -65,38 +68,17 @@ cd ./jvue-server/src/main/java/com/terwergreen/jvueserver # that's all ``` -~~3. Jvue-front~~ +3. jvue-front ```bash cd ./jvue-front yarn yarn dev ``` - -### Test docker(for dev) +or somplely ```bash -docker compose -f docker-compose.yml up --build -``` - -### vercel - -1. config - -``` -vercel pull -``` - -2. build - -``` -vercel build -``` - -3. start(not work) - -``` -vercel dev +./dev.sh ``` # Structure @@ -108,4 +90,4 @@ Have fun and enjoy! You can contribute simplely by create a pull request for me -For detailed explanation on how things work, please visit [author's blog](https://terwergreen.com). \ No newline at end of file +For detailed explanation on how things work, please visit [author's blog](https://blog.terwergreen.com). \ No newline at end of file diff --git a/dev.sh b/dev.sh new file mode 100755 index 0000000..6fb08b0 --- /dev/null +++ b/dev.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# sudo n 14 + +cd jvue-server +./mvnw clean spring-boot:run -Dspring-boot.run.profiles=dev -DskipTests & + +cd ../jvue-front +yarn dev \ No newline at end of file diff --git a/docker-compose-mysql.yml b/docker-compose-mysql.yml deleted file mode 100644 index 39cb0d5..0000000 --- a/docker-compose-mysql.yml +++ /dev/null @@ -1,28 +0,0 @@ -# 构建docker-compose项目 -# docker compose --log-level INFO up -- build -# docker compose --log-level INFO up -d --build - -version: '3' -services: - jvue-mysql: - image: jvue/mysql:5.7.24 - container_name: jvue-mysql - build: - context: ./ - dockerfile: ./jvue-mysql/Dockerfile - ports: - - "3306:3306" - environment: - # 最好使用此设定时区,其它静像也可以使用,也可以用"TZ=Asia/Shanghai" - - "TZ=CST-8" - - "MYSQL_ROOT_PASSWORD=123456" - - "MYSQL_ROOT_HOST=%" - - "MYSQL_DATABASE=bugucms4" - - "MYSQL_USER=terwer" - - "MYSQL_PASSWORD=123456" - volumes: - - ./data/mysql/db:/var/db - - ./data/mysql/log:/var/log - - ./jvue-mysql/my.cnf:/etc/my.cnf - - ./jvue-mysql/init:/docker-entrypoint-initdb.d/ - restart: "no" \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 37f30da..ff8ca0d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,42 +2,43 @@ # docker compose --log-level INFO up -- build # docker compose --log-level INFO up -d --build -version: '3' +version: "3.8" + services: -# jvue-nginx: -# image: jvue/nginx:1.15.9 -# container_name: jvue-nginx -# build: -# context: ./ -# dockerfile: ./jvue-nginx/Dockerfile -# ports: -# - "80:80" -# volumes: -# - ./jvue-nginx/nginx.conf:/etc/nginx/conf.d/default.conf -# - ./data/nginx/log:/var/log/nginx -# restart: "no" -# jvue-mysql: -# image: jvue/mysql:5.7.24 -# container_name: jvue-mysql -# build: -# context: ./ -# dockerfile: ./jvue-mysql/Dockerfile -# ports: -# - "3306:3306" -# environment: -# # 最好使用此设定时区,其它静像也可以使用,也可以用"TZ=Asia/Shanghai" -# - "TZ=CST-8" -# - "MYSQL_ROOT_PASSWORD=123456" -# - "MYSQL_ROOT_HOST=%" -# - "MYSQL_DATABASE=bugucms4" -# - "MYSQL_USER=terwer" -# - "MYSQL_PASSWORD=123456" -# volumes: -# - ./data/mysql/db:/var/db -# - ./data/mysql/log:/var/log -# - ./jvue-mysql/my.cnf:/etc/my.cnf -# - ./jvue-mysql/init:/docker-entrypoint-initdb.d/ -# restart: always + jvue-nginx: + image: jvue/nginx:1.15.9 + container_name: jvue-nginx + build: + context: ./ + dockerfile: ./jvue-nginx/Dockerfile + ports: + - "80:80" + volumes: + - ./jvue-nginx/nginx.conf:/etc/nginx/conf.d/default.conf + - ./data/nginx/log:/var/log/nginx + restart: "no" + jvue-mysql: + image: jvue/mysql:5.7.24 + container_name: jvue-mysql + build: + context: ./ + dockerfile: ./jvue-mysql/Dockerfile + ports: + - "3308:3306" + environment: + # 最好使用此设定时区,其它静像也可以使用,也可以用"TZ=Asia/Shanghai" + - "TZ=CST-8" + - "MYSQL_ROOT_PASSWORD=123456" + - "MYSQL_ROOT_HOST=%" + - "MYSQL_DATABASE=bugucms4" + - "MYSQL_USER=terwer" + - "MYSQL_PASSWORD=123456" + volumes: + - ./data/mysql/db:/var/db + - ./data/mysql/log:/var/log + - ./jvue-mysql/my.cnf:/etc/my.cnf + - ./jvue-mysql/init:/docker-entrypoint-initdb.d/ + restart: "no" jvue-server: image: jvue/server:4.0.1 container_name: jvue-server @@ -47,20 +48,18 @@ services: ports: - "8002:8002" working_dir: /app - command: mvn clean spring-boot:run -Dspring-boot.run.profiles=dev -DskipTests + command: mvn clean spring-boot:run -Dspring-boot.run.profiles=docker -DskipTests volumes: - ./jvue-server:/app - ./data/maven/.m2:/root/.m2 - ./data/server/logs:/logs restart: "no" -# jvue-front: -# container_name: jvue-front -# image: jvue/front:4.0.1 -# build: -# context: . -# dockerfile: ./jvue-front/Dockerfile -# ports: -# - "3000:3000" -# environment: -# - npm_config_unsafe_perm=true -# restart: "no" \ No newline at end of file + jvue-front: + container_name: jvue-front + image: jvue/front:4.0.1 + build: + context: . + dockerfile: ./jvue-front/Dockerfile + ports: + - "3000:3000" + restart: "no" \ No newline at end of file diff --git a/jvue-front/.editorconfig b/jvue-front/.editorconfig new file mode 100644 index 0000000..5d12634 --- /dev/null +++ b/jvue-front/.editorconfig @@ -0,0 +1,13 @@ +# editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/jvue-front/.eslintrc.js b/jvue-front/.eslintrc.js new file mode 100644 index 0000000..ee741f8 --- /dev/null +++ b/jvue-front/.eslintrc.js @@ -0,0 +1,31 @@ +module.exports = { + root: true, + env: { + browser: true, + node: true + }, + parserOptions: { + parser: "babel-eslint" + }, + extends: [ + "@nuxtjs", + "plugin:nuxt/recommended", + "plugin:prettier/recommended", + "prettier", + "prettier/vue" + ], + plugins: ["prettier"], + // add your custom rules here + rules: { + "nuxt/no-cjs-in-config": "off", + "no-console": "off", + "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off", + "no-unused-vars": [ + 2, + { + vars: "local", + args: "none" + } + ] + } +}; diff --git a/jvue-front/.gitignore b/jvue-front/.gitignore new file mode 100644 index 0000000..706ae60 --- /dev/null +++ b/jvue-front/.gitignore @@ -0,0 +1,91 @@ +# Created by .ignore support plugin (hsz.mobi) +### Node template +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# next.js build output +.next + +# nuxt.js build output +.nuxt + +# Nuxt generate +dist + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless + +# IDE +.idea + +# Service worker +sw.* +yarn.lock +.yarnclean +.nuxtrc +node_modules +node_modules_dev/ +node_modules_prod/ +node_modules/.yargit n-integrity diff --git a/jvue-front/.prettierrc b/jvue-front/.prettierrc new file mode 100644 index 0000000..032e7bb --- /dev/null +++ b/jvue-front/.prettierrc @@ -0,0 +1,5 @@ +{ + "no-console": false, + "semi": true, + "singleQuote": false +} diff --git a/jvue-front/Dockerfile b/jvue-front/Dockerfile new file mode 100644 index 0000000..97274d0 --- /dev/null +++ b/jvue-front/Dockerfile @@ -0,0 +1,31 @@ +# 依赖的镜像 +FROM node:14-alpine + +# 工作目录 +WORKDIR /app + +# 安装依赖 +COPY ./jvue-front/package.json ./ + +# yarn 已经有了,没必要重复安装 +RUN yarn config set registry https://registry.npmmirror.com/ --global && \ + yarn config set disturl https://npmmirror.com/package/dist --global && \ + yarn config set sass_binary_site https://cdn.npmmirror.com/binaries/node-sass --global && \ + yarn config set electron_mirror https://registry.npmmirror.com/binary.html?path=electron/ --global && \ + yarn config set puppeteer_download_host https://registry.npmmirror.com/binary.html --global && \ + yarn config set chromedriver_cdnurl https://cdn.npmmirror.com/binaries/chromedriver --global && \ + yarn config set operadriver_cdnurl https://cdn.npmmirror.com/binaries/operadriver --global && \ + yarn config set phantomjs_cdnurl https://cdn.npmmirror.com/binaries/phantomjs --global && \ + yarn config set selenium_cdnurl https://cdn.npmmirror.com/binaries/selenium --global && \ + yarn config set node_inspector_cdnurl https://cdn.npmmirror.com/binaries/node-inspector --global + +RUN yarn + +RUN yarn build + +COPY ./jvue-front . + +# 注意这个一定要要在yarn后面,否则devDependencies的包无法安装 +# ENV HOST 0.0.0.0 + +CMD ["yarn", "start"] diff --git a/jvue-front/README.md b/jvue-front/README.md index d492803..7696140 100644 --- a/jvue-front/README.md +++ b/jvue-front/README.md @@ -1,3 +1,36 @@ -# Notice +# jvue-front -This moudule is moved to [https://github.com/terwer/jvue-front](https://github.com/terwer/jvue-front) \ No newline at end of file +> Front module for jvue + +## Build Setup + +注意:已经兼容node16 + +``` +npm i -g yarn +``` + +```bash +# install dependencies +$ yarn + +# serve with hot reload at localhost:3000 +$ yarn dev + +# build for production and launch server +$ yarn build +$ yarn start + +# generate static project +$ yarn generate +``` + +## notice + +node-sass version policy + +[https://github.com/sass/node-sass#node-version-support-policy](https://github.com/sass/node-sass#node-version-support-policy) + +this project support **node 16** + +For detailed explanation on how things work, checkout [Nuxt.js docs](https://nuxtjs.org). diff --git a/jvue-front/assets/README.md b/jvue-front/assets/README.md new file mode 100644 index 0000000..34766f9 --- /dev/null +++ b/jvue-front/assets/README.md @@ -0,0 +1,7 @@ +# ASSETS + +**This directory is not required, you can delete it if you don't want to use it.** + +This directory contains your un-compiled assets such as LESS, SASS, or JavaScript. + +More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/assets#webpacked). diff --git a/jvue-front/assets/logo-dark.png b/jvue-front/assets/logo-dark.png new file mode 100644 index 0000000..0c4bf3d Binary files /dev/null and b/jvue-front/assets/logo-dark.png differ diff --git a/jvue-front/assets/logo.png b/jvue-front/assets/logo.png new file mode 100644 index 0000000..8e3f2eb Binary files /dev/null and b/jvue-front/assets/logo.png differ diff --git a/jvue-front/assets/mp-qrcode.png b/jvue-front/assets/mp-qrcode.png new file mode 100644 index 0000000..0616cae Binary files /dev/null and b/jvue-front/assets/mp-qrcode.png differ diff --git a/jvue-front/components/Logo.vue b/jvue-front/components/Logo.vue new file mode 100644 index 0000000..6c72854 --- /dev/null +++ b/jvue-front/components/Logo.vue @@ -0,0 +1,79 @@ + + + diff --git a/jvue-front/components/README.md b/jvue-front/components/README.md new file mode 100644 index 0000000..a079f10 --- /dev/null +++ b/jvue-front/components/README.md @@ -0,0 +1,7 @@ +# COMPONENTS + +**This directory is not required, you can delete it if you don't want to use it.** + +The components directory contains your Vue.js Components. + +_Nuxt.js doesn't supercharge these components._ diff --git a/jvue-front/components/themes/default/Artalk.vue b/jvue-front/components/themes/default/Artalk.vue new file mode 100644 index 0000000..665ce21 --- /dev/null +++ b/jvue-front/components/themes/default/Artalk.vue @@ -0,0 +1,57 @@ + + + diff --git a/jvue-front/components/themes/default/Aside.vue b/jvue-front/components/themes/default/Aside.vue new file mode 100644 index 0000000..4521f8d --- /dev/null +++ b/jvue-front/components/themes/default/Aside.vue @@ -0,0 +1,80 @@ + + + + diff --git a/jvue-front/components/themes/default/Body.vue b/jvue-front/components/themes/default/Body.vue new file mode 100644 index 0000000..3bb1377 --- /dev/null +++ b/jvue-front/components/themes/default/Body.vue @@ -0,0 +1,94 @@ + + + + + diff --git a/jvue-front/components/themes/default/Footer.vue b/jvue-front/components/themes/default/Footer.vue new file mode 100644 index 0000000..84aa033 --- /dev/null +++ b/jvue-front/components/themes/default/Footer.vue @@ -0,0 +1,179 @@ + + + + + diff --git a/jvue-front/components/themes/default/FriendLink.vue b/jvue-front/components/themes/default/FriendLink.vue new file mode 100644 index 0000000..bcc9df1 --- /dev/null +++ b/jvue-front/components/themes/default/FriendLink.vue @@ -0,0 +1,67 @@ + + + + + diff --git a/jvue-front/components/themes/default/Header.vue b/jvue-front/components/themes/default/Header.vue new file mode 100644 index 0000000..c0a13cf --- /dev/null +++ b/jvue-front/components/themes/default/Header.vue @@ -0,0 +1,107 @@ + + + + + diff --git a/jvue-front/components/themes/default/HeaderMenu.vue b/jvue-front/components/themes/default/HeaderMenu.vue new file mode 100644 index 0000000..62c9cf9 --- /dev/null +++ b/jvue-front/components/themes/default/HeaderMenu.vue @@ -0,0 +1,124 @@ + + + + + diff --git a/jvue-front/components/themes/default/HeaderTime.vue b/jvue-front/components/themes/default/HeaderTime.vue new file mode 100644 index 0000000..740464a --- /dev/null +++ b/jvue-front/components/themes/default/HeaderTime.vue @@ -0,0 +1,56 @@ + + + + + diff --git a/jvue-front/components/themes/default/PostList.vue b/jvue-front/components/themes/default/PostList.vue new file mode 100644 index 0000000..d47d49d --- /dev/null +++ b/jvue-front/components/themes/default/PostList.vue @@ -0,0 +1,151 @@ + + + + + diff --git a/jvue-front/layouts/README.md b/jvue-front/layouts/README.md new file mode 100644 index 0000000..cad1ad5 --- /dev/null +++ b/jvue-front/layouts/README.md @@ -0,0 +1,7 @@ +# LAYOUTS + +**This directory is not required, you can delete it if you don't want to use it.** + +This directory contains your Application Layouts. + +More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/views#layouts). diff --git a/jvue-front/layouts/default.vue b/jvue-front/layouts/default.vue new file mode 100644 index 0000000..9ba9597 --- /dev/null +++ b/jvue-front/layouts/default.vue @@ -0,0 +1,55 @@ + + + diff --git a/jvue-front/middleware/README.md b/jvue-front/middleware/README.md new file mode 100644 index 0000000..01595de --- /dev/null +++ b/jvue-front/middleware/README.md @@ -0,0 +1,8 @@ +# MIDDLEWARE + +**This directory is not required, you can delete it if you don't want to use it.** + +This directory contains your application middleware. +Middleware let you define custom functions that can be run before rendering either a page or a group of pages. + +More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/routing#middleware). diff --git a/jvue-front/nuxt.config.js b/jvue-front/nuxt.config.js new file mode 100644 index 0000000..b4ed3e2 --- /dev/null +++ b/jvue-front/nuxt.config.js @@ -0,0 +1,89 @@ +const pkg = require("./package"); + +const development = process.env.NODE_ENV !== "production"; + +module.exports = { + debug: true, + mode: "universal", + telemetry: false, + + /* + ** Headers of the page + */ + head: { + title: pkg.name, + meta: [ + { charset: "utf-8" }, + { name: "viewport", content: "width=device-width, initial-scale=1" }, + { hid: "description", name: "description", content: pkg.description } + ], + link: [{ rel: "icon", type: "image/x-icon", href: "/favicon.ico" }] + }, + + /* + ** Customize the progress-bar color + */ + loading: { color: "#fff" }, + + /* + ** Global CSS + */ + css: [], + + /* + ** Plugins to load before mounting the App + */ + plugins: [ + "~/plugins/axios", + "~plugins/element-ui", + { + src: "@/plugins/font-awesome", + ssr: false // 只在客户端打包 + }, + { + src: "~/plugins/vue-hljs", + ssr: false // 只在客户端打包 + }, + { + src: "~/plugins/baidu-tongji", + ssr: false // 只在客户端打包 + } + ], + + /* + ** Nuxt.js modules + */ + modules: [ + // Doc: https://axios.nuxtjs.org/usage + "@nuxtjs/axios" + ], + /* + ** Axios module configuration + */ + axios: { + // See https://github.com/nuxt-community/axios-module#options + baseURL: development ? "http://localhost:8002/api" : "http://localhost/api" + }, + + /* + ** Build configuration + */ + build: { + transpile: [/^element-ui/], + + /* + ** You can extend webpack config here + */ + extend(config, ctx) { + // Run ESLint on save + if (ctx.isDev && ctx.isClient) { + config.module.rules.push({ + enforce: "pre", + test: /\.(js|vue)$/, + loader: "eslint-loader", + exclude: /(node_modules)/ + }); + } + } + } +}; diff --git a/jvue-front/package.json b/jvue-front/package.json new file mode 100644 index 0000000..a588dc0 --- /dev/null +++ b/jvue-front/package.json @@ -0,0 +1,54 @@ +{ + "name": "bugucms-front", + "version": "4.2.0", + "description": "Front module for jvue", + "author": "terwer", + "private": true, + "scripts": { + "dev": "cross-env NODE_ENV=development nodemon server/index.js --watch server", + "build": "nuxt build", + "start": "nuxt build && cross-env NODE_ENV=production node server/index.js", + "generate": "nuxt generate", + "lint": "eslint --ext .js,.vue --ignore-path .gitignore --ignore-pattern !.eslintrc.js --fix ." + }, + "dependencies": { + "@nuxtjs/axios": "^5.3.6", + "artalk": "^2.3.4", + "cross-env": "^5.2.0", + "element-ui": "2.4.11", + "express": "^4.16.4", + "font-awesome": "^4.7.0", + "highlight.js": "^11.6.0", + "nuxt": "^2.15.8" + }, + "devDependencies": { + "@nuxt/types": "^2.15.8", + "@nuxtjs/eslint-config": "^0.0.1", + "@vue/eslint-config-prettier": "^4.0.1", + "babel-eslint": "^10.0.1", + "eslint": "^7.8.1", + "eslint-config-prettier": "^4.1.0", + "eslint-config-standard": ">=12.0.0", + "eslint-loader": "^2.1.2", + "eslint-plugin-import": ">=2.16.0", + "eslint-plugin-jest": ">=22.3.0", + "eslint-plugin-n": "^15.2.3", + "eslint-plugin-node": ">=8.0.1", + "eslint-plugin-nuxt": ">=0.4.2", + "eslint-plugin-prettier": "^3.0.1", + "eslint-plugin-promise": ">=4.0.1", + "eslint-plugin-standard": ">=4.0.0", + "eslint-plugin-vue": "^7.0.0", + "node-sass": "^6.0.1", + "nodemon": "^1.18.9", + "prettier": "^1.16.4", + "qs": "^6.6.0", + "sass-loader": "^10.3.1" + }, + "config": { + "nuxt": { + "host": "0.0.0.0", + "port": "3000" + } + } +} diff --git a/jvue-front/pages/README.md b/jvue-front/pages/README.md new file mode 100644 index 0000000..1d5d48b --- /dev/null +++ b/jvue-front/pages/README.md @@ -0,0 +1,6 @@ +# PAGES + +This directory contains your Application Views and Routes. +The framework reads all the `*.vue` files inside this directory and creates the router of your application. + +More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/routing). diff --git a/jvue-front/pages/about.vue b/jvue-front/pages/about.vue new file mode 100644 index 0000000..66db441 --- /dev/null +++ b/jvue-front/pages/about.vue @@ -0,0 +1,136 @@ + + + + + + + diff --git a/jvue-front/pages/common.css b/jvue-front/pages/common.css new file mode 100644 index 0000000..538584d --- /dev/null +++ b/jvue-front/pages/common.css @@ -0,0 +1,88 @@ +/** +* 所有主题公共样式 +* 注意:每个主题都要引用这个样式 +*/ +body { + font-family: "LXGW WenKai","Wenquanyi Micro Hei","Wenquanyi Micro Hei Mono","Microsoft YaHei", "PT Sans", "-apple-system", "Liberation Mono", monospace, dejavu sans mono,Fira Code,Microsoft Yahei,Consolas,Courier New,monospace,Menlo,Monaco !important; + color: #666 !important; +} +body, +* { + box-sizing: border-box; +} +body a { + text-decoration: none; + color: #00a4ff; +} +body a:hover { + color: orangered; +} +.el-header, +.el-footer { + background-color: #fff; + color: #333; + line-height: 60px; + padding: 0; + height: auto !important; +} +.el-main { + background-color: #fff; + color: #333; + text-align: left; + line-height: 45px; + padding: 0 !important; + overflow: hidden; +} +body > .el-container { + margin-bottom: 40px; +} +.hide { + display: none; +} +/*! +* 遮罩层 +*/ +.mask { + position: fixed; + top: 0; + right: 0; + left: 0; + bottom: 0; + background: rgba(0, 0, 0, 0.6); + z-index: 999999; +} +.text-center { + text-align: center; +} +/*! +* element-ui 覆盖样式 +*/ +.el-menu{ + background-color: transparent; +} + +/* 代码块 */ +code-group{ +} +code-group code-block{ + display: none; +} +code-group code-block[active]{ + display: block; +} +.code-tab{ + list-style: none; + padding: 0; + margin: 0; +} +.code-tab-item{ + cursor: pointer; + list-style: none; + display: inline-block; + min-width: 60px; + text-align: center; +} +.code-tab .current{ + background: #f5f5f5; + padding: 5px 0; +} diff --git a/jvue-front/pages/default.css b/jvue-front/pages/default.css new file mode 100644 index 0000000..83db088 --- /dev/null +++ b/jvue-front/pages/default.css @@ -0,0 +1,47 @@ +/*! + * Theme Name: terwer + * Theme URL: https://github.com/terwer + * Description: 本主题是一款适合博客、新闻资讯、自媒体的主题模板。基于bootstrap响应式布局,自适应PC、手机、平板等多种设备浏览。包含普通文章、专题、视频、图集、下载五中文章类型,多种文章页模板。自带前端用户中心,前端登录注册、资料编辑、投稿、文章编辑、评论管理、收藏管理、用户关注一应俱全。文章列表及评论列表AJAX加载。视频支持本地上传、视频链接及视频平台视频。 + * Author: 倚楼听雨 + * Author URI: https://github.com/terwer + * Tags:blog + * Version: 1.0 + */ +/*! + * 自定义默认主题 + * css名称必须有default关键字 + */ +.post-list-title h2{ + color: #000000; +} +.post-list-title h2:hover{ + color: #409EFF; +} +.aside-link h2{ + color: #000000; +} +.aside-link h2:hover{ + color: #409EFF; +} +/* 加载更多 */ +.loadmore-default { + padding: 0; + border-radius: 4px; + border: 1px solid #EBEEF5; + overflow: hidden; + background: #fff; + text-align: center; +} +.loadmore-default a { + color: #303133; + text-decoration: none; + display: block; + padding: 0; + text-align: center; + font-size: 14px; + background: #fff; +} +.loadmore-default a:hover { + color: #409EFF; + background-color: rgba(153, 153, 153, 0.17); +} diff --git a/jvue-front/pages/default.vue b/jvue-front/pages/default.vue new file mode 100644 index 0000000..3f1976d --- /dev/null +++ b/jvue-front/pages/default.vue @@ -0,0 +1,71 @@ + + + + + diff --git a/jvue-front/pages/essay.css b/jvue-front/pages/essay.css new file mode 100644 index 0000000..85d657f --- /dev/null +++ b/jvue-front/pages/essay.css @@ -0,0 +1,64 @@ +/** + @Name: default + @Author: terwer + @Copyright: terwergreen.com + */ +/* =========== + 工具样式 + =========== */ +.pull-right{ + float: right !important; +} + +.pull-left{ + float: left !important; +} + +/* 辅助 */ +.lay-blog .container .count .layblog-this{color: #FF5722 !important;} + +/* start container */ +.lay-blog .container-wrap{margin:0px auto 0;min-height:100%;padding:40px 0 160px 0;box-sizing: border-box;} +.lay-blog .container{width:1200px;margin:0 auto;} +.lay-blog .container h4{font-weight:bold;line-height:32px;font-size:16px;} +.lay-blog .container h4 p{padding-left:40px;color:#666666;} +.lay-blog .container h4 p i{font-size:26px;padding-right:10px;position:relative;top:3px;} +.lay-blog .container .item{margin-bottom: 15px; background: #fff; padding-top: 20px;} +.lay-blog .container .item .item-box{padding:0 35px 24px;font-size:14px;} +.lay-blog .container .item h3{line-height:36px;font-size:20px;} +.lay-blog .container .item h5{line-height: 38px;color:#a5a5a5;} +.lay-blog .container .item p{line-height:30px; padding-bottom: 10px;} +.lay-blog .container .item .comment{width: 100%; line-height: 56px; background: #f9f9f9; font-size: 14px; overflow:hidden;} +.lay-blog .container .item .comment a{display:inline-block;width:50%;text-align:center;float: left;} +.lay-blog .container .item .comment a+a{border-left:1px solid #efefef;margin-left:-1px;} +.lay-blog .container .item-btn{text-align:center;/*margin-top:20px;*/} + + +@media only screen and (max-width: 750px) { + .lay-blog .container{width:100%; margin: 0 auto 70px;} + .lay-blog .container .contar-wrap{padding: 0 10px 10px;} + + .lay-blog .container-wrap{padding-top: 20px;} +} +/* end container */ + +/* start message*/ +.container-message textarea{ + font-size:14px; + width: 100%; + height: 105px; + margin: auto; +} +.lay-blog .container-message .item-btn{ + text-align: right; +} +.lay-blog .container-message .item-btn{/*margin-bottom: 50px;*/} +.lay-blog .container-message .info-item{font-size:14px;margin-bottom: 16px;clear: both;} +.lay-blog .container-message .info-img{cursor: pointer;float: left;padding-right:20px;width: 50px; margin-top: 20px;margin-left: 20px;} +.lay-blog .container-message .info-text{padding-left: 60px;border: solid 1px #ffffff;border-radius: 4px;} +.lay-blog .container-message .title{overflow:hidden;} +.lay-blog .container-message .title .name{float: left; display: block; line-height: 38px; color:#787878;} +.info-intr{padding-left: 10px;line-height: 24px;margin-bottom: 5px;} +.lay-blog .container-message .title .info-img{float: right;color:#4b5a75; width: auto;} +.lay-blog .container-message .title .info-img i{font-size: 24px;padding-right: 5px;position: relative;top: 4px;} +.lay-blog .container-message .paging{text-align:center;} diff --git a/jvue-front/pages/essay/index.vue b/jvue-front/pages/essay/index.vue new file mode 100644 index 0000000..d263c61 --- /dev/null +++ b/jvue-front/pages/essay/index.vue @@ -0,0 +1,278 @@ + + + + + diff --git a/jvue-front/pages/index.vue b/jvue-front/pages/index.vue new file mode 100644 index 0000000..fb0d7ce --- /dev/null +++ b/jvue-front/pages/index.vue @@ -0,0 +1,91 @@ + + + + + diff --git a/jvue-front/pages/note.vue b/jvue-front/pages/note.vue new file mode 100644 index 0000000..e3b63aa --- /dev/null +++ b/jvue-front/pages/note.vue @@ -0,0 +1,93 @@ + + + + + diff --git a/jvue-front/pages/post/_id.vue b/jvue-front/pages/post/_id.vue new file mode 100644 index 0000000..bea9458 --- /dev/null +++ b/jvue-front/pages/post/_id.vue @@ -0,0 +1,333 @@ + + + + + + + diff --git a/jvue-front/pages/s/_keyword.vue b/jvue-front/pages/s/_keyword.vue new file mode 100644 index 0000000..2fbfde2 --- /dev/null +++ b/jvue-front/pages/s/_keyword.vue @@ -0,0 +1,98 @@ + + + + + + + diff --git a/jvue-front/pages/tag/_tag.vue b/jvue-front/pages/tag/_tag.vue new file mode 100644 index 0000000..5a77944 --- /dev/null +++ b/jvue-front/pages/tag/_tag.vue @@ -0,0 +1,98 @@ + + + + + + + diff --git a/jvue-front/plugins/README.md b/jvue-front/plugins/README.md new file mode 100644 index 0000000..ca1f9d8 --- /dev/null +++ b/jvue-front/plugins/README.md @@ -0,0 +1,7 @@ +# PLUGINS + +**This directory is not required, you can delete it if you don't want to use it.** + +This directory contains Javascript plugins that you want to run before mounting the root Vue.js application. + +More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/plugins). diff --git a/jvue-front/plugins/axios.js b/jvue-front/plugins/axios.js new file mode 100644 index 0000000..643f727 --- /dev/null +++ b/jvue-front/plugins/axios.js @@ -0,0 +1,39 @@ +/** + * axios + * + *@author Terwer + *@version 1.0 + *2019/3/19 16:39 + **/ +import qs from "qs"; +import { getLogger } from "../util/logger"; +const logger = getLogger("plugins/axios"); + +export default function({ $axios, redirect }) { + $axios.onRequest(config => { + const url = config.baseURL + config.url; + logger.info("url=>" + url); + + const headers = config.headers || {}; + config.headers = Object.assign(headers, { + "content-type": "application/x-www-form-urlencoded" + }); + logger.info("headers=>" + qs.stringify(config.headers)); + + const params = config.data || {}; + config.data = qs.stringify(params); + logger.info("params=>" + config.data); + }); + + $axios.onError(error => { + const code = parseInt(error.response && error.response.status); + if (code === 400) { + console.error("400"); + // redirect("/400"); + } else if (code === 500) { + console.error("500"); + // redirect("/sorry"); + } + console.error("axios error=>", error); + }); +} diff --git a/jvue-front/plugins/baidu-tongji.js b/jvue-front/plugins/baidu-tongji.js new file mode 100644 index 0000000..25bc4bb --- /dev/null +++ b/jvue-front/plugins/baidu-tongji.js @@ -0,0 +1,21 @@ +// eslint-disable-next-line no-use-before-define,no-var +var _hmt = _hmt || []; +(function() { + const hm = document.createElement("script"); + hm.src = "https://hm.baidu.com/hm.js?8cf152054e4b32b33cbc68fef515bbb5"; + hm.id = "baidu_tj"; + const s = document.getElementsByTagName("script")[0]; + s.parentNode.insertBefore(hm, s); +})(); + +console.log("Register baidutongji success"); + +export default ({ app: { router }, store }) => { + router.afterEach((to, from) => { + try { + window._hmt = window._hmt || []; + window._hmt.push(["_trackPageview", to.fullPath]); + console.log("百度统计上报,to=>", to); + } catch (e) {} + }); +}; diff --git a/jvue-front/plugins/element-ui.js b/jvue-front/plugins/element-ui.js new file mode 100644 index 0000000..864b00d --- /dev/null +++ b/jvue-front/plugins/element-ui.js @@ -0,0 +1,11 @@ +import Vue from "vue"; +import Element from "element-ui"; +import locale from "element-ui/lib/locale/lang/zh-CN"; +import { getLogger } from "../util/logger"; +import "element-ui/lib/theme-chalk/index.css"; +const logger = getLogger("element-ui"); + +export default () => { + Vue.use(Element, { locale }); + logger.info("Register element-ui success"); +}; diff --git a/jvue-front/plugins/font-awesome.js b/jvue-front/plugins/font-awesome.js new file mode 100644 index 0000000..2a1d655 --- /dev/null +++ b/jvue-front/plugins/font-awesome.js @@ -0,0 +1,8 @@ +/** + * font-awesome + * + *@author Terwer + *@version 1.0 + *2019/3/20 14:27 + **/ +import "font-awesome/css/font-awesome.min.css"; diff --git a/jvue-front/plugins/lib/codecopy/codecopy.css b/jvue-front/plugins/lib/codecopy/codecopy.css new file mode 100644 index 0000000..9208d60 --- /dev/null +++ b/jvue-front/plugins/lib/codecopy/codecopy.css @@ -0,0 +1,54 @@ +.hljs-copy-wrapper { + position: relative; + overflow: hidden; +} +.hljs-copy-wrapper:hover .hljs-copy-button, +.hljs-copy-button:focus { + transform: translateX(0); +} +.hljs-copy-button { + position: absolute; + transform: translateX(calc(100% + 1.125em)); + top: 1em; + right: 1em; + width: 2rem; + height: 2rem; + text-indent: -9999px; /* Hide the inner text */ + color: #fff; + border-radius: 0.25rem; + border: 1px solid #ffffff22; + /*background-color: #2d2b57;*/ + background-color: #0d6efd; + background-image: url('data:image/svg+xml;utf-8,'); + background-repeat: no-repeat; + background-position: center; + transition: background-color 200ms ease, transform 200ms ease-out; + cursor: pointer; +} +.hljs-copy-button:hover { + border-color: #ffffff44; +} +.hljs-copy-button:active { + border-color: #ffffff66; +} +.hljs-copy-button[data-copied="true"] { + text-indent: 0px; /* Shows the inner text */ + width: auto; + background-image: none; +} +@media (prefers-reduced-motion) { + .hljs-copy-button { + transition: none; + } +} + +/* visually-hidden */ +.hljs-copy-alert { + clip: rect(0 0 0 0); + clip-path: inset(50%); + height: 1px; + overflow: hidden; + position: absolute; + white-space: nowrap; + width: 1px; +} diff --git a/jvue-front/plugins/lib/codecopy/index.js b/jvue-front/plugins/lib/codecopy/index.js new file mode 100644 index 0000000..614a6e6 --- /dev/null +++ b/jvue-front/plugins/lib/codecopy/index.js @@ -0,0 +1,97 @@ +/** + * @file highlight-copy.js + * @author Arron Hunt + * @copyright Copyright 2021. All rights reserved. + */ + +/** + * Adds a copy button to highlightjs code blocks + */ +export class CopyButtonPlugin { + /** + * Create a new CopyButtonPlugin class instance + * @param {Object} [options] - Functions that will be called when a copy event fires + * @param {CopyCallback} [options.callback] + * @param {Hook} [options.hook] + */ + constructor(options = {}) { + // @ts-ignore + self.hook = options.hook; + // @ts-ignore + self.callback = options.callback; + } + + // @ts-ignore + "after:highlightElement"({ el, text }) { + // Create the copy button and append it to the codeblock. + const button = Object.assign(document.createElement("button"), { + innerHTML: "Copy", + className: "hljs-copy-button" + }); + // @ts-ignore + button.dataset.copied = false; + el.parentElement.classList.add("hljs-copy-wrapper"); + el.parentElement.appendChild(button); + + // Add a custom proprety to the code block so that the copy button can reference and match its background-color value. + el.parentElement.style.setProperty( + "--hljs-theme-background", + window.getComputedStyle(el).backgroundColor + ); + + button.onclick = function() { + if (!navigator.clipboard) return; + + let newText = text; + // @ts-ignore + // eslint-disable-next-line no-undef + if (hook && typeof hook === "function") { + // @ts-ignore + // eslint-disable-next-line no-undef + newText = hook(text, el) || text; + } + + navigator.clipboard + .writeText(newText) + .then(function() { + button.innerHTML = "复制成功"; + // @ts-ignore + button.dataset.copied = true; + + let alert = Object.assign(document.createElement("div"), { + role: "status", + className: "hljs-copy-alert", + innerHTML: "复制到剪贴板" + }); + el.parentElement.appendChild(alert); + + setTimeout(() => { + button.innerHTML = "Copy"; + // @ts-ignore + button.dataset.copied = false; + el.parentElement.removeChild(alert); + // @ts-ignore + alert = null; + }, 2000); + }) + .then(function() { + // @ts-ignore + // eslint-disable-next-line no-undef + if (typeof callback === "function") return callback(newText, el); + }); + }; + } +} + +/** + * @typedef {function} CopyCallback + * @param {string} text - The raw text copied to the clipboard. + * @param {HTMLElement} el - The code block element that was copied from. + * @returns {undefined} + */ +/** + * @typedef {function} Hook + * @param {string} text - The raw text copied to the clipboard. + * @param {HTMLElement} el - The code block element that was copied from. + * @returns {string|undefined} + */ diff --git a/jvue-front/plugins/lib/vue-hljs/main.js b/jvue-front/plugins/lib/vue-hljs/main.js new file mode 100644 index 0000000..d971031 --- /dev/null +++ b/jvue-front/plugins/lib/vue-hljs/main.js @@ -0,0 +1,80 @@ +import Hljs from "highlight.js"; +import { CopyButtonPlugin } from "../codecopy"; +import "../codecopy/codecopy.css"; + +const vueHljs = {}; + +vueHljs.install = Vue => { + // 代码复制 + Hljs.addPlugin( + // @ts-ignore + new CopyButtonPlugin({ + // callback: (text:any, el:any) => console.log("Copied to clipboard", text), + }) + ); + + Vue.directive("highlight", el => { + const blocks = el.querySelectorAll("pre code"); + Array.prototype.forEach.call(blocks, Hljs.highlightBlock); + + // 代码选项卡 + // 代码块 + const codeGroups = el.querySelectorAll("code-group"); + // 处理每个代码块 + codeGroups.forEach(group => { + // 防止重复添加 + if (group.getElementsByTagName("ul").length === 0) { + const newNode = document.createElement("ul"); + newNode.setAttribute("class", "code-tab"); + + const codeBlocks = group.querySelectorAll("code-block"); + codeBlocks.forEach(block => { + const title = block.attributes.getNamedItem("title")?.value; + const active = block.attributes.getNamedItem("active")?.value; + const isActive = active !== undefined; + // console.log(block.attributes.length) + // console.log(title) + // console.log(isActive) + + const item = document.createElement("li"); + item.setAttribute( + "class", + isActive ? "code-tab-item current" : "code-tab-item" + ); + item.innerHTML = title || ""; + item.addEventListener("click", function(event) { + const targetElement = event.target; + // 选择状态 + // console.log(codeBlocks[0].innerHTML) + const allLis = targetElement.parentElement.querySelectorAll("li"); + allLis.forEach(li => { + li.setAttribute("class", "code-tab-item"); + }); + targetElement.setAttribute("class", "code-tab-item current"); + + // 设置tab + codeBlocks.forEach(cb => { + if ( + cb.attributes.getNamedItem("title")?.value === + targetElement.innerHTML + ) { + cb.setAttribute("active", ""); + } else { + cb.removeAttribute("active"); + } + }); + // console.log(targetElement.innerHTML); + }); + + newNode.append(item); + }); + + const firstBlock = codeBlocks[0]; + firstBlock?.parentNode?.insertBefore(newNode, firstBlock); + // console.log("tab") + } + }); + }); +}; + +export default vueHljs; diff --git a/jvue-front/plugins/lib/vue-hljs/vs.css b/jvue-front/plugins/lib/vue-hljs/vs.css new file mode 100644 index 0000000..50897d3 --- /dev/null +++ b/jvue-front/plugins/lib/vue-hljs/vs.css @@ -0,0 +1,52 @@ +code{ + font-family: "LXGW WenKai","Wenquanyi Micro Hei","Wenquanyi Micro Hei Mono","Microsoft YaHei", "PT Sans", "-apple-system", "Liberation Mono", monospace, dejavu sans mono,Fira Code,Microsoft Yahei,Consolas,Courier New,monospace,Menlo,Monaco !important; + font-size: 14px; color: red; +} +.hljs { + font-family: "LXGW WenKai","Wenquanyi Micro Hei","Wenquanyi Micro Hei Mono","Microsoft YaHei", "PT Sans", "-apple-system", "Liberation Mono", monospace, dejavu sans mono,Fira Code,Microsoft Yahei,Consolas,Courier New,monospace,Menlo,Monaco !important; + font-size: 14px; + display: block; + overflow-x: auto; + padding: .5em; + line-height: 1.6; + color: black; + background-color: #f5f5f5!important; + /*border: 1px solid #ccc!important;*/ + border-radius: 3px!important; +} + +.hljs-comment, .hljs-quote, .hljs-variable { + color: #008000 +} + +.hljs-keyword, .hljs-selector-tag, .hljs-built_in, .hljs-name, .hljs-tag { + color: #00f +} + +.hljs-string, .hljs-title, .hljs-section, .hljs-attribute, .hljs-literal, .hljs-template-tag, .hljs-template-variable, .hljs-type, .hljs-addition { + color: #a31515 +} + +.hljs-deletion, .hljs-selector-attr, .hljs-selector-pseudo, .hljs-meta { + color: #2b91af +} + +.hljs-doctag { + color: #808080 +} + +.hljs-attr { + color: #f00 +} + +.hljs-symbol, .hljs-bullet, .hljs-link { + color: #00b0e8 +} + +.hljs-emphasis { + font-style: italic +} + +.hljs-strong { + font-weight: bold +} diff --git a/jvue-front/plugins/lib/vue-hljs/vs2015.css b/jvue-front/plugins/lib/vue-hljs/vs2015.css new file mode 100644 index 0000000..f6a1f38 --- /dev/null +++ b/jvue-front/plugins/lib/vue-hljs/vs2015.css @@ -0,0 +1,95 @@ +code{ + font-family: "LXGW WenKai","Wenquanyi Micro Hei","Wenquanyi Micro Hei Mono","Microsoft YaHei", "PT Sans", "-apple-system", "Liberation Mono", monospace, dejavu sans mono,Fira Code,Microsoft Yahei,Consolas,Courier New,monospace,Menlo,Monaco !important; + color: #D69D85; + font-size: 14px; +} +.hljs { + font-family: "LXGW WenKai","Wenquanyi Micro Hei","Wenquanyi Micro Hei Mono","Microsoft YaHei", "PT Sans", "-apple-system", "Liberation Mono", monospace, dejavu sans mono,Fira Code,Microsoft Yahei,Consolas,Courier New,monospace,Menlo,Monaco !important; + font-size: 14px; + display: block; + overflow-x: auto; + padding: .5em; + background: #181818; + color: #DCDCDC; + border: solid 1px #181818; + border-radius: 5px; + line-height: 1.6; +} + +.hljs-keyword, .hljs-literal, .hljs-symbol, .hljs-name { + color: #569CD6 +} + +.hljs-link { + color: #569CD6; + text-decoration: underline +} + +.hljs-built_in, .hljs-type { + color: #4EC9B0 +} + +.hljs-number, .hljs-class { + color: #B8D7A3 +} + +.hljs-string, .hljs-meta-string { + color: #D69D85 +} + +.hljs-regexp, .hljs-template-tag { + color: #9A5334 +} + +.hljs-subst, .hljs-function, .hljs-title, .hljs-params, .hljs-formula { + color: #DCDCDC +} + +.hljs-comment, .hljs-quote { + color: #57A64A; + font-style: italic +} + +.hljs-doctag { + color: #608B4E +} + +.hljs-meta, .hljs-meta-keyword, .hljs-tag { + color: #9B9B9B +} + +.hljs-variable, .hljs-template-variable { + color: #BD63C5 +} + +.hljs-attr, .hljs-attribute, .hljs-builtin-name { + color: #9CDCFE +} + +.hljs-section { + color: gold +} + +.hljs-emphasis { + font-style: italic +} + +.hljs-strong { + font-weight: bold +} + +.hljs-bullet, .hljs-selector-tag, .hljs-selector-id, .hljs-selector-class, .hljs-selector-attr, .hljs-selector-pseudo { + color: #D7BA7D +} + +.hljs-addition { + background-color: #144212; + display: inline-block; + width: 100% +} + +.hljs-deletion { + background-color: #600; + display: inline-block; + width: 100% +} diff --git a/jvue-front/plugins/vue-hljs.js b/jvue-front/plugins/vue-hljs.js new file mode 100644 index 0000000..90e4f6c --- /dev/null +++ b/jvue-front/plugins/vue-hljs.js @@ -0,0 +1,14 @@ +/** + * vue-hljs + * + *@author Terwer + *@version 1.0 + *2019/3/21 12:02 + **/ +import Vue from "vue"; +import { getLogger } from "../util/logger"; +import vueHljs from "./lib/vue-hljs/main"; +const logger = getLogger("plugins/vue-hljs"); + +Vue.use(vueHljs); +logger.debug("Register vue-hljs success"); diff --git a/jvue-front/server/index.js b/jvue-front/server/index.js new file mode 100644 index 0000000..8986810 --- /dev/null +++ b/jvue-front/server/index.js @@ -0,0 +1,34 @@ +const express = require("express"); +const consola = require("consola"); +const { Nuxt, Builder } = require("nuxt"); +const app = express(); + +// Import and Set Nuxt.js options +const config = require("../nuxt.config.js"); +config.dev = !(process.env.NODE_ENV === "production"); + +async function start() { + // Init Nuxt.js + const nuxt = new Nuxt(config); + + const { host, port } = nuxt.options.server; + + // Build only in dev mode + if (config.dev) { + const builder = new Builder(nuxt); + await builder.build(); + } else { + await nuxt.ready(); + } + + // Give nuxt middleware to express + app.use(nuxt.render); + + // Listen the server + app.listen(port, host); + consola.ready({ + message: `Front module is running on http://${host}:${port} ...`, + badge: true + }); +} +start(); diff --git a/jvue-front/static/README.md b/jvue-front/static/README.md new file mode 100644 index 0000000..cf00435 --- /dev/null +++ b/jvue-front/static/README.md @@ -0,0 +1,11 @@ +# STATIC + +**This directory is not required, you can delete it if you don't want to use it.** + +This directory contains your static files. +Each file inside this directory is mapped to `/`. +Thus you'd want to delete this README.md before deploying to production. + +Example: `/static/robots.txt` is mapped as `/robots.txt`. + +More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/assets#static). diff --git a/jvue-front/static/favicon.ico b/jvue-front/static/favicon.ico new file mode 100644 index 0000000..a76ddd3 Binary files /dev/null and b/jvue-front/static/favicon.ico differ diff --git a/jvue-front/static/google66cd66cd747092f4.html b/jvue-front/static/google66cd66cd747092f4.html new file mode 100644 index 0000000..3139024 --- /dev/null +++ b/jvue-front/static/google66cd66cd747092f4.html @@ -0,0 +1 @@ +google-site-verification: google66cd66cd747092f4.html \ No newline at end of file diff --git a/jvue-front/store/README.md b/jvue-front/store/README.md new file mode 100644 index 0000000..1972d27 --- /dev/null +++ b/jvue-front/store/README.md @@ -0,0 +1,10 @@ +# STORE + +**This directory is not required, you can delete it if you don't want to use it.** + +This directory contains your Vuex Store files. +Vuex Store option is implemented in the Nuxt.js framework. + +Creating a file in this directory automatically activates the option in the framework. + +More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/vuex-store). diff --git a/jvue-front/util/Calendar.js b/jvue-front/util/Calendar.js new file mode 100644 index 0000000..2926688 --- /dev/null +++ b/jvue-front/util/Calendar.js @@ -0,0 +1,1027 @@ +/** + * Calendar.js + * + *@author Terwer + *@version 1.0 + *2019/2/28 9:47 + **/ +/** + * @1900-2100区间内的公历、农历互转 + * @charset UTF-8 + * @Author Jea杨(JJonline@JJonline.Cn) + * @Time 2014-7-21 + * @Time 2016-8-13 Fixed 2033hex、Attribution Annals + * @Time 2016-9-25 Fixed lunar LeapMonth Param Bug + * @Time 2017-7-24 Fixed use getTerm Func Param Error.use solar year,NOT lunar year + * @Version 1.0.3 + * @公历转农历:calendar.solar2lunar(1987,11,01); //[you can ignore params of prefix 0] + * @农历转公历:calendar.lunar2solar(1987,09,10); //[you can ignore params of prefix 0] + */ +const calendar = { + /** + * 农历1900-2100的润大小信息表 + * @Array Of Property + * @return Hex + */ + lunarInfo: [ + 0x04bd8, + 0x04ae0, + 0x0a570, + 0x054d5, + 0x0d260, + 0x0d950, + 0x16554, + 0x056a0, + 0x09ad0, + 0x055d2, // 1900-1909 + 0x04ae0, + 0x0a5b6, + 0x0a4d0, + 0x0d250, + 0x1d255, + 0x0b540, + 0x0d6a0, + 0x0ada2, + 0x095b0, + 0x14977, // 1910-1919 + 0x04970, + 0x0a4b0, + 0x0b4b5, + 0x06a50, + 0x06d40, + 0x1ab54, + 0x02b60, + 0x09570, + 0x052f2, + 0x04970, // 1920-1929 + 0x06566, + 0x0d4a0, + 0x0ea50, + 0x06e95, + 0x05ad0, + 0x02b60, + 0x186e3, + 0x092e0, + 0x1c8d7, + 0x0c950, // 1930-1939 + 0x0d4a0, + 0x1d8a6, + 0x0b550, + 0x056a0, + 0x1a5b4, + 0x025d0, + 0x092d0, + 0x0d2b2, + 0x0a950, + 0x0b557, // 1940-1949 + 0x06ca0, + 0x0b550, + 0x15355, + 0x04da0, + 0x0a5b0, + 0x14573, + 0x052b0, + 0x0a9a8, + 0x0e950, + 0x06aa0, // 1950-1959 + 0x0aea6, + 0x0ab50, + 0x04b60, + 0x0aae4, + 0x0a570, + 0x05260, + 0x0f263, + 0x0d950, + 0x05b57, + 0x056a0, // 1960-1969 + 0x096d0, + 0x04dd5, + 0x04ad0, + 0x0a4d0, + 0x0d4d4, + 0x0d250, + 0x0d558, + 0x0b540, + 0x0b6a0, + 0x195a6, // 1970-1979 + 0x095b0, + 0x049b0, + 0x0a974, + 0x0a4b0, + 0x0b27a, + 0x06a50, + 0x06d40, + 0x0af46, + 0x0ab60, + 0x09570, // 1980-1989 + 0x04af5, + 0x04970, + 0x064b0, + 0x074a3, + 0x0ea50, + 0x06b58, + 0x05ac0, + 0x0ab60, + 0x096d5, + 0x092e0, // 1990-1999 + 0x0c960, + 0x0d954, + 0x0d4a0, + 0x0da50, + 0x07552, + 0x056a0, + 0x0abb7, + 0x025d0, + 0x092d0, + 0x0cab5, // 2000-2009 + 0x0a950, + 0x0b4a0, + 0x0baa4, + 0x0ad50, + 0x055d9, + 0x04ba0, + 0x0a5b0, + 0x15176, + 0x052b0, + 0x0a930, // 2010-2019 + 0x07954, + 0x06aa0, + 0x0ad50, + 0x05b52, + 0x04b60, + 0x0a6e6, + 0x0a4e0, + 0x0d260, + 0x0ea65, + 0x0d530, // 2020-2029 + 0x05aa0, + 0x076a3, + 0x096d0, + 0x04afb, + 0x04ad0, + 0x0a4d0, + 0x1d0b6, + 0x0d250, + 0x0d520, + 0x0dd45, // 2030-2039 + 0x0b5a0, + 0x056d0, + 0x055b2, + 0x049b0, + 0x0a577, + 0x0a4b0, + 0x0aa50, + 0x1b255, + 0x06d20, + 0x0ada0, // 2040-2049 + /** Add By JJonline@JJonline.Cn**/ + 0x14b63, + 0x09370, + 0x049f8, + 0x04970, + 0x064b0, + 0x168a6, + 0x0ea50, + 0x06b20, + 0x1a6c4, + 0x0aae0, // 2050-2059 + 0x0a2e0, + 0x0d2e3, + 0x0c960, + 0x0d557, + 0x0d4a0, + 0x0da50, + 0x05d55, + 0x056a0, + 0x0a6d0, + 0x055d4, // 2060-2069 + 0x052d0, + 0x0a9b8, + 0x0a950, + 0x0b4a0, + 0x0b6a6, + 0x0ad50, + 0x055a0, + 0x0aba4, + 0x0a5b0, + 0x052b0, // 2070-2079 + 0x0b273, + 0x06930, + 0x07337, + 0x06aa0, + 0x0ad50, + 0x14b55, + 0x04b60, + 0x0a570, + 0x054e4, + 0x0d160, // 2080-2089 + 0x0e968, + 0x0d520, + 0x0daa0, + 0x16aa6, + 0x056d0, + 0x04ae0, + 0x0a9d4, + 0x0a2d0, + 0x0d150, + 0x0f252, // 2090-2099 + 0x0d520 + ], // 2100 + + /** + * 公历每个月份的天数普通表 + * @Array Of Property + * @return Number + */ + solarMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], + + /** + * 天干地支之天干速查表 + * @Array Of Property trans["甲","乙","丙","丁","戊","己","庚","辛","壬","癸"] + * @return Cn string + */ + Gan: [ + "\u7532", + "\u4e59", + "\u4e19", + "\u4e01", + "\u620a", + "\u5df1", + "\u5e9a", + "\u8f9b", + "\u58ec", + "\u7678" + ], + + /** + * 天干地支之地支速查表 + * @Array Of Property + * @trans["子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"] + * @return Cn string + */ + Zhi: [ + "\u5b50", + "\u4e11", + "\u5bc5", + "\u536f", + "\u8fb0", + "\u5df3", + "\u5348", + "\u672a", + "\u7533", + "\u9149", + "\u620c", + "\u4ea5" + ], + + /** + * 天干地支之地支速查表<=>生肖 + * @Array Of Property + * @trans["鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"] + * @return Cn string + */ + Animals: [ + "\u9f20", + "\u725b", + "\u864e", + "\u5154", + "\u9f99", + "\u86c7", + "\u9a6c", + "\u7f8a", + "\u7334", + "\u9e21", + "\u72d7", + "\u732a" + ], + + /** + * 24节气速查表 + * @Array Of Property + * @trans["小寒","大寒","立春","雨水","惊蛰","春分","清明","谷雨","立夏","小满","芒种","夏至","小暑","大暑","立秋","处暑","白露","秋分","寒露","霜降","立冬","小雪","大雪","冬至"] + * @return Cn string + */ + solarTerm: [ + "\u5c0f\u5bd2", + "\u5927\u5bd2", + "\u7acb\u6625", + "\u96e8\u6c34", + "\u60ca\u86f0", + "\u6625\u5206", + "\u6e05\u660e", + "\u8c37\u96e8", + "\u7acb\u590f", + "\u5c0f\u6ee1", + "\u8292\u79cd", + "\u590f\u81f3", + "\u5c0f\u6691", + "\u5927\u6691", + "\u7acb\u79cb", + "\u5904\u6691", + "\u767d\u9732", + "\u79cb\u5206", + "\u5bd2\u9732", + "\u971c\u964d", + "\u7acb\u51ac", + "\u5c0f\u96ea", + "\u5927\u96ea", + "\u51ac\u81f3" + ], + + /** + * 1900-2100各年的24节气日期速查表 + * @Array Of Property + * @return 0x string For splice + */ + sTermInfo: [ + "9778397bd097c36b0b6fc9274c91aa", + "97b6b97bd19801ec9210c965cc920e", + "97bcf97c3598082c95f8c965cc920f", + "97bd0b06bdb0722c965ce1cfcc920f", + "b027097bd097c36b0b6fc9274c91aa", + "97b6b97bd19801ec9210c965cc920e", + "97bcf97c359801ec95f8c965cc920f", + "97bd0b06bdb0722c965ce1cfcc920f", + "b027097bd097c36b0b6fc9274c91aa", + "97b6b97bd19801ec9210c965cc920e", + "97bcf97c359801ec95f8c965cc920f", + "97bd0b06bdb0722c965ce1cfcc920f", + "b027097bd097c36b0b6fc9274c91aa", + "9778397bd19801ec9210c965cc920e", + "97b6b97bd19801ec95f8c965cc920f", + "97bd09801d98082c95f8e1cfcc920f", + "97bd097bd097c36b0b6fc9210c8dc2", + "9778397bd197c36c9210c9274c91aa", + "97b6b97bd19801ec95f8c965cc920e", + "97bd09801d98082c95f8e1cfcc920f", + "97bd097bd097c36b0b6fc9210c8dc2", + "9778397bd097c36c9210c9274c91aa", + "97b6b97bd19801ec95f8c965cc920e", + "97bcf97c3598082c95f8e1cfcc920f", + "97bd097bd097c36b0b6fc9210c8dc2", + "9778397bd097c36c9210c9274c91aa", + "97b6b97bd19801ec9210c965cc920e", + "97bcf97c3598082c95f8c965cc920f", + "97bd097bd097c35b0b6fc920fb0722", + "9778397bd097c36b0b6fc9274c91aa", + "97b6b97bd19801ec9210c965cc920e", + "97bcf97c3598082c95f8c965cc920f", + "97bd097bd097c35b0b6fc920fb0722", + "9778397bd097c36b0b6fc9274c91aa", + "97b6b97bd19801ec9210c965cc920e", + "97bcf97c359801ec95f8c965cc920f", + "97bd097bd097c35b0b6fc920fb0722", + "9778397bd097c36b0b6fc9274c91aa", + "97b6b97bd19801ec9210c965cc920e", + "97bcf97c359801ec95f8c965cc920f", + "97bd097bd097c35b0b6fc920fb0722", + "9778397bd097c36b0b6fc9274c91aa", + "97b6b97bd19801ec9210c965cc920e", + "97bcf97c359801ec95f8c965cc920f", + "97bd097bd07f595b0b6fc920fb0722", + "9778397bd097c36b0b6fc9210c8dc2", + "9778397bd19801ec9210c9274c920e", + "97b6b97bd19801ec95f8c965cc920f", + "97bd07f5307f595b0b0bc920fb0722", + "7f0e397bd097c36b0b6fc9210c8dc2", + "9778397bd097c36c9210c9274c920e", + "97b6b97bd19801ec95f8c965cc920f", + "97bd07f5307f595b0b0bc920fb0722", + "7f0e397bd097c36b0b6fc9210c8dc2", + "9778397bd097c36c9210c9274c91aa", + "97b6b97bd19801ec9210c965cc920e", + "97bd07f1487f595b0b0bc920fb0722", + "7f0e397bd097c36b0b6fc9210c8dc2", + "9778397bd097c36b0b6fc9274c91aa", + "97b6b97bd19801ec9210c965cc920e", + "97bcf7f1487f595b0b0bb0b6fb0722", + "7f0e397bd097c35b0b6fc920fb0722", + "9778397bd097c36b0b6fc9274c91aa", + "97b6b97bd19801ec9210c965cc920e", + "97bcf7f1487f595b0b0bb0b6fb0722", + "7f0e397bd097c35b0b6fc920fb0722", + "9778397bd097c36b0b6fc9274c91aa", + "97b6b97bd19801ec9210c965cc920e", + "97bcf7f1487f531b0b0bb0b6fb0722", + "7f0e397bd097c35b0b6fc920fb0722", + "9778397bd097c36b0b6fc9274c91aa", + "97b6b97bd19801ec9210c965cc920e", + "97bcf7f1487f531b0b0bb0b6fb0722", + "7f0e397bd07f595b0b6fc920fb0722", + "9778397bd097c36b0b6fc9274c91aa", + "97b6b97bd19801ec9210c9274c920e", + "97bcf7f0e47f531b0b0bb0b6fb0722", + "7f0e397bd07f595b0b0bc920fb0722", + "9778397bd097c36b0b6fc9210c91aa", + "97b6b97bd197c36c9210c9274c920e", + "97bcf7f0e47f531b0b0bb0b6fb0722", + "7f0e397bd07f595b0b0bc920fb0722", + "9778397bd097c36b0b6fc9210c8dc2", + "9778397bd097c36c9210c9274c920e", + "97b6b7f0e47f531b0723b0b6fb0722", + "7f0e37f5307f595b0b0bc920fb0722", + "7f0e397bd097c36b0b6fc9210c8dc2", + "9778397bd097c36b0b70c9274c91aa", + "97b6b7f0e47f531b0723b0b6fb0721", + "7f0e37f1487f595b0b0bb0b6fb0722", + "7f0e397bd097c35b0b6fc9210c8dc2", + "9778397bd097c36b0b6fc9274c91aa", + "97b6b7f0e47f531b0723b0b6fb0721", + "7f0e27f1487f595b0b0bb0b6fb0722", + "7f0e397bd097c35b0b6fc920fb0722", + "9778397bd097c36b0b6fc9274c91aa", + "97b6b7f0e47f531b0723b0b6fb0721", + "7f0e27f1487f531b0b0bb0b6fb0722", + "7f0e397bd097c35b0b6fc920fb0722", + "9778397bd097c36b0b6fc9274c91aa", + "97b6b7f0e47f531b0723b0b6fb0721", + "7f0e27f1487f531b0b0bb0b6fb0722", + "7f0e397bd097c35b0b6fc920fb0722", + "9778397bd097c36b0b6fc9274c91aa", + "97b6b7f0e47f531b0723b0b6fb0721", + "7f0e27f1487f531b0b0bb0b6fb0722", + "7f0e397bd07f595b0b0bc920fb0722", + "9778397bd097c36b0b6fc9274c91aa", + "97b6b7f0e47f531b0723b0787b0721", + "7f0e27f0e47f531b0b0bb0b6fb0722", + "7f0e397bd07f595b0b0bc920fb0722", + "9778397bd097c36b0b6fc9210c91aa", + "97b6b7f0e47f149b0723b0787b0721", + "7f0e27f0e47f531b0723b0b6fb0722", + "7f0e397bd07f595b0b0bc920fb0722", + "9778397bd097c36b0b6fc9210c8dc2", + "977837f0e37f149b0723b0787b0721", + "7f07e7f0e47f531b0723b0b6fb0722", + "7f0e37f5307f595b0b0bc920fb0722", + "7f0e397bd097c35b0b6fc9210c8dc2", + "977837f0e37f14998082b0787b0721", + "7f07e7f0e47f531b0723b0b6fb0721", + "7f0e37f1487f595b0b0bb0b6fb0722", + "7f0e397bd097c35b0b6fc9210c8dc2", + "977837f0e37f14998082b0787b06bd", + "7f07e7f0e47f531b0723b0b6fb0721", + "7f0e27f1487f531b0b0bb0b6fb0722", + "7f0e397bd097c35b0b6fc920fb0722", + "977837f0e37f14998082b0787b06bd", + "7f07e7f0e47f531b0723b0b6fb0721", + "7f0e27f1487f531b0b0bb0b6fb0722", + "7f0e397bd097c35b0b6fc920fb0722", + "977837f0e37f14998082b0787b06bd", + "7f07e7f0e47f531b0723b0b6fb0721", + "7f0e27f1487f531b0b0bb0b6fb0722", + "7f0e397bd07f595b0b0bc920fb0722", + "977837f0e37f14998082b0787b06bd", + "7f07e7f0e47f531b0723b0b6fb0721", + "7f0e27f1487f531b0b0bb0b6fb0722", + "7f0e397bd07f595b0b0bc920fb0722", + "977837f0e37f14998082b0787b06bd", + "7f07e7f0e47f149b0723b0787b0721", + "7f0e27f0e47f531b0b0bb0b6fb0722", + "7f0e397bd07f595b0b0bc920fb0722", + "977837f0e37f14998082b0723b06bd", + "7f07e7f0e37f149b0723b0787b0721", + "7f0e27f0e47f531b0723b0b6fb0722", + "7f0e397bd07f595b0b0bc920fb0722", + "977837f0e37f14898082b0723b02d5", + "7ec967f0e37f14998082b0787b0721", + "7f07e7f0e47f531b0723b0b6fb0722", + "7f0e37f1487f595b0b0bb0b6fb0722", + "7f0e37f0e37f14898082b0723b02d5", + "7ec967f0e37f14998082b0787b0721", + "7f07e7f0e47f531b0723b0b6fb0722", + "7f0e37f1487f531b0b0bb0b6fb0722", + "7f0e37f0e37f14898082b0723b02d5", + "7ec967f0e37f14998082b0787b06bd", + "7f07e7f0e47f531b0723b0b6fb0721", + "7f0e37f1487f531b0b0bb0b6fb0722", + "7f0e37f0e37f14898082b072297c35", + "7ec967f0e37f14998082b0787b06bd", + "7f07e7f0e47f531b0723b0b6fb0721", + "7f0e27f1487f531b0b0bb0b6fb0722", + "7f0e37f0e37f14898082b072297c35", + "7ec967f0e37f14998082b0787b06bd", + "7f07e7f0e47f531b0723b0b6fb0721", + "7f0e27f1487f531b0b0bb0b6fb0722", + "7f0e37f0e366aa89801eb072297c35", + "7ec967f0e37f14998082b0787b06bd", + "7f07e7f0e47f149b0723b0787b0721", + "7f0e27f1487f531b0b0bb0b6fb0722", + "7f0e37f0e366aa89801eb072297c35", + "7ec967f0e37f14998082b0723b06bd", + "7f07e7f0e47f149b0723b0787b0721", + "7f0e27f0e47f531b0723b0b6fb0722", + "7f0e37f0e366aa89801eb072297c35", + "7ec967f0e37f14998082b0723b06bd", + "7f07e7f0e37f14998083b0787b0721", + "7f0e27f0e47f531b0723b0b6fb0722", + "7f0e37f0e366aa89801eb072297c35", + "7ec967f0e37f14898082b0723b02d5", + "7f07e7f0e37f14998082b0787b0721", + "7f07e7f0e47f531b0723b0b6fb0722", + "7f0e36665b66aa89801e9808297c35", + "665f67f0e37f14898082b0723b02d5", + "7ec967f0e37f14998082b0787b0721", + "7f07e7f0e47f531b0723b0b6fb0722", + "7f0e36665b66a449801e9808297c35", + "665f67f0e37f14898082b0723b02d5", + "7ec967f0e37f14998082b0787b06bd", + "7f07e7f0e47f531b0723b0b6fb0721", + "7f0e36665b66a449801e9808297c35", + "665f67f0e37f14898082b072297c35", + "7ec967f0e37f14998082b0787b06bd", + "7f07e7f0e47f531b0723b0b6fb0721", + "7f0e26665b66a449801e9808297c35", + "665f67f0e37f1489801eb072297c35", + "7ec967f0e37f14998082b0787b06bd", + "7f07e7f0e47f531b0723b0b6fb0721", + "7f0e27f1487f531b0b0bb0b6fb0722" + ], + + /** + * 数字转中文速查表 + * @Array Of Property + * @trans ['日','一','二','三','四','五','六','七','八','九','十'] + * @return Cn string + */ + nStr1: [ + "\u65e5", + "\u4e00", + "\u4e8c", + "\u4e09", + "\u56db", + "\u4e94", + "\u516d", + "\u4e03", + "\u516b", + "\u4e5d", + "\u5341" + ], + + /** + * 日期转农历称呼速查表 + * @Array Of Property + * @trans ['初','十','廿','卅'] + * @return Cn string + */ + nStr2: ["\u521d", "\u5341", "\u5eff", "\u5345"], + + /** + * 月份转农历称呼速查表 + * @Array Of Property + * @trans ['正','一','二','三','四','五','六','七','八','九','十','冬','腊'] + * @return Cn string + */ + nStr3: [ + "\u6b63", + "\u4e8c", + "\u4e09", + "\u56db", + "\u4e94", + "\u516d", + "\u4e03", + "\u516b", + "\u4e5d", + "\u5341", + "\u51ac", + "\u814a" + ], + + /** + * 返回农历y年一整年的总天数 + * @param lunar Year + * @return Number + * @eg:var count = calendar.lYearDays(1987) ;//count=387 + */ + lYearDays: function(y) { + let i; + let sum = 348; + for (i = 0x8000; i > 0x8; i >>= 1) { + sum += this.lunarInfo[y - 1900] & i ? 1 : 0; + } + return sum + this.leapDays(y); + }, + + /** + * 返回农历y年闰月是哪个月;若y年没有闰月 则返回0 + * @param lunar Year + * @return Number (0-12) + * @eg:var leapMonth = calendar.leapMonth(1987) ;//leapMonth=6 + */ + leapMonth: function(y) { + // 闰字编码 \u95f0 + return this.lunarInfo[y - 1900] & 0xf; + }, + + /** + * 返回农历y年闰月的天数 若该年没有闰月则返回0 + * @param lunar Year + * @return Number (0、29、30) + * @eg:var leapMonthDay = calendar.leapDays(1987) ;//leapMonthDay=29 + */ + leapDays: function(y) { + if (this.leapMonth(y)) { + return this.lunarInfo[y - 1900] & 0x10000 ? 30 : 29; + } + return 0; + }, + + /** + * 返回农历y年m月(非闰月)的总天数,计算m为闰月时的天数请使用leapDays方法 + * @param lunar Year + * @return Number (-1、29、30) + * @eg:var MonthDay = calendar.monthDays(1987,9) ;//MonthDay=29 + */ + monthDays: function(y, m) { + if (m > 12 || m < 1) { + return -1; + } // 月份参数从1至12,参数错误返回-1 + return this.lunarInfo[y - 1900] & (0x10000 >> m) ? 30 : 29; + }, + + /** + * 返回公历(!)y年m月的天数 + * @param solar Year + * @return Number (-1、28、29、30、31) + * @eg:var solarMonthDay = calendar.leapDays(1987) ;//solarMonthDay=30 + */ + solarDays: function(y, m) { + if (m > 12 || m < 1) { + return -1; + } // 若参数错误 返回-1 + const ms = m - 1; + if (ms === 1) { + // 2月份的闰平规律测算后确认返回28或29 + return (y % 4 === 0 && y % 100 !== 0) || y % 400 === 0 ? 29 : 28; + } else { + return this.solarMonth[ms]; + } + }, + + /** + * 农历年份转换为干支纪年 + * @param lYear 农历年的年份数 + * @return Cn string + */ + toGanZhiYear: function(lYear) { + let ganKey = (lYear - 3) % 10; + let zhiKey = (lYear - 3) % 12; + if (ganKey === 0) ganKey = 10; // 如果余数为0则为最后一个天干 + if (zhiKey === 0) zhiKey = 12; // 如果余数为0则为最后一个地支 + return this.Gan[ganKey - 1] + this.Zhi[zhiKey - 1]; + }, + + /** + * 公历月、日判断所属星座 + * @param cMonth [description] + * @param cDay [description] + * @return Cn string + */ + toAstro: function(cMonth, cDay) { + const s = + "\u9b54\u7faf\u6c34\u74f6\u53cc\u9c7c\u767d\u7f8a\u91d1\u725b\u53cc\u5b50\u5de8\u87f9\u72ee\u5b50\u5904\u5973\u5929\u79e4\u5929\u874e\u5c04\u624b\u9b54\u7faf"; + const arr = [20, 19, 21, 21, 21, 22, 23, 23, 23, 23, 22, 22]; + return ( + s.substr(cMonth * 2 - (cDay < arr[cMonth - 1] ? 2 : 0), 2) + "\u5ea7" + ); // 座 + }, + + /** + * 传入offset偏移量返回干支 + * @param offset 相对甲子的偏移量 + * @return Cn string + */ + toGanZhi: function(offset) { + return this.Gan[offset % 10] + this.Zhi[offset % 12]; + }, + + /** + * 传入公历(!)y年获得该年第n个节气的公历日期 + * @param y公历年(1900-2100);n二十四节气中的第几个节气(1~24);从n=1(小寒)算起 + * @return day Number + * @eg:var _24 = calendar.getTerm(1987,3) ;//_24=4;意即1987年2月4日立春 + */ + getTerm: function(y, n) { + if (y < 1900 || y > 2100) { + return -1; + } + if (n < 1 || n > 24) { + return -1; + } + const _table = this.sTermInfo[y - 1900]; + const _info = [ + parseInt("0x" + _table.substr(0, 5)).toString(), + parseInt("0x" + _table.substr(5, 5)).toString(), + parseInt("0x" + _table.substr(10, 5)).toString(), + parseInt("0x" + _table.substr(15, 5)).toString(), + parseInt("0x" + _table.substr(20, 5)).toString(), + parseInt("0x" + _table.substr(25, 5)).toString() + ]; + const _calday = [ + _info[0].substr(0, 1), + _info[0].substr(1, 2), + _info[0].substr(3, 1), + _info[0].substr(4, 2), + + _info[1].substr(0, 1), + _info[1].substr(1, 2), + _info[1].substr(3, 1), + _info[1].substr(4, 2), + + _info[2].substr(0, 1), + _info[2].substr(1, 2), + _info[2].substr(3, 1), + _info[2].substr(4, 2), + + _info[3].substr(0, 1), + _info[3].substr(1, 2), + _info[3].substr(3, 1), + _info[3].substr(4, 2), + + _info[4].substr(0, 1), + _info[4].substr(1, 2), + _info[4].substr(3, 1), + _info[4].substr(4, 2), + + _info[5].substr(0, 1), + _info[5].substr(1, 2), + _info[5].substr(3, 1), + _info[5].substr(4, 2) + ]; + return parseInt(_calday[n - 1]); + }, + + /** + * 传入农历数字月份返回汉语通俗表示法 + * @param lunar month + * @return Cn string + * @eg:var cnMonth = calendar.toChinaMonth(12) ;//cnMonth='腊月' + */ + toChinaMonth: function(m) { + // 月 => \u6708 + if (m > 12 || m < 1) { + return -1; + } // 若参数错误 返回-1 + let s = this.nStr3[m - 1]; + s += "\u6708"; // 加上月字 + return s; + }, + + /** + * 传入农历日期数字返回汉字表示法 + * @param lunar day + * @return Cn string + * @eg:var cnDay = calendar.toChinaDay(21) ;//cnMonth='廿一' + */ + toChinaDay: function(d) { + // 日 => \u65e5 + let s; + switch (d) { + case 10: + s = "\u521d\u5341"; + break; + case 20: + s = "\u4e8c\u5341"; + break; + case 30: + s = "\u4e09\u5341"; + break; + default: + s = this.nStr2[Math.floor(d / 10)]; + s += this.nStr1[d % 10]; + } + return s; + }, + + /** + * 年份转生肖[!仅能大致转换] => 精确划分生肖分界线是“立春” + * @param y year + * @return Cn string + * @eg:var animal = calendar.getAnimal(1987) ;//animal='兔' + */ + getAnimal: function(y) { + return this.Animals[(y - 4) % 12]; + }, + + /** + * 传入阳历年月日获得详细的公历、农历object信息 <=>JSON + * @param y solar year + * @param m solar month + * @param d solar day + * @return JSON object + * @eg:console.log(calendar.solar2lunar(1987,11,01)); + */ + solar2lunar: function(y, m, d) { + // 参数区间1900.1.31~2100.12.31 + // 年份限定、上限 + if (y < 1900 || y > 2100) { + return -1; // undefined转换为数字变为NaN + } + // 公历传参最下限 + if (y === 1900 && m === 1 && d < 31) { + return -1; + } + // 未传参 获得当天 + let objDate; + if (!y) { + objDate = new Date(); + } else { + objDate = new Date(y, parseInt(m) - 1, d); + } + let i; + let leap = 0; + let temp = 0; + // 修正ymd参数 + y = objDate.getFullYear(); + m = objDate.getMonth() + 1; + d = objDate.getDate(); + let offset = + (Date.UTC(objDate.getFullYear(), objDate.getMonth(), objDate.getDate()) - + Date.UTC(1900, 0, 31)) / + 86400000; + for (i = 1900; i < 2101 && offset > 0; i++) { + temp = this.lYearDays(i); + offset -= temp; + } + if (offset < 0) { + offset += temp; + i--; + } + + // 是否今天 + const isTodayObj = new Date(); + let isToday = false; + if ( + isTodayObj.getFullYear() === y && + isTodayObj.getMonth() + 1 === m && + isTodayObj.getDate() === d + ) { + isToday = true; + } + // 星期几 + let nWeek = objDate.getDay(); + const cWeek = this.nStr1[nWeek]; + // 数字表示周几顺应天朝周一开始的惯例 + if (nWeek === 0) { + nWeek = 7; + } + // 农历年 + const year = i; + leap = this.leapMonth(i); // 闰哪个月 + let isLeap = false; + + // 效验闰月 + for (i = 1; i < 13 && offset > 0; i++) { + // 闰月 + if (leap > 0 && i === leap + 1 && isLeap === false) { + --i; + isLeap = true; + temp = this.leapDays(year); // 计算农历闰月天数 + } else { + temp = this.monthDays(year, i); // 计算农历普通月天数 + } + // 解除闰月 + if (isLeap === true && i === leap + 1) { + isLeap = false; + } + offset -= temp; + } + // 闰月导致数组下标重叠取反 + if (offset === 0 && leap > 0 && i === leap + 1) { + if (isLeap) { + isLeap = false; + } else { + isLeap = true; + --i; + } + } + if (offset < 0) { + offset += temp; + --i; + } + // 农历月 + const month = i; + // 农历日 + const day = offset + 1; + // 天干地支处理 + const sm = m - 1; + const gzY = this.toGanZhiYear(year); + + // 当月的两个节气 + // bugfix-2017-7-24 11:03:38 use lunar Year Param `y` Not `year` + const firstNode = this.getTerm(y, m * 2 - 1); // 返回当月「节」为几日开始 + const secondNode = this.getTerm(y, m * 2); // 返回当月「节」为几日开始 + + // 依据12节气修正干支月 + let gzM = this.toGanZhi((y - 1900) * 12 + m + 11); + if (d >= firstNode) { + gzM = this.toGanZhi((y - 1900) * 12 + m + 12); + } + + // 传入的日期的节气与否 + let isTerm = false; + let Term = null; + if (firstNode === d) { + isTerm = true; + Term = this.solarTerm[m * 2 - 2]; + } + if (secondNode === d) { + isTerm = true; + Term = this.solarTerm[m * 2 - 1]; + } + // 日柱 当月一日与 1900/1/1 相差天数 + const dayCyclical = Date.UTC(y, sm, 1, 0, 0, 0, 0) / 86400000 + 25567 + 10; + const gzD = this.toGanZhi(dayCyclical + d - 1); + // 该日期所属的星座 + const astro = this.toAstro(m, d); + + return { + lYear: year, + lMonth: month, + lDay: day, + Animal: this.getAnimal(year), + IMonthCn: (isLeap ? "\u95f0" : "") + this.toChinaMonth(month), + IDayCn: this.toChinaDay(day), + cYear: y, + cMonth: m, + cDay: d, + gzYear: gzY, + gzMonth: gzM, + gzDay: gzD, + isToday, + isLeap, + nWeek, + ncWeek: "\u661f\u671f" + cWeek, + isTerm, + Term, + astro + }; + }, + + /** + * 传入农历年月日以及传入的月份是否闰月获得详细的公历、农历object信息 <=>JSON + * @param y lunar year + * @param m lunar month + * @param d lunar day + * @param isLeapMonth lunar month is leap or not.[如果是农历闰月第四个参数赋值true即可] + * @return JSON object + * @eg:console.log(calendar.lunar2solar(1987,9,10)); + */ + lunar2solar: function(y, m, d, isLeapMonth) { + // 参数区间1900.1.31~2100.12.1 + isLeapMonth = !!isLeapMonth; + // var leapOffset = 0; + const leapMonth = this.leapMonth(y); + // var leapDay = this.leapDays(y); + if (isLeapMonth && leapMonth !== m) { + return -1; + } // 传参要求计算该闰月公历 但该年得出的闰月与传参的月份并不同 + if ( + (y === 2100 && m === 12 && d > 1) || + (y === 1900 && m === 1 && d < 31) + ) { + return -1; + } // 超出了最大极限值 + const day = this.monthDays(y, m); + let _day = day; + // bugFix 2016-9-25 + // if month is leap, _day use leapDays method + if (isLeapMonth) { + _day = this.leapDays(y, m); + } + if (y < 1900 || y > 2100 || d > _day) { + return -1; + } // 参数合法性效验 + + // 计算农历的时间差 + let offset = 0; + for (let i = 1900; i < y; i++) { + offset += this.lYearDays(i); + } + let leap = 0; + let isAdd = false; + for (let i = 1; i < m; i++) { + leap = this.leapMonth(y); + if (!isAdd) { + // 处理闰月 + if (leap <= i && leap > 0) { + offset += this.leapDays(y); + isAdd = true; + } + } + offset += this.monthDays(y, i); + } + // 转换闰月农历 需补充该年闰月的前一个月的时差 + if (isLeapMonth) { + offset += day; + } + // 1900年农历正月一日的公历时间为1900年1月30日0时0分0秒(该时间也是本农历的最开始起始点) + const stmap = Date.UTC(1900, 1, 30, 0, 0, 0); + const calObj = new Date((offset + d - 31) * 86400000 + stmap); + const cY = calObj.getUTCFullYear(); + const cM = calObj.getUTCMonth() + 1; + const cD = calObj.getUTCDate(); + + return this.solar2lunar(cY, cM, cD); + } +}; +export { calendar }; diff --git a/jvue-front/util/DateUtil.js b/jvue-front/util/DateUtil.js new file mode 100644 index 0000000..7d990cb --- /dev/null +++ b/jvue-front/util/DateUtil.js @@ -0,0 +1,88 @@ +/** + * DateUtil.js + * + *@author Terwer + *@version 1.0 + *2019/2/28 9:47 + **/ +import { calendar } from "./Calendar"; + +const lunar = calendar.solar2lunar(); + +/** + * 根据日期获取星期几 + * @returns {string} 星期 + */ +const getWeekByDay = function() { + const day = new Date(); + const today = [ + "星期日", + "星期一", + "星期二", + "星期三", + "星期四", + "星期五", + "星期六" + ]; // 创建星期数组 + // console.log(today[day.getDay()]); + return today[day.getDay()]; // 返一个星期中的某一天,其中0为星期日 +}; + +/** + * 获取星期 + * @returns {string} + */ +const getClientTime = function() { + // 获取客户端时间 + const now = new Date(); + let currDatetime = ""; + // currDatetime += now.getFullYear() + "年"; + // currDatetime += + // now.getMonth() + 1 > 9 ? now.getMonth() + 1 : "0" + (now.getMonth() + 1); + // currDatetime += "月"; + // currDatetime += now.getDate() > 9 ? now.getDate() : "0" + now.getDate(); + // currDatetime += "日 "; + currDatetime += now.getHours() > 9 ? now.getHours() : "0" + now.getHours(); + currDatetime += ":"; + currDatetime += + now.getMinutes() > 9 ? now.getMinutes() : "0" + now.getMinutes(); + currDatetime += ":"; + currDatetime += + now.getSeconds() > 9 ? now.getSeconds() : "0" + now.getSeconds(); + return currDatetime; +}; + +const getPopTime = function() { + const popTime = + "阳历:" + + lunar.cYear + + "年" + + lunar.cMonth + + "月" + + lunar.cDay + + "日(" + + lunar.astro + + ")"; + return popTime; +}; + +const getTradTime = function() { + const tradTime = + "农历:" + lunar.lYear + "年" + lunar.IMonthCn + lunar.IDayCn; + return tradTime; +}; + +const getShengXiao = function() { + const shengxiao = + lunar.gzYear + + "年" + + lunar.gzMonth + + "月" + + lunar.gzDay + + "日(" + + lunar.Animal + + "年)"; + return shengxiao; +}; + +export { getClientTime, getPopTime, getTradTime, getShengXiao, getWeekByDay }; diff --git a/jvue-front/util/dom.js b/jvue-front/util/dom.js new file mode 100644 index 0000000..777ce22 --- /dev/null +++ b/jvue-front/util/dom.js @@ -0,0 +1,8 @@ +/** + * dom.js + * + * @author Terwer + * @version 1.0 + * 19-2-28 上午12:28 + **/ +export const inBrowser = typeof window !== "undefined"; diff --git a/jvue-front/util/logger.js b/jvue-front/util/logger.js new file mode 100644 index 0000000..439095b --- /dev/null +++ b/jvue-front/util/logger.js @@ -0,0 +1,48 @@ +/** + * logger.js + * + *@author Terwer + *@version 1.0 + *2019/3/19 17:07 + **/ +const isDebugEnabled = process.env.NODE_ENV !== "production"; +const isInfoEnabled = true; +const isErrorEnabled = true; + +let loggerName = "default"; + +console.log( + "isDebugEnabled,isInfoEnabled,isErrorEnabled=>", + `${isDebugEnabled},${isInfoEnabled},${isErrorEnabled}` +); + +const debug = log => { + if (isDebugEnabled) { + console.warn("[", loggerName, "]", log); + } +}; + +const info = log => { + if (isInfoEnabled) { + console.log("[", loggerName, "]", log); + } +}; + +const error = log => { + if (isErrorEnabled) { + console.error("[", loggerName, "]", log); + } +}; + +const logger = { + debug, + info, + error +}; + +export const getLogger = name => { + if (name) { + loggerName = name; + } + return logger; +}; diff --git a/jvue-front/vercel.json b/jvue-front/vercel.json new file mode 100644 index 0000000..9d3e5ce --- /dev/null +++ b/jvue-front/vercel.json @@ -0,0 +1,9 @@ +{ + "builds": [ + { + "src": "nuxt.config.js", + "use": "@nuxtjs/vercel-builder", + "config": {} + } + ] +} diff --git a/jvue-server/Dockerfile b/jvue-server/Dockerfile index 1a4afd8..c52c1f1 100644 --- a/jvue-server/Dockerfile +++ b/jvue-server/Dockerfile @@ -1,5 +1,5 @@ # 构建镜像 -# docker build . -t jvue-server:4.0.0 --force-rm --no-cache +# docker build . -t jvue-server:4.2.0 --force-rm --no-cache # 依赖的镜像 FROM maven:3.6.0-jdk-8-alpine diff --git a/jvue-server/mvnw b/jvue-server/mvnw old mode 100644 new mode 100755 diff --git a/jvue-server/pom.xml b/jvue-server/pom.xml index 3376262..2d55f7b 100644 --- a/jvue-server/pom.xml +++ b/jvue-server/pom.xml @@ -10,7 +10,7 @@ com.terwergreen jvue-server - 4.1.0 + 4.2.0 war jvue-server Next light-weight,responsive project With Docker,Vue,Vue CLI 3,webpack and Spring Boot diff --git a/jvue-server/src/main/java/com/terwergreen/jvueserver/coresevice/xmlrpc/IMetaWeblog.java b/jvue-server/src/main/java/com/terwergreen/jvueserver/coresevice/xmlrpc/IMetaWeblog.java index 04fa2f1..5070d73 100644 --- a/jvue-server/src/main/java/com/terwergreen/jvueserver/coresevice/xmlrpc/IMetaWeblog.java +++ b/jvue-server/src/main/java/com/terwergreen/jvueserver/coresevice/xmlrpc/IMetaWeblog.java @@ -84,6 +84,20 @@ public interface IMetaWeblog { */ List> getRecentPosts(String blogid, String username, String password, int numberOfPosts) throws XmlRpcException; + /** + * 获取最近的文章列表:metaWeblog.getRecentPosts + * + * @param blogid blogid + * @param username 用户名 + * @param password 密码 + * @param numberOfPosts 数目 + * @param page 页码 + * @param keyword 关键字 + * @return 文章列表 + * @throws XmlRpcException 异常 + */ + List> getRecentPosts(String blogid, String username, String password, int numberOfPosts, int page, String keyword) throws XmlRpcException; + /** * 上传媒体对象:metaWeblog.newMediaObject * diff --git a/jvue-server/src/main/java/com/terwergreen/jvueserver/coresevice/xmlrpc/MetaWeblogImpl.java b/jvue-server/src/main/java/com/terwergreen/jvueserver/coresevice/xmlrpc/MetaWeblogImpl.java index 1538dbd..98c1c65 100644 --- a/jvue-server/src/main/java/com/terwergreen/jvueserver/coresevice/xmlrpc/MetaWeblogImpl.java +++ b/jvue-server/src/main/java/com/terwergreen/jvueserver/coresevice/xmlrpc/MetaWeblogImpl.java @@ -223,6 +223,11 @@ public List> getCategories(String blogid, String username, S @Override public List> getRecentPosts(String blogid, String username, String password, int numberOfPosts) throws XmlRpcException { + return this.getRecentPosts(blogid, username, password, numberOfPosts, 1, ""); + } + + @Override + public List> getRecentPosts(String blogid, String username, String password, int numberOfPosts, int page, String keyword) throws XmlRpcException { logger.info("metaWeblog.getRecentPosts -> blogid: {}, numberOfPosts: {}", blogid, numberOfPosts); List> posts = new ArrayList<>(); @@ -230,6 +235,8 @@ public List> getRecentPosts(String blogid, String username, try { Map paraMap = new HashMap<>(); paraMap.put("pageSize", numberOfPosts); + paraMap.put("pageNum", page); + paraMap.put("search", keyword); List postList = getPostService().getRecentPosts(paraMap); for (Post postObj : postList) { diff --git a/jvue-server/src/main/java/com/terwergreen/jvueserver/service/impl/PostServiceImpl.java b/jvue-server/src/main/java/com/terwergreen/jvueserver/service/impl/PostServiceImpl.java index 5eb2140..89546ff 100644 --- a/jvue-server/src/main/java/com/terwergreen/jvueserver/service/impl/PostServiceImpl.java +++ b/jvue-server/src/main/java/com/terwergreen/jvueserver/service/impl/PostServiceImpl.java @@ -39,8 +39,16 @@ public List getRecentPosts(Map paraMap) { Map newParamMap = new HashMap<>(); newParamMap.put("postType", PostTypeEmum.POST_TYPE_POST.getName()); + String search = (String) paraMap.getOrDefault("search", ""); + newParamMap.put("search", search); + if (StringUtils.isNotEmpty(search)) { + String[] tagArray = new String[]{search}; + newParamMap.put("tagArray", tagArray); + } + Integer pageSize = (Integer) paraMap.getOrDefault("pageSize", 10); - PageInfo pageList = getPostsByPage(1, pageSize, newParamMap); + Integer pageNum = (Integer) paraMap.getOrDefault("pageNum", 1); + PageInfo pageList = getPostsByPage(pageNum, pageSize, newParamMap); return pageList.getList(); } diff --git a/jvue-server/src/main/resources/application-docker.properties b/jvue-server/src/main/resources/application-docker.properties index 6d584ff..83f243d 100644 --- a/jvue-server/src/main/resources/application-docker.properties +++ b/jvue-server/src/main/resources/application-docker.properties @@ -6,10 +6,10 @@ server.port=8002 # https://docs.oracle.com/en/java/javase/11/docs/specs/security/standard-names.html#keystore-types # \u60a8\u9700\u8981\u4f7f\u7528\u5b9e\u9645\u7684\u8bc1\u4e66\u540d\u79f0\u66ff\u6362domain_name.pfx\u3002 -server.ssl.key-store=classpath:v4.pfx -# \u586b\u5199pfx-password.txt\u6587\u4ef6\u5185\u7684\u5bc6\u7801\u3002 -server.ssl.key-store-password=${SSL_KEY_PASSWORD} -server.ssl.keyStoreType=PKCS12 +#server.ssl.key-store=classpath:v4.pfx +## \u586b\u5199pfx-password.txt\u6587\u4ef6\u5185\u7684\u5bc6\u7801\u3002 +#server.ssl.key-store-password=${SSL_KEY_PASSWORD} +#server.ssl.keyStoreType=PKCS12 # ================================================ # DataSource\u914d\u7f6e @@ -18,7 +18,7 @@ server.ssl.keyStoreType=PKCS12 mybatis.mapper-locations=classpath:mappers/*.xml # MySQL spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver -spring.datasource.url=jdbc:MySQL://jvue-mysql:3306/bugucms4?useUnicode=true&characterEncoding=utf8&useSSL=false +spring.datasource.url=jdbc:MySQL://jvue-mysql:3308/bugucms4?useUnicode=true&characterEncoding=utf8&useSSL=false spring.datasource.username=terwer spring.datasource.password=123456 # PageHelper diff --git a/jvue-server/src/main/resources/application.properties b/jvue-server/src/main/resources/application.properties index 2456ca5..172022f 100644 --- a/jvue-server/src/main/resources/application.properties +++ b/jvue-server/src/main/resources/application.properties @@ -1,5 +1,5 @@ application.title=JVue Framework -application.formatted-version=v4.1.0 +application.formatted-version=v4.2.0 logging.level.root=INFO logging.level.com.terwergreen.jvueserver=DEBUG diff --git a/jvue-server/src/main/resources/mappers/spl-mapping-post.xml b/jvue-server/src/main/resources/mappers/spl-mapping-post.xml index 63aa043..7ba6260 100644 --- a/jvue-server/src/main/resources/mappers/spl-mapping-post.xml +++ b/jvue-server/src/main/resources/mappers/spl-mapping-post.xml @@ -21,7 +21,7 @@ ) - AND ( + OR ( find_in_set(#{tag},tags) diff --git a/replace_arg.sh b/replace_arg.sh old mode 100644 new mode 100755