diff --git a/.env b/.env index 88e1ca2..75f3569 100644 --- a/.env +++ b/.env @@ -15,17 +15,22 @@ ### # 项目标题,建议全局配置 -VITE_TITLE=示例项目 +VITE_APP_TITLE=示例项目 +# 版权信息 +VITE_APP_COPY=Copyright 2023 jlzhou.top Inc. All rights reserved. + +# 首页显示DEMO +VITE_APP_DEMO=0 # 请求后端api的基础地址 # 小程序需加入白名单,并设置跨域 -VITE_BASE_API=http://127.0.0.1:8080/ +VITE_APP_BASE_API=http://127.0.0.1:8080/ # 外部资源的基础地址 # 小程序需加入白名单,并设置跨域 -VITE_BASE_RESOURCES=http://127.0.0.1:8080/ +VITE_APP_BASE_RESOURCES=http://127.0.0.1:8080/ # WebSocket的基础地址 -VITE_BASE_WS=ws://127.0.0.1:8080/ +VITE_APP_BASE_WS=ws://127.0.0.1:8080/ -VITE_TEST1=全局测试变量 \ No newline at end of file +VITE_APP_TEST1=全局测试变量 diff --git a/.env.development b/.env.development index 12eebb9..d731af0 100644 --- a/.env.development +++ b/.env.development @@ -18,13 +18,16 @@ # 请求后端api的基础地址 # 小程序需加入白名单,并设置跨域 -VITE_BASE_API=http://127.0.0.1:8080/ +VITE_APP_BASE_API=http://127.0.0.1:8080/ # 外部资源的基础地址 # 小程序需加入白名单,并设置跨域 -VITE_BASE_RESOURCES=http://127.0.0.1:8080/ +VITE_APP_BASE_RESOURCES=http://127.0.0.1:8080/ # WebSocket的基础地址 -VITE_BASE_WS=ws://127.0.0.1:8080/ +VITE_APP_BASE_WS=ws://127.0.0.1:8080/ -VITE_TEST2=测试开发环境变量 \ No newline at end of file +VITE_APP_TEST2=测试开发环境变量 + +# 首页显示DEMO +VITE_APP_DEMO=1 \ No newline at end of file diff --git a/.env.development.local.copy b/.env.development.local.copy index 669e0c3..86ca25d 100644 --- a/.env.development.local.copy +++ b/.env.development.local.copy @@ -17,13 +17,13 @@ # 请求后端api的基础地址 # 小程序需加入白名单,并设置跨域 -VITE_BASE_API=http://127.0.0.1:8080/ +VITE_APP_BASE_API=http://127.0.0.1:8080/ # 外部资源的基础地址 # 小程序需加入白名单,并设置跨域 -VITE_BASE_RESOURCES=http://127.0.0.1:8080/ +VITE_APP_BASE_RESOURCES=http://127.0.0.1:8080/ # WebSocket的基础地址 -VITE_BASE_WS=ws://127.0.0.1:8080/ +VITE_APP_BASE_WS=ws://127.0.0.1:8080/ -VITE_TEST22=测试本地开发环境变量 \ No newline at end of file +VITE_APP_TEST22=测试本地开发环境变量 \ No newline at end of file diff --git a/.env.production b/.env.production index 53e576c..c560ebd 100644 --- a/.env.production +++ b/.env.production @@ -18,13 +18,13 @@ # 请求后端api的基础地址 # 小程序需加入白名单,并设置跨域 -VITE_BASE_API=http://127.0.0.1:8080/ +VITE_APP_BASE_API=http://127.0.0.1:8080/ # 外部资源的基础地址 # 小程序需加入白名单,并设置跨域 -VITE_BASE_RESOURCES=http://127.0.0.1:8080/ +VITE_APP_BASE_RESOURCES=http://127.0.0.1:8080/ # WebSocket的基础地址 -VITE_BASE_WS=ws://127.0.0.1:8080/ +VITE_APP_BASE_WS=ws://127.0.0.1:8080/ -VITE_TEST3=测试生产环境变量 \ No newline at end of file +VITE_APP_TEST3=测试生产环境变量 \ No newline at end of file diff --git a/package.json b/package.json index a2b6bb7..5a45f11 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,7 @@ "@dcloudio/uni-cli-shared": "3.0.0-3071120230427001", "@dcloudio/uni-stacktracey": "3.0.0-3071120230427001", "@dcloudio/vite-plugin-uni": "3.0.0-3071120230427001", - "vite": "4.1.4" + "vite": "4.1.4", + "sass": "^1.59.3" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 496f7cd..85d9959 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -19,6 +19,7 @@ specifiers: '@dcloudio/uni-quickapp-webview': 3.0.0-3071120230427001 '@dcloudio/uni-stacktracey': 3.0.0-3071120230427001 '@dcloudio/vite-plugin-uni': 3.0.0-3071120230427001 + sass: 1.59.3 vite: 4.1.4 vue: ^3.2.45 vue-i18n: ^9.1.9 @@ -46,7 +47,8 @@ devDependencies: '@dcloudio/uni-cli-shared': registry.npmmirror.com/@dcloudio/uni-cli-shared/3.0.0-3071120230427001_vue@3.3.2 '@dcloudio/uni-stacktracey': registry.npmmirror.com/@dcloudio/uni-stacktracey/3.0.0-3071120230427001 '@dcloudio/vite-plugin-uni': registry.npmmirror.com/@dcloudio/vite-plugin-uni/3.0.0-3071120230427001_vite@4.1.4+vue@3.3.2 - vite: registry.npmmirror.com/vite/4.1.4 + sass: registry.npmmirror.com/sass/1.59.3 + vite: registry.npmmirror.com/vite/4.1.4_sass@1.59.3 packages: @@ -2084,7 +2086,7 @@ packages: magic-string: registry.npmmirror.com/magic-string/0.27.0 picocolors: registry.npmmirror.com/picocolors/1.0.0 terser: registry.npmmirror.com/terser/5.17.3 - vite: registry.npmmirror.com/vite/4.1.4 + vite: registry.npmmirror.com/vite/4.1.4_sass@1.59.3 transitivePeerDependencies: - postcss - supports-color @@ -3018,7 +3020,7 @@ packages: regenerator-runtime: registry.npmmirror.com/regenerator-runtime/0.13.11 systemjs: registry.npmmirror.com/systemjs/6.14.1 terser: registry.npmmirror.com/terser/5.17.3 - vite: registry.npmmirror.com/vite/4.1.4 + vite: registry.npmmirror.com/vite/4.1.4_sass@1.59.3 transitivePeerDependencies: - supports-color dev: true @@ -3036,7 +3038,7 @@ packages: '@babel/core': registry.npmmirror.com/@babel/core/7.21.8 '@babel/plugin-transform-typescript': registry.npmmirror.com/@babel/plugin-transform-typescript/7.21.3_@babel+core@7.21.8 '@vue/babel-plugin-jsx': registry.npmmirror.com/@vue/babel-plugin-jsx/1.1.1_@babel+core@7.21.8 - vite: registry.npmmirror.com/vite/4.1.4 + vite: registry.npmmirror.com/vite/4.1.4_sass@1.59.3 vue: registry.npmmirror.com/vue/3.3.2 transitivePeerDependencies: - supports-color @@ -3052,7 +3054,7 @@ packages: vite: ^4.0.0 vue: ^3.2.25 dependencies: - vite: registry.npmmirror.com/vite/4.1.4 + vite: registry.npmmirror.com/vite/4.1.4_sass@1.59.3 vue: registry.npmmirror.com/vue/3.3.2 registry.npmmirror.com/@vue/babel-helper-vue-transform-on/1.0.2: @@ -4106,6 +4108,11 @@ packages: version: 1.2.1 dev: false + registry.npmmirror.com/immutable/4.3.0: + resolution: {integrity: sha512-0AOCmOip+xgJwEVTQj1EfiDDOkPmuyllDuTuEX+DDXUgapLAsBIfkg3sxCYyCEA8mQqZrrxPUGjcOQ2JS3WLkg==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/immutable/-/immutable-4.3.0.tgz} + name: immutable + version: 4.3.0 + registry.npmmirror.com/inherits/2.0.4: resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/inherits/-/inherits-2.0.4.tgz} name: inherits @@ -4929,6 +4936,17 @@ packages: version: 2.1.2 dev: true + registry.npmmirror.com/sass/1.59.3: + resolution: {integrity: sha512-QCq98N3hX1jfTCoUAsF3eyGuXLsY7BCnCEg9qAact94Yc21npG2/mVOqoDvE0fCbWDqiM4WlcJQla0gWG2YlxQ==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/sass/-/sass-1.59.3.tgz} + name: sass + version: 1.59.3 + engines: {node: '>=12.0.0'} + hasBin: true + dependencies: + chokidar: registry.npmmirror.com/chokidar/3.5.3 + immutable: registry.npmmirror.com/immutable/4.3.0 + source-map-js: registry.npmmirror.com/source-map-js/1.0.2 + registry.npmmirror.com/sax/1.2.4: resolution: {integrity: sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/sax/-/sax-1.2.4.tgz} name: sax @@ -5240,8 +5258,9 @@ packages: engines: {node: '>= 0.8'} dev: true - registry.npmmirror.com/vite/4.1.4: + registry.npmmirror.com/vite/4.1.4_sass@1.59.3: resolution: {integrity: sha512-3knk/HsbSTKEin43zHu7jTwYWv81f8kgAL99G5NWBcA1LKvtvcVAC4JjBH1arBunO9kQka+1oGbrMKOjk4ZrBg==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/vite/-/vite-4.1.4.tgz} + id: registry.npmmirror.com/vite/4.1.4 name: vite version: 4.1.4 engines: {node: ^14.18.0 || >=16.0.0} @@ -5271,6 +5290,7 @@ packages: postcss: registry.npmmirror.com/postcss/8.4.23 resolve: registry.npmmirror.com/resolve/1.22.2 rollup: registry.npmmirror.com/rollup/3.21.7 + sass: registry.npmmirror.com/sass/1.59.3 optionalDependencies: fsevents: registry.npmmirror.com/fsevents/2.3.2 diff --git a/src/env.js b/src/env.js new file mode 100644 index 0000000..fcb79e9 --- /dev/null +++ b/src/env.js @@ -0,0 +1,41 @@ +/** + * 将环境变量去掉VITE_APP_后,转换成小驼峰命名规则的属性的对象 + * export: env,useEnv + * env: 转换后的环境变量 + * useEnv: vue插件,本质将转换后环境变量绑定:app.config.globalProperties.$env + * @Author : J.L.Zhou + * @EMail : 12020042@qq.com + * @Tel : 151 1104 7708 + * @CreateTime : 2023-05-16 10:44:48 + * @LastEditos : J.L.Zhou + * @LastEditTime : 2023-05-16 10:44:48 + * @Version : 1.0 + * Copyright 2023 jlzhou.top Inc. All rights reserved. + * Warning: this content is only for internal circulation of the company. + * It is forbidden to divulge it or use it for other commercial purposes. + */ + +console.debug("原始的环境变量",import.meta.env); +const env = {}; +let name,value; +for(name in import.meta.env){ + if(!name.startsWith("VITE_APP_")){ + continue; + } + value = import.meta.env[name]; + name = name.substr(9).toLowerCase().split(/_+/); + for (var i = 1; i < name.length; i++) { + name[i]=name[i].substr(0,1).toUpperCase()+name[i].substr(1); + } + name = name.join(""); + env[name] = value; +} +console.debug('转换后的环境变量',env); + +const useEnv = { + install(app){ + app.config.globalProperties.$env=env; + } +} +export {env,useEnv}; + diff --git a/src/main.js b/src/main.js index f4a704a..96432c8 100644 --- a/src/main.js +++ b/src/main.js @@ -2,11 +2,13 @@ import { createSSRApp } from "vue"; import App from "./App.vue"; +import {useEnv} from "./env.js" + -console.debug(import.meta.env); export function createApp() { const app = createSSRApp(App); + app.use(useEnv) return { app, }; diff --git a/src/manifest.json b/src/manifest.json index 309b9ec..9fb4b88 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,6 +1,6 @@ { - "name" : "", - "appid" : "", + "name" : "示例项目", + "appid" : "__UNI__59B9EAC", "description" : "", "versionName" : "1.0.0", "versionCode" : "100", @@ -50,7 +50,7 @@ "quickapp" : {}, /* 小程序特有相关 */ "mp-weixin" : { - "appid" : "", + "appid" : "wxa02013cebc06dde4", "setting" : { "urlCheck" : false }, @@ -65,8 +65,8 @@ "mp-toutiao" : { "usingComponents" : true }, - "uniStatistics": { - "enable": false + "uniStatistics" : { + "enable" : false }, "vueVersion" : "3" } diff --git a/src/pages.json b/src/pages.json index 1aea851..5ed1cb7 100644 --- a/src/pages.json +++ b/src/pages.json @@ -1,16 +1,43 @@ { + "easycom": { + "custom": { + "^w-(.*)": "@/w-components/w-$1/w-$1.vue" + } + + }, + "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages { - "path": "pages/index/index", - "style": { - "navigationBarTitleText": "uni-app" - } + "path": "pages/index/index" } ], + "subPackages": [{ + "root": "pages/demo", + "pages": [{ + "path": "demo1" + }] + }], + "preloadRule": { + "pages/index/index": { + "network": "all", + "packages": ["pages/demo"] + } + }, "globalStyle": { + "navigationStyle": "custom", "navigationBarTextStyle": "black", - "navigationBarTitleText": "uni-app", + "navigationBarTitleText": "", "navigationBarBackgroundColor": "#F8F8F8", "backgroundColor": "#F8F8F8" + }, + "condition": { + //模式配置,仅开发期间生效 + "current": 0, //当前激活的模式(list 的索引项) + "list": [{ + "name": "", //模式名称 + "path": "pages/demo/demo1", //启动页面,必选 + "query": "" //启动参数,在页面的onLoad函数里面得到 + }] } -} + +} \ No newline at end of file diff --git a/src/pages/demo/demo1.vue b/src/pages/demo/demo1.vue new file mode 100644 index 0000000..98a24c3 --- /dev/null +++ b/src/pages/demo/demo1.vue @@ -0,0 +1,25 @@ + + + + + \ No newline at end of file diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 6ea68cd..30fb0ad 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -1,48 +1,63 @@ - - + .demo { + background-color: #0002; + width: 6rem; + margin: 1rem auto 0; + font-size: 1rem; + border-radius: 5rem; + cursor: pointer; + transition: all .5s; + + &:hover, + &:active { + opacity: .7; + } + } + + } + + .wave { + background-color: $w-color-1; + width: 100%; + height: auto; + padding: 0; + margin: 0; + aspect-ratio: 4/1; + } + } + \ No newline at end of file diff --git a/src/pages/template.vue b/src/pages/template.vue new file mode 100644 index 0000000..322fec9 --- /dev/null +++ b/src/pages/template.vue @@ -0,0 +1,18 @@ + + + + + diff --git a/src/static/favicon.ico b/src/static/favicon.ico new file mode 100644 index 0000000..86d7bc6 Binary files /dev/null and b/src/static/favicon.ico differ diff --git a/src/static/logo.png b/src/static/logo.png index b5771e2..bbea6dd 100644 Binary files a/src/static/logo.png and b/src/static/logo.png differ diff --git a/src/static/wave.svg b/src/static/wave.svg new file mode 100644 index 0000000..35d8cf7 --- /dev/null +++ b/src/static/wave.svg @@ -0,0 +1,17 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/uni.scss b/src/uni.scss index 288300d..6be1aa3 100644 --- a/src/uni.scss +++ b/src/uni.scss @@ -12,6 +12,9 @@ * 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件 */ +/* 自定义主体颜色 */ +$w-color-1:#2564a1; +$w-color-2:#2c77bf; /* 颜色变量 */ /* 行为相关颜色 */ diff --git a/src/w-components/README.md b/src/w-components/README.md new file mode 100644 index 0000000..53593c0 --- /dev/null +++ b/src/w-components/README.md @@ -0,0 +1 @@ +# 自定义组件库 diff --git a/src/w-components/mixins/mp-weixin.js b/src/w-components/mixins/mp-weixin.js new file mode 100644 index 0000000..23b9cb9 --- /dev/null +++ b/src/w-components/mixins/mp-weixin.js @@ -0,0 +1,24 @@ +/** + * + * @Author : J.L.Zhou + * @EMail : 12020042@qq.com + * @Tel : 151 1104 7708 + * @CreateTime : 2023-05-16 17:04:05 + * @LastEditos : J.L.Zhou + * @LastEditTime : 2023-05-16 17:04:05 + * @Version : 1.0 + * Copyright 2023 jlzhou.top Inc. All rights reserved. + * Warning: this content is only for internal circulation of the company. + * It is forbidden to divulge it or use it for other commercial purposes. + */ +export default { + // 将自定义节点设置成虚拟的,更加接近Vue组件的表现,可以去掉微信小程序自定义组件多出的最外层标签 + options: { + // #ifdef MP-WEIXIN + multipleSlots: true, //是否启动多slots支持 + styleIsolation: 'shared', //页面式样和组件内式样共享 + addGlobalClass: true, //页面式样是否影响到自定义组件 + virtualHost: true, //将自定义节点设置为虚拟的 + // #endif + } +} \ No newline at end of file diff --git a/src/w-components/w-footer/w-footer.vue b/src/w-components/w-footer/w-footer.vue new file mode 100644 index 0000000..da5125e --- /dev/null +++ b/src/w-components/w-footer/w-footer.vue @@ -0,0 +1,38 @@ + + + + + \ No newline at end of file diff --git a/src/w-components/w-loader/w-loader.vue b/src/w-components/w-loader/w-loader.vue new file mode 100644 index 0000000..9838b15 --- /dev/null +++ b/src/w-components/w-loader/w-loader.vue @@ -0,0 +1,149 @@ + + + + + \ No newline at end of file