Merge branch 'master' of https://gitee.com/youlaiorg/vue-uniapp-template into dev
This commit is contained in:
@@ -3,16 +3,7 @@ import { defineUniPages } from "@uni-helper/vite-plugin-uni-pages";
|
|||||||
|
|
||||||
export default defineUniPages({
|
export default defineUniPages({
|
||||||
// 你也可以定义 pages 字段,它具有最高的优先级。
|
// 你也可以定义 pages 字段,它具有最高的优先级。
|
||||||
pages: [
|
pages: [],
|
||||||
{
|
|
||||||
path: "pages/index/index",
|
|
||||||
layout: "tabbar",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "pages/mine/index",
|
|
||||||
layout: "tabbar",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
globalStyle: {
|
globalStyle: {
|
||||||
navigationBarBackgroundColor: "@navBgColor",
|
navigationBarBackgroundColor: "@navBgColor",
|
||||||
navigationBarTextStyle: "@navTxtStyle",
|
navigationBarTextStyle: "@navTxtStyle",
|
||||||
|
|||||||
@@ -36,8 +36,6 @@ const { themeVars, theme } = useTheme();
|
|||||||
const { activeTabbar, getTabbarItemValue, setTabbarItemActive, tabbarList } = useTabbar();
|
const { activeTabbar, getTabbarItemValue, setTabbarItemActive, tabbarList } = useTabbar();
|
||||||
|
|
||||||
function handleTabbarChange({ value }: { value: string }) {
|
function handleTabbarChange({ value }: { value: string }) {
|
||||||
console.log("tabbarChange", value);
|
|
||||||
|
|
||||||
setTabbarItemActive(value);
|
setTabbarItemActive(value);
|
||||||
router.pushTab({ name: value });
|
router.pushTab({ name: value });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "",
|
"name": "vue-uniapp-template",
|
||||||
"appid": "",
|
"appid": "",
|
||||||
"description": "",
|
"description": "有来移动端跨端解决方案开发模板",
|
||||||
"versionName": "1.0.0",
|
"versionName": "1.0.0",
|
||||||
"versionCode": "100",
|
"versionCode": "100",
|
||||||
"transformPx": false,
|
"transformPx": false,
|
||||||
/* 5+App特有相关 */
|
|
||||||
"app-plus": {
|
"app-plus": {
|
||||||
"usingComponents": true,
|
"usingComponents": true,
|
||||||
"nvueStyleCompiler": "uni-app",
|
"nvueStyleCompiler": "uni-app",
|
||||||
@@ -16,11 +15,8 @@
|
|||||||
"autoclose": true,
|
"autoclose": true,
|
||||||
"delay": 0
|
"delay": 0
|
||||||
},
|
},
|
||||||
/* 模块配置 */
|
|
||||||
"modules": {},
|
"modules": {},
|
||||||
/* 应用发布信息 */
|
|
||||||
"distribute": {
|
"distribute": {
|
||||||
/* android打包配置 */
|
|
||||||
"android": {
|
"android": {
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
|
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
|
||||||
@@ -40,15 +36,11 @@
|
|||||||
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
|
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
/* ios打包配置 */
|
|
||||||
"ios": {},
|
"ios": {},
|
||||||
/* SDK配置 */
|
|
||||||
"sdkConfigs": {}
|
"sdkConfigs": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/* 快应用特有相关 */
|
|
||||||
"quickapp": {},
|
"quickapp": {},
|
||||||
/* 小程序特有相关 */
|
|
||||||
"mp-weixin": {
|
"mp-weixin": {
|
||||||
"appid": "wx99a151dc43d2637b",
|
"appid": "wx99a151dc43d2637b",
|
||||||
"setting": {
|
"setting": {
|
||||||
|
|||||||
@@ -3,79 +3,75 @@
|
|||||||
{
|
{
|
||||||
"path": "pages/index/index",
|
"path": "pages/index/index",
|
||||||
"type": "home",
|
"type": "home",
|
||||||
"style": {},
|
"name": "home",
|
||||||
|
"style": {
|
||||||
|
"navigationStyle": "custom"
|
||||||
|
},
|
||||||
"layout": "tabbar"
|
"layout": "tabbar"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/login/index",
|
"path": "pages/login/index",
|
||||||
"type": "page",
|
"type": "page"
|
||||||
"style": {}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/mine/index",
|
"path": "pages/mine/index",
|
||||||
"type": "page",
|
"type": "page",
|
||||||
"style": {},
|
"name": "mine",
|
||||||
|
"style": {
|
||||||
|
"navigationStyle": "custom"
|
||||||
|
},
|
||||||
"layout": "tabbar"
|
"layout": "tabbar"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/work/index",
|
"path": "pages/work/index",
|
||||||
"type": "page",
|
"type": "page",
|
||||||
"name": "work",
|
"name": "work",
|
||||||
"meta": {
|
"style": {
|
||||||
"requireAuth": true,
|
"navigationBarTitleText": "工作台"
|
||||||
"title": "需要登录的页面"
|
|
||||||
},
|
},
|
||||||
"style": {}
|
"meta": {
|
||||||
|
"requireAuth": true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/mine/about/index",
|
"path": "pages/mine/about/index",
|
||||||
"type": "page",
|
"type": "page"
|
||||||
"style": {}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/mine/faq/index",
|
"path": "pages/mine/faq/index",
|
||||||
"type": "page",
|
"type": "page"
|
||||||
"style": {}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/mine/feedback/index",
|
"path": "pages/mine/feedback/index",
|
||||||
"type": "page",
|
"type": "page"
|
||||||
"style": {}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/mine/profile/complete-profile",
|
"path": "pages/mine/profile/complete-profile",
|
||||||
"type": "page",
|
"type": "page"
|
||||||
"style": {}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/mine/profile/index",
|
"path": "pages/mine/profile/index",
|
||||||
"type": "page",
|
"type": "page"
|
||||||
"style": {}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/mine/settings/index",
|
"path": "pages/mine/settings/index",
|
||||||
"type": "page",
|
"type": "page"
|
||||||
"style": {}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/mine/settings/account/index",
|
"path": "pages/mine/settings/account/index",
|
||||||
"type": "page",
|
"type": "page"
|
||||||
"style": {}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/mine/settings/agreement/index",
|
"path": "pages/mine/settings/agreement/index",
|
||||||
"type": "page",
|
"type": "page"
|
||||||
"style": {}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/mine/settings/network/index",
|
"path": "pages/mine/settings/network/index",
|
||||||
"type": "page",
|
"type": "page"
|
||||||
"style": {}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/mine/settings/theme/index",
|
"path": "pages/mine/settings/theme/index",
|
||||||
"type": "page",
|
"type": "page"
|
||||||
"style": {}
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"globalStyle": {
|
"globalStyle": {
|
||||||
|
|||||||
@@ -14,8 +14,7 @@
|
|||||||
v-for="(item, index) in navList"
|
v-for="(item, index) in navList"
|
||||||
:key="index"
|
:key="index"
|
||||||
use-slot
|
use-slot
|
||||||
link-type="navigateTo"
|
@click="handleNavClick(item)"
|
||||||
:url="item.url"
|
|
||||||
>
|
>
|
||||||
<view class="p-2">
|
<view class="p-2">
|
||||||
<image class="w-72rpx h-72rpx rounded-8rpx" :src="item.icon" />
|
<image class="w-72rpx h-72rpx rounded-8rpx" :src="item.icon" />
|
||||||
@@ -101,6 +100,7 @@ interface VisitStatsVO {
|
|||||||
totalPvCount: number;
|
totalPvCount: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
const current = ref<number>(0);
|
const current = ref<number>(0);
|
||||||
|
|
||||||
const visitStatsData = ref<VisitStatsVO>({
|
const visitStatsData = ref<VisitStatsVO>({
|
||||||
@@ -170,6 +170,12 @@ const navList = reactive([
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// 处理导航点击
|
||||||
|
function handleNavClick(item: any) {
|
||||||
|
// 使用路由系统进行导航,这样会触发路由守卫
|
||||||
|
router.push({ path: item.url });
|
||||||
|
}
|
||||||
|
|
||||||
// 生成静态的访问趋势数据
|
// 生成静态的访问趋势数据
|
||||||
const generateStaticTrendData = (days: number) => {
|
const generateStaticTrendData = (days: number) => {
|
||||||
const dates = [];
|
const dates = [];
|
||||||
@@ -265,4 +271,11 @@ onShow(() => {
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<route lang="json">
|
||||||
|
{
|
||||||
|
"name": "home",
|
||||||
|
"style": { "navigationStyle": "custom" },
|
||||||
|
"layout": "tabbar"
|
||||||
|
}
|
||||||
|
</route>
|
||||||
<style setup lang="scss"></style>
|
<style setup lang="scss"></style>
|
||||||
|
|||||||
@@ -249,6 +249,14 @@ onShow(() => {
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<route lang="json">
|
||||||
|
{
|
||||||
|
"name": "mine",
|
||||||
|
"style": { "navigationStyle": "custom" },
|
||||||
|
"layout": "tabbar"
|
||||||
|
}
|
||||||
|
</route>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
// 用户信息卡片
|
// 用户信息卡片
|
||||||
.user-profile {
|
.user-profile {
|
||||||
|
|||||||
@@ -1,25 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="app-container">
|
<view class="app-container">
|
||||||
<wd-navbar title="设置" left-arrow @click-left="handleBack" />
|
|
||||||
|
|
||||||
<wd-status-tip type="search" tip="建设中..." />
|
<wd-status-tip type="search" tip="建设中..." />
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts"></script>
|
||||||
|
|
||||||
<route lang="json">
|
<route lang="json">
|
||||||
{
|
{
|
||||||
"name": "work",
|
"name": "work",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "工作台"
|
||||||
|
},
|
||||||
"meta": {
|
"meta": {
|
||||||
"requireAuth": true,
|
"requireAuth": true
|
||||||
"title": "需要登录的页面"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
const handleBack = () => {
|
|
||||||
uni.navigateBack();
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss"></style>
|
<style lang="scss"></style>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { pages, subPackages } from "virtual:uni-pages";
|
import { pages, subPackages } from "virtual:uni-pages";
|
||||||
import { isLoggedIn } from "@/utils/auth";
|
import { isLoggedIn } from "@/utils/auth";
|
||||||
|
|
||||||
import { createRouter } from "uni-mini-router";
|
import { createRouter } from "uni-mini-router";
|
||||||
|
|
||||||
// 生成路由配置
|
// 生成路由配置
|
||||||
function generateRoutes() {
|
function generateRoutes() {
|
||||||
const routes = pages.map((page: { path: string; [key: string]: any }) => {
|
const routes = pages.map((page: { path: string; [key: string]: any }) => {
|
||||||
@@ -19,7 +19,6 @@ function generateRoutes() {
|
|||||||
routes.push(...subRoutes);
|
routes.push(...subRoutes);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return routes;
|
return routes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,39 +29,41 @@ const router = createRouter({
|
|||||||
|
|
||||||
// 全局前置守卫
|
// 全局前置守卫
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
console.log("路由跳转:", to.path);
|
|
||||||
// 检查页面是否需要登录
|
// 检查页面是否需要登录
|
||||||
if (to.meta && to.meta.requireAuth) {
|
if (to.meta && to.meta.requireAuth && !isLoggedIn()) {
|
||||||
if (!isLoggedIn) {
|
uni.showModal({
|
||||||
// 显示登录提示
|
title: "提示",
|
||||||
uni.showModal({
|
content: "该功能需要登录后使用",
|
||||||
title: "提示",
|
confirmText: "去登录",
|
||||||
content: "该功能需要登录后使用",
|
cancelText: "返回",
|
||||||
confirmText: "去登录",
|
success: (res) => {
|
||||||
cancelText: "返回",
|
if (res.confirm) {
|
||||||
success: (res) => {
|
// 记住原来要去的页面
|
||||||
if (res.confirm) {
|
uni.setStorageSync("redirect", to.fullPath);
|
||||||
// 记住原来要去的页面
|
// 使用 uni 原生导航而不是 router
|
||||||
uni.setStorageSync("redirect", to.fullPath);
|
uni.navigateTo({
|
||||||
next("/pages/login/index");
|
url: "/pages/login/index",
|
||||||
} else {
|
});
|
||||||
// 取消则返回首页
|
} else {
|
||||||
next("/pages/index/index");
|
// 取消则返回首页
|
||||||
}
|
uni.switchTab({
|
||||||
},
|
url: "/pages/index/index",
|
||||||
});
|
});
|
||||||
return;
|
}
|
||||||
}
|
},
|
||||||
|
// 确保在取消弹窗时也能调用 next
|
||||||
|
fail: () => {
|
||||||
|
next(false);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// 继续导航
|
||||||
|
next();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 继续导航
|
|
||||||
next();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
router.afterEach((to) => {
|
router.afterEach((to) => {
|
||||||
console.log("路由跳转完成:", to.path);
|
console.log("路由跳转完成:", to.path);
|
||||||
|
|
||||||
// 可以在这里做一些统计或记录
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
26
theme.json
Normal file
26
theme.json
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"light": {
|
||||||
|
"bgColor": "#F8F8F8",
|
||||||
|
"bgColorBottom": "#F8F8F8",
|
||||||
|
"bgColorTop": "#F8F8F8",
|
||||||
|
"bgTxtStyle": "dark",
|
||||||
|
"navBgColor": "#FFF",
|
||||||
|
"navTxtStyle": "black",
|
||||||
|
"tabBgColor": "#ffffff",
|
||||||
|
"tabBorderStyle": "black",
|
||||||
|
"tabColor": "#bfbfbf",
|
||||||
|
"tabSelectedColor": "#0165FF"
|
||||||
|
},
|
||||||
|
"dark": {
|
||||||
|
"bgColor": "#000",
|
||||||
|
"bgColorBottom": "#000",
|
||||||
|
"bgColorTop": "#000",
|
||||||
|
"bgTxtStyle": "light",
|
||||||
|
"navBgColor": "#000000",
|
||||||
|
"navTxtStyle": "white",
|
||||||
|
"tabBgColor": "#1a1a1a",
|
||||||
|
"tabBorderStyle": "white",
|
||||||
|
"tabColor": "#bfbfbf",
|
||||||
|
"tabSelectedColor": "#0165FF"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
"@/*": ["./src/*"]
|
"@/*": ["./src/*"]
|
||||||
},
|
},
|
||||||
"lib": ["esnext", "dom"],
|
"lib": ["esnext", "dom"],
|
||||||
"types": ["@dcloudio/types", "@uni-helper/uni-types", "wot-design-uni/global"]
|
"types": ["@dcloudio/types", "@uni-helper/uni-types", "wot-design-uni/global", "./src/types/vite-plugin-uni-pages"]
|
||||||
},
|
},
|
||||||
"vueCompilerOptions": {
|
"vueCompilerOptions": {
|
||||||
// 调整 Volar(Vue 语言服务工具)解析行为,用于为 uni-app 组件提供 TypeScript 类型
|
// 调整 Volar(Vue 语言服务工具)解析行为,用于为 uni-app 组件提供 TypeScript 类型
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ export default defineConfig(async ({ mode }: ConfigEnv): Promise<UserConfig> =>
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
dts: "src/types/auto-imports.d.ts", // 自动生成的类型声明文件
|
dts: "src/types/auto-imports.d.ts", // 自动生成的类型声明文件
|
||||||
dirs: ["./src/composables", "src/store", "src/utils", "src/api"],
|
dirs: ["src/composables", "src/store", "src/utils", "src/api"],
|
||||||
vueTemplate: true,
|
vueTemplate: true,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user