Skip to content

Commit

Permalink
perf: ♻️ 文件结构及代码逻辑优化
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed Feb 20, 2024
1 parent 07500b5 commit 3b66faf
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 26 deletions.
12 changes: 6 additions & 6 deletions pages.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,20 +119,20 @@ export default defineUniPages({
backgroundColor: '#F8F8F8',
list: [
{
iconPath: 'static/tabbar/tab-home.png',
selectedIconPath: 'static/tabbar/tab-home-active.png',
iconPath: 'static/tabbar/home.png',
selectedIconPath: 'static/tabbar/home-active.png',
pagePath: 'pages/index/home/index',
text: '主页',
},
{
iconPath: 'static/tabbar/tab-example.png',
selectedIconPath: 'static/tabbar/tab-example-active.png',
iconPath: 'static/tabbar/example.png',
selectedIconPath: 'static/tabbar/example-active.png',
pagePath: 'pages/index/example/index',
text: '示例',
},
{
iconPath: 'static/tabbar/tab-personal.png',
selectedIconPath: 'static/tabbar/tab-personal-active.png',
iconPath: 'static/tabbar/personal.png',
selectedIconPath: 'static/tabbar/personal-active.png',
pagePath: 'pages/index/personal/index',
text: '我的',
},
Expand Down
13 changes: 4 additions & 9 deletions src/components/dict-picker/dict-picker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
@change="onChange"
@cancel="onCancel"
>
<slot
:show-value="showValue"
:value="modelValue"
>
<slot :show-value="showValue" :value="modelValue">
<view class="flex items-center w-full">
<view class="flex-1 w-0">
<uv-input
Expand All @@ -21,9 +18,7 @@
></uv-input>
</view>
<view class="flex-none">
<uv-icon
name="arrow-right"
></uv-icon>
<uv-icon name="arrow-right"></uv-icon>
</view>
</view>
</slot>
Expand Down Expand Up @@ -72,8 +67,8 @@ export default {
showValue() {
return (
this.modelValue?.[this.labelKey]
|| this.$showDictLabel(this.scopedOptions, this.modelValue)
|| ''
|| this.$showDictLabel(this.scopedOptions, this.modelValue)
|| ''
)
},
},
Expand Down
12 changes: 6 additions & 6 deletions src/pages.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,20 @@
"backgroundColor": "#F8F8F8",
"list": [
{
"iconPath": "static/tabbar/tab-home.png",
"selectedIconPath": "static/tabbar/tab-home-active.png",
"iconPath": "static/tabbar/home.png",
"selectedIconPath": "static/tabbar/home-active.png",
"pagePath": "pages/index/home/index",
"text": "主页"
},
{
"iconPath": "static/tabbar/tab-example.png",
"selectedIconPath": "static/tabbar/tab-example-active.png",
"iconPath": "static/tabbar/example.png",
"selectedIconPath": "static/tabbar/example-active.png",
"pagePath": "pages/index/example/index",
"text": "示例"
},
{
"iconPath": "static/tabbar/tab-personal.png",
"selectedIconPath": "static/tabbar/tab-personal-active.png",
"iconPath": "static/tabbar/personal.png",
"selectedIconPath": "static/tabbar/personal-active.png",
"pagePath": "pages/index/personal/index",
"text": "我的"
}
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
6 changes: 3 additions & 3 deletions src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ export function fuzzyQuery(list, keyWord, { keyName = '' } = {}) {
* 解构对象属性为可响应的计算属性
* @param values 为对象时 对象的值作为计算属性的替换键名
* @param {string} sourcePath 默认值为 '$Route.query'
* @returns {object} Computeds
* @returns {object} Computed List
*/
export function mapComputed(keys = [], sourcePath = '$Route.query') {
const arr = Array.isArray(keys)
? keys.map(name => [name, name])
: Object.entries(keys)
const computeds = arr.reduce((obj, [name, replaceName]) => {
const computedList = arr.reduce((obj, [name, replaceName]) => {
if (!replaceName)
replaceName = name
const formatPath = [...sourcePath.split('.'), name].join('.')
Expand All @@ -46,7 +46,7 @@ export function mapComputed(keys = [], sourcePath = '$Route.query') {
}
return obj
}, {})
return computeds
return computedList
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/utils/uni-router/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isH5 } from '@uni-helper/uni-env'
import { createRouter as _createRouter } from 'uniapp-router-next'
import { createRouter as createRouterRaw } from 'uniapp-router-next'
import { aliasTransformer, resolvePages } from './helper.js'
import { homePage } from '@/configs/index.js'

Expand All @@ -18,7 +18,7 @@ export function createRouter({ pages, addRoutes = [], ...options } = {}) {

// console.log('createRouter.routes', routes)

const router = _createRouter({
const router = createRouterRaw({
...options,
platform: process.env.UNI_PLATFORM,
routes,
Expand Down

0 comments on commit 3b66faf

Please sign in to comment.