diff --git a/manifest.config.ts b/manifest.config.ts
index 8a7243d..df54acd 100644
--- a/manifest.config.ts
+++ b/manifest.config.ts
@@ -3,9 +3,11 @@ import { defineManifestConfig } from '@uni-helper/vite-plugin-uni-manifest'
import path from 'node:path'
import { loadEnv } from 'vite'
+// 获取环境变量的范例
const env = loadEnv(process.env.NODE_ENV!, path.resolve(process.cwd(), 'env'))
// console.log(env)
const { VITE_APP_TITLE, VITE_UNI_APPID, VITE_WX_APPID } = env
+
export default defineManifestConfig({
name: VITE_APP_TITLE,
appid: VITE_UNI_APPID,
diff --git a/pages.config.ts b/pages.config.ts
index d502476..30c3004 100644
--- a/pages.config.ts
+++ b/pages.config.ts
@@ -1,4 +1,5 @@
import { defineUniPages } from '@uni-helper/vite-plugin-uni-pages'
+import { isWxProd } from './vite.config'
export default defineUniPages({
globalStyle: {
@@ -24,26 +25,42 @@ export default defineUniPages({
fontSize: '10px',
iconWidth: '24px',
spacing: '3px',
- list: [
- {
- iconPath: 'static/tabbar/home.png',
- selectedIconPath: 'static/tabbar/homeHL.png',
- pagePath: 'pages/index/index',
- text: '首页',
- },
- {
- iconPath: 'static/tabbar/example.png',
- selectedIconPath: 'static/tabbar/exampleHL.png',
- pagePath: 'pages/demo/index',
- text: '示例',
- },
- {
- iconPath: 'static/tabbar/personal.png',
- selectedIconPath: 'static/tabbar/personalHL.png',
- pagePath: 'pages/my/index',
- text: '我的',
- },
- ],
+ list: isWxProd
+ ? [
+ {
+ iconPath: 'static/tabbar/home.png',
+ selectedIconPath: 'static/tabbar/homeHL.png',
+ pagePath: 'pages/index/index',
+ text: '首页',
+ },
+ {
+ iconPath: 'static/tabbar/personal.png',
+ selectedIconPath: 'static/tabbar/personalHL.png',
+ pagePath: 'pages/my/index',
+ text: '我的',
+ },
+ ]
+ : [
+ {
+ iconPath: 'static/tabbar/home.png',
+ selectedIconPath: 'static/tabbar/homeHL.png',
+ pagePath: 'pages/index/index',
+ text: '首页',
+ },
+ // 生产环境要注释掉demo,所以分开来写
+ {
+ iconPath: 'static/tabbar/example.png',
+ selectedIconPath: 'static/tabbar/exampleHL.png',
+ pagePath: 'pages/demo/index',
+ text: '示例',
+ },
+ {
+ iconPath: 'static/tabbar/personal.png',
+ selectedIconPath: 'static/tabbar/personalHL.png',
+ pagePath: 'pages/my/index',
+ text: '我的',
+ },
+ ],
},
// 你也可以定义 pages 字段,它具有最高的优先级。
pages: [],
diff --git a/src/components/fly-login/README.md b/src/components/fly-login/README.md
new file mode 100644
index 0000000..c931549
--- /dev/null
+++ b/src/components/fly-login/README.md
@@ -0,0 +1,7 @@
+# fly-login
+
+点击“点击显示微信头像”按钮后,出现的半屏登录弹窗,可以在任意页面引入。
+
+仿“掘金小册”小程序。
+
+
diff --git a/src/components/fly-login/defaultAvatar.png b/src/components/fly-login/defaultAvatar.png
new file mode 100644
index 0000000..e69596a
Binary files /dev/null and b/src/components/fly-login/defaultAvatar.png differ
diff --git a/src/components/fly-login/fly-login.vue b/src/components/fly-login/fly-login.vue
new file mode 100644
index 0000000..cc3bf0e
--- /dev/null
+++ b/src/components/fly-login/fly-login.vue
@@ -0,0 +1,116 @@
+
+
+
+
+ 获取您的昵称、头像
+
+
+
+
+
+ 头像
+
+
+
+
+ 昵称
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/fly-login/screenshot.png b/src/components/fly-login/screenshot.png
new file mode 100644
index 0000000..7ca7a26
Binary files /dev/null and b/src/components/fly-login/screenshot.png differ
diff --git a/src/pages.json b/src/pages.json
index 0f4e412..66a7baf 100644
--- a/src/pages.json
+++ b/src/pages.json
@@ -56,7 +56,7 @@
"type": "page"
},
{
- "path": "pages/login/login",
+ "path": "pages/login/index",
"type": "page",
"style": {
"navigationBarTitleText": "登录"
diff --git a/src/pages/login/index.vue b/src/pages/login/index.vue
new file mode 100644
index 0000000..a4c2542
--- /dev/null
+++ b/src/pages/login/index.vue
@@ -0,0 +1,40 @@
+
+{
+ style: { navigationBarTitleText: '登录' },
+}
+
+
+
+
+
+
+ {{ userStore.userInfo?.nickname }}
+
+
+
+
+ 点击显示微信头像
+
+
+
+
+
+
+
diff --git a/src/pages/login/login.vue b/src/pages/login/login.vue
deleted file mode 100644
index b588cbc..0000000
--- a/src/pages/login/login.vue
+++ /dev/null
@@ -1,9 +0,0 @@
-
-{
- style: { navigationBarTitleText: '登录' },
-}
-
-
-
- 登录
-
diff --git a/src/pages/my/index.vue b/src/pages/my/index.vue
index dcad3ee..ffd82cf 100644
--- a/src/pages/my/index.vue
+++ b/src/pages/my/index.vue
@@ -5,4 +5,12 @@
我的
+ 去登录
+
+
diff --git a/src/typings.d.ts b/src/typings.d.ts
index ad584c7..5b00d1f 100644
--- a/src/typings.d.ts
+++ b/src/typings.d.ts
@@ -1,6 +1,6 @@
export type UserInfo = {
- username: string
- token: string
+ nickname: string
+ avatar: string
}
export type UserItem = {
username: string
diff --git a/uni-pages.d.ts b/uni-pages.d.ts
index 164f39b..f261783 100644
--- a/uni-pages.d.ts
+++ b/uni-pages.d.ts
@@ -6,7 +6,7 @@
interface NavigateToOptions {
url: "pages/index/index" |
"pages/demo/index" |
- "pages/login/login" |
+ "pages/login/index" |
"pages/my/index" |
"pages/demo/demo/clock" |
"pages/demo/demo/component-auto-import" |
diff --git a/vite.config.ts b/vite.config.ts
index 43a9b53..8635ac7 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -24,9 +24,13 @@ import AutoImport from 'unplugin-auto-import/vite'
import viteCompression from 'vite-plugin-compression'
import ViteRestart from 'vite-plugin-restart'
import { visualizer } from 'rollup-plugin-visualizer'
-// TODO: 很多用户无法安装这个插件所以先注释掉了,如果你可以安装成功,那就可以放开这个注释,以及下面的配置
+// TODO: 很多用户无法安装这个插件所以先注释掉了,如果你可以安装成功,那就可以放开这个注释,以及下面的viteImagemin配置
+// 另外,小程序有主包2M的限制,所以一般图片会放到图片服务器(不放本地),那这个插件就没用,所以在开发h5的时候,使用本地图片才用得到,既然如此那就不装吧
// import viteImagemin from 'vite-plugin-imagemin'
+export const isWxProd =
+ process.env.UNI_PLATFORM === 'mp-weixin' && process.env.NODE_ENV === 'production'
+
// https://vitejs.dev/config/
export default ({ command, mode }) => {
console.log(mode === process.env.NODE_ENV)
@@ -43,11 +47,15 @@ export default ({ command, mode }) => {
const env = loadEnv(mode, path.resolve(process.cwd(), 'env'))
// console.log(env)
console.log(process.env.UNI_PLATFORM) // 得到 mp-weixin, h5 等
+
return defineConfig({
envDir: './env', // 自定义env目录
plugins: [
UniPages({
- exclude: ['**/components/**/**.*'],
+ // TODO: 生产环境小程序要过滤掉demo(demo里面很多图片,超过2M的包大小)
+ exclude: isWxProd
+ ? ['**/components/**/**.*', '**/demo/**/**.*']
+ : ['**/components/**/**.*'],
}),
UniLayouts(),
UniPlatform(),