Procházet zdrojové kódy

修改细节问题

快乐的梦鱼 před 2 týdny
rodič
revize
e5a3d207f4

+ 1 - 2
src/App.vue

@@ -55,7 +55,7 @@ onError((err) => {
 //设置请求基础地址
 RequestApiConfig.setConfig({
   ...RequestApiConfig.getConfig(),
-  BaseUrl: ApiCofig.serverProd,
+  BaseUrl: ApiCofig.server.Prod,
   EnableApiRequestLog: isTestEnv,
   EnableApiDataLog: false,
 })
@@ -77,7 +77,6 @@ configTheme(false, (theme, defaultDarkTheme) => {
   @import "@/components/index.scss";
 
   page {
-    //color: #00b66a;
     background: #f7f8f9;
   }
 </style>

+ 4 - 0
src/api/CommonContent.ts

@@ -287,6 +287,10 @@ export class CategoryListItem extends DataModel<CategoryListItem> {
   children?: CategoryListItem[];
 }
 
+/**
+ * 说明:
+ * * 主通用内容接口。
+ */
 export class CommonContentApi extends AppServerRequestModule<DataModel> {
 
   constructor(

+ 4 - 0
src/api/NotConfigue.ts

@@ -1,6 +1,10 @@
 import { DataModel } from '@imengyu/js-request-transform';
 import { AppServerRequestModule } from './RequestModules';
 
+/**
+ * 说明:
+ * * 通用接口。
+ */
 export class CommonApi extends AppServerRequestModule<DataModel> {
 
   constructor() {

+ 2 - 2
src/api/RequestModules.ts

@@ -4,11 +4,11 @@
  * * 不同服务器的请求模块。
  */
 
-import { isDev } from "../common/config/AppCofig";
 import ApiCofig from "@/common/config/ApiCofig";
+import { isDev } from "../common/config/AppCofig";
 import { appendGetUrlParams } from "@imengyu/imengyu-utils";
-import type { DataModel } from "@imengyu/js-request-transform";
 import { BaseAppServerRequestModule } from "./BaseAppServerRequestModule";
+import type { DataModel } from "@imengyu/js-request-transform";
 
 
 /**

+ 4 - 0
src/common/composeabe/AppInit.ts

@@ -2,6 +2,10 @@ import { useCollectStore } from "@/store/collect";
 import BugReporter from "../BugReporter";
 import { useAuthStore } from "@/store/auth";
 
+/**
+ * 说明:
+ * * 应用初始化逻辑。
+ */
 export function useAppInit() {
   
   const collectStore = useCollectStore();

+ 7 - 0
src/common/composeabe/ErrorDisplay.ts

@@ -1,3 +1,10 @@
+/**
+ * 说明:
+ * * 显示错误信息。
+ * @param e 错误信息
+ * @param title 弹窗标题
+ * @param callback 弹窗确认回调
+ */
 export function showError(e: any, title = '糟糕,出错了', callback?: () => void) {
   console.log('showError', e);
   let message = '';

+ 5 - 0
src/common/composeabe/LoaderCommon.ts

@@ -2,6 +2,11 @@ import type { Ref } from "vue";
 
 export type LoaderLoadType = 'loading' | 'finished' | 'nomore' | 'error' | 'empty';
 
+/**
+ * 说明:
+ * * 通用加载器接口。
+ * @param P 加载参数类型
+ */
 export interface ILoaderCommon<P> {
   loadError: Ref<string>;
   loadStatus: Ref<LoaderLoadType>;

+ 9 - 0
src/common/composeabe/RequireLogin.ts

@@ -2,10 +2,19 @@ import { confirm } from "@/components/utils/DialogAction";
 import { navTo } from "@/components/utils/PageAction";
 import { useAuthStore } from "@/store/auth";
 
+/**
+ * 说明:
+ * * 登录校验组合式代码。
+ */
 export function useReqireLogin() {
   const authStore = useAuthStore();
  
   return {
+    /**
+     * 校验登录状态
+     * @param cb 登录成功回调
+     * @param message 登录提示信息
+     */
     requireLogin(cb: () => void, message: string = '登录后查看') {
       if (!authStore.isLogged) {
         confirm({ 

+ 8 - 0
src/common/composeabe/SimpleDataLoader.ts

@@ -6,6 +6,14 @@ export interface ISimpleDataLoader<T, P> extends ILoaderCommon<P> {
   getLastParams: () => P | undefined;
 }
 
+/**
+ * 说明:
+ * * 简单数据加载器组合式代码。
+ * @param loader 数据加载函数
+ * @param loadWhenMounted 是否在挂载时自动加载数据
+ * @param emptyIfArrayEmpty 如果数组为空是否显示空状态
+ * @param showGlobalLoading 是否显示全局加载提示
+ */
 export function useSimpleDataLoader<T, P = any>(
   loader: (params?: P) => Promise<T>,
   loadWhenMounted = true,

+ 7 - 0
src/common/composeabe/SimpleLocalDataStorage.ts

@@ -1,6 +1,13 @@
 import { onMounted, ref, type Ref } from "vue";
 
 
+/**
+ * 说明:
+ * * 简单本地数据存储组合式代码。
+ * @param subKey 子键名
+ * @param requireValueAtLoad 是否在挂载时自动加载数据
+ * @param defaultValue 默认值
+ */
 export function useSimpleLocalDataStorage<T>(
   subKey: string, 
   requireValueAtLoad = false,

+ 6 - 0
src/common/composeabe/SimplePageContentLoader.ts

@@ -5,6 +5,12 @@ export interface ISimplePageContentLoader<T, P> extends ILoaderCommon<P> {
   content: Ref<T|null>;
 }
 
+/**
+ * 说明:
+ * * 简单页面内容加载器组合式代码。
+ * @param loader 数据加载函数
+ * @param options 选项
+ */
 export function useSimplePageContentLoader<T, P = any>(
   loader: (params?: P) => Promise<T>,
   options?: {

+ 7 - 0
src/common/composeabe/SimplePageListLoader.ts

@@ -8,6 +8,13 @@ export interface ISimplePageListLoader<T, P> extends ILoaderCommon<P> {
   total: Ref<number>;
 }
 
+/**
+ * 说明:
+ * * 简单页面分页列表加载器组合式代码。
+ * @param pageSize 每页数量
+ * @param loader 数据加载函数
+ * @param showGlobalLoading 是否显示全局加载提示
+ */
 export function useSimplePageListLoader<T, P = any>(
   pageSize: number, 
   loader: (page: number, pageSize: number, params?: P) => Promise<{ list: T[], total: number }>,

+ 5 - 0
src/common/composeabe/SwiperImagePreview.ts

@@ -1,3 +1,8 @@
+/**
+ * 说明:
+ * * 图片预览组合式代码。
+ * @param getList 获取图片列表函数
+ */
 export function useSwiperImagePreview(getList: () => string[]) {
   return {
     onPreviewImage: (index: number) => {

+ 0 - 35
src/common/composeabe/TabControl.ts

@@ -1,35 +0,0 @@
-import { computed, ref, watch } from "vue";
-
-export interface TabControlItem {
-  text: string,
-  [key: string]: any,
-}
-
-export function useTabControl(options: {
-  tabs?: TabControlItem[],
-  onTabChange?: (tab: number, tabId: number) => void,
-}) {
-
-  const tabCurrentIndex = ref(0)
-  const tabCurrentId = computed(() => {
-    return tabsArray.value.filter(t => t.visible !== false)[tabCurrentIndex.value].id
-  });
-  const tabsArray = ref<TabControlItem[]>(options.tabs ?? []);
-
-  watch(tabCurrentIndex, (v) => {
-    options.onTabChange?.(v, tabCurrentId.value) 
-    if (tabsArray.value[v].jump)
-      tabsArray.value[v].jump()
-  })
-
-  const tabs = computed(() => {
-    return tabsArray.value.filter(t => t.visible !== false)
-  })
-
-  return {
-    tabCurrentId,
-    tabCurrentIndex,
-    tabs,
-    tabsArray,
-  }
-}

+ 19 - 4
src/common/config/AppCofig.ts

@@ -12,7 +12,15 @@ export default {
   qqMapKey: 'TOIBZ-CA4WB-OFQUF-J3XG4-EEB2J-DXBX7',
   amapKey: '34eb1d57f93720a871bd11a90af0c91c',
   defaultLonLat: [ 118.161270, 24.529196 ],
+  /**
+   * 说明:
+   * * 是否需要登录才能访问应用。
+   */
   requireLogin: false,
+  /**
+   * 说明:
+   * * 无需登录即可访问的页面。
+   */
   noLoginPages: [
     '/pages/user/login',
     '/pages/user/register',
@@ -25,14 +33,21 @@ export default {
 }
 
 /**
- * 图炫地图配置
+ * 获取当前环境是否为开发环境
  */
-export function configAiMap() {
-}
-
 export const isDev = import.meta.env.DEV;
+/**
+ * 获取当前环境是否为生产环境
+ */
 export const isProd = import.meta.env.PROD;
 
 const accountInfo = uni.getAccountInfoSync();
+
+/**
+ * 获取当前环境版本
+ */
 export const envVersion = accountInfo.miniProgram.envVersion;
+/**
+ * 获取当前环境是否为测试环境
+ */
 export const isTestEnv = envVersion === 'develop' || envVersion === 'trial';

+ 1 - 1
src/pages/home/village/details.vue

@@ -20,7 +20,7 @@
             :width="750"
             mode="aspectFill"
             touchable
-            @click="onPreviewImage(k)"
+            @click="onPreviewImage(k as number)"
           />
         </swiper-item>
       </swiper>

+ 24 - 0
src/store/auth.ts

@@ -3,6 +3,9 @@ import { defineStore } from "pinia"
 
 const STORAGE_KEY = 'authInfo';
 
+/**
+ * 认证状态管理
+ */
 export const useAuthStore = defineStore('auth', {
   state: () => ({
     token: '',
@@ -12,6 +15,9 @@ export const useAuthStore = defineStore('auth', {
     loginType: 0,
   }),
   actions: {
+    /**
+     * 加载登录状态
+     */
     async loadLoginState() {
       try {
         const res = await uni.getStorage({ key: STORAGE_KEY });
@@ -35,6 +41,9 @@ export const useAuthStore = defineStore('auth', {
         return false;
       }
     },
+    /**
+     * 微信登录
+     */
     async loginWechart(code: string, res: UniApp.GetUserProfileRes) {
       const loginResult = await UserApi.loginThird({
         code,
@@ -51,6 +60,9 @@ export const useAuthStore = defineStore('auth', {
       );
       return loginResult;
     },
+    /**
+     * 手机号登录
+     */
     async loginMobile(account: string, password: string, loginType: number) {
       let loginResult;
       if (loginType == 0) {
@@ -68,6 +80,9 @@ export const useAuthStore = defineStore('auth', {
       await this.loginResultHandle(loginResult, loginType);
       return loginResult;
     },
+    /**
+     * 处理登录结果
+     */
     async loginResultHandle(loginResult: LoginResult, loginType: number) {
       this.token = loginResult.token;
       this.userId = loginResult.userInfo.id;
@@ -76,6 +91,9 @@ export const useAuthStore = defineStore('auth', {
       setToken(this.token);
       this.saveLoginState();
     },
+    /**
+     * 注销登录
+     */
     async logout() {
       this.token = '';
       this.userId = 0;
@@ -106,9 +124,15 @@ export const useAuthStore = defineStore('auth', {
     },
   },
   getters: {
+    /**
+     * 是否为管理员
+     */
     isAdmin(state) {
       return state.loginType === 1;
     },
+    /**
+     * 是否已登录
+     */
     isLogged(state) {
       return state.token != '' && state.userId != 0
     },

+ 21 - 0
src/store/collect.ts

@@ -4,20 +4,32 @@ import { useAuthStore } from './auth';
 import { CollectableModulesNameMapping } from '@/pages/dig/forms/forms';
 import VillageApi from '@/api/inhert/VillageApi';
 
+/** 
+ * 采集模块状态 
+ */
 export const useCollectStore = defineStore('collect', () => {
   const collectableModules = ref(new Map<string, number>());
   const collectableAllModules = ref(new Map<string, number>());
   const collectableCatalogs = ref<number[]>([]);
   const authStore = useAuthStore();
 
+  /**
+   * 设置采集模块状态数据
+   */
   function setCollectableModules(modules: Map<string, number>) {
     collectableModules.value = modules;
   }
+  /**
+   * 判断是否可以采集指定目录
+   */
   function canCollectCatalog(catalogId: number) {
     if (authStore.isAdmin)
       return true;
     return collectableCatalogs.value.includes(catalogId);
   }
+  /**
+   * 判断是否可以采集指定模块
+   */
   function canCollect(module: string) {
     if (authStore.isAdmin)
       return true;
@@ -25,11 +37,17 @@ export const useCollectStore = defineStore('collect', () => {
       return true;
     return collectableModules.value.has(module);
   }
+  /**
+   * 获取采集模块的内部名称
+   */
   function getCollectModuleId(module: string) {
     if (collectableAllModules.value.has(CollectableModulesNameMapping[module]))
       return collectableAllModules.value.get(CollectableModulesNameMapping[module]);
     return collectableAllModules.value.get(module);
   }
+  /**
+   * 从ID获取采集模块的内部名称
+   */
   function getCollectModuleInternalNameById(id: number) {
     for (const [key, value] of collectableAllModules.value) {
       if (value == id) {
@@ -61,6 +79,9 @@ export const useCollectStore = defineStore('collect', () => {
     setCollectableModules(collectableModulesMap);
   }
   
+  /**
+   * 判断采集模块状态是否为空
+   */
   const isEmpty = computed(() => collectableModules.value.size === 0 && collectableCatalogs.value.length === 0);
 
   return {