commit e9b415d4bdebe343e418609566ad6e3e2b074d55 Author: zoujiandong <10130823232@qq.com> Date: Wed Dec 10 09:05:18 2025 +0800 init diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..ec3b670 --- /dev/null +++ b/.env.development @@ -0,0 +1,4 @@ +VITE_BASE_URL="https://dev-vote.igandan.com/api/v/" +VITE_IMAGE_URL = 'http://dev-vote-system.oss-cn-beijing.aliyuncs.com' +VITE_SHARE_URL = 'https://dev-vote.igandan.com/web/v/' +VITE_WE_URL = 'https://dev-wx.igandan.com' \ No newline at end of file diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..34029fa --- /dev/null +++ b/.env.production @@ -0,0 +1,4 @@ +VITE_BASE_URL="https://prod-vote.igandan.com/api/v/" +VITE_IMAGE_URL = 'http://prod-vote-system.oss-cn-beijing.aliyuncs.com' +VITE_SHARE_URL = 'https://prod-vote.igandan.com/web/v/' +VITE_WE_URL = 'https://wx.igandan.com' \ No newline at end of file diff --git a/.env.test b/.env.test new file mode 100644 index 0000000..ec3b670 --- /dev/null +++ b/.env.test @@ -0,0 +1,4 @@ +VITE_BASE_URL="https://dev-vote.igandan.com/api/v/" +VITE_IMAGE_URL = 'http://dev-vote-system.oss-cn-beijing.aliyuncs.com' +VITE_SHARE_URL = 'https://dev-vote.igandan.com/web/v/' +VITE_WE_URL = 'https://dev-wx.igandan.com' \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cff1aeb --- /dev/null +++ b/.gitignore @@ -0,0 +1,81 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build +/dist + +# misc +.DS_Store +*.pem + +*.d.ts + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# local env files +.env.local +.env.development.local +.env.test.local +.env.production.local + +# vercel +.vercel + +# typescript +*.tsbuildinfo + + +# eslint +.eslintcache + +# stylelint +.stylelintcache + +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +yarn.lock + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? + +# node_modules +node_modules +package-lock.json +package-lock.json +components.d.ts + diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/index.html b/index.html new file mode 100644 index 0000000..7576df1 --- /dev/null +++ b/index.html @@ -0,0 +1,13 @@ + + + + + + + <%- title %> + + +
+ + + diff --git a/jsconfig.json b/jsconfig.json new file mode 100644 index 0000000..709c3f8 --- /dev/null +++ b/jsconfig.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "target": "ES6", + "module": "commonjs", + "allowSyntheticDefaultImports": true, + "baseUrl": "./", + "paths": { + "@/*": ["src/*"] + } + }, + "exclude": [ + "node_modules" + ] +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..4ddde33 --- /dev/null +++ b/package.json @@ -0,0 +1,38 @@ +{ + "name": "wxapp-home", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "test": "vite --mode=test", + "build": "vite build", + "build-test": "vite build --mode=test", + "preview": "vite preview" + }, + "dependencies": { + "axios": "^1.5.0", + "lodash": "^4.17.21", + "reset-css": "^5.0.2", + "vant": "^4.9.4", + "vconsole": "^3.15.1", + "vue": "^3.3.4", + "vue-lazyload": "^3.0.0", + "vue-router": "^4.2.4", + "weixin-js-sdk": "^1.6.0" + }, + "devDependencies": { + "@types/node": "^20.4.5", + "@vant/auto-import-resolver": "^1.2.1", + "@vitejs/plugin-vue": "^4.2.3", + "rollup-plugin-external-globals": "^0.8.0", + "rollup-plugin-visualizer": "^5.9.2", + "sass": "^1.69.5", + "terser": "^5.19.1", + "unplugin-auto-import": "^0.16.7", + "unplugin-vue-components": "^0.25.2", + "vite": "^4.4.5", + "vite-plugin-compression": "^0.5.1", + "vite-plugin-html": "^3.2.0" + } +} diff --git a/public/vite.svg b/public/vite.svg new file mode 100644 index 0000000..e7b8dfb --- /dev/null +++ b/public/vite.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/App.vue b/src/App.vue new file mode 100644 index 0000000..a57339a --- /dev/null +++ b/src/App.vue @@ -0,0 +1,43 @@ + + \ No newline at end of file diff --git a/src/assets/bg1.png b/src/assets/bg1.png new file mode 100644 index 0000000..8360708 Binary files /dev/null and b/src/assets/bg1.png differ diff --git a/src/assets/closepop.png b/src/assets/closepop.png new file mode 100644 index 0000000..9ac95ce Binary files /dev/null and b/src/assets/closepop.png differ diff --git a/src/assets/first.png b/src/assets/first.png new file mode 100644 index 0000000..57f4444 Binary files /dev/null and b/src/assets/first.png differ diff --git a/src/assets/jiesao.png b/src/assets/jiesao.png new file mode 100644 index 0000000..1a9cf70 Binary files /dev/null and b/src/assets/jiesao.png differ diff --git a/src/assets/paiming1.png b/src/assets/paiming1.png new file mode 100644 index 0000000..42d1b64 Binary files /dev/null and b/src/assets/paiming1.png differ diff --git a/src/assets/rank.png b/src/assets/rank.png new file mode 100644 index 0000000..3d5f0cc Binary files /dev/null and b/src/assets/rank.png differ diff --git a/src/assets/search.png b/src/assets/search.png new file mode 100644 index 0000000..786581f Binary files /dev/null and b/src/assets/search.png differ diff --git a/src/assets/second.png b/src/assets/second.png new file mode 100644 index 0000000..015e080 Binary files /dev/null and b/src/assets/second.png differ diff --git a/src/assets/shipin.png b/src/assets/shipin.png new file mode 100644 index 0000000..8d94122 Binary files /dev/null and b/src/assets/shipin.png differ diff --git a/src/assets/sucess.png b/src/assets/sucess.png new file mode 100644 index 0000000..7270278 Binary files /dev/null and b/src/assets/sucess.png differ diff --git a/src/assets/third.png b/src/assets/third.png new file mode 100644 index 0000000..23d4f9a Binary files /dev/null and b/src/assets/third.png differ diff --git a/src/assets/toupiao.png b/src/assets/toupiao.png new file mode 100644 index 0000000..b9320ec Binary files /dev/null and b/src/assets/toupiao.png differ diff --git a/src/assets/toupiao1.png b/src/assets/toupiao1.png new file mode 100644 index 0000000..d3140cb Binary files /dev/null and b/src/assets/toupiao1.png differ diff --git a/src/assets/tuwen.png b/src/assets/tuwen.png new file mode 100644 index 0000000..9ffe464 Binary files /dev/null and b/src/assets/tuwen.png differ diff --git a/src/assets/votbutton.png b/src/assets/votbutton.png new file mode 100644 index 0000000..87a5320 Binary files /dev/null and b/src/assets/votbutton.png differ diff --git a/src/components/headTop.vue b/src/components/headTop.vue new file mode 100644 index 0000000..cd9eba1 --- /dev/null +++ b/src/components/headTop.vue @@ -0,0 +1,95 @@ + + + diff --git a/src/components/votButton.vue b/src/components/votButton.vue new file mode 100644 index 0000000..370ed48 --- /dev/null +++ b/src/components/votButton.vue @@ -0,0 +1,73 @@ + + + diff --git a/src/components/votView.vue b/src/components/votView.vue new file mode 100644 index 0000000..6381617 --- /dev/null +++ b/src/components/votView.vue @@ -0,0 +1,175 @@ + + + \ No newline at end of file diff --git a/src/main.js b/src/main.js new file mode 100644 index 0000000..a4652fc --- /dev/null +++ b/src/main.js @@ -0,0 +1,21 @@ +import { createApp } from 'vue' +import 'reset-css' +import './style.css' +import App from './App.vue' +import router from "@/router/index.js" +import Vant from 'vant'; + +import VConsole from 'vconsole'; +router.afterEach((to, from, next) => { + window.scrollTo(0, 0); + +}) + +// const vConsole = new VConsole(); +const app = createApp(App); + +app.use(router); +app.use(Vant); + + +app.mount('#app') diff --git a/src/router/index.js b/src/router/index.js new file mode 100644 index 0000000..d8568cd --- /dev/null +++ b/src/router/index.js @@ -0,0 +1,131 @@ +import { createWebHashHistory, createRouter, createWebHistory } from 'vue-router'; + +import Home from "@/views/home.vue" +import voteList from '@/views/voteList.vue'; +import articleDetails from '@/views/articleDetails.vue'; +import videoDetails from '@/views/videoDetails.vue'; +import { login } from '@/utils/api.js'; +const routes = [ + +{ + path: '/', + redirect: '/home', +}, +{ + path: '/home', + name: 'home', + component: Home, + +}, +{ + path: '/voteList', + name: 'voteList', + component: voteList, + +}, +{ + path: '/articleDetails', + name: 'articleDetails', + component: articleDetails, + +}, +{ + path: '/videoDetails', + name: 'videoDetails', + component: videoDetails, + +}, +]; + + +const router = createRouter({ + // createWebHashHistory URL 带井号 + // createWebHistory URL 去井号 + history:createWebHistory('web/v'), + routes: routes, +}); + + +// 全局前置守卫 +router.beforeEach((to, from, next) => { + // 在这里编写拦截逻辑 + // 例如,检查用户是否已经登录 + // if (to.path =='/home') { + const urlToBeAccessed = to.fullPath; // 获取即将跳转的完整URL + // alert(urlToBeAccessed+' 11111') + console.log('即将跳转到:', urlToBeAccessed); + if(urlToBeAccessed.includes('subscribe')){ + const token=localStorage.getItem('bearer-tokens'); + if(typeof token === "undefined"||token ==null|| token == ""|| token == "undefined") + { + // alert(' 2222') + let queryParams = to.query; + let subscribe = queryParams.subscribe + // alert(subscribe+' 3333') + if(subscribe == '1'){ + + // let openid = queryParams.openid + let openid = getCookie('wechat_user_openid') + console.log("openid",openid) + localStorage.setItem('qr-tickets', ""); + + login(openid).then((data) => { + + if(200==data.code) + { + localStorage.setItem('bearer-tokens', 'Bearer '+data.data.token); + + } + else + { + + localStorage.setItem('bearer-tokens', ""); + } + + next(); + }); + + } + else + { + // alert(subscribe+' 4444') + localStorage.setItem('bearer-tokens', ""); + // alert(queryParams.ticket) + localStorage.setItem('qr-tickets', queryParams.ticket); + + next(); + } + } + else{ + next(); + } + + } + else{ + next(); + } + + +}); + +//设置cookie +function setCookie(name, value) { + document.cookie = name + "=" + escape(value) + "; path=/"; +} + +//获取cookie +function getCookie(name) { + var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)"); + + if (arr = document.cookie.match(reg)) + + return unescape(arr[2]); + else + return null; + +} + + + + +export default router; diff --git a/src/style.css b/src/style.css new file mode 100644 index 0000000..add3742 --- /dev/null +++ b/src/style.css @@ -0,0 +1,22 @@ +body{ + background:#fff; +} +/* @font-face { + font-family: "阿里巴巴普惠体 2.0 65 Medium";font-weight: 500;src: url("//at.alicdn.com/wf/webfont/sgTFboRMJU3n/JxNJC26HiA0D.woff2") format("woff2"), + url("//at.alicdn.com/wf/webfont/sgTFboRMJU3n/T8cUklUUIqA1.woff") format("woff"); + font-display: swap; + } */ +/* 在线链接服务仅供平台体验和调试使用,平台不承诺服务的稳定性,企业客户需下载字体包自行发布使用并做好备份。 */ + +/* @font-face { + font-family:AlibabaPuHuiTiR; + src:url('../src/assets/font/Alibaba_PuHuiTi_2.0_55_Regular_55_Regular.ttf') +} +@font-face { + font-family:AlibabaPuHuiTiH; + src:url('../src/assets/font/Alibaba_PuHuiTi_2.0_105_Heavy_105_Heavy.ttf') +} +@font-face { + font-family:AlibabaPuHuiTiB; + src:url('../src/assets/font/Alibaba_PuHuiTi_2.0_55_Regular_85_Bold.ttf') +} */ \ No newline at end of file diff --git a/src/utils/api.js b/src/utils/api.js new file mode 100644 index 0000000..1bd7fe1 --- /dev/null +++ b/src/utils/api.js @@ -0,0 +1,103 @@ +import service from './request'; +export function agreement(agreement_type) { + return service({ + url:'agreement', + method: 'get', + params:{ + agreement_type:agreement_type, + } + + }) +} +export function votedata() { + return service({ + url:'data', + method: 'get' + + }) +} +export function browse() { + return service({ + url:'browse', + method: 'post', + + }) +} +export function articlepage(page,page_size,keyword) { + return service({ + url:'article/page', + method: 'get', + params:{ + page:page, + page_size:page_size, + keyword:keyword, + + } + + }) +} +export function videopage(page,page_size,keyword) { + return service({ + url:'video/page', + method: 'get', + params:{ + page:page, + page_size:page_size, + keyword:keyword, + + } + + }) +} + export function rankarticle() { + return service({ + url:'rank/article', + method: 'get', + + }) +} +export function rankvideo() { + return service({ + url:'rank/video', + method: 'get', + + }) +} + +export function votearticle(article_id) { + return service({ + url:'vote/article/'+article_id, + method: 'post', + }) +} + +export function votevideo(video_id) { + return service({ + url:'vote/video/'+video_id, + method: 'post', + }) +} +export function getarticle(article_id) { + return service({ + url:'article/'+article_id, + method: 'get', + }) +} + +export function getvideo(video_id) { + return service({ + url:'video/'+video_id, + method: 'get', + }) +} + +export function login(openid) { + return service({ + url:'login', + method: 'post', + params:{ + openid:openid, + } + + }) +} \ No newline at end of file diff --git a/src/utils/authorize.js b/src/utils/authorize.js new file mode 100644 index 0000000..e454c71 --- /dev/null +++ b/src/utils/authorize.js @@ -0,0 +1,49 @@ + +import {useRoute } from 'vue-router'; + +export function goAuth() { + const route = useRoute(); + var redirectUrl = window.location.href; + const urlParams = new URLSearchParams(window.location.search); + + if(redirectUrl.includes('voteList')) { + redirectUrl = import.meta.env.VITE_SHARE_URL+'voteList'; + } + else if(redirectUrl.includes('articleDetails')) { + redirectUrl = import.meta.env.VITE_SHARE_URL+'articleDetails?id='+route.query.id+'&name='+encodeURIComponent(route.query.name); + } + else if(redirectUrl.includes('videoDetails')) { + + + redirectUrl = import.meta.env.VITE_SHARE_URL+'videoDetails?id='+urlParams.get('id')+'&name='+encodeURIComponent(urlParams.get('name')); + // redirectUrl = import.meta.env.VITE_SHARE_URL+'videoDetails?id='+route.query.id+'&name='+encodeURIComponent(route.query.name); + + } + else + { + redirectUrl = import.meta.env.VITE_SHARE_URL+'home'; + } + + redirectUrl = encodeURIComponent(redirectUrl); + + window.location.href =import.meta.env.VITE_WE_URL+"/AuthorizeURL/grant?sceneStr=hero-video&follow=1&scope=snsapi_base&back_url=" + redirectUrl; + + + } + + export function saveurl(url,id,name) { + const route = useRoute(); + + // const urlSearchParams = new URLSearchParams(window.location.search) + // let subscribe = urlSearchParams.get('subscribe') + let subscribe =route.query.subscribe + + if(subscribe=='0') { + localStorage.setItem('gotourls', url) + localStorage.setItem('gotourlids', id) + localStorage.setItem('gotourlnames', name) + } + } + + + \ No newline at end of file diff --git a/src/utils/const.js b/src/utils/const.js new file mode 100644 index 0000000..a770807 --- /dev/null +++ b/src/utils/const.js @@ -0,0 +1 @@ +export const title='肝胆英雄榜最具影响力视频投票'; \ No newline at end of file diff --git a/src/utils/request.js b/src/utils/request.js new file mode 100644 index 0000000..f3a5ad9 --- /dev/null +++ b/src/utils/request.js @@ -0,0 +1,139 @@ +import axios from 'axios'; +import {goAuth}from '@/utils/authorize.js'; +// create an axios instance +const service = axios.create({ + baseURL:import.meta.env.VITE_BASE_URL, + timeout: 8000, + // withCredentials: true, + headers:{ + 'Content-Type':'application/x-www-form-urlencoded', + // 'Authorization':'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiMTgzMDQ4NjkyMDYxMDcxMzYwMCIsImV4cCI6MTcyNTM0MzQ2NSwibmJmIjoxNzI1MjU3MDY1LCJpYXQiOjE3MjUyNTcwNjV9.GBkHpVzRb2XeEZmnrjPQ6x57CdHvH8WLxT9Uqc24TRg', + } +}); + +// request interceptor +service.interceptors.request.use( + (config) => { + // Store 必须在拦截器内部导入,在外部导入会显示 Pinia 未初始化 + // 设置请求头部 Authorization + // console.log("333333"); + // console.log(config); + + const token=localStorage.getItem('bearer-tokens'); + + if(typeof token === "undefined"||token ==null|| token == ""|| token == "undefined") + { + + } + else + { + config.headers['Authorization'] = token; + } + + + return config; + }, + (error) => { + console.error(error); + return Promise.reject(error); + } +); + +// response interceptor +service.interceptors.response.use( + (response) => { + // console.log(response) + //var Authorization_token = response.headers.Authorization; + // if (Authorization_token) { + // sessionStorage.setItem('token', Authorization_token); //当token快过期时,服务器会返回新token,本地刷新 + // } + const { code, message } = response.data; + // console.log("code",code); + if(code == 401 || code==405 ) + { + localStorage.setItem('bearer-tokens', ""); + // let back_url = window.location.href; + // window.location.href="https://wx.igandan.com/hcp/toLogin?back_url="+back_url; + // window.location.href="https://twx.igandan.org/hcp/toLogin?back_url="+back_url; + goAuth(); + } + else if (code == 401 || code==403 || code==405 || code==406) { + //Message.clear(); + // Message.error({ + // content: message, + // duration: 3000 + // }); + // 重定向路由到登陆页面 + + }else if(code === 400){ + // Message.error({ + // content: '缺少参数', + // duration: 3000 + // }); + }else if(code == 402){ + // Message.error({ + // content: '请求无权限', + // duration: 3000 + // }); + }else if(code == 201){ + // Message.error({ + // content: '账户状态异常', + // duration: 3000 + // }); + }else if(code==-1){ + // Message.error({ + // content: message, + // duration: 3000 + // }); + } + + return response.data; + }, + (error) => { + console.log("------------------"); + console.log(error); + + const { code, message } = error.response.data; + // 如果过期则退出登录 + if(code == 60003) + { + // let back_url = window.location.href; + // window.location.href="https://wx.igandan.com/hcp/toLogin?back_url="+back_url; + } + else if (code === 401 || code==403 || code==405 || code==406) { + // Message.error({ + // content: message, + // duration: 3000 + // }); + // // 重定向路由到登陆页面 + // store.clearInfo(); + // window.location.href="/login"; + }else if(code === 400){ + // Message.error({ + // content: '缺少参数', + // duration: 3000 + // }); + }else if(code === 402){ + // Message.error({ + // content: '请求无权限', + // duration: 3000 + // }); + }else if(code === 201){ + // Message.error({ + // content: '账户状态异常', + // duration: 3000 + // }); + }else { + // Message.error({ + // content: error.message, + // duration: 3000 + // }) + } + return Promise.reject(message); + } +); +// export const imgurl='http://47.105.52.114:8085/app/'; +export const fromwexin='&from=wx'; +export const frommywexin='?from=wx'; +export const qrcodeurl='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket='; +export default service; \ No newline at end of file diff --git a/src/utils/wxshare-1.6.0.js b/src/utils/wxshare-1.6.0.js new file mode 100644 index 0000000..5aa050a --- /dev/null +++ b/src/utils/wxshare-1.6.0.js @@ -0,0 +1,97 @@ +import wx from 'weixin-js-sdk' +import axios from 'axios' +let share = { + title: "", + desc: "", + link: "", + imgUrl: "", + init: function () { + var path = location.href.split('#')[0]; + var url = ""; + var appid = ""; + if (path.indexOf("//wx.igandan.com") > 1 || path.indexOf("oss")>1||path.indexOf("prod")>1) { + url = "https://app.igandan.com/app/manager/getSignature4bing"; + appid = "wxa4132ef4701ac5e4"; + } else { + url = "https://dev-app.igandan.com/app/manager/getSignature4bing"; + appid = "wx68affaa9d23528f8"; + + } + +axios.get(url, { + params: { + path: encodeURIComponent(window.location.href.split('#')[0]), + appid: appid + } + }).then(json => { + wx.config({ + debug:false, + appId: appid, + timestamp: json.data.timestamp, + nonceStr: json.data.nonceStr, + signature: json.data.signature, + jsApiList: ['updateAppMessageShareData', 'updateTimelineShareData', 'onMenuShareTimeline', 'onMenuShareAppMessage'] + }); + + wx.checkJsApi({ + jsApiList: ['updateAppMessageShareData', 'updateTimelineShareData', 'onMenuShareTimeline', 'onMenuShareAppMessage'], // 需要检测的JS接口列表,所有JS接口列表见附录2, + success: function (res) { + console.log(res) + } + }); + wx.ready(function () { + + + wx.updateAppMessageShareData({ + title: share.title, + desc: share.desc, + link: share.link, + imgUrl: share.imgUrl, + success: function () {} + }) + wx.updateTimelineShareData({ + title: share.title, + desc: share.desc, + link: share.link, + imgUrl: share.imgUrl, + success: function () {} + }) + wx.onMenuShareTimeline({ + title: share.title, + desc: share.desc, + link: share.link, + imgUrl: share.imgUrl, + success: function () {} + }) + wx.onMenuShareAppMessage({ + title: share.title, + desc: share.desc, + link: share.link, + imgUrl: share.imgUrl, + success: function () {} + }) + }); + + + }).catch((e) => { + console.log('获取数据失败'); + }); + + } +} + +function WXSHARE(title, desc, link, imgUrl) { + share.title = title; + share.desc = desc; + share.link = link; + if (imgUrl == undefined || imgUrl == "") { + imgUrl = "https://doc.igandan.com/app/html/img/2016/20160714132557.png"; + } + share.imgUrl = imgUrl; + share.init(); +}; + + +export { + WXSHARE +} \ No newline at end of file diff --git a/src/views/articleDetails.vue b/src/views/articleDetails.vue new file mode 100644 index 0000000..f804244 --- /dev/null +++ b/src/views/articleDetails.vue @@ -0,0 +1,249 @@ + + + \ No newline at end of file diff --git a/src/views/home.vue b/src/views/home.vue new file mode 100644 index 0000000..ddcd225 --- /dev/null +++ b/src/views/home.vue @@ -0,0 +1,196 @@ + + + \ No newline at end of file diff --git a/src/views/videoDetails.vue b/src/views/videoDetails.vue new file mode 100644 index 0000000..b571bd6 --- /dev/null +++ b/src/views/videoDetails.vue @@ -0,0 +1,329 @@ + + + \ No newline at end of file diff --git a/src/views/voteList.vue b/src/views/voteList.vue new file mode 100644 index 0000000..052232b --- /dev/null +++ b/src/views/voteList.vue @@ -0,0 +1,737 @@ + + + \ No newline at end of file diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..797756b --- /dev/null +++ b/stats.html @@ -0,0 +1,4838 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/vite.config.js b/vite.config.js new file mode 100644 index 0000000..b26130f --- /dev/null +++ b/vite.config.js @@ -0,0 +1,104 @@ +import { + join +} from 'path' +import { + defineConfig +} from 'vite'; +import vue from '@vitejs/plugin-vue'; +import { + VuetifyResolver +} from 'unplugin-vue-components/resolvers'; +import Components from 'unplugin-vue-components/vite'; +import AutoImport from 'unplugin-auto-import/vite'; +import viteCompression from 'vite-plugin-compression' +import { visualizer } from 'rollup-plugin-visualizer' //查看项目的依赖 +import { createHtmlPlugin } from 'vite-plugin-html' +import { VantResolver } from '@vant/auto-import-resolver'; +export default defineConfig(({ command }) => { + return { + base: command === 'build' ? './' : '/web/v', + plugins: [ + vue(), + + AutoImport({ + // 自动导入 Vue 相关函数,如:ref, reactive, toRef 等 + imports: ['vue'], + resolvers: [VantResolver()], + }), + visualizer({ + open: false + }), + // 将下面的添加到plugin下 + createHtmlPlugin({ + minify: true, + inject: { + data: { + title: '肝胆英雄榜最具影响力视频投票', + } + } + }), + Components({ + resolvers: [VuetifyResolver()], + include: [/\.vue$/, /\.vue\?vue/, /\.md$/], + dirs: ['src/components', 'src/views'], + resolvers: [VantResolver()], + }), + ], + + build: { + assetsInlineLimit: 4096, // 图片转 base64 编码的阈值 + minify: 'terser', + plugins: [ + viteCompression({ + threshold: 1024000 // 对大于 1mb 的文件进行压缩 + }), + ], + // rollup 配置 + rollupOptions: { + output: { + chunkFileNames: 'static/js/[name]-[hash].js', // 引入文件名的名称 + entryFileNames: 'static/js/[name]-[hash].js', // 包的入口文件名称 + assetFileNames: 'static/[ext]/[name]-[hash].[ext]', // 资源文件像 字体,图片等 + manualChunks(id) { + // 如果不同模块使用的插件基本相同那就尽可能打包在同一个文件中,减少http请求,如果不同模块使用不同插件明显,那就分成不同模块打包。这是一个矛盾体。 + // 这里使用的是最小化拆分包。如果是前者可以直接选择返回'vendor'。 + if (id.includes('node_modules')) { + return id.toString().split('node_modules/')[1].split('/')[0].toString(); //让打开那个页面,加载那个页面的js ,让之间的关联足够小 + // return 'vendor' 如果不同模块使用的插件基本相同那就尽可能打包在同一个文件中,减少http请求; + } + } + } + }, + terserOptions: { + compress: { + //生产环境时移除console + drop_console: true, + drop_debugger: true, + }, + }, + }, + resolve: { + alias: { + '@': join(__dirname, 'src'), + } + }, + server: { + host: true, + port: 1798, + //secure: false, + proxy: { + // '/api': { + //   target: 'https://vue3.go-admin.dev', + //   changeOrigin: true,             //开启跨域 + //   rewrite: (path) => path.replace(/^\/api/, '') + // }, + '/api': { + target: 'https://prod-vote.igandan.com', + changeOrigin: true, //开启跨域 + rewrite: (path) => path.replace(/^\/api/, '') + } + } + }, + publicDir: '/public' + } +}); \ No newline at end of file