Compare commits
21 Commits
main
...
base-sard-
Author | SHA1 | Date | |
---|---|---|---|
![]() |
78fbe6557e | ||
![]() |
127bd8abc0 | ||
![]() |
d3054a906e | ||
![]() |
2b5afd6581 | ||
![]() |
7158f558d5 | ||
![]() |
7674604042 | ||
![]() |
980b2c95e1 | ||
![]() |
94c51bcd2a | ||
![]() |
f500c48482 | ||
![]() |
6c80163673 | ||
![]() |
e6a0997c2e | ||
![]() |
1eb4cab66f | ||
![]() |
749ff30f80 | ||
![]() |
4a5d8f9cb8 | ||
![]() |
5c18e0e8ec | ||
![]() |
668ff750b2 | ||
![]() |
1272f9bd8f | ||
![]() |
f6c7a27bcb | ||
![]() |
ca04b37b6b | ||
![]() |
3c09e54b9a | ||
![]() |
2f7c60856b |
31
.github/release.yml
vendored
31
.github/release.yml
vendored
@ -1,31 +0,0 @@
|
||||
categories:
|
||||
- title: 🚀 新功能
|
||||
labels: [feat, feature]
|
||||
- title: 🛠️ 修复
|
||||
labels: [fix, bugfix]
|
||||
- title: 💅 样式
|
||||
labels: [style]
|
||||
- title: 📄 文档
|
||||
labels: [docs]
|
||||
- title: ⚡️ 性能
|
||||
labels: [perf]
|
||||
- title: 🧪 测试
|
||||
labels: [test]
|
||||
- title: ♻️ 重构
|
||||
labels: [refactor]
|
||||
- title: 📦 构建
|
||||
labels: [build]
|
||||
- title: 🚨 补丁
|
||||
labels: [patch, hotfix]
|
||||
- title: 🌐 发布
|
||||
labels: [release, publish]
|
||||
- title: 🔧 流程
|
||||
labels: [ci, cd, workflow]
|
||||
- title: ⚙️ 配置
|
||||
labels: [config, chore]
|
||||
- title: 📁 文件
|
||||
labels: [file]
|
||||
- title: 🎨 格式化
|
||||
labels: [format]
|
||||
- title: 🔀 其他
|
||||
labels: [other, misc]
|
80
.github/workflows/auto-merge.yml
vendored
80
.github/workflows/auto-merge.yml
vendored
@ -1,80 +0,0 @@
|
||||
name: Auto Merge Main to Other Branches
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch: # 手动触发
|
||||
|
||||
jobs:
|
||||
merge-to-i18n:
|
||||
name: Merge main into i18n
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GH_TOKEN_AUTO_MERGE }}
|
||||
|
||||
- name: Merge main into i18n
|
||||
run: |
|
||||
git config user.name "GitHub Actions"
|
||||
git config user.email "actions@github.com"
|
||||
git checkout i18n
|
||||
git merge main --no-ff -m "Auto merge main into i18n"
|
||||
git push origin i18n
|
||||
|
||||
merge-to-base-sard-ui:
|
||||
name: Merge main into base-sard-ui
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GH_TOKEN_AUTO_MERGE }}
|
||||
|
||||
- name: Merge main into base-sard-ui
|
||||
run: |
|
||||
git config user.name "GitHub Actions"
|
||||
git config user.email "actions@github.com"
|
||||
git checkout base-sard-ui
|
||||
git merge main --no-ff -m "Auto merge main into base-sard-ui"
|
||||
git push origin base-sard-ui
|
||||
|
||||
merge-to-base-uv-ui:
|
||||
name: Merge main into base-uv-ui
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GH_TOKEN_AUTO_MERGE }}
|
||||
|
||||
- name: Merge main into base-uv-ui
|
||||
run: |
|
||||
git config user.name "GitHub Actions"
|
||||
git config user.email "actions@github.com"
|
||||
git checkout base-uv-ui
|
||||
git merge main --no-ff -m "Auto merge main into base-uv-ui"
|
||||
git push origin base-uv-ui
|
||||
|
||||
merge-to-base-uview-plus:
|
||||
name: Merge main into base-uview-plus
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GH_TOKEN_AUTO_MERGE }}
|
||||
|
||||
- name: Merge main into base-uview-plus
|
||||
run: |
|
||||
git config user.name "GitHub Actions"
|
||||
git config user.email "actions@github.com"
|
||||
git checkout base-uview-plus
|
||||
git merge main --no-ff -m "Auto merge main into base-uview-plus"
|
||||
git push origin base-uview-plus
|
119
.github/workflows/release-log.yml
vendored
119
.github/workflows/release-log.yml
vendored
@ -1,119 +0,0 @@
|
||||
name: Auto Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: read
|
||||
issues: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Install yq
|
||||
run: sudo snap install yq
|
||||
|
||||
- name: Generate changelog
|
||||
id: changelog
|
||||
env:
|
||||
CONFIG_FILE: .github/release.yml
|
||||
run: |
|
||||
# 解析配置文件
|
||||
declare -A category_map
|
||||
while IFS=";" read -r title labels; do
|
||||
for label in $labels; do
|
||||
category_map[$label]="$title"
|
||||
done
|
||||
done < <(yq -o=tsv '.categories[] | [.title, (.labels | join(" "))] | join(";")' $CONFIG_FILE)
|
||||
# 获取版本范围
|
||||
mapfile -t tags < <(git tag -l --sort=-version:refname)
|
||||
current_tag=${tags[0]}
|
||||
previous_tag=${tags[1]:-}
|
||||
if [[ -z "$previous_tag" ]]; then
|
||||
commit_range="$current_tag"
|
||||
echo "首次发布版本: $current_tag"
|
||||
else
|
||||
commit_range="$previous_tag..$current_tag"
|
||||
echo "版本范围: $commit_range"
|
||||
fi
|
||||
# 获取所有符合规范的提交
|
||||
commits=$(git log --pretty=format:"%s|%h" "$commit_range")
|
||||
# 生成分类日志
|
||||
declare -A log_entries
|
||||
while IFS="|" read -r subject hash; do
|
||||
# type=$(echo "$subject" | cut -d':' -f1 | tr -d ' ')
|
||||
type=$(echo "$subject" | sed -E 's/^([[:alnum:]]+)(\(.*\))?:.*/\1/' | tr -d ' ')
|
||||
found=0
|
||||
for label in "${!category_map[@]}"; do
|
||||
if [[ "$type" == "$label" ]]; then
|
||||
entry="- ${subject} (${hash:0:7})"
|
||||
log_entries[${category_map[$label]}]+="$entry"$'\n'
|
||||
found=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ $found -eq 0 ]]; then
|
||||
entry="- ${subject} (${hash:0:7})"
|
||||
log_entries["其他"]+="$entry"$'\n'
|
||||
fi
|
||||
done <<< "$commits"
|
||||
|
||||
# 统计提交数量
|
||||
commit_count=$(git log --oneline "$commit_range" | wc -l)
|
||||
# 统计受影响的文件数量
|
||||
file_count=$(git diff --name-only "$commit_range" | wc -l)
|
||||
# 统计贡献者信息
|
||||
contributor_stats=$(git shortlog -sn "$commit_range")
|
||||
contributor_notes=""
|
||||
while IFS= read -r line; do
|
||||
commits=$(echo "$line" | awk '{print $1}')
|
||||
name=$(echo "$line" | awk '{$1=""; print $0}' | sed 's/^ //')
|
||||
contributor_notes+="- @${name} (${commits} commits)\n"
|
||||
done <<< "$contributor_stats"
|
||||
# 构建输出内容
|
||||
release_notes="## 版本更新日志 ($current_tag)\n\n"
|
||||
while IFS= read -r category; do
|
||||
if [[ -n "${log_entries[$category]}" ]]; then
|
||||
release_notes+="### $category\n${log_entries[$category]}\n"
|
||||
fi
|
||||
done < <(yq '.categories[].title' $CONFIG_FILE)
|
||||
# 构建输出内容
|
||||
release_notes="## 版本更新日志 ($current_tag)\n\n"
|
||||
current_date=$(date +"%Y-%m-%d")
|
||||
# 添加发布日期和下载统计信息
|
||||
release_notes+=" ### 📅 发布日期: ${current_date}\n"
|
||||
while IFS= read -r category; do
|
||||
if [[ -n "${log_entries[$category]}" ]]; then
|
||||
release_notes+="### $category\n${log_entries[$category]}\n"
|
||||
fi
|
||||
done < <(yq '.categories[].title' $CONFIG_FILE)
|
||||
|
||||
# 添加统计信息
|
||||
release_notes+="### 📊 统计信息\n"
|
||||
release_notes+="- 本次发布包含 ${commit_count} 个提交\n"
|
||||
release_notes+="- 影响 ${file_count} 个文件\n\n"
|
||||
# 添加贡献者信息
|
||||
release_notes+="### 👥 贡献者\n"
|
||||
release_notes+="感谢这些优秀的贡献者(按提交次数排序):\n"
|
||||
release_notes+="${contributor_notes}\n"
|
||||
release_notes+="---\n"
|
||||
# 写入文件
|
||||
echo -e "$release_notes" > changelog.md
|
||||
echo "生成日志内容:"
|
||||
cat changelog.md
|
||||
- name: Create Release
|
||||
uses: ncipollo/release-action@v1
|
||||
with:
|
||||
generateReleaseNotes: false
|
||||
bodyFile: changelog.md
|
||||
tag: ${{ github.ref_name }}
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "unibest",
|
||||
"type": "commonjs",
|
||||
"version": "3.1.0",
|
||||
"version": "3.0.0",
|
||||
"description": "unibest - 最好的 uniapp 开发模板",
|
||||
"update-time": "2025-06-21",
|
||||
"author": {
|
||||
@ -98,8 +98,9 @@
|
||||
"js-cookie": "^3.0.5",
|
||||
"pinia": "2.0.36",
|
||||
"pinia-plugin-persistedstate": "3.2.1",
|
||||
"qs": "6.5.3",
|
||||
"sard-uniapp": "^1.17.1",
|
||||
"vue": "^3.4.21",
|
||||
"wot-design-uni": "^1.9.1",
|
||||
"z-paging": "2.8.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -13,7 +13,7 @@ export default defineUniPages({
|
||||
autoscan: true,
|
||||
custom: {
|
||||
'^fg-(.*)': '@/components/fg-$1/fg-$1.vue',
|
||||
'^wd-(.*)': 'wot-design-uni/components/wd-$1/wd-$1.vue',
|
||||
'^sar-(.*)': 'sard-uniapp/components/$1/$1.vue',
|
||||
'^(?!z-paging-refresh|z-paging-load-more)z-paging(.*)':
|
||||
'z-paging/components/z-paging$1/z-paging$1.vue',
|
||||
},
|
||||
|
7281
pnpm-lock.yaml
generated
7281
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -17,6 +17,8 @@ onHide(() => {
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
@import 'sard-uniapp/index.scss';
|
||||
/* stylelint-disable selector-type-no-unknown */
|
||||
button::after {
|
||||
border: none;
|
||||
}
|
||||
|
@ -1,58 +0,0 @@
|
||||
<script lang="ts" setup>
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
leftText?: string
|
||||
rightText?: string
|
||||
leftArrow?: boolean
|
||||
bordered?: boolean
|
||||
fixed?: boolean
|
||||
placeholder?: boolean
|
||||
zIndex?: number
|
||||
safeAreaInsetTop?: boolean
|
||||
leftDisabled?: boolean
|
||||
rightDisabled?: boolean
|
||||
}>(),
|
||||
{
|
||||
leftText: '返回',
|
||||
rightText: '',
|
||||
leftArrow: true,
|
||||
bordered: true,
|
||||
fixed: false,
|
||||
placeholder: true,
|
||||
zIndex: 1,
|
||||
safeAreaInsetTop: true,
|
||||
leftDisabled: false,
|
||||
rightDisabled: false,
|
||||
},
|
||||
)
|
||||
|
||||
function handleClickLeft() {
|
||||
uni.navigateBack({
|
||||
fail() {
|
||||
uni.reLaunch({
|
||||
url: '/pages/index/index',
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<wd-navbar
|
||||
:left-text="leftText"
|
||||
:right-text="rightText"
|
||||
:left-arrow="leftArrow"
|
||||
:bordered="bordered"
|
||||
:fixed="fixed"
|
||||
:placeholder="placeholder"
|
||||
:z-index="zIndex"
|
||||
:safe-area-inset-top="safeAreaInsetTop"
|
||||
:left-disabled="leftDisabled"
|
||||
:right-disabled="rightDisabled"
|
||||
@click-left="handleClickLeft"
|
||||
>
|
||||
<template #title>
|
||||
<slot />
|
||||
</template>
|
||||
</wd-navbar>
|
||||
</template>
|
@ -1,7 +1,7 @@
|
||||
import qs from 'qs'
|
||||
import { useUserStore } from '@/store'
|
||||
import { getEnvBaseUrl } from '@/utils'
|
||||
import { platform } from '@/utils/platform'
|
||||
import { stringifyQuery } from '@/utils/queryString'
|
||||
|
||||
export type CustomRequestOptions = UniApp.RequestOptions & {
|
||||
query?: Record<string, any>
|
||||
@ -18,7 +18,7 @@ const httpInterceptor = {
|
||||
invoke(options: CustomRequestOptions) {
|
||||
// 接口请求支持通过 query 参数配置 queryString
|
||||
if (options.query) {
|
||||
const queryStr = stringifyQuery(options.query)
|
||||
const queryStr = qs.stringify(options.query)
|
||||
if (options.url.includes('?')) {
|
||||
options.url += `&${queryStr}`
|
||||
}
|
||||
|
@ -1,17 +1,7 @@
|
||||
<script lang="ts" setup>
|
||||
import type { ConfigProviderThemeVars } from 'wot-design-uni'
|
||||
|
||||
const themeVars: ConfigProviderThemeVars = {
|
||||
// colorTheme: 'red',
|
||||
// buttonPrimaryBgColor: '#07c160',
|
||||
// buttonPrimaryColor: '#07c160',
|
||||
}
|
||||
</script>
|
||||
<script lang="ts" setup></script>
|
||||
|
||||
<template>
|
||||
<wd-config-provider :theme-vars="themeVars">
|
||||
<div>
|
||||
<slot />
|
||||
<wd-toast />
|
||||
<wd-message-box />
|
||||
</wd-config-provider>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -1,17 +1,7 @@
|
||||
<script lang="ts" setup>
|
||||
import type { ConfigProviderThemeVars } from 'wot-design-uni'
|
||||
|
||||
const themeVars: ConfigProviderThemeVars = {
|
||||
// colorTheme: 'red',
|
||||
// buttonPrimaryBgColor: '#07c160',
|
||||
// buttonPrimaryColor: '#07c160',
|
||||
}
|
||||
</script>
|
||||
<script lang="ts" setup></script>
|
||||
|
||||
<template>
|
||||
<wd-config-provider :theme-vars="themeVars">
|
||||
<div>
|
||||
<slot />
|
||||
<wd-toast />
|
||||
<wd-message-box />
|
||||
</wd-config-provider>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -7,9 +7,9 @@ import { tabbarList as _tabBarList, cacheTabbarEnable, selectedTabbarStrategy }
|
||||
const customTabbarEnable = selectedTabbarStrategy === 1 || selectedTabbarStrategy === 2
|
||||
/** tabbarList 里面的 path 从 pages.config.ts 得到 */
|
||||
const tabbarList = _tabBarList.map(item => ({ ...item, path: `/${item.pagePath}` }))
|
||||
function selectTabBar({ value: index }: { value: number }) {
|
||||
const url = tabbarList[index].path
|
||||
tabbarStore.setCurIdx(index)
|
||||
function selectTabBar(name: number) {
|
||||
const url = tabbarList[name].path
|
||||
tabbarStore.setCurIdx(name)
|
||||
if (cacheTabbarEnable) {
|
||||
uni.switchTab({ url })
|
||||
}
|
||||
@ -34,9 +34,9 @@ onLoad(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<wd-tabbar
|
||||
<sar-tabbar
|
||||
v-if="customTabbarEnable"
|
||||
v-model="tabbarStore.curIdx"
|
||||
v-model:current="tabbarStore.curIdx"
|
||||
bordered
|
||||
safeareainsetbottom
|
||||
placeholder
|
||||
@ -44,10 +44,17 @@ onLoad(() => {
|
||||
@change="selectTabBar"
|
||||
>
|
||||
<block v-for="(item, idx) in tabbarList" :key="item.path">
|
||||
<wd-tabbar-item v-if="item.iconType === 'uiLib'" :title="item.text" :icon="item.icon" />
|
||||
<wd-tabbar-item
|
||||
<sar-tabbar-item
|
||||
v-if="item.iconType === 'uiLib'"
|
||||
:text="item.text"
|
||||
:icon="item.icon"
|
||||
:name="idx"
|
||||
/>
|
||||
|
||||
<sar-tabbar-item
|
||||
v-else-if="item.iconType === 'unocss' || item.iconType === 'iconfont'"
|
||||
:title="item.text"
|
||||
:text="item.text"
|
||||
:name="idx"
|
||||
>
|
||||
<template #icon>
|
||||
<view
|
||||
@ -56,12 +63,12 @@ onLoad(() => {
|
||||
:class="[item.icon, idx === tabbarStore.curIdx ? 'is-active' : 'is-inactive']"
|
||||
/>
|
||||
</template>
|
||||
</wd-tabbar-item>
|
||||
<wd-tabbar-item v-else-if="item.iconType === 'local'" :title="item.text">
|
||||
</sar-tabbar-item>
|
||||
<sar-tabbar-item v-else-if="item.iconType === 'local'" :text="item.text" :name="idx">
|
||||
<template #icon>
|
||||
<image :src="item.icon" h-40rpx w-40rpx />
|
||||
</template>
|
||||
</wd-tabbar-item>
|
||||
</sar-tabbar-item>
|
||||
</block>
|
||||
</wd-tabbar>
|
||||
</sar-tabbar>
|
||||
</template>
|
||||
|
@ -23,7 +23,7 @@ export const tabbarList = [
|
||||
selectedIconPath: 'static/tabbar/homeHL.png',
|
||||
pagePath: 'pages/index/index',
|
||||
text: '首页',
|
||||
icon: 'home',
|
||||
icon: 'image',
|
||||
iconType: 'uiLib',
|
||||
},
|
||||
{
|
||||
|
@ -1,19 +1,10 @@
|
||||
<script lang="ts" setup>
|
||||
import type { ConfigProviderThemeVars } from 'wot-design-uni'
|
||||
import FgTabbar from './fg-tabbar/fg-tabbar.vue'
|
||||
|
||||
const themeVars: ConfigProviderThemeVars = {
|
||||
// colorTheme: 'red',
|
||||
// buttonPrimaryBgColor: '#07c160',
|
||||
// buttonPrimaryColor: '#07c160',
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<wd-config-provider :theme-vars="themeVars">
|
||||
<view>
|
||||
<slot />
|
||||
<FgTabbar />
|
||||
<wd-toast />
|
||||
<wd-message-box />
|
||||
</wd-config-provider>
|
||||
</view>
|
||||
</template>
|
||||
|
@ -10,7 +10,7 @@
|
||||
"autoscan": true,
|
||||
"custom": {
|
||||
"^fg-(.*)": "@/components/fg-$1/fg-$1.vue",
|
||||
"^wd-(.*)": "wot-design-uni/components/wd-$1/wd-$1.vue",
|
||||
"^sar-(.*)": "sard-uniapp/components/$1/$1.vue",
|
||||
"^(?!z-paging-refresh|z-paging-load-more)z-paging(.*)": "z-paging/components/z-paging$1/z-paging$1.vue"
|
||||
}
|
||||
},
|
||||
@ -29,7 +29,7 @@
|
||||
"selectedIconPath": "static/tabbar/homeHL.png",
|
||||
"pagePath": "pages/index/index",
|
||||
"text": "首页",
|
||||
"icon": "home",
|
||||
"icon": "image",
|
||||
"iconType": "uiLib"
|
||||
},
|
||||
{
|
||||
|
@ -61,9 +61,9 @@ function reset() {
|
||||
<!-- #endif -->
|
||||
|
||||
<!-- http://localhost:9000/#/pages/index/request -->
|
||||
<wd-button class="my-6" @click="run">
|
||||
<sar-button class="my-6" @click="run">
|
||||
发送请求
|
||||
</wd-button>
|
||||
</sar-button>
|
||||
<view class="h-16">
|
||||
<view v-if="loading">
|
||||
loading...
|
||||
@ -77,8 +77,8 @@ function reset() {
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
<wd-button type="error" class="my-6" :disabled="!data" @click="reset">
|
||||
<sar-button theme="danger" class="my-6" :disabled="!data" @click="reset">
|
||||
重置数据
|
||||
</wd-button>
|
||||
</sar-button>
|
||||
</view>
|
||||
</template>
|
||||
|
@ -13,9 +13,9 @@ const { loading, data, run } = useUpload()
|
||||
|
||||
<template>
|
||||
<view class="p-4 text-center">
|
||||
<wd-button @click="run">
|
||||
<sar-button @click="run">
|
||||
选择图片并上传
|
||||
</wd-button>
|
||||
</sar-button>
|
||||
<view v-if="loading" class="h-10 text-blue">
|
||||
上传...
|
||||
</view>
|
||||
|
@ -56,7 +56,7 @@ console.log('index')
|
||||
<view class="mt-10">
|
||||
<image src="/static/logo.svg" alt="" class="mx-auto block h-28 w-28" />
|
||||
</view>
|
||||
<view class="mt-4 text-center text-4xl text-[#d14328]">
|
||||
<view class="main-title-color mt-4 text-center text-4xl">
|
||||
unibest
|
||||
</view>
|
||||
<view class="mb-8 mt-2 text-center text-2xl">
|
||||
@ -88,7 +88,7 @@ console.log('index')
|
||||
<view class="mt-4 text-center">
|
||||
模板分支是:
|
||||
<text class="text-green-500">
|
||||
base
|
||||
base-sard-ui
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
|
@ -1,29 +0,0 @@
|
||||
/**
|
||||
* 将对象序列化为URL查询字符串,用于替代第三方的 qs 库,节省宝贵的体积
|
||||
* 支持基本类型值和数组,不支持嵌套对象
|
||||
* @param obj 要序列化的对象
|
||||
* @returns 序列化后的查询字符串
|
||||
*/
|
||||
export function stringifyQuery(obj: Record<string, any>): string {
|
||||
if (!obj || typeof obj !== 'object' || Array.isArray(obj))
|
||||
return ''
|
||||
|
||||
return Object.entries(obj)
|
||||
.filter(([_, value]) => value !== undefined && value !== null)
|
||||
.map(([key, value]) => {
|
||||
// 对键进行编码
|
||||
const encodedKey = encodeURIComponent(key)
|
||||
|
||||
// 处理数组类型
|
||||
if (Array.isArray(value)) {
|
||||
return value
|
||||
.filter(item => item !== undefined && item !== null)
|
||||
.map(item => `${encodedKey}=${encodeURIComponent(item)}`)
|
||||
.join('&')
|
||||
}
|
||||
|
||||
// 处理基本类型
|
||||
return `${encodedKey}=${encodeURIComponent(value)}`
|
||||
})
|
||||
.join('&')
|
||||
}
|
@ -14,7 +14,7 @@
|
||||
"@dcloudio/types",
|
||||
"@uni-helper/uni-types",
|
||||
"@types/wechat-miniprogram",
|
||||
"wot-design-uni/global.d.ts",
|
||||
"sard-uniapp/global",
|
||||
"z-paging/types",
|
||||
"./src/typings.d.ts"
|
||||
],
|
||||
|
@ -182,5 +182,8 @@ export default async ({ command, mode }) => {
|
||||
},
|
||||
},
|
||||
},
|
||||
optimizeDeps: {
|
||||
exclude: ['sard-uniapp'],
|
||||
},
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user