Prechádzať zdrojové kódy

docs: 新增demo 展示插件

zhangyuhan 1 rok pred
rodič
commit
8c61537ae9

+ 98 - 0
data/data-models/modules/quick-search/README.md

@@ -0,0 +1,98 @@
+# useQuickSearchModel
+> 搜索业务模型
+
+::: tip
+该业务模型已集成 API 接口请求。
+:::
+
+## 前置要求
+
+* 使用 `interceptors-data-models.js`,将 service axios 实例中注入
+
+```javascript
+// interceptors-data-models.js
+import service from './interceptors-anti'
+import { injectRequest } from '@jy/data-models'
+
+injectRequest(service)
+```
+
+
+## 业务模型使用
+```javascript
+// 导入监控业务模型
+import useQuickSearchModel from '@jy/data-models/modules/quick-search/model'
+
+// 解构基础业务
+const APIModel = useQuickSearchModel({
+  type: 'search-bid'
+})
+
+const {
+  list,
+  total,
+  loading,
+  finished,
+  selectIds,
+  listIds,
+  searchResultCount,
+  isSelectSomeCheckbox,
+  selectCheckboxCount,
+  isSelectListAllCheckbox,
+  doToggleItemSelection,
+  doToggleListSelection,
+  doClearAllSelection,
+  doQuery: doRunQuery
+} = APIModel
+```
+
+### useQuickSearchModel()
+
+#### 参数文档
+
+|      参数       | 描述 |                        类型                         | 默认值 |
+|:-------------:|:--:|:-------------------------------------------------:|:---:|
+|  type  | 类型 | String |  -  |
+|  getParams  | 类型 | Function |  () => {}  |
+
+#### type 映射
+```js{2-6}
+const APIS = {
+  'search-bid': SearchBidListApi,
+  'search-ent': SearchEntListApi,
+  'search-supply': SearchSupplyListApi,
+  'search-purchase': SearchPurchaseListApi,
+  'search-nzj': SearchNzjListApi
+}
+```
+
+### doQuery
+```
+return {
+    success: success,
+    list: res.data?.list || [],
+    total: res.data?.total || 0,
+    origin: res.data
+}
+```
+
+
+### 如何新增搜索 API业务模型
+
+::: code-group
+
+<<< ./api/search-bid.js
+
+<<< ./plugins/search-bid.js
+
+```js [model/index.js]
+const APIS = {
+  ...,
+  'search-new': SearchNewListApi
+}
+```
+
+
+
+:::
+

+ 15 - 2
docs/.vitepress/config.mts

@@ -2,6 +2,8 @@ import { defineConfig } from 'vitepress'
 import { CustomAvatars } from './constant'
 // @ts-ignore
 import { getChangelogAndContributors } from 'vitepress-plugin-changelog'
+import { demoPreviewPlugin } from '@vitepress-code-preview/plugin'
+import { viteDemoPreviewPlugin } from '@vitepress-code-preview/plugin'
 
 export default defineConfig({
   base: '/efe-docs/',
@@ -124,6 +126,7 @@ export default defineConfig({
             items: [
               { text: 'article 详情页', link: '/article/' },
               { text: 'quick-monitor<br>项目、企业、业主监控', link: '/quick-monitor/' },
+              { text: 'quick-search<br>标讯、企业、采购搜索', link: '/quick-search/' },
             ]
           }
         ]
@@ -207,6 +210,16 @@ export default defineConfig({
       rollupOptions: {
         external: ["vue/server-renderer"]
       }
-    }
-  }
+    },
+    plugins: [
+      viteDemoPreviewPlugin()
+    ]
+  },
+  markdown: {
+    config(md) {
+      md.use(demoPreviewPlugin, {
+        docRoot: '../'
+      })
+    },
+  },
 })

+ 3 - 0
docs/.vitepress/theme/index.js

@@ -3,11 +3,14 @@ import './custom.css'
 import 'vitepress-plugin-changelog/changelog.css'
 import Changelog from 'vitepress-plugin-changelog/Changelog.vue'
 import PageLayout from '../layout/PageLayout.vue'
+import DemoPreview, { useComponents } from '@vitepress-code-preview/container'
+import '@vitepress-code-preview/container/dist/style.css'
 
 export default {
   extends: DefaultTheme,
   Layout: PageLayout,
   async enhanceApp({ app }) {
    app.component('changelog', Changelog)
+   useComponents(app, DemoPreview)
   }
 }

+ 3 - 1
docs/package.json

@@ -13,7 +13,9 @@
   "devDependencies": {
     "md5": "^2.3.0",
     "vitepress": "1.0.2",
-    "vitepress-plugin-changelog": "^0.1.1"
+    "vitepress-plugin-changelog": "^0.1.1",
+    "@vitepress-code-preview/container":"^1.0.7",
+    "@vitepress-code-preview/plugin": "^1.0.4"
   },
   "engines": {
     "node": ">=16",