feat: 更改自定义参数引入方式
This commit is contained in:
parent
c5b0b44fed
commit
2496110d5d
4
.env
4
.env
@ -7,10 +7,6 @@ VITE_SITE_URL = "imsyy.top"
|
||||
VITE_SITE_LOGO = "/images/icon/favicon.ico"
|
||||
VITE_SITE_APPLE_LOGO = "/images/logo/apple-touch-icon.png"
|
||||
|
||||
# 百度统计
|
||||
## 若不需要,请设为空即可
|
||||
VITE_SITE_BAIDUTONGJI = "14e9f35ff8bc67fd4bcb5f07a6e6655a"
|
||||
|
||||
# 简介文本
|
||||
VITE_DESC_HELLO = "Hello World !"
|
||||
VITE_DESC_TEXT = "一个建立于 21 世纪的小站,存活于互联网的边缘"
|
||||
|
30
index.html
30
index.html
@ -6,15 +6,15 @@
|
||||
<meta http-equiv="Access-Control-Allow-Origin" content="*">
|
||||
<!-- <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"> -->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="icon" href="<%- logo %>">
|
||||
<link rel="apple-touch-icon" href="<%- appleLogo %>" />
|
||||
<link rel="bookmark" href="<%- appleLogo %>" />
|
||||
<link rel="apple-touch-icon-precomposed" sizes="200x200" href="<%- appleLogo %>" />
|
||||
<meta name="description" content="<%- description %>" />
|
||||
<meta name="keywords" content="<%- keywords %>" />
|
||||
<meta name="author" content="<%- author %>" />
|
||||
<link rel="icon" href="%VITE_SITE_LOGO%">
|
||||
<link rel="apple-touch-icon" href="%VITE_SITE_APPLE_LOGO%" />
|
||||
<link rel="bookmark" href="%VITE_SITE_APPLE_LOGO%" />
|
||||
<link rel="apple-touch-icon-precomposed" sizes="200x200" href="%VITE_SITE_APPLE_LOGO%" />
|
||||
<meta name="description" content="%VITE_SITE_DES%" />
|
||||
<meta name="keywords" content="%VITE_SITE_KEYWORDS%" />
|
||||
<meta name="author" content="%VITE_SITE_ANTHOR%" />
|
||||
<meta name="theme-color" content="#424242" />
|
||||
<title><%- title %></title>
|
||||
<title>%VITE_SITE_NAME%</title>
|
||||
<!-- HarmonyOS Sans -->
|
||||
<!-- 本站 CDN 已开启防盗链,非本站域名不可访问,请更改链接为下方内容,否则自定义字体将失效 -->
|
||||
<!-- https://s1.hdslb.com/bfs/static/jinkela/long/font/regular.css -->
|
||||
@ -26,18 +26,6 @@
|
||||
window.location.href =
|
||||
"https://support.dmeng.net/upgrade-your-browser.html?referrer=" + encodeURIComponent(window.location.href)
|
||||
</script>
|
||||
<% if (tongji) { %>
|
||||
<!-- 百度统计 -->
|
||||
<script>
|
||||
var _hmt = _hmt || [];
|
||||
(function() {
|
||||
var hm = document.createElement("script");
|
||||
hm.src = "https://hm.baidu.com/hm.js?<%- tongji %>";
|
||||
var s = document.getElementsByTagName("script")[0];
|
||||
s.parentNode.insertBefore(hm, s);
|
||||
})();
|
||||
</script>
|
||||
<% } %>
|
||||
</head>
|
||||
|
||||
<body class="loading">
|
||||
@ -52,7 +40,7 @@
|
||||
<div class="inner three"></div>
|
||||
</div>
|
||||
<div class="loading-word">
|
||||
<p class="loading-title" id="loading-title"><%- title %></p>
|
||||
<p class="loading-title" id="loading-title">%VITE_SITE_NAME%</p>
|
||||
<span id="loading-text">加载中</span>
|
||||
</div>
|
||||
</div>
|
||||
|
10
package.json
10
package.json
@ -20,20 +20,20 @@
|
||||
"pinia": "^2.0.23",
|
||||
"pinia-plugin-persistedstate": "^3.0.0",
|
||||
"swiper": "^9.3.2",
|
||||
"terser": "^5.16.1",
|
||||
"vue": "^3.2.37",
|
||||
"vue": "^3.3.4",
|
||||
"vue3-aplayer": "^1.7.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vicons/fa": "^0.12.0",
|
||||
"@vicons/material": "^0.12.0",
|
||||
"@vicons/utils": "^0.1.4",
|
||||
"@vitejs/plugin-vue": "^3.1.0",
|
||||
"@vitejs/plugin-vue": "^4.2.3",
|
||||
"sass": "^1.55.0",
|
||||
"terser": "^5.16.1",
|
||||
"unplugin-auto-import": "^0.11.2",
|
||||
"unplugin-vue-components": "^0.22.8",
|
||||
"vite": "^3.1.0",
|
||||
"vite-plugin-html": "^3.2.0",
|
||||
"vite": "^4.4.5",
|
||||
"vite-plugin-compression": "^0.5.1",
|
||||
"vite-plugin-pwa": "^0.14.1"
|
||||
}
|
||||
}
|
||||
|
883
pnpm-lock.yaml
883
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
241
vite.config.js
241
vite.config.js
@ -1,135 +1,120 @@
|
||||
import {
|
||||
defineConfig,
|
||||
loadEnv
|
||||
} from 'vite';
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
import AutoImport from 'unplugin-auto-import/vite'
|
||||
import Components from 'unplugin-vue-components/vite'
|
||||
import {
|
||||
ElementPlusResolver
|
||||
} from 'unplugin-vue-components/resolvers'
|
||||
import {
|
||||
createHtmlPlugin
|
||||
} from 'vite-plugin-html';
|
||||
import {
|
||||
resolve
|
||||
} from 'path';
|
||||
import {
|
||||
VitePWA
|
||||
} from 'vite-plugin-pwa';
|
||||
import { defineConfig, loadEnv } from "vite";
|
||||
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
|
||||
import { resolve } from "path";
|
||||
import { VitePWA } from "vite-plugin-pwa";
|
||||
import vue from "@vitejs/plugin-vue";
|
||||
import AutoImport from "unplugin-auto-import/vite";
|
||||
import Components from "unplugin-vue-components/vite";
|
||||
import viteCompression from "vite-plugin-compression";
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default ({
|
||||
mode
|
||||
}) => defineConfig({
|
||||
plugins: [
|
||||
vue(),
|
||||
AutoImport({
|
||||
resolvers: [ElementPlusResolver()],
|
||||
}),
|
||||
Components({
|
||||
resolvers: [ElementPlusResolver()],
|
||||
}),
|
||||
createHtmlPlugin({
|
||||
minify: true,
|
||||
inject: {
|
||||
data: {
|
||||
logo: loadEnv(mode, process.cwd()).VITE_SITE_LOGO,
|
||||
appleLogo: loadEnv(mode, process.cwd()).VITE_SITE_APPLE_LOGO,
|
||||
title: loadEnv(mode, process.cwd()).VITE_SITE_NAME,
|
||||
author: loadEnv(mode, process.cwd()).VITE_SITE_ANTHOR,
|
||||
keywords: loadEnv(mode, process.cwd()).VITE_SITE_KEYWORDS,
|
||||
export default ({ mode }) =>
|
||||
defineConfig({
|
||||
plugins: [
|
||||
vue(),
|
||||
AutoImport({
|
||||
resolvers: [ElementPlusResolver()],
|
||||
}),
|
||||
Components({
|
||||
resolvers: [ElementPlusResolver()],
|
||||
}),
|
||||
VitePWA({
|
||||
registerType: "autoUpdate",
|
||||
workbox: {
|
||||
skipWaiting: true,
|
||||
clientsClaim: true,
|
||||
runtimeCaching: [
|
||||
{
|
||||
urlPattern: /(.*?)\.(js|css|woff2|woff|ttf)/, // js / css 静态资源缓存
|
||||
handler: "CacheFirst",
|
||||
options: {
|
||||
cacheName: "js-css-cache",
|
||||
},
|
||||
},
|
||||
{
|
||||
urlPattern: /(.*?)\.(png|jpe?g|svg|gif|bmp|psd|tiff|tga|eps)/, // 图片缓存
|
||||
handler: "CacheFirst",
|
||||
options: {
|
||||
cacheName: "image-cache",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
manifest: {
|
||||
name: loadEnv(mode, process.cwd()).VITE_SITE_NAME,
|
||||
short_name: loadEnv(mode, process.cwd()).VITE_SITE_NAME,
|
||||
description: loadEnv(mode, process.cwd()).VITE_SITE_DES,
|
||||
tongji: loadEnv(mode, process.cwd()).VITE_SITE_BAIDUTONGJI,
|
||||
display: "standalone",
|
||||
start_url: "/",
|
||||
theme_color: "#424242",
|
||||
background_color: "#424242",
|
||||
icons: [
|
||||
{
|
||||
src: "/images/icon/48.png",
|
||||
sizes: "48x48",
|
||||
type: "image/png",
|
||||
},
|
||||
{
|
||||
src: "/images/icon/72.png",
|
||||
sizes: "72x72",
|
||||
type: "image/png",
|
||||
},
|
||||
{
|
||||
src: "/images/icon/96.png",
|
||||
sizes: "96x96",
|
||||
type: "image/png",
|
||||
},
|
||||
{
|
||||
src: "/images/icon/128.png",
|
||||
sizes: "128x128",
|
||||
type: "image/png",
|
||||
},
|
||||
{
|
||||
src: "/images/icon/144.png",
|
||||
sizes: "144x144",
|
||||
type: "image/png",
|
||||
},
|
||||
{
|
||||
src: "/images/icon/192.png",
|
||||
sizes: "192x192",
|
||||
type: "image/png",
|
||||
},
|
||||
{
|
||||
src: "/images/icon/512.png",
|
||||
sizes: "512x512",
|
||||
type: "image/png",
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
viteCompression(),
|
||||
],
|
||||
server: {
|
||||
port: "3000",
|
||||
hmr: true,
|
||||
},
|
||||
resolve: {
|
||||
alias: [
|
||||
{
|
||||
find: "@",
|
||||
replacement: resolve(__dirname, "src"),
|
||||
},
|
||||
],
|
||||
},
|
||||
css: {
|
||||
preprocessorOptions: {
|
||||
scss: {
|
||||
charset: false,
|
||||
additionalData: `@import "./src/style/global.scss";`,
|
||||
},
|
||||
},
|
||||
}),
|
||||
VitePWA({
|
||||
registerType: 'autoUpdate',
|
||||
workbox: {
|
||||
skipWaiting: true,
|
||||
clientsClaim: true,
|
||||
runtimeCaching: [{
|
||||
urlPattern: /(.*?)\.(js|css|woff2|woff|ttf)/, // js / css 静态资源缓存
|
||||
handler: 'CacheFirst',
|
||||
options: {
|
||||
cacheName: 'js-css-cache',
|
||||
},
|
||||
},
|
||||
{
|
||||
urlPattern: /(.*?)\.(png|jpe?g|svg|gif|bmp|psd|tiff|tga|eps)/, // 图片缓存
|
||||
handler: 'CacheFirst',
|
||||
options: {
|
||||
cacheName: 'image-cache',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
manifest: {
|
||||
"name": loadEnv(mode, process.cwd()).VITE_SITE_NAME,
|
||||
"short_name": loadEnv(mode, process.cwd()).VITE_SITE_NAME,
|
||||
"description": loadEnv(mode, process.cwd()).VITE_SITE_DES,
|
||||
"display": "standalone",
|
||||
"start_url": "/",
|
||||
"theme_color": "#424242",
|
||||
"background_color": "#424242",
|
||||
"icons": [{
|
||||
"src": "/images/icon/48.png",
|
||||
"sizes": "48x48",
|
||||
"type": "image/png"
|
||||
}, {
|
||||
"src": "/images/icon/72.png",
|
||||
"sizes": "72x72",
|
||||
"type": "image/png"
|
||||
}, {
|
||||
"src": "/images/icon/96.png",
|
||||
"sizes": "96x96",
|
||||
"type": "image/png"
|
||||
}, {
|
||||
"src": "/images/icon/128.png",
|
||||
"sizes": "128x128",
|
||||
"type": "image/png"
|
||||
}, {
|
||||
"src": "/images/icon/144.png",
|
||||
"sizes": "144x144",
|
||||
"type": "image/png"
|
||||
}, {
|
||||
"src": "/images/icon/192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png"
|
||||
}, {
|
||||
"src": "/images/icon/512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png"
|
||||
}]
|
||||
}
|
||||
}),
|
||||
],
|
||||
server: {
|
||||
port: "3000",
|
||||
hmr: true,
|
||||
},
|
||||
resolve: {
|
||||
alias: [{
|
||||
find: '@',
|
||||
replacement: resolve(__dirname, "src"),
|
||||
}, ]
|
||||
},
|
||||
css: {
|
||||
preprocessorOptions: {
|
||||
scss: {
|
||||
charset: false,
|
||||
additionalData: `@import "./src/style/global.scss";`
|
||||
}
|
||||
}
|
||||
},
|
||||
build: {
|
||||
minify: 'terser',
|
||||
terserOptions: {
|
||||
compress: {
|
||||
// 生产环境时移除 console
|
||||
pure_funcs: ['console.log'],
|
||||
},
|
||||
build: {
|
||||
minify: "terser",
|
||||
terserOptions: {
|
||||
compress: {
|
||||
pure_funcs: ["console.log"],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user