Compare commits
267 Commits
v2.12.1-ox
...
main
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0dd0cab15d | ||
![]() |
02d8fb1268 | ||
![]() |
ee8fc19a47 | ||
![]() |
dd11e45d5f | ||
![]() |
8455f09e8c | ||
![]() |
edefc99702 | ||
![]() |
946ad7c976 | ||
![]() |
cfe5634c91 | ||
![]() |
2000eda414 | ||
![]() |
69b7429909 | ||
![]() |
926d700b60 | ||
![]() |
f0cd8ee943 | ||
![]() |
67f76415e1 | ||
![]() |
e67da2203c | ||
![]() |
cb033104ee | ||
![]() |
28e59cd599 | ||
![]() |
1af7213e96 | ||
![]() |
d5c14ac3ae | ||
![]() |
27d4441ca6 | ||
![]() |
ea50a639ed | ||
![]() |
e171c29d28 | ||
![]() |
ae515cd85e | ||
![]() |
e1654359fd | ||
![]() |
32cf872405 | ||
![]() |
c355f6e8f1 | ||
![]() |
227f19a93c | ||
![]() |
9cf0c212bf | ||
![]() |
79c333e647 | ||
![]() |
9c074652e1 | ||
![]() |
6402f8825f | ||
![]() |
4fc50a6bb5 | ||
![]() |
28d8000ad8 | ||
![]() |
144dec8881 | ||
![]() |
e2c319079a | ||
![]() |
1efb68cb9b | ||
![]() |
ba7252c332 | ||
![]() |
548b0515f6 | ||
![]() |
b03f7ee310 | ||
![]() |
e2eda79403 | ||
![]() |
2a97bf0aaa | ||
![]() |
f8641457ad | ||
![]() |
407bc849ec | ||
![]() |
38328280c4 | ||
![]() |
d2f7b5e1ec | ||
![]() |
7b3e757301 | ||
![]() |
2a71d02ab8 | ||
![]() |
4b77ca6c13 | ||
![]() |
21234cdbe2 | ||
![]() |
5250fac0a1 | ||
![]() |
91faa0f301 | ||
![]() |
13ebc5aacc | ||
![]() |
d86bfa719d | ||
![]() |
72c261ef67 | ||
![]() |
a7671ce4a9 | ||
![]() |
de32f4515f | ||
![]() |
74e52f000a | ||
![]() |
7bd338e07c | ||
![]() |
119edac05a | ||
![]() |
f93ed08cb2 | ||
![]() |
393c37bd56 | ||
![]() |
7a1ae5b0f3 | ||
![]() |
c47564e51a | ||
![]() |
7a2e870641 | ||
![]() |
3b7688a20b | ||
![]() |
e2c0ac4721 | ||
![]() |
11c6f158d0 | ||
![]() |
9ef3b7d7d4 | ||
![]() |
4f67168494 | ||
![]() |
bf61c3d1f0 | ||
![]() |
9a34868fb7 | ||
![]() |
fe751745e5 | ||
![]() |
29f526242d | ||
![]() |
ba8c0a2e7f | ||
![]() |
33638c5a9e | ||
![]() |
6a7ece9b3f | ||
![]() |
47d8401c47 | ||
![]() |
11b7880810 | ||
![]() |
c1b12eab84 | ||
![]() |
136fb5d507 | ||
![]() |
4445e18b02 | ||
![]() |
7dd210e427 | ||
![]() |
2f2a14cd06 | ||
![]() |
3eb06627c2 | ||
![]() |
c6d4a46968 | ||
![]() |
09e048ba85 | ||
![]() |
968a090876 | ||
![]() |
39f4ba793d | ||
![]() |
ea2f3a6990 | ||
![]() |
f6208a191d | ||
![]() |
23cd9a522e | ||
![]() |
f2119f3f73 | ||
![]() |
61a2fd8a27 | ||
![]() |
3808f515cf | ||
![]() |
61bb8363cd | ||
![]() |
bd64215f86 | ||
![]() |
a4d366c01e | ||
![]() |
8f711caada | ||
![]() |
3a2b4febd2 | ||
![]() |
da79ac04e6 | ||
![]() |
95dbb93256 | ||
![]() |
6996037cd4 | ||
![]() |
cc886bd326 | ||
![]() |
c1200eabe8 | ||
![]() |
0864bc9e3f | ||
![]() |
26d49ac5bc | ||
![]() |
907c20d9d8 | ||
![]() |
25fb9705cc | ||
![]() |
4efb14cbff | ||
![]() |
0723fb178b | ||
![]() |
6866c17184 | ||
![]() |
1558430435 | ||
![]() |
6da7d46913 | ||
![]() |
5f97a3ff8a | ||
![]() |
12b9384df6 | ||
![]() |
1f3749d08d | ||
![]() |
2c566253f3 | ||
![]() |
28fad4a480 | ||
![]() |
8233556683 | ||
![]() |
8464a040ab | ||
![]() |
0d42825314 | ||
![]() |
8a434fa761 | ||
![]() |
b286d07623 | ||
![]() |
9dcea8189e | ||
![]() |
d5a3772b3a | ||
![]() |
3bf7fcb844 | ||
![]() |
7b61242611 | ||
![]() |
51d399f38b | ||
![]() |
e79ae9a17f | ||
![]() |
3f08e45e06 | ||
![]() |
a0a2106fe7 | ||
![]() |
291be04925 | ||
![]() |
81a1e8e42d | ||
![]() |
3e604e3c7f | ||
![]() |
bb0a57bd1f | ||
![]() |
22ce0f481d | ||
![]() |
d76a5baad9 | ||
![]() |
667e0647c4 | ||
![]() |
0042afe215 | ||
![]() |
b857669c0c | ||
![]() |
b454473591 | ||
![]() |
91d66fda51 | ||
![]() |
6777d20d41 | ||
![]() |
1905a3f8bb | ||
![]() |
54105b9968 | ||
![]() |
d980dbb97a | ||
![]() |
c594222abd | ||
![]() |
53d68c10a0 | ||
![]() |
b5cd1319c0 | ||
![]() |
b6fbf54c1c | ||
![]() |
d35fabd893 | ||
![]() |
6673c2e269 | ||
![]() |
a57d4c08b3 | ||
![]() |
cb33ed7a00 | ||
![]() |
efe570c8c9 | ||
![]() |
3c398ab101 | ||
![]() |
aed4b934ed | ||
![]() |
56bfdfaf70 | ||
![]() |
2959974f86 | ||
![]() |
085a1d73a2 | ||
![]() |
7f80ded4c2 | ||
![]() |
639c2a0e75 | ||
![]() |
3c7701d21b | ||
![]() |
5952515ac7 | ||
![]() |
13c3e78cc6 | ||
![]() |
e5103ddb7a | ||
![]() |
ac2128bb76 | ||
![]() |
5b55e01089 | ||
![]() |
e57853fda0 | ||
![]() |
16c27345ed | ||
![]() |
c214a15bb7 | ||
![]() |
24b43088a9 | ||
![]() |
1ee3d06ed8 | ||
![]() |
5144ceabd1 | ||
![]() |
7eb4c23116 | ||
![]() |
53ebadf0a2 | ||
![]() |
8c1dda51ed | ||
![]() |
637ca983cf | ||
![]() |
1b61a262da | ||
![]() |
6fe2b888e4 | ||
![]() |
003e8685a4 | ||
![]() |
7eab089118 | ||
![]() |
cd130de1cf | ||
![]() |
988cf6aa53 | ||
![]() |
7afa74d381 | ||
![]() |
1bec786aaa | ||
![]() |
46ae55c73c | ||
![]() |
0865a33ad4 | ||
![]() |
f01b98693e | ||
![]() |
8b357ab8c5 | ||
![]() |
7f41078fa0 | ||
![]() |
e4571097c8 | ||
![]() |
dec635a59d | ||
![]() |
5823f89e5f | ||
![]() |
d20f359769 | ||
![]() |
18d52a8e48 | ||
![]() |
3b2395da26 | ||
![]() |
12aae659fe | ||
![]() |
45744d412e | ||
![]() |
4b7a28fe97 | ||
![]() |
c1ed654ff3 | ||
![]() |
bb30afe1b6 | ||
![]() |
4ebc32dd3b | ||
![]() |
b1bfd0d336 | ||
![]() |
208f2395a6 | ||
![]() |
a616867641 | ||
![]() |
bde0332183 | ||
![]() |
588c3a446f | ||
![]() |
a9d3eccad5 | ||
![]() |
01679809b8 | ||
![]() |
a4fd81d2a8 | ||
![]() |
7ab753ee8d | ||
![]() |
e20b84c8d5 | ||
![]() |
77020a13a0 | ||
![]() |
79bbc09850 | ||
![]() |
556f9052d1 | ||
![]() |
3e2cc7be81 | ||
![]() |
5871cb5fd8 | ||
![]() |
3a088be68b | ||
![]() |
eab3de02fd | ||
![]() |
7e26a71db8 | ||
![]() |
8bf7145752 | ||
![]() |
fd1102b425 | ||
![]() |
005d2406ab | ||
![]() |
fbd6343b2b | ||
![]() |
b11b17ec40 | ||
![]() |
9736931bfd | ||
![]() |
85c34bc922 | ||
![]() |
70801959ea | ||
![]() |
aa758845f6 | ||
![]() |
c6eccbfa19 | ||
![]() |
3ae09fc804 | ||
![]() |
695486e41f | ||
![]() |
7cf16d608c | ||
![]() |
0d948a0691 | ||
![]() |
50cb3419c2 | ||
![]() |
7271f3c618 | ||
![]() |
d6c6022a18 | ||
![]() |
84d4607b2a | ||
![]() |
4f6d271c28 | ||
![]() |
ee52ae132d | ||
![]() |
de8df540c2 | ||
![]() |
6d4bb21f52 | ||
![]() |
ffa5c68e66 | ||
![]() |
5eadda62de | ||
![]() |
041403f5d8 | ||
![]() |
137fa5846b | ||
![]() |
ffc37d9030 | ||
![]() |
7e3ab3ca19 | ||
![]() |
cdae57adce | ||
![]() |
39007ec045 | ||
![]() |
d4935d1186 | ||
![]() |
12acce4575 | ||
![]() |
3f15da98de | ||
![]() |
fb4a6e7bec | ||
![]() |
6cdb56bb12 | ||
![]() |
e7d0a685d4 | ||
![]() |
c3debbb636 | ||
![]() |
a7c3dbaea2 | ||
![]() |
c032fe5a1e | ||
![]() |
6a018d89be | ||
![]() |
cc716a1e0c | ||
![]() |
be35efd530 | ||
![]() |
37b52d1243 | ||
![]() |
4770817fdc | ||
![]() |
3a12eb35eb | ||
![]() |
01916970e8 | ||
![]() |
ee43df4fa6 |
@ -1,106 +1,3 @@
|
|||||||
const fs = require('fs')
|
|
||||||
const path = require('path')
|
|
||||||
const { execSync } = require('child_process')
|
|
||||||
|
|
||||||
const scopes = fs
|
|
||||||
.readdirSync(path.resolve(__dirname, 'src'), { withFileTypes: true })
|
|
||||||
.filter((dirent) => dirent.isDirectory())
|
|
||||||
.map((dirent) => dirent.name.replace(/s$/, ''))
|
|
||||||
|
|
||||||
// precomputed scope
|
|
||||||
const scopeComplete = execSync('git status --porcelain || true')
|
|
||||||
.toString()
|
|
||||||
.trim()
|
|
||||||
.split('\n')
|
|
||||||
.find((r) => ~r.indexOf('M src'))
|
|
||||||
?.replace(/(\/)/g, '%%')
|
|
||||||
?.match(/src%%((\w|-)*)/)?.[1]
|
|
||||||
?.replace(/s$/, '')
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
ignores: [(commit) => commit.includes('init')],
|
|
||||||
extends: ['@commitlint/config-conventional'],
|
extends: ['@commitlint/config-conventional'],
|
||||||
rules: {
|
|
||||||
'body-leading-blank': [2, 'always'],
|
|
||||||
'footer-leading-blank': [1, 'always'],
|
|
||||||
'header-max-length': [2, 'always', 108],
|
|
||||||
'subject-empty': [2, 'never'],
|
|
||||||
'type-empty': [2, 'never'],
|
|
||||||
'subject-case': [0],
|
|
||||||
'type-enum': [
|
|
||||||
2,
|
|
||||||
'always',
|
|
||||||
[
|
|
||||||
'feat',
|
|
||||||
'fix',
|
|
||||||
'perf',
|
|
||||||
'style',
|
|
||||||
'docs',
|
|
||||||
'test',
|
|
||||||
'refactor',
|
|
||||||
'build',
|
|
||||||
'ci',
|
|
||||||
'chore',
|
|
||||||
'revert',
|
|
||||||
'wip',
|
|
||||||
'workflow',
|
|
||||||
'types',
|
|
||||||
'release',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
},
|
|
||||||
prompt: {
|
|
||||||
/** @use `pnpm commit :f` */
|
|
||||||
alias: {
|
|
||||||
f: 'docs: fix typos',
|
|
||||||
r: 'docs: update README',
|
|
||||||
s: 'style: update code format',
|
|
||||||
b: 'build: bump dependencies',
|
|
||||||
c: 'chore: update config',
|
|
||||||
},
|
|
||||||
customScopesAlign: !scopeComplete ? 'top' : 'bottom',
|
|
||||||
defaultScope: scopeComplete,
|
|
||||||
scopes: [...scopes, 'mock'],
|
|
||||||
allowEmptyIssuePrefixs: false,
|
|
||||||
allowCustomIssuePrefixs: false,
|
|
||||||
|
|
||||||
// English
|
|
||||||
typesAppend: [
|
|
||||||
{ value: 'wip', name: 'wip: work in process' },
|
|
||||||
{ value: 'workflow', name: 'workflow: workflow improvements' },
|
|
||||||
{ value: 'types', name: 'types: type definition file changes' },
|
|
||||||
],
|
|
||||||
|
|
||||||
// 中英文对照版
|
|
||||||
// messages: {
|
|
||||||
// type: '选择你要提交的类型 :',
|
|
||||||
// scope: '选择一个提交范围 (可选):',
|
|
||||||
// customScope: '请输入自定义的提交范围 :',
|
|
||||||
// subject: '填写简短精炼的变更描述 :\n',
|
|
||||||
// body: '填写更加详细的变更描述 (可选)。使用 "|" 换行 :\n',
|
|
||||||
// breaking: '列举非兼容性重大的变更 (可选)。使用 "|" 换行 :\n',
|
|
||||||
// footerPrefixsSelect: '选择关联issue前缀 (可选):',
|
|
||||||
// customFooterPrefixs: '输入自定义issue前缀 :',
|
|
||||||
// footer: '列举关联issue (可选) 例如: #31, #I3244 :\n',
|
|
||||||
// confirmCommit: '是否提交或修改commit ?',
|
|
||||||
// },
|
|
||||||
// types: [
|
|
||||||
// { value: 'feat', name: 'feat: 新增功能' },
|
|
||||||
// { value: 'fix', name: 'fix: 修复缺陷' },
|
|
||||||
// { value: 'docs', name: 'docs: 文档变更' },
|
|
||||||
// { value: 'style', name: 'style: 代码格式' },
|
|
||||||
// { value: 'refactor', name: 'refactor: 代码重构' },
|
|
||||||
// { value: 'perf', name: 'perf: 性能优化' },
|
|
||||||
// { value: 'test', name: 'test: 添加疏漏测试或已有测试改动' },
|
|
||||||
// { value: 'build', name: 'build: 构建流程、外部依赖变更 (如升级 npm 包、修改打包配置等)' },
|
|
||||||
// { value: 'ci', name: 'ci: 修改 CI 配置、脚本' },
|
|
||||||
// { value: 'revert', name: 'revert: 回滚 commit' },
|
|
||||||
// { value: 'chore', name: 'chore: 对构建过程或辅助工具和库的更改 (不影响源文件、测试用例)' },
|
|
||||||
// { value: 'wip', name: 'wip: 正在开发中' },
|
|
||||||
// { value: 'workflow', name: 'workflow: 工作流程改进' },
|
|
||||||
// { value: 'types', name: 'types: 类型定义文件修改' },
|
|
||||||
// ],
|
|
||||||
// emptyScopesAlias: 'empty: 不填写',
|
|
||||||
// customScopesAlias: 'custom: 自定义',
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
vite.config.ts
|
|
||||||
uno.config.ts
|
|
||||||
pages.config.ts
|
|
||||||
manifest.config.ts
|
|
60
.github/release.yml
vendored
60
.github/release.yml
vendored
@ -1,31 +1,31 @@
|
|||||||
categories:
|
categories:
|
||||||
- title: '🚀 新功能'
|
- title: 🚀 新功能
|
||||||
labels: ['feat', 'feature']
|
labels: [feat, feature]
|
||||||
- title: '🛠️ 修复'
|
- title: 🛠️ 修复
|
||||||
labels: ['fix', 'bugfix']
|
labels: [fix, bugfix]
|
||||||
- title: '💅 样式'
|
- title: 💅 样式
|
||||||
labels: ['style']
|
labels: [style]
|
||||||
- title: '📄 文档'
|
- title: 📄 文档
|
||||||
labels: ['docs']
|
labels: [docs]
|
||||||
- title: '⚡️ 性能'
|
- title: ⚡️ 性能
|
||||||
labels: ['perf']
|
labels: [perf]
|
||||||
- title: '🧪 测试'
|
- title: 🧪 测试
|
||||||
labels: ['test']
|
labels: [test]
|
||||||
- title: '♻️ 重构'
|
- title: ♻️ 重构
|
||||||
labels: ['refactor']
|
labels: [refactor]
|
||||||
- title: '📦 构建'
|
- title: 📦 构建
|
||||||
labels: ['build']
|
labels: [build]
|
||||||
- title: '🚨 补丁'
|
- title: 🚨 补丁
|
||||||
labels: ['patch', 'hotfix']
|
labels: [patch, hotfix]
|
||||||
- title: '🌐 发布'
|
- title: 🌐 发布
|
||||||
labels: ['release', 'publish']
|
labels: [release, publish]
|
||||||
- title: '🔧 流程'
|
- title: 🔧 流程
|
||||||
labels: ['ci', 'cd', 'workflow']
|
labels: [ci, cd, workflow]
|
||||||
- title: '⚙️ 配置'
|
- title: ⚙️ 配置
|
||||||
labels: ['config', 'chore']
|
labels: [config, chore]
|
||||||
- title: '📁 文件'
|
- title: 📁 文件
|
||||||
labels: ['file']
|
labels: [file]
|
||||||
- title: '🎨 格式化'
|
- title: 🎨 格式化
|
||||||
labels: ['format']
|
labels: [format]
|
||||||
- title: '🔀 其他'
|
- title: 🔀 其他
|
||||||
labels: ['other', 'misc']
|
labels: [other, misc]
|
||||||
|
70
.github/workflows/auto-merge.yml
vendored
70
.github/workflows/auto-merge.yml
vendored
@ -1,32 +1,14 @@
|
|||||||
name: Auto Merge Base to Other Branches
|
name: Auto Merge Main to Other Branches
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- base
|
- main
|
||||||
workflow_dispatch: # 手动触发
|
workflow_dispatch: # 手动触发
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
merge-to-main:
|
|
||||||
name: Merge base into main
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
token: ${{ secrets.GH_TOKEN_AUTO_MERGE }}
|
|
||||||
|
|
||||||
- name: Merge base into main
|
|
||||||
run: |
|
|
||||||
git config user.name "GitHub Actions"
|
|
||||||
git config user.email "actions@github.com"
|
|
||||||
git checkout main
|
|
||||||
git merge base --no-ff -m "Auto merge base into main"
|
|
||||||
git push origin main
|
|
||||||
|
|
||||||
merge-to-i18n:
|
merge-to-i18n:
|
||||||
name: Merge base into i18n
|
name: Merge main into i18n
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
@ -35,16 +17,16 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
token: ${{ secrets.GH_TOKEN_AUTO_MERGE }}
|
token: ${{ secrets.GH_TOKEN_AUTO_MERGE }}
|
||||||
|
|
||||||
- name: Merge base into i18n
|
- name: Merge main into i18n
|
||||||
run: |
|
run: |
|
||||||
git config user.name "GitHub Actions"
|
git config user.name "GitHub Actions"
|
||||||
git config user.email "actions@github.com"
|
git config user.email "actions@github.com"
|
||||||
git checkout i18n
|
git checkout i18n
|
||||||
git merge base --no-ff -m "Auto merge base into i18n"
|
git merge main --no-ff -m "Auto merge main into i18n"
|
||||||
git push origin i18n
|
git push origin i18n
|
||||||
|
|
||||||
merge-to-tabbar:
|
merge-to-base-sard-ui:
|
||||||
name: Merge base into tabbar
|
name: Merge main into base-sard-ui
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
@ -53,16 +35,16 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
token: ${{ secrets.GH_TOKEN_AUTO_MERGE }}
|
token: ${{ secrets.GH_TOKEN_AUTO_MERGE }}
|
||||||
|
|
||||||
- name: Merge base into tabbar
|
- name: Merge main into base-sard-ui
|
||||||
run: |
|
run: |
|
||||||
git config user.name "GitHub Actions"
|
git config user.name "GitHub Actions"
|
||||||
git config user.email "actions@github.com"
|
git config user.email "actions@github.com"
|
||||||
git checkout tabbar
|
git checkout base-sard-ui
|
||||||
git merge base --no-ff -m "Auto merge base into tabbar"
|
git merge main --no-ff -m "Auto merge main into base-sard-ui"
|
||||||
git push origin tabbar
|
git push origin base-sard-ui
|
||||||
|
|
||||||
merge-to-spa:
|
merge-to-base-uv-ui:
|
||||||
name: Merge base into spa
|
name: Merge main into base-uv-ui
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
@ -71,10 +53,28 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
token: ${{ secrets.GH_TOKEN_AUTO_MERGE }}
|
token: ${{ secrets.GH_TOKEN_AUTO_MERGE }}
|
||||||
|
|
||||||
- name: Merge base into spa
|
- name: Merge main into base-uv-ui
|
||||||
run: |
|
run: |
|
||||||
git config user.name "GitHub Actions"
|
git config user.name "GitHub Actions"
|
||||||
git config user.email "actions@github.com"
|
git config user.email "actions@github.com"
|
||||||
git checkout spa
|
git checkout base-uv-ui
|
||||||
git merge base --no-ff -m "Auto merge base into spa"
|
git merge main --no-ff -m "Auto merge main into base-uv-ui"
|
||||||
git push origin spa
|
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
|
||||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -27,7 +27,7 @@ dist
|
|||||||
docs/.vitepress/dist
|
docs/.vitepress/dist
|
||||||
docs/.vitepress/cache
|
docs/.vitepress/cache
|
||||||
|
|
||||||
types
|
src/types
|
||||||
|
|
||||||
# lock 文件还是不要了,我主要的版本写死就好了
|
# lock 文件还是不要了,我主要的版本写死就好了
|
||||||
# pnpm-lock.yaml
|
# pnpm-lock.yaml
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
|
||||||
"extends": ["config:recommended"],
|
|
||||||
"plugins": ["import", "typescript", "unicorn"],
|
|
||||||
"rules": {
|
|
||||||
"no-console": "off",
|
|
||||||
"no-unused-vars": "off"
|
|
||||||
},
|
|
||||||
"env": {
|
|
||||||
"es6": true
|
|
||||||
},
|
|
||||||
"globals": {
|
|
||||||
"foo": "readonly"
|
|
||||||
},
|
|
||||||
"ignorePatterns": ["node_modules", "dist", "src/static/**", "src/uni_modules/**"],
|
|
||||||
"settings": {},
|
|
||||||
"overrides": [
|
|
||||||
{
|
|
||||||
"files": ["*.test.ts", "*.spec.ts"],
|
|
||||||
"rules": {
|
|
||||||
"@typescript-eslint/no-explicit-any": "off"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,3 +1,5 @@
|
|||||||
|
node_modules
|
||||||
|
|
||||||
# unplugin-auto-import 生成的类型文件,每次提交都改变,所以加入这里吧,与 .gitignore 配合使用
|
# unplugin-auto-import 生成的类型文件,每次提交都改变,所以加入这里吧,与 .gitignore 配合使用
|
||||||
auto-import.d.ts
|
auto-import.d.ts
|
||||||
|
|
||||||
|
76
.vscode/settings.json
vendored
76
.vscode/settings.json
vendored
@ -1,14 +1,7 @@
|
|||||||
{
|
{
|
||||||
// 默认格式化工具选择prettier
|
// 默认格式化工具选择prettier
|
||||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||||
// 保存的时候自动格式化
|
|
||||||
"editor.formatOnSave": true,
|
|
||||||
//开启自动修复
|
|
||||||
"editor.codeActionsOnSave": {
|
|
||||||
"source.fixAll": "explicit",
|
|
||||||
"source.fixAll.eslint": "explicit",
|
|
||||||
"source.fixAll.stylelint": "explicit"
|
|
||||||
},
|
|
||||||
// 配置stylelint检查的文件类型范围
|
// 配置stylelint检查的文件类型范围
|
||||||
"stylelint.validate": ["css", "scss", "vue", "html"], // 与package.json的scripts对应
|
"stylelint.validate": ["css", "scss", "vue", "html"], // 与package.json的scripts对应
|
||||||
"stylelint.enable": true,
|
"stylelint.enable": true,
|
||||||
@ -48,6 +41,7 @@
|
|||||||
"tabbar",
|
"tabbar",
|
||||||
"Toutiao",
|
"Toutiao",
|
||||||
"unibest",
|
"unibest",
|
||||||
|
"uview",
|
||||||
"uvui",
|
"uvui",
|
||||||
"Wechat",
|
"Wechat",
|
||||||
"WechatMiniprogram",
|
"WechatMiniprogram",
|
||||||
@ -59,7 +53,67 @@
|
|||||||
"explorer.fileNesting.patterns": {
|
"explorer.fileNesting.patterns": {
|
||||||
"README.md": "index.html,favicon.ico,robots.txt,CHANGELOG.md",
|
"README.md": "index.html,favicon.ico,robots.txt,CHANGELOG.md",
|
||||||
"pages.config.ts": "manifest.config.ts,openapi-ts-request.config.ts",
|
"pages.config.ts": "manifest.config.ts,openapi-ts-request.config.ts",
|
||||||
"package.json": "pnpm-lock.yaml,pnpm-workspace.yaml,LICENSE,.gitattributes,.gitignore,.gitpod.yml,CNAME,.npmrc,.browserslistrc",
|
"package.json": "tsconfig.json,pnpm-lock.yaml,pnpm-workspace.yaml,LICENSE,.gitattributes,.gitignore,.gitpod.yml,CNAME,.npmrc,.browserslistrc",
|
||||||
".oxlintrc.json": "tsconfig.json,.commitlintrc.*,.prettier*,.editorconfig,.commitlint.cjs,.eslint*"
|
"eslint.config.mjs": ".commitlintrc.*,.prettier*,.editorconfig,.commitlint.cjs,.eslint*"
|
||||||
}
|
},
|
||||||
|
|
||||||
|
// // 保存的时候自动格式化
|
||||||
|
// "prettier.enable": true,
|
||||||
|
// "editor.formatOnSave": true,
|
||||||
|
// // 开启自动修复
|
||||||
|
// "editor.codeActionsOnSave": {
|
||||||
|
// "source.fixAll": "explicit",
|
||||||
|
// "source.fixAll.eslint": "explicit",
|
||||||
|
// "source.fixAll.stylelint": "explicit"
|
||||||
|
// },
|
||||||
|
|
||||||
|
// Disable the default formatter, use eslint instead
|
||||||
|
"prettier.enable": false,
|
||||||
|
"editor.formatOnSave": false,
|
||||||
|
|
||||||
|
// Auto fix
|
||||||
|
"editor.codeActionsOnSave": {
|
||||||
|
"source.fixAll.eslint": "explicit",
|
||||||
|
"source.organizeImports": "never"
|
||||||
|
},
|
||||||
|
|
||||||
|
// Silent the stylistic rules in you IDE, but still auto fix them
|
||||||
|
"eslint.rules.customizations": [
|
||||||
|
{ "rule": "style/*", "severity": "off", "fixable": true },
|
||||||
|
{ "rule": "format/*", "severity": "off", "fixable": true },
|
||||||
|
{ "rule": "*-indent", "severity": "off", "fixable": true },
|
||||||
|
{ "rule": "*-spacing", "severity": "off", "fixable": true },
|
||||||
|
{ "rule": "*-spaces", "severity": "off", "fixable": true },
|
||||||
|
{ "rule": "*-order", "severity": "off", "fixable": true },
|
||||||
|
{ "rule": "*-dangle", "severity": "off", "fixable": true },
|
||||||
|
{ "rule": "*-newline", "severity": "off", "fixable": true },
|
||||||
|
{ "rule": "*quotes", "severity": "off", "fixable": true },
|
||||||
|
{ "rule": "*semi", "severity": "off", "fixable": true }
|
||||||
|
],
|
||||||
|
|
||||||
|
// Enable eslint for all supported languages
|
||||||
|
"eslint.validate": [
|
||||||
|
"javascript",
|
||||||
|
"javascriptreact",
|
||||||
|
"typescript",
|
||||||
|
"typescriptreact",
|
||||||
|
"vue",
|
||||||
|
"html",
|
||||||
|
"markdown",
|
||||||
|
"json",
|
||||||
|
"json5",
|
||||||
|
"jsonc",
|
||||||
|
"yaml",
|
||||||
|
"toml",
|
||||||
|
"xml",
|
||||||
|
"gql",
|
||||||
|
"graphql",
|
||||||
|
"astro",
|
||||||
|
"svelte",
|
||||||
|
"css",
|
||||||
|
"less",
|
||||||
|
"scss",
|
||||||
|
"pcss",
|
||||||
|
"postcss"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
24
.vscode/vue3.code-snippets
vendored
24
.vscode/vue3.code-snippets
vendored
@ -27,12 +27,12 @@
|
|||||||
" },",
|
" },",
|
||||||
"}",
|
"}",
|
||||||
"</route>\n",
|
"</route>\n",
|
||||||
"<template>",
|
|
||||||
" <view class=\"\">$2</view>",
|
|
||||||
"</template>\n",
|
|
||||||
"<script lang=\"ts\" setup>",
|
"<script lang=\"ts\" setup>",
|
||||||
"//$3",
|
"//$3",
|
||||||
"</script>\n",
|
"</script>\n",
|
||||||
|
"<template>",
|
||||||
|
" <view class=\"\">$2</view>",
|
||||||
|
"</template>\n",
|
||||||
"<style lang=\"scss\" scoped>",
|
"<style lang=\"scss\" scoped>",
|
||||||
"//$4",
|
"//$4",
|
||||||
"</style>\n",
|
"</style>\n",
|
||||||
@ -41,16 +41,28 @@
|
|||||||
"Print unibest style": {
|
"Print unibest style": {
|
||||||
"scope": "vue",
|
"scope": "vue",
|
||||||
"prefix": "st",
|
"prefix": "st",
|
||||||
"body": ["<style lang=\"scss\" scoped>", "//", "</style>\n"],
|
"body": [
|
||||||
|
"<style lang=\"scss\" scoped>",
|
||||||
|
"//",
|
||||||
|
"</style>\n"
|
||||||
|
],
|
||||||
},
|
},
|
||||||
"Print unibest script": {
|
"Print unibest script": {
|
||||||
"scope": "vue",
|
"scope": "vue",
|
||||||
"prefix": "sc",
|
"prefix": "sc",
|
||||||
"body": ["<script lang=\"ts\" setup>", "//$3", "</script>\n"],
|
"body": [
|
||||||
|
"<script lang=\"ts\" setup>",
|
||||||
|
"//$3",
|
||||||
|
"</script>\n"
|
||||||
|
],
|
||||||
},
|
},
|
||||||
"Print unibest template": {
|
"Print unibest template": {
|
||||||
"scope": "vue",
|
"scope": "vue",
|
||||||
"prefix": "te",
|
"prefix": "te",
|
||||||
"body": ["<template>", " <view class=\"\">$1</view>", "</template>\n"],
|
"body": [
|
||||||
|
"<template>",
|
||||||
|
" <view class=\"\">$1</view>",
|
||||||
|
"</template>\n"
|
||||||
|
],
|
||||||
},
|
},
|
||||||
}
|
}
|
@ -70,13 +70,13 @@
|
|||||||
## 📦 运行(支持热更新)
|
## 📦 运行(支持热更新)
|
||||||
|
|
||||||
- web平台: `pnpm dev:h5`, 然后打开 [http://localhost:9000/](http://localhost:9000/)。
|
- web平台: `pnpm dev:h5`, 然后打开 [http://localhost:9000/](http://localhost:9000/)。
|
||||||
- weixin平台:`pnpm dev:mp-weixin` 然后打开微信开发者工具,导入本地文件夹,选择本项目的`dist/dev/mp-weixin` 文件。
|
- weixin平台:`pnpm dev:mp` 然后打开微信开发者工具,导入本地文件夹,选择本项目的`dist/dev/mp-weixin` 文件。
|
||||||
- APP平台:`pnpm dev:app`, 然后打开 `HBuilderX`,导入刚刚生成的`dist/dev/app` 文件夹,选择运行到模拟器(开发时优先使用),或者运行的安卓/ios基座。
|
- APP平台:`pnpm dev:app`, 然后打开 `HBuilderX`,导入刚刚生成的`dist/dev/app` 文件夹,选择运行到模拟器(开发时优先使用),或者运行的安卓/ios基座。
|
||||||
|
|
||||||
## 🔗 发布
|
## 🔗 发布
|
||||||
|
|
||||||
- web平台: `pnpm build:h5`,打包后的文件在 `dist/build/h5`,可以放到web服务器,如nginx运行。如果最终不是放在根目录,可以在 `manifest.config.ts` 文件的 `h5.router.base` 属性进行修改。
|
- web平台: `pnpm build:h5`,打包后的文件在 `dist/build/h5`,可以放到web服务器,如nginx运行。如果最终不是放在根目录,可以在 `manifest.config.ts` 文件的 `h5.router.base` 属性进行修改。
|
||||||
- weixin平台:`pnpm build:mp-weixin`, 打包后的文件在 `dist/build/mp-weixin`,然后通过微信开发者工具导入,并点击右上角的“上传”按钮进行上传。
|
- weixin平台:`pnpm build:mp`, 打包后的文件在 `dist/build/mp-weixin`,然后通过微信开发者工具导入,并点击右上角的“上传”按钮进行上传。
|
||||||
- APP平台:`pnpm build:app`, 然后打开 `HBuilderX`,导入刚刚生成的`dist/build/app` 文件夹,选择发行 - APP云打包。
|
- APP平台:`pnpm build:app`, 然后打开 `HBuilderX`,导入刚刚生成的`dist/build/app` 文件夹,选择发行 - APP云打包。
|
||||||
|
|
||||||
## 📄 License
|
## 📄 License
|
||||||
|
22
eslint.config.mjs
Normal file
22
eslint.config.mjs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import uniHelper from '@uni-helper/eslint-config'
|
||||||
|
|
||||||
|
export default uniHelper({
|
||||||
|
unocss: true,
|
||||||
|
vue: true,
|
||||||
|
markdown: false,
|
||||||
|
ignores: [
|
||||||
|
'src/uni_modules/',
|
||||||
|
'dist',
|
||||||
|
],
|
||||||
|
rules: {
|
||||||
|
'no-console': 'off',
|
||||||
|
'no-unused-vars': 'off',
|
||||||
|
'vue/no-unused-refs': 'off',
|
||||||
|
'unused-imports/no-unused-vars': 'off',
|
||||||
|
'eslint-comments/no-unlimited-disable': 'off',
|
||||||
|
'jsdoc/check-param-names': 'off',
|
||||||
|
'jsdoc/require-returns-description': 'off',
|
||||||
|
'ts/no-empty-object-type': 'off',
|
||||||
|
'no-extend-native': 'off',
|
||||||
|
},
|
||||||
|
})
|
@ -1,6 +1,7 @@
|
|||||||
|
import path from 'node:path'
|
||||||
|
import process from 'node:process'
|
||||||
// manifest.config.ts
|
// manifest.config.ts
|
||||||
import { defineManifestConfig } from '@uni-helper/vite-plugin-uni-manifest'
|
import { defineManifestConfig } from '@uni-helper/vite-plugin-uni-manifest'
|
||||||
import path from 'node:path'
|
|
||||||
import { loadEnv } from 'vite'
|
import { loadEnv } from 'vite'
|
||||||
|
|
||||||
// 获取环境变量的范例
|
// 获取环境变量的范例
|
||||||
@ -14,14 +15,14 @@ const {
|
|||||||
} = env
|
} = env
|
||||||
|
|
||||||
export default defineManifestConfig({
|
export default defineManifestConfig({
|
||||||
name: VITE_APP_TITLE,
|
'name': VITE_APP_TITLE,
|
||||||
appid: VITE_UNI_APPID,
|
'appid': VITE_UNI_APPID,
|
||||||
description: '',
|
'description': '',
|
||||||
versionName: '1.0.0',
|
'versionName': '1.0.0',
|
||||||
versionCode: '100',
|
'versionCode': '100',
|
||||||
transformPx: false,
|
'transformPx': false,
|
||||||
locale: VITE_FALLBACK_LOCALE, // 'zh-Hans'
|
'locale': VITE_FALLBACK_LOCALE, // 'zh-Hans'
|
||||||
h5: {
|
'h5': {
|
||||||
router: {
|
router: {
|
||||||
base: VITE_APP_PUBLIC_BASE,
|
base: VITE_APP_PUBLIC_BASE,
|
||||||
},
|
},
|
||||||
@ -82,14 +83,14 @@ export default defineManifestConfig({
|
|||||||
ios: {
|
ios: {
|
||||||
appstore: 'static/app/icons/1024x1024.png',
|
appstore: 'static/app/icons/1024x1024.png',
|
||||||
ipad: {
|
ipad: {
|
||||||
app: 'static/app/icons/76x76.png',
|
'app': 'static/app/icons/76x76.png',
|
||||||
'app@2x': 'static/app/icons/152x152.png',
|
'app@2x': 'static/app/icons/152x152.png',
|
||||||
notification: 'static/app/icons/20x20.png',
|
'notification': 'static/app/icons/20x20.png',
|
||||||
'notification@2x': 'static/app/icons/40x40.png',
|
'notification@2x': 'static/app/icons/40x40.png',
|
||||||
'proapp@2x': 'static/app/icons/167x167.png',
|
'proapp@2x': 'static/app/icons/167x167.png',
|
||||||
settings: 'static/app/icons/29x29.png',
|
'settings': 'static/app/icons/29x29.png',
|
||||||
'settings@2x': 'static/app/icons/58x58.png',
|
'settings@2x': 'static/app/icons/58x58.png',
|
||||||
spotlight: 'static/app/icons/40x40.png',
|
'spotlight': 'static/app/icons/40x40.png',
|
||||||
'spotlight@2x': 'static/app/icons/80x80.png',
|
'spotlight@2x': 'static/app/icons/80x80.png',
|
||||||
},
|
},
|
||||||
iphone: {
|
iphone: {
|
||||||
@ -107,7 +108,7 @@ export default defineManifestConfig({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
/* 快应用特有相关 */
|
/* 快应用特有相关 */
|
||||||
quickapp: {},
|
'quickapp': {},
|
||||||
/* 小程序特有相关 */
|
/* 小程序特有相关 */
|
||||||
'mp-weixin': {
|
'mp-weixin': {
|
||||||
appid: VITE_WX_APPID,
|
appid: VITE_WX_APPID,
|
||||||
@ -130,8 +131,8 @@ export default defineManifestConfig({
|
|||||||
'mp-toutiao': {
|
'mp-toutiao': {
|
||||||
usingComponents: true,
|
usingComponents: true,
|
||||||
},
|
},
|
||||||
uniStatistics: {
|
'uniStatistics': {
|
||||||
enable: false,
|
enable: false,
|
||||||
},
|
},
|
||||||
vueVersion: '3',
|
'vueVersion': '3',
|
||||||
})
|
})
|
||||||
|
61
package.json
61
package.json
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "unibest",
|
"name": "unibest",
|
||||||
"type": "commonjs",
|
"type": "commonjs",
|
||||||
"version": "2.12.1",
|
"version": "3.1.0",
|
||||||
"description": "unibest - 最好的 uniapp 开发模板",
|
"description": "unibest - 最好的 uniapp 开发模板",
|
||||||
"update-time": "2025-05-28",
|
"update-time": "2025-06-21",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "feige996",
|
"name": "feige996",
|
||||||
"zhName": "菲鸽",
|
"zhName": "菲鸽",
|
||||||
@ -12,13 +12,14 @@
|
|||||||
"gitee": "https://gitee.com/feige996"
|
"gitee": "https://gitee.com/feige996"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"homepage": "https://unibest.tech",
|
||||||
"repository": "https://github.com/feige996/unibest",
|
"repository": "https://github.com/feige996/unibest",
|
||||||
"repository-gitee": "https://gitee.com/feige996/unibest",
|
"repository-gitee": "https://gitee.com/feige996/unibest",
|
||||||
"repository-deprecated": "https://github.com/codercup/unibest",
|
"repository-old": "https://github.com/codercup/unibest",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/feige996/unibest/issues"
|
"url": "https://github.com/feige996/unibest/issues",
|
||||||
|
"url-old": "https://github.com/codercup/unibest/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://feige996.github.io/unibest/",
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18",
|
"node": ">=18",
|
||||||
"pnpm": ">=7.30"
|
"pnpm": ">=7.30"
|
||||||
@ -71,21 +72,8 @@
|
|||||||
"type-check": "vue-tsc --noEmit",
|
"type-check": "vue-tsc --noEmit",
|
||||||
"openapi-ts-request": "openapi-ts",
|
"openapi-ts-request": "openapi-ts",
|
||||||
"prepare": "git init && husky",
|
"prepare": "git init && husky",
|
||||||
"lint": "oxlint",
|
"lint": "eslint",
|
||||||
"lint-fix": "oxlint --fix"
|
"lint:fix": "eslint --fix"
|
||||||
},
|
|
||||||
"lint-staged": {
|
|
||||||
"**/*.{html,cjs,json,md,scss,css,txt}": [
|
|
||||||
"prettier --write --cache"
|
|
||||||
],
|
|
||||||
"**/*.{js,jsx,ts,tsx,vue,mjs,cjs,mts,cts}": [
|
|
||||||
"oxlint --fix",
|
|
||||||
"prettier --write --cache"
|
|
||||||
],
|
|
||||||
"!**/{node_modules,dist}/**": []
|
|
||||||
},
|
|
||||||
"resolutions": {
|
|
||||||
"bin-wrapper": "npm:bin-wrapper-china"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@dcloudio/uni-app": "3.0.0-4060620250520001",
|
"@dcloudio/uni-app": "3.0.0-4060620250520001",
|
||||||
@ -110,12 +98,12 @@
|
|||||||
"js-cookie": "^3.0.5",
|
"js-cookie": "^3.0.5",
|
||||||
"pinia": "2.0.36",
|
"pinia": "2.0.36",
|
||||||
"pinia-plugin-persistedstate": "3.2.1",
|
"pinia-plugin-persistedstate": "3.2.1",
|
||||||
"qs": "6.5.3",
|
"vue": "^3.4.21",
|
||||||
"vue": "^3.5.15",
|
|
||||||
"wot-design-uni": "^1.9.1",
|
"wot-design-uni": "^1.9.1",
|
||||||
"z-paging": "^2.8.4"
|
"z-paging": "2.8.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@antfu/eslint-config": "^4.15.0",
|
||||||
"@commitlint/cli": "^19.8.1",
|
"@commitlint/cli": "^19.8.1",
|
||||||
"@commitlint/config-conventional": "^19.8.1",
|
"@commitlint/config-conventional": "^19.8.1",
|
||||||
"@dcloudio/types": "^3.4.8",
|
"@dcloudio/types": "^3.4.8",
|
||||||
@ -123,39 +111,48 @@
|
|||||||
"@dcloudio/uni-cli-shared": "3.0.0-4060620250520001",
|
"@dcloudio/uni-cli-shared": "3.0.0-4060620250520001",
|
||||||
"@dcloudio/uni-stacktracey": "3.0.0-4060620250520001",
|
"@dcloudio/uni-stacktracey": "3.0.0-4060620250520001",
|
||||||
"@dcloudio/vite-plugin-uni": "3.0.0-4060620250520001",
|
"@dcloudio/vite-plugin-uni": "3.0.0-4060620250520001",
|
||||||
"@esbuild/darwin-arm64": "0.25.5",
|
"@esbuild/darwin-arm64": "0.20.2",
|
||||||
"@esbuild/darwin-x64": "0.25.5",
|
"@esbuild/darwin-x64": "0.20.2",
|
||||||
"@iconify-json/carbon": "^1.2.4",
|
"@iconify-json/carbon": "^1.2.4",
|
||||||
"@rollup/rollup-darwin-x64": "^4.28.0",
|
"@rollup/rollup-darwin-x64": "^4.28.0",
|
||||||
"@types/node": "^20.17.9",
|
"@types/node": "^20.17.9",
|
||||||
"@types/wechat-miniprogram": "^3.4.8",
|
"@types/wechat-miniprogram": "^3.4.8",
|
||||||
|
"@uni-helper/eslint-config": "^0.4.0",
|
||||||
"@uni-helper/uni-types": "1.0.0-alpha.3",
|
"@uni-helper/uni-types": "1.0.0-alpha.3",
|
||||||
"@uni-helper/unocss-preset-uni": "^0.2.11",
|
"@uni-helper/unocss-preset-uni": "^0.2.11",
|
||||||
"@uni-helper/vite-plugin-uni-components": "^0.2.0",
|
"@uni-helper/vite-plugin-uni-components": "0.2.0",
|
||||||
"@uni-helper/vite-plugin-uni-layouts": "^0.1.10",
|
"@uni-helper/vite-plugin-uni-layouts": "0.1.10",
|
||||||
"@uni-helper/vite-plugin-uni-manifest": "^0.2.8",
|
"@uni-helper/vite-plugin-uni-manifest": "0.2.8",
|
||||||
"@uni-helper/vite-plugin-uni-pages": "0.2.20",
|
"@uni-helper/vite-plugin-uni-pages": "0.2.28",
|
||||||
"@uni-helper/vite-plugin-uni-platform": "^0.0.4",
|
"@uni-helper/vite-plugin-uni-platform": "0.0.4",
|
||||||
"@uni-ku/bundle-optimizer": "^1.3.3",
|
"@uni-ku/bundle-optimizer": "^1.3.3",
|
||||||
|
"@unocss/eslint-plugin": "^66.2.3",
|
||||||
"@unocss/preset-legacy-compat": "^0.59.4",
|
"@unocss/preset-legacy-compat": "^0.59.4",
|
||||||
"@vue/runtime-core": "^3.4.21",
|
"@vue/runtime-core": "^3.4.21",
|
||||||
"@vue/tsconfig": "^0.1.3",
|
"@vue/tsconfig": "^0.1.3",
|
||||||
"autoprefixer": "^10.4.20",
|
"autoprefixer": "^10.4.20",
|
||||||
|
"eslint": "^9.29.0",
|
||||||
"husky": "^9.1.7",
|
"husky": "^9.1.7",
|
||||||
"lint-staged": "^15.2.10",
|
"lint-staged": "^15.2.10",
|
||||||
"openapi-ts-request": "^1.1.2",
|
"openapi-ts-request": "^1.1.2",
|
||||||
"oxlint": "1.0.0",
|
|
||||||
"postcss": "^8.4.49",
|
"postcss": "^8.4.49",
|
||||||
"postcss-html": "^1.7.0",
|
"postcss-html": "^1.7.0",
|
||||||
"postcss-scss": "^4.0.9",
|
"postcss-scss": "^4.0.9",
|
||||||
|
"prettier": "^3.5.3",
|
||||||
"rollup-plugin-visualizer": "^5.12.0",
|
"rollup-plugin-visualizer": "^5.12.0",
|
||||||
"sass": "1.77.8",
|
"sass": "1.77.8",
|
||||||
"terser": "^5.36.0",
|
"terser": "^5.36.0",
|
||||||
"typescript": "^5.7.2",
|
"typescript": "^5.7.2",
|
||||||
"unocss": "65.4.2",
|
"unocss": "65.4.2",
|
||||||
"unplugin-auto-import": "^0.17.8",
|
"unplugin-auto-import": "^0.17.8",
|
||||||
"vite": "6.3.5",
|
"vite": "5.2.8",
|
||||||
"vite-plugin-restart": "^0.4.2",
|
"vite-plugin-restart": "^0.4.2",
|
||||||
"vue-tsc": "^2.2.10"
|
"vue-tsc": "^2.2.10"
|
||||||
|
},
|
||||||
|
"resolutions": {
|
||||||
|
"bin-wrapper": "npm:bin-wrapper-china"
|
||||||
|
},
|
||||||
|
"lint-staged": {
|
||||||
|
"*": "eslint --fix"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { defineUniPages } from '@uni-helper/vite-plugin-uni-pages'
|
import { defineUniPages } from '@uni-helper/vite-plugin-uni-pages'
|
||||||
|
import { tabBar } from './src/layouts/fg-tabbar/tabbarList'
|
||||||
|
|
||||||
export default defineUniPages({
|
export default defineUniPages({
|
||||||
globalStyle: {
|
globalStyle: {
|
||||||
@ -17,35 +18,6 @@ export default defineUniPages({
|
|||||||
'z-paging/components/z-paging$1/z-paging$1.vue',
|
'z-paging/components/z-paging$1/z-paging$1.vue',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// 如果不需要tabBar,推荐使用 spa 模板。(pnpm create xxx -t spa)
|
// tabbar 的配置统一在 “./src/layouts/fg-tabbar/tabbarList.ts” 文件中
|
||||||
tabBar: {
|
tabBar: tabBar as any,
|
||||||
color: '#999999',
|
|
||||||
selectedColor: '#018d71',
|
|
||||||
backgroundColor: '#F8F8F8',
|
|
||||||
borderStyle: 'black',
|
|
||||||
height: '50px',
|
|
||||||
fontSize: '10px',
|
|
||||||
iconWidth: '24px',
|
|
||||||
spacing: '3px',
|
|
||||||
list: [
|
|
||||||
{
|
|
||||||
iconPath: 'static/tabbar/home.png',
|
|
||||||
selectedIconPath: 'static/tabbar/homeHL.png',
|
|
||||||
pagePath: 'pages/index/index',
|
|
||||||
text: '首页',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
iconPath: 'static/tabbar/example.png',
|
|
||||||
selectedIconPath: 'static/tabbar/exampleHL.png',
|
|
||||||
pagePath: 'pages/about/about',
|
|
||||||
text: '关于',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
iconPath: 'static/tabbar/personal.png',
|
|
||||||
selectedIconPath: 'static/tabbar/personalHL.png',
|
|
||||||
pagePath: 'pages/mine/index',
|
|
||||||
text: '我的',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
13
patches/@dcloudio__uni-h5.patch
Normal file
13
patches/@dcloudio__uni-h5.patch
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
diff --git a/dist/uni-h5.es.js b/dist/uni-h5.es.js
|
||||||
|
index 7421bad97d94ad34a3d4d94292a9ee9071430662..19c6071ee4036ceb8d1cfa09030e471c002d2cda 100644
|
||||||
|
--- a/dist/uni-h5.es.js
|
||||||
|
+++ b/dist/uni-h5.es.js
|
||||||
|
@@ -23410,7 +23410,7 @@ function useShowTabBar(emit2) {
|
||||||
|
const tabBar2 = useTabBar();
|
||||||
|
const showTabBar2 = computed(() => route.meta.isTabBar && tabBar2.shown);
|
||||||
|
updateCssVar({
|
||||||
|
- "--tab-bar-height": tabBar2.height
|
||||||
|
+ "--tab-bar-height": tabBar2?.height || 0
|
||||||
|
});
|
||||||
|
return showTabBar2;
|
||||||
|
}
|
2802
pnpm-lock.yaml
generated
2802
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
2
pnpm-workspace.yaml
Normal file
2
pnpm-workspace.yaml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
patchedDependencies:
|
||||||
|
'@dcloudio/uni-h5': patches/@dcloudio__uni-h5.patch
|
@ -2,8 +2,7 @@
|
|||||||
// # 在升级完后,会自动添加很多无用依赖,这需要删除以减小依赖包体积
|
// # 在升级完后,会自动添加很多无用依赖,这需要删除以减小依赖包体积
|
||||||
// # 只需要执行下面的命令即可
|
// # 只需要执行下面的命令即可
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
const { exec } = require('node:child_process')
|
||||||
const { exec } = require('child_process')
|
|
||||||
|
|
||||||
// 定义要执行的命令
|
// 定义要执行的命令
|
||||||
const dependencies = [
|
const dependencies = [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
|
import { onHide, onLaunch, onShow } from '@dcloudio/uni-app'
|
||||||
import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'
|
|
||||||
import { usePageAuth } from '@/hooks/usePageAuth'
|
import { usePageAuth } from '@/hooks/usePageAuth'
|
||||||
|
import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'
|
||||||
|
|
||||||
usePageAuth()
|
usePageAuth()
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { ICaptcha, IUpdateInfo, IUpdatePassword, IUserInfoVo, IUserLogin } from './login.typings'
|
import type { ICaptcha, IUpdateInfo, IUpdatePassword, IUserInfoVo, IUserLogin } from './types/login'
|
||||||
import { http } from '@/utils/http'
|
import { http } from '@/utils/http'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -15,7 +15,7 @@ export interface ILoginForm {
|
|||||||
* 获取验证码
|
* 获取验证码
|
||||||
* @returns ICaptcha 验证码
|
* @returns ICaptcha 验证码
|
||||||
*/
|
*/
|
||||||
export const getCode = () => {
|
export function getCode() {
|
||||||
return http.get<ICaptcha>('/user/getCode')
|
return http.get<ICaptcha>('/user/getCode')
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,35 +23,35 @@ export const getCode = () => {
|
|||||||
* 用户登录
|
* 用户登录
|
||||||
* @param loginForm 登录表单
|
* @param loginForm 登录表单
|
||||||
*/
|
*/
|
||||||
export const login = (loginForm: ILoginForm) => {
|
export function login(loginForm: ILoginForm) {
|
||||||
return http.post<IUserLogin>('/user/login', loginForm)
|
return http.post<IUserLogin>('/user/login', loginForm)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户信息
|
* 获取用户信息
|
||||||
*/
|
*/
|
||||||
export const getUserInfo = () => {
|
export function getUserInfo() {
|
||||||
return http.get<IUserInfoVo>('/user/info')
|
return http.get<IUserInfoVo>('/user/info')
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 退出登录
|
* 退出登录
|
||||||
*/
|
*/
|
||||||
export const logout = () => {
|
export function logout() {
|
||||||
return http.get<void>('/user/logout')
|
return http.get<void>('/user/logout')
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改用户信息
|
* 修改用户信息
|
||||||
*/
|
*/
|
||||||
export const updateInfo = (data: IUpdateInfo) => {
|
export function updateInfo(data: IUpdateInfo) {
|
||||||
return http.post('/user/updateInfo', data)
|
return http.post('/user/updateInfo', data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改用户密码
|
* 修改用户密码
|
||||||
*/
|
*/
|
||||||
export const updateUserPassword = (data: IUpdatePassword) => {
|
export function updateUserPassword(data: IUpdatePassword) {
|
||||||
return http.post('/user/updatePassword', data)
|
return http.post('/user/updatePassword', data)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,12 +59,12 @@ export const updateUserPassword = (data: IUpdatePassword) => {
|
|||||||
* 获取微信登录凭证
|
* 获取微信登录凭证
|
||||||
* @returns Promise 包含微信登录凭证(code)
|
* @returns Promise 包含微信登录凭证(code)
|
||||||
*/
|
*/
|
||||||
export const getWxCode = () => {
|
export function getWxCode() {
|
||||||
return new Promise<UniApp.LoginRes>((resolve, reject) => {
|
return new Promise<UniApp.LoginRes>((resolve, reject) => {
|
||||||
uni.login({
|
uni.login({
|
||||||
provider: 'weixin',
|
provider: 'weixin',
|
||||||
success: (res) => resolve(res),
|
success: res => resolve(res),
|
||||||
fail: (err) => reject(new Error(err)),
|
fail: err => reject(new Error(err)),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -78,6 +78,6 @@ export const getWxCode = () => {
|
|||||||
* @param params 微信登录参数,包含code
|
* @param params 微信登录参数,包含code
|
||||||
* @returns Promise 包含登录结果
|
* @returns Promise 包含登录结果
|
||||||
*/
|
*/
|
||||||
export const wxLogin = (data: { code: string }) => {
|
export function wxLogin(data: { code: string }) {
|
||||||
return http.post<IUserLogin>('/user/wxLogin', data)
|
return http.post<IUserLogin>('/user/wxLogin', data)
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* 用户信息
|
* 用户信息
|
||||||
*/
|
*/
|
||||||
export type IUserInfoVo = {
|
export interface IUserInfoVo {
|
||||||
id: number
|
id: number
|
||||||
username: string
|
username: string
|
||||||
avatar: string
|
avatar: string
|
||||||
@ -11,7 +11,7 @@ export type IUserInfoVo = {
|
|||||||
/**
|
/**
|
||||||
* 登录返回的信息
|
* 登录返回的信息
|
||||||
*/
|
*/
|
||||||
export type IUserLogin = {
|
export interface IUserLogin {
|
||||||
id: string
|
id: string
|
||||||
username: string
|
username: string
|
||||||
token: string
|
token: string
|
||||||
@ -20,7 +20,7 @@ export type IUserLogin = {
|
|||||||
/**
|
/**
|
||||||
* 获取验证码
|
* 获取验证码
|
||||||
*/
|
*/
|
||||||
export type ICaptcha = {
|
export interface ICaptcha {
|
||||||
captchaEnabled: boolean
|
captchaEnabled: boolean
|
||||||
uuid: string
|
uuid: string
|
||||||
image: string
|
image: string
|
||||||
@ -28,7 +28,7 @@ export type ICaptcha = {
|
|||||||
/**
|
/**
|
||||||
* 上传成功的信息
|
* 上传成功的信息
|
||||||
*/
|
*/
|
||||||
export type IUploadSuccessInfo = {
|
export interface IUploadSuccessInfo {
|
||||||
fileId: number
|
fileId: number
|
||||||
originalName: string
|
originalName: string
|
||||||
fileName: string
|
fileName: string
|
||||||
@ -41,7 +41,7 @@ export type IUploadSuccessInfo = {
|
|||||||
/**
|
/**
|
||||||
* 更新用户信息
|
* 更新用户信息
|
||||||
*/
|
*/
|
||||||
export type IUpdateInfo = {
|
export interface IUpdateInfo {
|
||||||
id: number
|
id: number
|
||||||
name: string
|
name: string
|
||||||
sex: string
|
sex: string
|
||||||
@ -49,7 +49,7 @@ export type IUpdateInfo = {
|
|||||||
/**
|
/**
|
||||||
* 更新用户信息
|
* 更新用户信息
|
||||||
*/
|
*/
|
||||||
export type IUpdatePassword = {
|
export interface IUpdatePassword {
|
||||||
id: number
|
id: number
|
||||||
oldPassword: string
|
oldPassword: string
|
||||||
newPassword: string
|
newPassword: string
|
@ -1,47 +0,0 @@
|
|||||||
@import 'wot-design-uni/components/wd-button/index.scss';
|
|
||||||
:deep(.wd-privacy-popup) {
|
|
||||||
width: 600rpx;
|
|
||||||
padding: 0 24rpx;
|
|
||||||
box-sizing: border-box;
|
|
||||||
border-radius: 32rpx;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wd-privacy-popup {
|
|
||||||
&__header {
|
|
||||||
width: 100%;
|
|
||||||
height: 128rpx;
|
|
||||||
line-height: 128rpx;
|
|
||||||
color: rgba(0, 0, 0, 0.85);
|
|
||||||
font-size: 30rpx;
|
|
||||||
padding: 0 12rpx;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__container {
|
|
||||||
width: 100%;
|
|
||||||
box-sizing: border-box;
|
|
||||||
padding: 0 12rpx;
|
|
||||||
margin-bottom: 32rpx;
|
|
||||||
|
|
||||||
font-size: 28rpx;
|
|
||||||
line-height: 1.8;
|
|
||||||
color: #3e3e3e;
|
|
||||||
text-align: left;
|
|
||||||
font-weight: 550;
|
|
||||||
&-protocol {
|
|
||||||
color: #4d80f0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&__footer {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
padding-bottom: 36rpx;
|
|
||||||
|
|
||||||
button {
|
|
||||||
border: none;
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,144 +0,0 @@
|
|||||||
<template>
|
|
||||||
<view>
|
|
||||||
<wd-popup
|
|
||||||
v-model="showPopup"
|
|
||||||
:close-on-click-modal="false"
|
|
||||||
custom-class="wd-privacy-popup"
|
|
||||||
@close="handleClose"
|
|
||||||
>
|
|
||||||
<view class="wd-privacy-popup__header">
|
|
||||||
<!--标题-->
|
|
||||||
<view class="wd-picker__title">{{ title }}</view>
|
|
||||||
</view>
|
|
||||||
<view class="wd-privacy-popup__container">
|
|
||||||
<text>{{ desc }}</text>
|
|
||||||
<text class="wd-privacy-popup__container-protocol" @click="openPrivacyContract">
|
|
||||||
{{ protocol }}
|
|
||||||
</text>
|
|
||||||
<text>{{ subDesc }}</text>
|
|
||||||
</view>
|
|
||||||
<view class="wd-privacy-popup__footer">
|
|
||||||
<button
|
|
||||||
class="wd-privacy-popup__footer-disagree wd-button is-block is-round is-medium is-plain"
|
|
||||||
id="disagree-btn"
|
|
||||||
@click="handleDisagree"
|
|
||||||
>
|
|
||||||
拒绝
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
class="wd-privacy-popup__footer-agree wd-button is-primary is-block is-round is-medium"
|
|
||||||
id="agree-btn"
|
|
||||||
open-type="agreePrivacyAuthorization"
|
|
||||||
@agreeprivacyauthorization="handleAgree"
|
|
||||||
>
|
|
||||||
同意
|
|
||||||
</button>
|
|
||||||
</view>
|
|
||||||
</wd-popup>
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts">
|
|
||||||
export default {
|
|
||||||
name: 'privacy-popup',
|
|
||||||
options: {
|
|
||||||
virtualHost: true,
|
|
||||||
addGlobalClass: true,
|
|
||||||
styleIsolation: 'shared',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
|
||||||
import { onBeforeMount, ref } from 'vue'
|
|
||||||
|
|
||||||
type Props = {
|
|
||||||
title?: string // 标题
|
|
||||||
desc?: string // 描述
|
|
||||||
subDesc?: string // 字描述
|
|
||||||
protocol?: string // 协议名称
|
|
||||||
}
|
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
|
||||||
title: '用户隐私保护提示',
|
|
||||||
desc: '感谢您使用本应用,您使用本应用的服务之前请仔细阅读并同意',
|
|
||||||
subDesc:
|
|
||||||
'。当您点击同意并开始时用产品服务时,即表示你已理解并同息该条款内容,该条款将对您产生法律约束力。如您拒绝,将无法使用相应服务。',
|
|
||||||
protocol: '《用户隐私保护指引》',
|
|
||||||
})
|
|
||||||
|
|
||||||
const showPopup = ref<boolean>(false) // 是否展示popup
|
|
||||||
|
|
||||||
const privacyResolves = ref(new Set()) // onNeedPrivacyAuthorization的reslove
|
|
||||||
|
|
||||||
const privacyHandler = (resolve: any) => {
|
|
||||||
showPopup.value = true
|
|
||||||
privacyResolves.value.add(resolve)
|
|
||||||
}
|
|
||||||
|
|
||||||
const emit = defineEmits(['agree', 'disagree'])
|
|
||||||
|
|
||||||
onBeforeMount(() => {
|
|
||||||
// 注册监听
|
|
||||||
if ((wx as any).onNeedPrivacyAuthorization) {
|
|
||||||
;(wx as any).onNeedPrivacyAuthorization((resolve: any) => {
|
|
||||||
if (typeof privacyHandler === 'function') {
|
|
||||||
privacyHandler(resolve)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 同意隐私协议
|
|
||||||
*/
|
|
||||||
function handleAgree() {
|
|
||||||
showPopup.value = false
|
|
||||||
privacyResolves.value.forEach((resolve: any) => {
|
|
||||||
resolve({
|
|
||||||
event: 'agree',
|
|
||||||
buttonId: 'agree-btn',
|
|
||||||
})
|
|
||||||
})
|
|
||||||
privacyResolves.value.clear()
|
|
||||||
emit('agree')
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拒绝隐私协议
|
|
||||||
*/
|
|
||||||
function handleDisagree() {
|
|
||||||
showPopup.value = false
|
|
||||||
privacyResolves.value.forEach((resolve: any) => {
|
|
||||||
resolve({
|
|
||||||
event: 'disagree',
|
|
||||||
})
|
|
||||||
})
|
|
||||||
privacyResolves.value.clear()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 打开隐私协议
|
|
||||||
*/
|
|
||||||
function openPrivacyContract() {
|
|
||||||
;(wx as any).openPrivacyContract({
|
|
||||||
success: (res) => {
|
|
||||||
console.log('openPrivacyContract success')
|
|
||||||
},
|
|
||||||
fail: (res) => {
|
|
||||||
console.error('openPrivacyContract fail', res)
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 弹出框关闭时清空
|
|
||||||
*/
|
|
||||||
function handleClose() {
|
|
||||||
privacyResolves.value.clear()
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
@import './index.scss';
|
|
||||||
</style>
|
|
7
src/env.d.ts
vendored
7
src/env.d.ts
vendored
@ -2,8 +2,8 @@
|
|||||||
/// <reference types="vite-svg-loader" />
|
/// <reference types="vite-svg-loader" />
|
||||||
|
|
||||||
declare module '*.vue' {
|
declare module '*.vue' {
|
||||||
import { DefineComponent } from 'vue'
|
import type { DefineComponent } from 'vue'
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
|
|
||||||
const component: DefineComponent<{}, {}, any>
|
const component: DefineComponent<{}, {}, any>
|
||||||
export default component
|
export default component
|
||||||
}
|
}
|
||||||
@ -29,3 +29,6 @@ interface ImportMetaEnv {
|
|||||||
interface ImportMeta {
|
interface ImportMeta {
|
||||||
readonly env: ImportMetaEnv
|
readonly env: ImportMetaEnv
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare const __VITE_APP_PROXY__: 'true' | 'false'
|
||||||
|
declare const __UNI_PLATFORM__: 'app' | 'h5' | 'mp-alipay' | 'mp-baidu' | 'mp-kuaishou' | 'mp-lark' | 'mp-qq' | 'mp-tiktok' | 'mp-weixin' | 'mp-xiaochengxu'
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { onLoad } from '@dcloudio/uni-app'
|
import { onLoad } from '@dcloudio/uni-app'
|
||||||
import { needLoginPages as _needLoginPages, getNeedLoginPages } from '@/utils'
|
|
||||||
import { useUserStore } from '@/store'
|
import { useUserStore } from '@/store'
|
||||||
|
import { needLoginPages as _needLoginPages, getNeedLoginPages } from '@/utils'
|
||||||
|
|
||||||
const loginRoute = import.meta.env.VITE_LOGIN_URL
|
const loginRoute = import.meta.env.VITE_LOGIN_URL
|
||||||
const isDev = import.meta.env.DEV
|
const isDev = import.meta.env.DEV
|
||||||
const isLogined = () => {
|
function isLogined() {
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
return !!userStore.userInfo.username
|
return !!userStore.userInfo.username
|
||||||
}
|
}
|
||||||
@ -20,7 +20,8 @@ export function usePageAuth() {
|
|||||||
let needLoginPages: string[] = []
|
let needLoginPages: string[] = []
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
needLoginPages = getNeedLoginPages()
|
needLoginPages = getNeedLoginPages()
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
needLoginPages = _needLoginPages
|
needLoginPages = _needLoginPages
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { UnwrapRef } from 'vue'
|
import type { UnwrapRef } from 'vue'
|
||||||
|
|
||||||
type IUseRequestOptions<T> = {
|
interface IUseRequestOptions<T> {
|
||||||
/** 是否立即执行 */
|
/** 是否立即执行 */
|
||||||
immediate?: boolean
|
immediate?: boolean
|
||||||
/** 初始化数据 */
|
/** 初始化数据 */
|
||||||
|
@ -7,7 +7,7 @@ type TfileType = 'image' | 'file'
|
|||||||
type TImage = 'png' | 'jpg' | 'jpeg' | 'webp' | '*'
|
type TImage = 'png' | 'jpg' | 'jpeg' | 'webp' | '*'
|
||||||
type TFile = 'doc' | 'docx' | 'ppt' | 'zip' | 'xls' | 'xlsx' | 'txt' | TImage
|
type TFile = 'doc' | 'docx' | 'ppt' | 'zip' | 'xls' | 'xlsx' | 'txt' | TImage
|
||||||
|
|
||||||
type TOptions<T extends TfileType> = {
|
interface TOptions<T extends TfileType> {
|
||||||
formData?: Record<string, any>
|
formData?: Record<string, any>
|
||||||
maxSize?: number
|
maxSize?: number
|
||||||
accept?: T extends 'image' ? TImage[] : TFile[]
|
accept?: T extends 'image' ? TImage[] : TFile[]
|
||||||
@ -30,6 +30,46 @@ export default function useUpload<T extends TfileType>(options: TOptions<T> = {}
|
|||||||
const error = ref<Error | null>(null)
|
const error = ref<Error | null>(null)
|
||||||
const data = ref<any>(null)
|
const data = ref<any>(null)
|
||||||
|
|
||||||
|
const handleFileChoose = ({ tempFilePath, size }: { tempFilePath: string, size: number }) => {
|
||||||
|
if (size > maxSize) {
|
||||||
|
uni.showToast({
|
||||||
|
title: `文件大小不能超过 ${maxSize / 1024 / 1024}MB`,
|
||||||
|
icon: 'none',
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// const fileExtension = file?.tempFiles?.name?.split('.').pop()?.toLowerCase()
|
||||||
|
// const isTypeValid = accept.some((type) => type === '*' || type.toLowerCase() === fileExtension)
|
||||||
|
|
||||||
|
// if (!isTypeValid) {
|
||||||
|
// uni.showToast({
|
||||||
|
// title: `仅支持 ${accept.join(', ')} 格式的文件`,
|
||||||
|
// icon: 'none',
|
||||||
|
// })
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
|
loading.value = true
|
||||||
|
uploadFile({
|
||||||
|
tempFilePath,
|
||||||
|
formData,
|
||||||
|
onSuccess: (res) => {
|
||||||
|
const { data: _data } = JSON.parse(res)
|
||||||
|
data.value = _data
|
||||||
|
// console.log('上传成功', res)
|
||||||
|
success?.(_data)
|
||||||
|
},
|
||||||
|
onError: (err) => {
|
||||||
|
error.value = err
|
||||||
|
onError?.(err)
|
||||||
|
},
|
||||||
|
onComplete: () => {
|
||||||
|
loading.value = false
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const run = () => {
|
const run = () => {
|
||||||
// 微信小程序从基础库 2.21.0 开始, wx.chooseImage 停止维护,请使用 uni.chooseMedia 代替。
|
// 微信小程序从基础库 2.21.0 开始, wx.chooseImage 停止维护,请使用 uni.chooseMedia 代替。
|
||||||
// 微信小程序在2023年10月17日之后,使用本API需要配置隐私协议
|
// 微信小程序在2023年10月17日之后,使用本API需要配置隐私协议
|
||||||
@ -37,19 +77,21 @@ export default function useUpload<T extends TfileType>(options: TOptions<T> = {}
|
|||||||
count: 1,
|
count: 1,
|
||||||
success: (res: any) => {
|
success: (res: any) => {
|
||||||
console.log('File selected successfully:', res)
|
console.log('File selected successfully:', res)
|
||||||
// h5中res:{errMsg: "chooseImage:ok", tempFilePaths: "blob:http://localhost:9000/f74ab6b8-a14d-4cb6-a10d-fcf4511a0de5", tempFiles: [File]}
|
|
||||||
// h5的File有一下字段:{name: "girl.jpeg", size: 48976, type: "image/jpeg"}
|
|
||||||
// 小程序中res:{errMsg: "chooseImage:ok", tempFiles: [{fileType: "image", size: 48976, tempFilePath: "http://tmp/5iG1WpIxTaJf3ece38692a337dc06df7eb69ecb49c6b.jpeg"}]}
|
// 小程序中res:{errMsg: "chooseImage:ok", tempFiles: [{fileType: "image", size: 48976, tempFilePath: "http://tmp/5iG1WpIxTaJf3ece38692a337dc06df7eb69ecb49c6b.jpeg"}]}
|
||||||
|
// h5中res:{errMsg: "chooseImage:ok", tempFilePaths: "blob:http://localhost:9000/f74ab6b8-a14d-4cb6-a10d-fcf4511a0de5", tempFiles: [File]}
|
||||||
|
// h5的File有以下字段:{name: "girl.jpeg", size: 48976, type: "image/jpeg"}
|
||||||
|
// App中res:{errMsg: "chooseImage:ok", tempFilePaths: "file:///Users/feige/xxx/gallery/1522437259-compressed-IMG_0006.jpg", tempFiles: [File]}
|
||||||
|
// App的File有以下字段:{path: "file:///Users/feige/xxx/gallery/1522437259-compressed-IMG_0006.jpg", size: 48976}
|
||||||
let tempFilePath = ''
|
let tempFilePath = ''
|
||||||
let size = 0
|
let size = 0
|
||||||
// #ifdef H5
|
|
||||||
tempFilePath = res.tempFilePaths[0]
|
|
||||||
size = res.tempFiles[0].size
|
|
||||||
// #endif
|
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
tempFilePath = res.tempFiles[0].tempFilePath
|
tempFilePath = res.tempFiles[0].tempFilePath
|
||||||
size = res.tempFiles[0].size
|
size = res.tempFiles[0].size
|
||||||
// #endif
|
// #endif
|
||||||
|
// #ifndef MP-WEIXIN
|
||||||
|
tempFilePath = res.tempFilePaths[0]
|
||||||
|
size = res.tempFiles[0].size
|
||||||
|
// #endif
|
||||||
handleFileChoose({ tempFilePath, size })
|
handleFileChoose({ tempFilePath, size })
|
||||||
},
|
},
|
||||||
fail: (err: any) => {
|
fail: (err: any) => {
|
||||||
@ -70,7 +112,8 @@ export default function useUpload<T extends TfileType>(options: TOptions<T> = {}
|
|||||||
// #ifndef MP-WEIXIN
|
// #ifndef MP-WEIXIN
|
||||||
uni.chooseImage(chooseFileOptions)
|
uni.chooseImage(chooseFileOptions)
|
||||||
// #endif
|
// #endif
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
uni.chooseFile({
|
uni.chooseFile({
|
||||||
...chooseFileOptions,
|
...chooseFileOptions,
|
||||||
type: 'all',
|
type: 'all',
|
||||||
@ -78,46 +121,6 @@ export default function useUpload<T extends TfileType>(options: TOptions<T> = {}
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleFileChoose = ({ tempFilePath, size }: { tempFilePath: string; size: number }) => {
|
|
||||||
if (size > maxSize) {
|
|
||||||
uni.showToast({
|
|
||||||
title: `文件大小不能超过 ${maxSize / 1024 / 1024}MB`,
|
|
||||||
icon: 'none',
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// const fileExtension = file?.tempFiles?.name?.split('.').pop()?.toLowerCase()
|
|
||||||
// const isTypeValid = accept.some((type) => type === '*' || type.toLowerCase() === fileExtension)
|
|
||||||
|
|
||||||
// if (!isTypeValid) {
|
|
||||||
// uni.showToast({
|
|
||||||
// title: `仅支持 ${accept.join(', ')} 格式的文件`,
|
|
||||||
// icon: 'none',
|
|
||||||
// })
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
|
|
||||||
loading.value = true
|
|
||||||
uploadFile({
|
|
||||||
tempFilePath: tempFilePath,
|
|
||||||
formData,
|
|
||||||
onSuccess: (res) => {
|
|
||||||
const { data: _data } = JSON.parse(res)
|
|
||||||
data.value = _data
|
|
||||||
// console.log('上传成功', res)
|
|
||||||
success?.(_data)
|
|
||||||
},
|
|
||||||
onError: (err) => {
|
|
||||||
error.value = err
|
|
||||||
onError?.(err)
|
|
||||||
},
|
|
||||||
onComplete: () => {
|
|
||||||
loading.value = false
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return { loading, error, data, run }
|
return { loading, error, data, run }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +146,8 @@ async function uploadFile({
|
|||||||
try {
|
try {
|
||||||
const data = uploadFileRes.data
|
const data = uploadFileRes.data
|
||||||
onSuccess(data)
|
onSuccess(data)
|
||||||
} catch (err) {
|
}
|
||||||
|
catch (err) {
|
||||||
onError(err)
|
onError(err)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
export { routeInterceptor } from './route'
|
|
||||||
export { requestInterceptor } from './request'
|
|
||||||
export { prototypeInterceptor } from './prototype'
|
export { prototypeInterceptor } from './prototype'
|
||||||
|
export { requestInterceptor } from './request'
|
||||||
|
export { routeInterceptor } from './route'
|
||||||
|
@ -2,10 +2,11 @@ export const prototypeInterceptor = {
|
|||||||
install() {
|
install() {
|
||||||
// 解决低版本手机不识别 array.at() 导致运行报错的问题
|
// 解决低版本手机不识别 array.at() 导致运行报错的问题
|
||||||
if (typeof Array.prototype.at !== 'function') {
|
if (typeof Array.prototype.at !== 'function') {
|
||||||
// eslint-disable-next-line no-extend-native
|
|
||||||
Array.prototype.at = function (index: number) {
|
Array.prototype.at = function (index: number) {
|
||||||
if (index < 0) return this[this.length + index]
|
if (index < 0)
|
||||||
if (index >= this.length) return undefined
|
return this[this.length + index]
|
||||||
|
if (index >= this.length)
|
||||||
|
return undefined
|
||||||
return this[index]
|
return this[index]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
/* eslint-disable no-param-reassign */
|
|
||||||
import qs from 'qs'
|
|
||||||
import { useUserStore } from '@/store'
|
import { useUserStore } from '@/store'
|
||||||
import { platform } from '@/utils/platform'
|
|
||||||
import { getEnvBaseUrl } from '@/utils'
|
import { getEnvBaseUrl } from '@/utils'
|
||||||
|
import { platform } from '@/utils/platform'
|
||||||
|
import { stringifyQuery } from '@/utils/queryString'
|
||||||
|
|
||||||
export type CustomRequestOptions = UniApp.RequestOptions & {
|
export type CustomRequestOptions = UniApp.RequestOptions & {
|
||||||
query?: Record<string, any>
|
query?: Record<string, any>
|
||||||
@ -19,10 +18,11 @@ const httpInterceptor = {
|
|||||||
invoke(options: CustomRequestOptions) {
|
invoke(options: CustomRequestOptions) {
|
||||||
// 接口请求支持通过 query 参数配置 queryString
|
// 接口请求支持通过 query 参数配置 queryString
|
||||||
if (options.query) {
|
if (options.query) {
|
||||||
const queryStr = qs.stringify(options.query)
|
const queryStr = stringifyQuery(options.query)
|
||||||
if (options.url.includes('?')) {
|
if (options.url.includes('?')) {
|
||||||
options.url += `&${queryStr}`
|
options.url += `&${queryStr}`
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
options.url += `?${queryStr}`
|
options.url += `?${queryStr}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -33,7 +33,8 @@ const httpInterceptor = {
|
|||||||
if (JSON.parse(__VITE_APP_PROXY__)) {
|
if (JSON.parse(__VITE_APP_PROXY__)) {
|
||||||
// 自动拼接代理前缀
|
// 自动拼接代理前缀
|
||||||
options.url = import.meta.env.VITE_APP_PROXY_PREFIX + options.url
|
options.url = import.meta.env.VITE_APP_PROXY_PREFIX + options.url
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
options.url = baseUrl + options.url
|
options.url = baseUrl + options.url
|
||||||
}
|
}
|
||||||
// #endif
|
// #endif
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
* 我这里应为大部分都可以随便进入,所以使用黑名单
|
* 我这里应为大部分都可以随便进入,所以使用黑名单
|
||||||
*/
|
*/
|
||||||
import { useUserStore } from '@/store'
|
import { useUserStore } from '@/store'
|
||||||
import { needLoginPages as _needLoginPages, getNeedLoginPages, getLastPage } from '@/utils'
|
import { needLoginPages as _needLoginPages, getLastPage, getNeedLoginPages } from '@/utils'
|
||||||
|
|
||||||
// TODO Check
|
// TODO Check
|
||||||
const loginRoute = import.meta.env.VITE_LOGIN_URL
|
const loginRoute = import.meta.env.VITE_LOGIN_URL
|
||||||
|
|
||||||
const isLogined = () => {
|
function isLogined() {
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
return !!userStore.userInfo.username
|
return !!userStore.userInfo.username
|
||||||
}
|
}
|
||||||
@ -37,7 +37,8 @@ const navigateToInterceptor = {
|
|||||||
// 为了防止开发时出现BUG,这里每次都获取一下。生产环境可以移到函数外,性能更好
|
// 为了防止开发时出现BUG,这里每次都获取一下。生产环境可以移到函数外,性能更好
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
needLoginPages = getNeedLoginPages()
|
needLoginPages = getNeedLoginPages()
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
needLoginPages = _needLoginPages
|
needLoginPages = _needLoginPages
|
||||||
}
|
}
|
||||||
const isNeedLogin = needLoginPages.includes(path)
|
const isNeedLogin = needLoginPages.includes(path)
|
||||||
|
@ -1,12 +1,3 @@
|
|||||||
<template>
|
|
||||||
<wd-config-provider :themeVars="themeVars">
|
|
||||||
<slot />
|
|
||||||
<wd-toast />
|
|
||||||
<wd-message-box />
|
|
||||||
<privacy-popup />
|
|
||||||
</wd-config-provider>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { ConfigProviderThemeVars } from 'wot-design-uni'
|
import type { ConfigProviderThemeVars } from 'wot-design-uni'
|
||||||
|
|
||||||
@ -16,3 +7,11 @@ const themeVars: ConfigProviderThemeVars = {
|
|||||||
// buttonPrimaryColor: '#07c160',
|
// buttonPrimaryColor: '#07c160',
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<wd-config-provider :theme-vars="themeVars">
|
||||||
|
<slot />
|
||||||
|
<wd-toast />
|
||||||
|
<wd-message-box />
|
||||||
|
</wd-config-provider>
|
||||||
|
</template>
|
||||||
|
@ -1,11 +1,3 @@
|
|||||||
<template>
|
|
||||||
<wd-config-provider :themeVars="themeVars">
|
|
||||||
<slot />
|
|
||||||
<wd-toast />
|
|
||||||
<wd-message-box />
|
|
||||||
</wd-config-provider>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { ConfigProviderThemeVars } from 'wot-design-uni'
|
import type { ConfigProviderThemeVars } from 'wot-design-uni'
|
||||||
|
|
||||||
@ -15,3 +7,11 @@ const themeVars: ConfigProviderThemeVars = {
|
|||||||
// buttonPrimaryColor: '#07c160',
|
// buttonPrimaryColor: '#07c160',
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<wd-config-provider :theme-vars="themeVars">
|
||||||
|
<slot />
|
||||||
|
<wd-toast />
|
||||||
|
<wd-message-box />
|
||||||
|
</wd-config-provider>
|
||||||
|
</template>
|
||||||
|
67
src/layouts/fg-tabbar/fg-tabbar.vue
Normal file
67
src/layouts/fg-tabbar/fg-tabbar.vue
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { tabbarStore } from './tabbar'
|
||||||
|
// 'i-carbon-code',
|
||||||
|
import { tabbarList as _tabBarList, cacheTabbarEnable, selectedTabbarStrategy } from './tabbarList'
|
||||||
|
|
||||||
|
// @ts-expect-error 预知的判断
|
||||||
|
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)
|
||||||
|
if (cacheTabbarEnable) {
|
||||||
|
uni.switchTab({ url })
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
uni.navigateTo({ url })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onLoad(() => {
|
||||||
|
// 解决原生 tabBar 未隐藏导致有2个 tabBar 的问题
|
||||||
|
// @ts-expect-error 预知的判断
|
||||||
|
const hideRedundantTabbarEnable = selectedTabbarStrategy === 1
|
||||||
|
hideRedundantTabbarEnable
|
||||||
|
&& uni.hideTabBar({
|
||||||
|
fail(err) {
|
||||||
|
console.log('hideTabBar fail: ', err)
|
||||||
|
},
|
||||||
|
success(res) {
|
||||||
|
console.log('hideTabBar success: ', res)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<wd-tabbar
|
||||||
|
v-if="customTabbarEnable"
|
||||||
|
v-model="tabbarStore.curIdx"
|
||||||
|
bordered
|
||||||
|
safeareainsetbottom
|
||||||
|
placeholder
|
||||||
|
fixed
|
||||||
|
@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
|
||||||
|
v-else-if="item.iconType === 'unocss' || item.iconType === 'iconfont'"
|
||||||
|
:title="item.text"
|
||||||
|
>
|
||||||
|
<template #icon>
|
||||||
|
<view
|
||||||
|
h-40rpx
|
||||||
|
w-40rpx
|
||||||
|
: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">
|
||||||
|
<template #icon>
|
||||||
|
<image :src="item.icon" h-40rpx w-40rpx />
|
||||||
|
</template>
|
||||||
|
</wd-tabbar-item>
|
||||||
|
</block>
|
||||||
|
</wd-tabbar>
|
||||||
|
</template>
|
16
src/layouts/fg-tabbar/tabbar.md
Normal file
16
src/layouts/fg-tabbar/tabbar.md
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# tabbar 说明
|
||||||
|
|
||||||
|
`tabbar` 分为 `4 种` 情况:
|
||||||
|
|
||||||
|
- `完全原生 tabbar`,使用 `switchTab` 切换 tabbar,`tabbar` 页面有缓存。
|
||||||
|
- 优势:原生自带的 tabbar,最先渲染,有缓存。
|
||||||
|
- 劣势:只能使用 2 组图片来切换选中和非选中状态,修改颜色只能重新换图片(或者用 iconfont)。
|
||||||
|
- `半自定义 tabbar`,使用 `switchTab` 切换 tabbar,`tabbar` 页面有缓存。使用了第三方 UI 库的 `tabbar` 组件,并隐藏了原生 `tabbar` 的显示。
|
||||||
|
- 优势:可以随意配置自己想要的 `svg icon`,切换字体颜色方便。有缓存。可以实现各种花里胡哨的动效等。
|
||||||
|
- 劣势:首次点击 tababr 会闪烁。
|
||||||
|
- `全自定义 tabbar`,使用 `navigateTo` 切换 `tabbar`,`tabbar` 页面无缓存。使用了第三方 UI 库的 `tabbar` 组件。
|
||||||
|
- 优势:可以随意配置自己想要的 svg icon,切换字体颜色方便。可以实现各种花里胡哨的动效等。
|
||||||
|
- 劣势:首次点击 `tababr` 会闪烁,无缓存。
|
||||||
|
- `无 tabbar`,只有一个页面入口,底部无 `tabbar` 显示;常用语临时活动页。
|
||||||
|
|
||||||
|
> 注意:花里胡哨的效果需要自己实现,本模版不提供。
|
11
src/layouts/fg-tabbar/tabbar.ts
Normal file
11
src/layouts/fg-tabbar/tabbar.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
/**
|
||||||
|
* tabbar 状态,增加 storageSync 保证刷新浏览器时在正确的 tabbar 页面
|
||||||
|
* 使用reactive简单状态,而不是 pinia 全局状态
|
||||||
|
*/
|
||||||
|
export const tabbarStore = reactive({
|
||||||
|
curIdx: uni.getStorageSync('app-tabbar-index') || 0,
|
||||||
|
setCurIdx(idx: number) {
|
||||||
|
this.curIdx = idx
|
||||||
|
uni.setStorageSync('app-tabbar-index', idx)
|
||||||
|
},
|
||||||
|
})
|
65
src/layouts/fg-tabbar/tabbarList.ts
Normal file
65
src/layouts/fg-tabbar/tabbarList.ts
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/**
|
||||||
|
* tabbar 选择的策略,更详细的介绍见 tabbar.md 文件
|
||||||
|
* 0: 'NATIVE_TABBAR' `完全原生 tabbar`
|
||||||
|
* 2: 'FULL_CUSTOM_TABBAR' `全自定义 tabbar`
|
||||||
|
* 1: 'HALF_CUSTOM_TABBAR' `半自定义 tabbar`
|
||||||
|
* 3: 'NO_TABBAR' `无 tabbar`
|
||||||
|
*
|
||||||
|
* 温馨提示:本文件的任何代码更改了之后,都需要重新运行,否则 pages.json 不会更新导致错误
|
||||||
|
*/
|
||||||
|
|
||||||
|
// TODO:通过这里切换使用tabbar的策略
|
||||||
|
export const selectedTabbarStrategy = 0
|
||||||
|
|
||||||
|
// 0 和 1 时,需要tabbar缓存
|
||||||
|
export const cacheTabbarEnable = selectedTabbarStrategy < 2
|
||||||
|
|
||||||
|
// selectedTabbarStrategy==0 时,需要填 iconPath 和 selectedIconPath
|
||||||
|
// selectedTabbarStrategy==1 or 2 时,需要填 icon 和 iconType
|
||||||
|
// selectedTabbarStrategy==3 时,tabbarList 不生效
|
||||||
|
export const tabbarList = [
|
||||||
|
{
|
||||||
|
iconPath: 'static/tabbar/home.png',
|
||||||
|
selectedIconPath: 'static/tabbar/homeHL.png',
|
||||||
|
pagePath: 'pages/index/index',
|
||||||
|
text: '首页',
|
||||||
|
icon: 'home',
|
||||||
|
iconType: 'uiLib',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
iconPath: 'static/tabbar/example.png',
|
||||||
|
selectedIconPath: 'static/tabbar/exampleHL.png',
|
||||||
|
pagePath: 'pages/about/about',
|
||||||
|
text: '关于',
|
||||||
|
icon: 'i-carbon-code',
|
||||||
|
// 注意 unocss 的图标需要在 页面上引入一下,或者配置到 unocss.config.ts 的 safelist 中
|
||||||
|
iconType: 'unocss',
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// pagePath: 'pages/my/index',
|
||||||
|
// text: '我的',
|
||||||
|
// icon: '/static/logo.svg',
|
||||||
|
// iconType: 'local',
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// pagePath: 'pages/mine/index',
|
||||||
|
// text: '我的',
|
||||||
|
// icon: 'iconfont icon-my',
|
||||||
|
// iconType: 'iconfont',
|
||||||
|
// },
|
||||||
|
]
|
||||||
|
|
||||||
|
const _tabbar = {
|
||||||
|
color: '#999999',
|
||||||
|
selectedColor: '#018d71',
|
||||||
|
backgroundColor: '#F8F8F8',
|
||||||
|
borderStyle: 'black',
|
||||||
|
height: '50px',
|
||||||
|
fontSize: '10px',
|
||||||
|
iconWidth: '24px',
|
||||||
|
spacing: '3px',
|
||||||
|
list: tabbarList,
|
||||||
|
}
|
||||||
|
|
||||||
|
// 0和1 需要显示底部的tabbar的各种配置,以利用缓存
|
||||||
|
export const tabBar = cacheTabbarEnable ? _tabbar : undefined
|
19
src/layouts/tabbar.vue
Normal file
19
src/layouts/tabbar.vue
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<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">
|
||||||
|
<slot />
|
||||||
|
<FgTabbar />
|
||||||
|
<wd-toast />
|
||||||
|
<wd-message-box />
|
||||||
|
</wd-config-provider>
|
||||||
|
</template>
|
@ -1,11 +1,11 @@
|
|||||||
import '@/style/index.scss'
|
|
||||||
import { VueQueryPlugin } from '@tanstack/vue-query'
|
import { VueQueryPlugin } from '@tanstack/vue-query'
|
||||||
import 'uno.css'
|
|
||||||
import { createSSRApp } from 'vue'
|
import { createSSRApp } from 'vue'
|
||||||
|
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import { prototypeInterceptor, requestInterceptor, routeInterceptor } from './interceptors'
|
import { prototypeInterceptor, requestInterceptor, routeInterceptor } from './interceptors'
|
||||||
|
|
||||||
import store from './store'
|
import store from './store'
|
||||||
|
import '@/style/index.scss'
|
||||||
|
import 'virtual:uno.css'
|
||||||
|
|
||||||
export function createApp() {
|
export function createApp() {
|
||||||
const app = createSSRApp(App)
|
const app = createSSRApp(App)
|
||||||
|
@ -7,17 +7,21 @@
|
|||||||
}
|
}
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
<template>
|
|
||||||
<view class="text-center">
|
|
||||||
<view class="m-8">http://localhost:9000/#/pages-sub/demo/index</view>
|
|
||||||
<view class="text-green-500">分包页面demo</view>
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
// code here
|
// code here
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view class="text-center">
|
||||||
|
<view class="m-8">
|
||||||
|
http://localhost:9000/#/pages-sub/demo/index
|
||||||
|
</view>
|
||||||
|
<view class="text-green-500">
|
||||||
|
分包页面demo
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
//
|
//
|
||||||
</style>
|
</style>
|
||||||
|
@ -28,19 +28,17 @@
|
|||||||
"iconPath": "static/tabbar/home.png",
|
"iconPath": "static/tabbar/home.png",
|
||||||
"selectedIconPath": "static/tabbar/homeHL.png",
|
"selectedIconPath": "static/tabbar/homeHL.png",
|
||||||
"pagePath": "pages/index/index",
|
"pagePath": "pages/index/index",
|
||||||
"text": "首页"
|
"text": "首页",
|
||||||
|
"icon": "home",
|
||||||
|
"iconType": "uiLib"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"iconPath": "static/tabbar/example.png",
|
"iconPath": "static/tabbar/example.png",
|
||||||
"selectedIconPath": "static/tabbar/exampleHL.png",
|
"selectedIconPath": "static/tabbar/exampleHL.png",
|
||||||
"pagePath": "pages/about/about",
|
"pagePath": "pages/about/about",
|
||||||
"text": "关于"
|
"text": "关于",
|
||||||
},
|
"icon": "i-carbon-code",
|
||||||
{
|
"iconType": "unocss"
|
||||||
"iconPath": "static/tabbar/personal.png",
|
|
||||||
"selectedIconPath": "static/tabbar/personalHL.png",
|
|
||||||
"pagePath": "pages/mine/index",
|
|
||||||
"text": "我的"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -48,6 +46,7 @@
|
|||||||
{
|
{
|
||||||
"path": "pages/index/index",
|
"path": "pages/index/index",
|
||||||
"type": "home",
|
"type": "home",
|
||||||
|
"layout": "tabbar",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationStyle": "custom",
|
"navigationStyle": "custom",
|
||||||
"navigationBarTitleText": "首页"
|
"navigationBarTitleText": "首页"
|
||||||
@ -56,45 +55,9 @@
|
|||||||
{
|
{
|
||||||
"path": "pages/about/about",
|
"path": "pages/about/about",
|
||||||
"type": "page",
|
"type": "page",
|
||||||
|
"layout": "tabbar",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "关于",
|
"navigationBarTitleText": "关于"
|
||||||
"navigationStyle": "custom"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "pages/login/index",
|
|
||||||
"type": "page",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "登录",
|
|
||||||
"navigationStyle": "custom"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "pages/mine/index",
|
|
||||||
"type": "page",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "我的"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "pages/mine/about/index",
|
|
||||||
"type": "page",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "关于我们"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "pages/mine/info/index",
|
|
||||||
"type": "page",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "个人资料"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "pages/mine/password/index",
|
|
||||||
"type": "page",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "修改密码"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -1,50 +1,40 @@
|
|||||||
<route lang="json5">
|
<route lang="json5">
|
||||||
{
|
{
|
||||||
|
layout: 'tabbar',
|
||||||
style: {
|
style: {
|
||||||
navigationBarTitleText: '关于',
|
navigationBarTitleText: '关于',
|
||||||
navigationStyle: 'custom', // 开启自定义导航栏
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
<template>
|
|
||||||
<view>
|
|
||||||
<fg-navbar>关于</fg-navbar>
|
|
||||||
<view
|
|
||||||
class="bg-white overflow-hidden pt-2 px-4"
|
|
||||||
:style="{ marginTop: safeAreaInsets?.top + 'px' }"
|
|
||||||
>
|
|
||||||
<view class="text-center text-3xl mt-8">
|
|
||||||
鸽友们好,我是
|
|
||||||
<text class="text-red-500">菲鸽</text>
|
|
||||||
</view>
|
|
||||||
<!-- <button @click="toSubPage()">去分包</button> -->
|
|
||||||
<view class="test-css">测试 scss 样式</view>
|
|
||||||
<RequestComp />
|
|
||||||
<UploadComp />
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import RequestComp from './components/request.vue'
|
import RequestComp from './components/request.vue'
|
||||||
import UploadComp from './components/upload.vue'
|
import UploadComp from './components/upload.vue'
|
||||||
|
|
||||||
// 获取屏幕边界到安全区域距离
|
// 获取屏幕边界到安全区域距离
|
||||||
const { safeAreaInsets } = uni.getSystemInfoSync()
|
const { safeAreaInsets } = uni.getSystemInfoSync()
|
||||||
const toSubPage = () => {
|
|
||||||
uni.navigateTo({
|
|
||||||
url: '/pages-sub/demo/index',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 奇怪:同样的代码放在 vue 里面不会校验到错误,放在 .ts 文件里面会校验到错误
|
// 奇怪:同样的代码放在 vue 里面不会校验到错误,放在 .ts 文件里面会校验到错误
|
||||||
// const testOxlint = (name: string) => {
|
// const testOxlint = (name: string) => {
|
||||||
// console.log('oxlint')
|
// console.log('oxlint')
|
||||||
// }
|
// }
|
||||||
// testOxlint('oxlint')
|
// testOxlint('oxlint')
|
||||||
|
console.log('about')
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view>
|
||||||
|
<view class="mt-8 text-center text-3xl">
|
||||||
|
鸽友们好,我是
|
||||||
|
<text class="text-red-500">
|
||||||
|
菲鸽
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
<RequestComp />
|
||||||
|
<UploadComp />
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.test-css {
|
.test-css {
|
||||||
// 16rpx=>0.5rem
|
// 16rpx=>0.5rem
|
||||||
|
@ -7,36 +7,9 @@
|
|||||||
}
|
}
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
<template>
|
|
||||||
<view class="p-6 text-center">
|
|
||||||
<view class="my-2">使用的是 laf 云后台</view>
|
|
||||||
<view class="text-green-400">我的推荐码,可以获得佣金</view>
|
|
||||||
|
|
||||||
<!-- #ifdef H5 -->
|
|
||||||
<view class="my-2">
|
|
||||||
<a class="my-2" :href="recommendUrl" target="_blank">{{ recommendUrl }}</a>
|
|
||||||
</view>
|
|
||||||
<!-- #endif -->
|
|
||||||
|
|
||||||
<!-- #ifndef H5 -->
|
|
||||||
<view class="my-2 text-left text-sm">{{ recommendUrl }}</view>
|
|
||||||
<!-- #endif -->
|
|
||||||
|
|
||||||
<!-- http://localhost:9000/#/pages/index/request -->
|
|
||||||
<wd-button @click="run" class="my-6">发送请求</wd-button>
|
|
||||||
<view class="h-16">
|
|
||||||
<view v-if="loading">loading...</view>
|
|
||||||
<block v-else>
|
|
||||||
<view class="text-xl">请求数据如下</view>
|
|
||||||
<view class="text-green leading-8">{{ JSON.stringify(data) }}</view>
|
|
||||||
</block>
|
|
||||||
</view>
|
|
||||||
<wd-button type="error" @click="reset" class="my-6" :disabled="!data">重置数据</wd-button>
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { getFooAPI, postFooAPI, IFooItem } from '@/service/index/foo'
|
import type { IFooItem } from '@/service/index/foo'
|
||||||
|
import { getFooAPI } from '@/service/index/foo'
|
||||||
// import { findPetsByStatusQueryOptions } from '@/service/app'
|
// import { findPetsByStatusQueryOptions } from '@/service/app'
|
||||||
// import { useQuery } from '@tanstack/vue-query'
|
// import { useQuery } from '@tanstack/vue-query'
|
||||||
|
|
||||||
@ -61,7 +34,51 @@ const { loading, error, data, run } = useRequest<IFooItem>(() => getFooAPI('菲
|
|||||||
// refetch,
|
// refetch,
|
||||||
// } = useQuery(findPetsByStatusQueryOptions({ params: { status: ['available'] } }))
|
// } = useQuery(findPetsByStatusQueryOptions({ params: { status: ['available'] } }))
|
||||||
|
|
||||||
const reset = () => {
|
function reset() {
|
||||||
data.value = initialData
|
data.value = initialData
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view class="p-6 text-center">
|
||||||
|
<view class="my-2">
|
||||||
|
使用的是 laf 云后台
|
||||||
|
</view>
|
||||||
|
<view class="text-green-400">
|
||||||
|
我的推荐码,可以获得佣金
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- #ifdef H5 -->
|
||||||
|
<view class="my-2">
|
||||||
|
<a class="my-2" :href="recommendUrl" target="_blank">{{ recommendUrl }}</a>
|
||||||
|
</view>
|
||||||
|
<!-- #endif -->
|
||||||
|
|
||||||
|
<!-- #ifndef H5 -->
|
||||||
|
<view class="my-2 text-left text-sm">
|
||||||
|
{{ recommendUrl }}
|
||||||
|
</view>
|
||||||
|
<!-- #endif -->
|
||||||
|
|
||||||
|
<!-- http://localhost:9000/#/pages/index/request -->
|
||||||
|
<wd-button class="my-6" @click="run">
|
||||||
|
发送请求
|
||||||
|
</wd-button>
|
||||||
|
<view class="h-16">
|
||||||
|
<view v-if="loading">
|
||||||
|
loading...
|
||||||
|
</view>
|
||||||
|
<block v-else>
|
||||||
|
<view class="text-xl">
|
||||||
|
请求数据如下
|
||||||
|
</view>
|
||||||
|
<view class="text-green leading-8">
|
||||||
|
{{ JSON.stringify(data) }}
|
||||||
|
</view>
|
||||||
|
</block>
|
||||||
|
</view>
|
||||||
|
<wd-button type="error" class="my-6" :disabled="!data" @click="reset">
|
||||||
|
重置数据
|
||||||
|
</wd-button>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
@ -7,24 +7,32 @@
|
|||||||
}
|
}
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
<template>
|
|
||||||
<view class="p-4 text-center">
|
|
||||||
<wd-button @click="run">选择图片并上传</wd-button>
|
|
||||||
<view v-if="loading" class="text-blue h-10">上传...</view>
|
|
||||||
<template v-else>
|
|
||||||
<view class="m-2">上传后返回的接口数据:</view>
|
|
||||||
<view class="m-2">{{ data }}</view>
|
|
||||||
<view class="h-80 w-full">
|
|
||||||
<image v-if="data" :src="data.url" mode="scaleToFill" />
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
const { loading, data, run } = useUpload()
|
const { loading, data, run } = useUpload()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view class="p-4 text-center">
|
||||||
|
<wd-button @click="run">
|
||||||
|
选择图片并上传
|
||||||
|
</wd-button>
|
||||||
|
<view v-if="loading" class="h-10 text-blue">
|
||||||
|
上传...
|
||||||
|
</view>
|
||||||
|
<template v-else>
|
||||||
|
<view class="m-2">
|
||||||
|
上传后返回的接口数据:
|
||||||
|
</view>
|
||||||
|
<view class="m-2">
|
||||||
|
{{ data }}
|
||||||
|
</view>
|
||||||
|
<view v-if="data" class="h-80 w-full">
|
||||||
|
<image :src="data.url" mode="scaleToFill" />
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
//
|
//
|
||||||
</style>
|
</style>
|
||||||
|
@ -1,34 +1,14 @@
|
|||||||
<!-- 使用 type="home" 属性设置首页,其他页面不需要设置,默认为page;推荐使用json5,更强大,且允许注释 -->
|
<!-- 使用 type="home" 属性设置首页,其他页面不需要设置,默认为page;推荐使用json5,更强大,且允许注释 -->
|
||||||
<route lang="json5" type="home">
|
<route lang="json5" type="home">
|
||||||
{
|
{
|
||||||
|
layout: 'tabbar',
|
||||||
style: {
|
style: {
|
||||||
|
// 'custom' 表示开启自定义导航栏,默认 'default'
|
||||||
navigationStyle: 'custom',
|
navigationStyle: 'custom',
|
||||||
navigationBarTitleText: '首页',
|
navigationBarTitleText: '首页',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</route>
|
</route>
|
||||||
<template>
|
|
||||||
<view
|
|
||||||
class="bg-white overflow-hidden pt-2 px-4"
|
|
||||||
:style="{ marginTop: safeAreaInsets?.top + 'px' }"
|
|
||||||
>
|
|
||||||
<view class="mt-12">
|
|
||||||
<image src="/static/logo.svg" alt="" class="w-28 h-28 block mx-auto" />
|
|
||||||
</view>
|
|
||||||
<view class="text-center text-4xl text-[#d14328] mt-4">unibest</view>
|
|
||||||
<view class="text-center text-2xl mt-2 mb-8">最好用的 uniapp 开发模板</view>
|
|
||||||
|
|
||||||
<view class="text-justify max-w-100 m-auto text-4 indent mb-2">{{ description }}</view>
|
|
||||||
<view class="text-center mt-8">
|
|
||||||
当前平台是:
|
|
||||||
<text class="text-green-500">{{ PLATFORM.platform }}</text>
|
|
||||||
</view>
|
|
||||||
<view class="text-center mt-4">
|
|
||||||
模板分支是:
|
|
||||||
<text class="text-green-500">base</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import PLATFORM from '@/utils/platform'
|
import PLATFORM from '@/utils/platform'
|
||||||
@ -61,10 +41,55 @@ safeAreaInsets = systemInfo.safeAreaInsets
|
|||||||
// #endif
|
// #endif
|
||||||
const author = ref('菲鸽')
|
const author = ref('菲鸽')
|
||||||
const description = ref(
|
const description = ref(
|
||||||
'unibest 是一个集成了多种工具和技术的 uniapp 开发模板,由 uniapp + Vue3 + Ts + Vite6 + UnoCss + VSCode 构建,模板具有代码提示、自动格式化、统一配置、代码片段等功能,并内置了许多常用的基本组件和基本功能,让你编写 uniapp 拥有 best 体验。',
|
'unibest 是一个集成了多种工具和技术的 uniapp 开发模板,由 uniapp + Vue3 + Ts + Vite5 + UnoCss + VSCode 构建,模板具有代码提示、自动格式化、统一配置、代码片段等功能,并内置了许多常用的基本组件和基本功能,让你编写 uniapp 拥有 best 体验。',
|
||||||
)
|
)
|
||||||
// 测试 uni API 自动引入
|
// 测试 uni API 自动引入
|
||||||
onLoad(() => {
|
onLoad(() => {
|
||||||
console.log('项目作者:', author.value)
|
console.log('项目作者:', author.value)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
console.log('index')
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view class="bg-white px-4 pt-2" :style="{ marginTop: `${safeAreaInsets?.top}px` }">
|
||||||
|
<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]">
|
||||||
|
unibest
|
||||||
|
</view>
|
||||||
|
<view class="mb-8 mt-2 text-center text-2xl">
|
||||||
|
最好用的 uniapp 开发模板
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="m-auto mb-2 max-w-100 text-justify indent text-4">
|
||||||
|
{{ description }}
|
||||||
|
</view>
|
||||||
|
<view class="mt-4 text-center">
|
||||||
|
作者:
|
||||||
|
<text class="text-green-500">
|
||||||
|
菲鸽
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
<view class="mt-4 text-center">
|
||||||
|
官网地址:
|
||||||
|
<text class="text-green-500">
|
||||||
|
https://unibest.tech
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
<view class="mt-6 h-1px bg-#eee" />
|
||||||
|
<view class="mt-8 text-center">
|
||||||
|
当前平台是:
|
||||||
|
<text class="text-green-500">
|
||||||
|
{{ PLATFORM.platform }}
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
<view class="mt-4 text-center">
|
||||||
|
模板分支是:
|
||||||
|
<text class="text-green-500">
|
||||||
|
base
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
@ -1,584 +0,0 @@
|
|||||||
<route lang="json5" type="page">
|
|
||||||
{
|
|
||||||
style: {
|
|
||||||
navigationBarTitleText: '登录',
|
|
||||||
navigationStyle: 'custom',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
</route>
|
|
||||||
<template>
|
|
||||||
<view class="login-container">
|
|
||||||
<!-- 背景装饰元素 -->
|
|
||||||
<view class="bg-decoration bg-circle-1"></view>
|
|
||||||
<view class="bg-decoration bg-circle-2"></view>
|
|
||||||
<view class="bg-decoration bg-circle-3"></view>
|
|
||||||
|
|
||||||
<view class="login-header">
|
|
||||||
<image class="login-logo" :src="appLogo" mode="aspectFit"></image>
|
|
||||||
<view class="login-title">{{ appTitle }}</view>
|
|
||||||
</view>
|
|
||||||
<view class="login-form">
|
|
||||||
<view class="welcome-text">欢迎登录</view>
|
|
||||||
<view class="login-desc">请输入您的账号和密码</view>
|
|
||||||
<view class="login-input-group">
|
|
||||||
<view class="input-wrapper">
|
|
||||||
<wd-input
|
|
||||||
v-model="loginForm.username"
|
|
||||||
prefix-icon="user"
|
|
||||||
placeholder="请输入用户名"
|
|
||||||
clearable
|
|
||||||
class="login-input"
|
|
||||||
:border="false"
|
|
||||||
required
|
|
||||||
></wd-input>
|
|
||||||
<view class="input-bottom-line"></view>
|
|
||||||
</view>
|
|
||||||
<view class="input-wrapper">
|
|
||||||
<wd-input
|
|
||||||
v-model="loginForm.password"
|
|
||||||
prefix-icon="lock-on"
|
|
||||||
placeholder="请输入密码"
|
|
||||||
clearable
|
|
||||||
show-password
|
|
||||||
class="login-input"
|
|
||||||
:border="false"
|
|
||||||
required
|
|
||||||
></wd-input>
|
|
||||||
<view class="input-bottom-line"></view>
|
|
||||||
</view>
|
|
||||||
<!-- 验证码区域 -->
|
|
||||||
<view class="input-wrapper captcha-wrapper">
|
|
||||||
<wd-input
|
|
||||||
v-if="captcha.captchaEnabled"
|
|
||||||
v-model="loginForm.code"
|
|
||||||
prefix-icon="secured"
|
|
||||||
placeholder="请输入验证码"
|
|
||||||
clearable
|
|
||||||
class="login-input captcha-input"
|
|
||||||
:border="false"
|
|
||||||
required
|
|
||||||
>
|
|
||||||
<template #suffix>
|
|
||||||
<image
|
|
||||||
class="captcha-image"
|
|
||||||
:src="'data:image/gif;base64,' + captcha.image"
|
|
||||||
mode="aspectFit"
|
|
||||||
@click="refreshCaptcha"
|
|
||||||
></image>
|
|
||||||
</template>
|
|
||||||
</wd-input>
|
|
||||||
<view class="input-bottom-line"></view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<!-- 登录按钮组 -->
|
|
||||||
<view class="login-buttons">
|
|
||||||
<!-- 账号密码登录按钮 -->
|
|
||||||
<wd-button
|
|
||||||
type="primary"
|
|
||||||
size="large"
|
|
||||||
block
|
|
||||||
@click="handleAccountLogin"
|
|
||||||
class="account-login-btn"
|
|
||||||
>
|
|
||||||
<wd-icon name="right" size="18px" class="login-icon"></wd-icon>
|
|
||||||
登录
|
|
||||||
</wd-button>
|
|
||||||
<!-- 微信小程序一键登录按钮 -->
|
|
||||||
<!-- #ifdef MP-WEIXIN -->
|
|
||||||
<view class="divider">
|
|
||||||
<view class="divider-line"></view>
|
|
||||||
<view class="divider-text">或</view>
|
|
||||||
<view class="divider-line"></view>
|
|
||||||
</view>
|
|
||||||
<wd-button
|
|
||||||
type="info"
|
|
||||||
size="large"
|
|
||||||
block
|
|
||||||
plain
|
|
||||||
@click="handleWechatLogin"
|
|
||||||
class="wechat-login-btn"
|
|
||||||
>
|
|
||||||
微信一键登录
|
|
||||||
</wd-button>
|
|
||||||
<!-- #endif -->
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<!-- 隐私协议勾选 -->
|
|
||||||
<view class="privacy-agreement">
|
|
||||||
<wd-checkbox
|
|
||||||
v-model="agreePrivacy"
|
|
||||||
shape="square"
|
|
||||||
class="privacy-checkbox"
|
|
||||||
active-color="var(--wot-color-theme, #1989fa)"
|
|
||||||
>
|
|
||||||
<view class="agreement-text">
|
|
||||||
我已阅读并同意
|
|
||||||
<text class="agreement-link" @click.stop="handleAgreement('user')">《用户协议》</text>
|
|
||||||
和
|
|
||||||
<text class="agreement-link" @click.stop="handleAgreement('privacy')">《隐私政策》</text>
|
|
||||||
</view>
|
|
||||||
</wd-checkbox>
|
|
||||||
</view>
|
|
||||||
<view class="login-footer"></view>
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { ref } from 'vue'
|
|
||||||
import { useUserStore } from '@/store/user'
|
|
||||||
import { isMpWeixin } from '@/utils/platform'
|
|
||||||
import { getCode, ILoginForm } from '@/api/login'
|
|
||||||
import { toast } from '@/utils/toast'
|
|
||||||
import { isTableBar } from '@/utils/index'
|
|
||||||
import { ICaptcha } from '@/api/login.typings'
|
|
||||||
const redirectRoute = ref('')
|
|
||||||
|
|
||||||
// 获取环境变量
|
|
||||||
const appTitle = ref(import.meta.env.VITE_APP_TITLE || 'Unibest Login')
|
|
||||||
const appLogo = ref(import.meta.env.VITE_APP_LOGO || '/static/logo.svg')
|
|
||||||
|
|
||||||
// 初始化store
|
|
||||||
const userStore = useUserStore()
|
|
||||||
// 路由位置
|
|
||||||
// 验证码图片
|
|
||||||
const captcha = ref<ICaptcha>({
|
|
||||||
captchaEnabled: false,
|
|
||||||
uuid: '',
|
|
||||||
image: '',
|
|
||||||
})
|
|
||||||
// 登录表单数据
|
|
||||||
const loginForm = ref<ILoginForm>({
|
|
||||||
username: 'admin',
|
|
||||||
password: '123456',
|
|
||||||
code: '',
|
|
||||||
uuid: '',
|
|
||||||
})
|
|
||||||
// 隐私协议勾选状态
|
|
||||||
const agreePrivacy = ref(true)
|
|
||||||
|
|
||||||
// 页面加载完毕时触发
|
|
||||||
onLoad((option) => {
|
|
||||||
// 一进来就刷新验证码
|
|
||||||
captcha.value.captchaEnabled && refreshCaptcha()
|
|
||||||
// 获取跳转路由
|
|
||||||
if (option.redirect) {
|
|
||||||
redirectRoute.value = option.redirect
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// 账号密码登录
|
|
||||||
const handleAccountLogin = async () => {
|
|
||||||
if (!agreePrivacy.value) {
|
|
||||||
toast.error('请阅读同意协议')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 表单验证
|
|
||||||
if (!loginForm.value.username) {
|
|
||||||
toast.error('请输入用户名')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (!loginForm.value.password) {
|
|
||||||
toast.error('请输入密码')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (captcha.value.captchaEnabled && !loginForm.value.code) {
|
|
||||||
toast.error('请输入验证码')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 执行登录
|
|
||||||
await userStore.login(loginForm.value)
|
|
||||||
// 跳转到首页或重定向页面
|
|
||||||
const targetUrl = redirectRoute.value || '/pages/index/index'
|
|
||||||
if (isTableBar(targetUrl)) {
|
|
||||||
uni.switchTab({ url: targetUrl })
|
|
||||||
} else {
|
|
||||||
uni.redirectTo({ url: targetUrl })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 微信登录
|
|
||||||
const handleWechatLogin = async () => {
|
|
||||||
if (!isMpWeixin) {
|
|
||||||
toast.info('请在微信小程序中使用此功能')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 验证是否同意隐私协议
|
|
||||||
if (!agreePrivacy.value) {
|
|
||||||
toast.error('请先阅读并同意用户协议和隐私政策')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 微信登录
|
|
||||||
await userStore.wxLogin()
|
|
||||||
// 跳转到首页或重定向页面
|
|
||||||
const targetUrl = redirectRoute.value || '/pages/index/index'
|
|
||||||
if (isTableBar(targetUrl)) {
|
|
||||||
uni.switchTab({ url: targetUrl })
|
|
||||||
} else {
|
|
||||||
uni.redirectTo({ url: targetUrl })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 刷新验证码
|
|
||||||
const refreshCaptcha = () => {
|
|
||||||
// 获取验证码
|
|
||||||
getCode().then((res) => {
|
|
||||||
const { data } = res
|
|
||||||
loginForm.value.uuid = data.uuid
|
|
||||||
captcha.value = data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理协议点击
|
|
||||||
const handleAgreement = (type: 'user' | 'privacy') => {
|
|
||||||
const title = type === 'user' ? '用户协议' : '隐私政策'
|
|
||||||
// showToast(`查看${title}`)
|
|
||||||
// 实际项目中可以跳转到对应的协议页面
|
|
||||||
// uni.navigateTo({
|
|
||||||
// url: `/pages/agreement/${type}`
|
|
||||||
// })
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
/* 验证码输入框样式 */
|
|
||||||
.captcha-wrapper {
|
|
||||||
.captcha-input {
|
|
||||||
:deep(.wd-input__suffix) {
|
|
||||||
margin-right: 0;
|
|
||||||
padding-right: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.captcha-image {
|
|
||||||
width: 100px;
|
|
||||||
height: 36px;
|
|
||||||
margin-left: 10px;
|
|
||||||
border-radius: 8px;
|
|
||||||
cursor: pointer;
|
|
||||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
position: relative;
|
|
||||||
overflow: hidden;
|
|
||||||
|
|
||||||
&::after {
|
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
bottom: 0;
|
|
||||||
background: linear-gradient(to bottom, rgba(255, 255, 255, 0.1), transparent);
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:active {
|
|
||||||
opacity: 0.8;
|
|
||||||
transform: scale(0.96);
|
|
||||||
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.login-container {
|
|
||||||
box-sizing: border-box;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
min-height: 100vh;
|
|
||||||
padding: 0 70rpx;
|
|
||||||
background-color: #ffffff;
|
|
||||||
background-image: linear-gradient(
|
|
||||||
135deg,
|
|
||||||
rgba(25, 137, 250, 0.05) 0%,
|
|
||||||
rgba(255, 255, 255, 0) 100%
|
|
||||||
);
|
|
||||||
position: relative;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 背景装饰元素 */
|
|
||||||
.bg-decoration {
|
|
||||||
position: absolute;
|
|
||||||
border-radius: 50%;
|
|
||||||
background: linear-gradient(135deg, rgba(25, 137, 250, 0.05), rgba(25, 137, 250, 0.1));
|
|
||||||
z-index: 0;
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bg-circle-1 {
|
|
||||||
width: 500rpx;
|
|
||||||
height: 500rpx;
|
|
||||||
top: -200rpx;
|
|
||||||
right: -200rpx;
|
|
||||||
opacity: 0.6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bg-circle-2 {
|
|
||||||
width: 400rpx;
|
|
||||||
height: 400rpx;
|
|
||||||
bottom: 10%;
|
|
||||||
left: -200rpx;
|
|
||||||
opacity: 0.4;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bg-circle-3 {
|
|
||||||
width: 300rpx;
|
|
||||||
height: 300rpx;
|
|
||||||
bottom: -100rpx;
|
|
||||||
right: 10%;
|
|
||||||
opacity: 0.3;
|
|
||||||
background: linear-gradient(135deg, rgba(7, 193, 96, 0.05), rgba(7, 193, 96, 0.1));
|
|
||||||
}
|
|
||||||
|
|
||||||
.login-header {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
margin-top: 120rpx;
|
|
||||||
animation: fadeInDown 0.8s ease-out;
|
|
||||||
|
|
||||||
.login-logo {
|
|
||||||
width: 200rpx;
|
|
||||||
height: 200rpx;
|
|
||||||
border-radius: 36rpx;
|
|
||||||
box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.12);
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
|
|
||||||
&:active {
|
|
||||||
transform: scale(0.95);
|
|
||||||
box-shadow: 0 6rpx 15rpx rgba(0, 0, 0, 0.1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.login-title {
|
|
||||||
margin-top: 30rpx;
|
|
||||||
font-size: 46rpx;
|
|
||||||
font-weight: bold;
|
|
||||||
color: #333333;
|
|
||||||
letter-spacing: 3rpx;
|
|
||||||
text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.05);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.login-form {
|
|
||||||
flex: 1;
|
|
||||||
margin-top: 70rpx;
|
|
||||||
animation: fadeIn 0.8s ease-out 0.2s both;
|
|
||||||
|
|
||||||
.welcome-text {
|
|
||||||
margin-bottom: 16rpx;
|
|
||||||
font-size: 48rpx;
|
|
||||||
font-weight: bold;
|
|
||||||
color: #333333;
|
|
||||||
text-align: center;
|
|
||||||
letter-spacing: 1rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.login-desc {
|
|
||||||
margin-bottom: 70rpx;
|
|
||||||
font-size: 28rpx;
|
|
||||||
color: #888888;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.login-input-group {
|
|
||||||
margin-bottom: 60rpx;
|
|
||||||
position: relative;
|
|
||||||
z-index: 1;
|
|
||||||
|
|
||||||
.input-wrapper {
|
|
||||||
position: relative;
|
|
||||||
margin-bottom: 50rpx;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
border-radius: 16rpx;
|
|
||||||
overflow: hidden;
|
|
||||||
|
|
||||||
&:last-child {
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.login-input {
|
|
||||||
padding: 12rpx 20rpx;
|
|
||||||
background-color: rgba(245, 247, 250, 0.7);
|
|
||||||
border-radius: 16rpx;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
|
|
||||||
:deep(.wd-input__inner) {
|
|
||||||
font-size: 30rpx;
|
|
||||||
color: #333333;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.wd-input__placeholder) {
|
|
||||||
font-size: 28rpx;
|
|
||||||
color: #aaaaaa;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:focus-within {
|
|
||||||
background-color: rgba(245, 247, 250, 0.95);
|
|
||||||
box-shadow: 0 6rpx 16rpx rgba(0, 0, 0, 0.06);
|
|
||||||
transform: translateY(-3rpx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.input-bottom-line {
|
|
||||||
position: absolute;
|
|
||||||
bottom: -2rpx;
|
|
||||||
left: 5%;
|
|
||||||
width: 90%;
|
|
||||||
height: 2rpx;
|
|
||||||
background: linear-gradient(
|
|
||||||
to right,
|
|
||||||
transparent,
|
|
||||||
var(--wot-color-theme, #1989fa),
|
|
||||||
transparent
|
|
||||||
);
|
|
||||||
transition: transform 0.4s ease;
|
|
||||||
transform: scaleX(0);
|
|
||||||
opacity: 0.8;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:focus-within .input-bottom-line {
|
|
||||||
transform: scaleX(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.input-icon {
|
|
||||||
margin-right: 16rpx;
|
|
||||||
color: #666666;
|
|
||||||
transition: color 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:focus-within .input-icon {
|
|
||||||
color: var(--wot-color-theme, #1989fa);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.login-buttons {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 36rpx;
|
|
||||||
|
|
||||||
.account-login-btn {
|
|
||||||
height: 96rpx;
|
|
||||||
margin-top: 20rpx;
|
|
||||||
font-size: 32rpx;
|
|
||||||
font-weight: 500;
|
|
||||||
letter-spacing: 2rpx;
|
|
||||||
border-radius: 48rpx;
|
|
||||||
box-shadow: 0 10rpx 20rpx rgba(25, 137, 250, 0.25);
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
|
|
||||||
.login-icon {
|
|
||||||
margin-right: 8rpx;
|
|
||||||
opacity: 0.8;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:active {
|
|
||||||
box-shadow: 0 5rpx 10rpx rgba(25, 137, 250, 0.2);
|
|
||||||
transform: scale(0.98);
|
|
||||||
|
|
||||||
.login-icon {
|
|
||||||
transform: translateX(3rpx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.divider {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
margin: 24rpx 0;
|
|
||||||
|
|
||||||
.divider-line {
|
|
||||||
flex: 1;
|
|
||||||
height: 1px;
|
|
||||||
background-color: #eeeeee;
|
|
||||||
}
|
|
||||||
|
|
||||||
.divider-text {
|
|
||||||
padding: 0 24rpx;
|
|
||||||
font-size: 24rpx;
|
|
||||||
color: #999999;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.wechat-login-btn {
|
|
||||||
height: 96rpx;
|
|
||||||
font-size: 32rpx;
|
|
||||||
color: #07c160;
|
|
||||||
border-color: #07c160;
|
|
||||||
border-radius: 48rpx;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
|
|
||||||
.wechat-icon {
|
|
||||||
margin-right: 12rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:active {
|
|
||||||
background-color: rgba(7, 193, 96, 0.08);
|
|
||||||
transform: scale(0.98);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.privacy-agreement {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
margin: 30rpx 0 40rpx;
|
|
||||||
animation: fadeIn 0.8s ease-out 0.4s both;
|
|
||||||
|
|
||||||
.privacy-checkbox {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.agreement-text {
|
|
||||||
font-size: 26rpx;
|
|
||||||
line-height: 1.6;
|
|
||||||
color: #666666;
|
|
||||||
|
|
||||||
.agreement-link {
|
|
||||||
padding: 0 4rpx;
|
|
||||||
font-weight: 500;
|
|
||||||
color: var(--wot-color-theme, #1989fa);
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
|
|
||||||
&:active {
|
|
||||||
opacity: 0.8;
|
|
||||||
transform: scale(0.98);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.login-footer {
|
|
||||||
padding: 50rpx 0;
|
|
||||||
margin-top: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 添加动画效果 */
|
|
||||||
@keyframes fadeIn {
|
|
||||||
from {
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
to {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes fadeInDown {
|
|
||||||
from {
|
|
||||||
opacity: 0;
|
|
||||||
transform: translateY(-20px);
|
|
||||||
}
|
|
||||||
to {
|
|
||||||
opacity: 1;
|
|
||||||
transform: translateY(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
@ -1,173 +0,0 @@
|
|||||||
<route lang="json5">
|
|
||||||
{
|
|
||||||
style: {
|
|
||||||
navigationBarTitleText: '关于我们',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
</route>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<view class="about-container">
|
|
||||||
<view class="about-card">
|
|
||||||
<!-- 应用信息 -->
|
|
||||||
<view class="app-info">
|
|
||||||
<view class="logo-wrapper">
|
|
||||||
<wd-img :src="appLogo" width="120px" height="120px" radius="24rpx"></wd-img>
|
|
||||||
</view>
|
|
||||||
<view class="app-name">{{ appTitle }}</view>
|
|
||||||
<view class="app-version">版本 {{ packageJson.version }}</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 联系方式 -->
|
|
||||||
<view class="info-section">
|
|
||||||
<view class="section-title">联系我们</view>
|
|
||||||
<view class="section-content">
|
|
||||||
<view class="contact-item">
|
|
||||||
<wd-icon name="phone" size="20px" class="contact-icon"></wd-icon>
|
|
||||||
<text class="contact-text">客服电话:400-XXX-XXXX</text>
|
|
||||||
</view>
|
|
||||||
<view class="contact-item">
|
|
||||||
<wd-icon name="mail" size="20px" class="contact-icon"></wd-icon>
|
|
||||||
<text class="contact-text">邮箱:support@unibest.tech</text>
|
|
||||||
</view>
|
|
||||||
<view class="contact-item">
|
|
||||||
<wd-icon name="location" size="20px" class="contact-icon"></wd-icon>
|
|
||||||
<text class="contact-text">地址:中国·深圳</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 版权信息 -->
|
|
||||||
<view class="copyright">
|
|
||||||
<text>Copyright © 2025-{{ currentYear }} {{ appTitle }}</text>
|
|
||||||
<text>All Rights Reserved</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
|
||||||
import { ref, computed } from 'vue'
|
|
||||||
import packageJson from '@/../package.json'
|
|
||||||
|
|
||||||
const appTitle = ref(import.meta.env.VITE_APP_TITLE || 'unibest')
|
|
||||||
const appLogo = ref(import.meta.env.VITE_APP_LOGO || '/static/logo.svg')
|
|
||||||
|
|
||||||
// 当前年份
|
|
||||||
const currentYear = computed(() => new Date().getFullYear())
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.about-container {
|
|
||||||
background-color: #f5f7fa;
|
|
||||||
padding: 30rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.about-card {
|
|
||||||
background-color: #ffffff;
|
|
||||||
border-radius: 24rpx;
|
|
||||||
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
|
|
||||||
overflow: hidden;
|
|
||||||
padding: 40rpx 30rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 应用信息 */
|
|
||||||
.app-info {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
padding: 30rpx 0 50rpx;
|
|
||||||
border-bottom: 2rpx solid #f0f0f0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo-wrapper {
|
|
||||||
margin-bottom: 20rpx;
|
|
||||||
box-shadow: 0 8rpx 16rpx rgba(0, 0, 0, 0.08);
|
|
||||||
border-radius: 24rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.app-name {
|
|
||||||
font-size: 40rpx;
|
|
||||||
font-weight: 600;
|
|
||||||
color: #333;
|
|
||||||
margin-bottom: 10rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.app-version {
|
|
||||||
font-size: 28rpx;
|
|
||||||
color: #999;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 信息区块 */
|
|
||||||
.info-section {
|
|
||||||
padding: 40rpx 0;
|
|
||||||
border-bottom: 2rpx solid #f0f0f0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.section-title {
|
|
||||||
font-size: 34rpx;
|
|
||||||
font-weight: 600;
|
|
||||||
color: #333;
|
|
||||||
margin-bottom: 20rpx;
|
|
||||||
position: relative;
|
|
||||||
padding-left: 24rpx;
|
|
||||||
|
|
||||||
&::before {
|
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
top: 50%;
|
|
||||||
transform: translateY(-50%);
|
|
||||||
width: 8rpx;
|
|
||||||
height: 32rpx;
|
|
||||||
background: linear-gradient(135deg, #4a7bff, #6a5acd);
|
|
||||||
border-radius: 4rpx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.section-content {
|
|
||||||
padding: 0 10rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content-text {
|
|
||||||
font-size: 30rpx;
|
|
||||||
color: #666;
|
|
||||||
line-height: 1.6;
|
|
||||||
text-align: justify;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 联系方式 */
|
|
||||||
.contact-item {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
margin-bottom: 20rpx;
|
|
||||||
|
|
||||||
&:last-child {
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.contact-icon {
|
|
||||||
margin-right: 20rpx;
|
|
||||||
color: #4a7bff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.contact-text {
|
|
||||||
font-size: 30rpx;
|
|
||||||
color: #666;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 版权信息 */
|
|
||||||
.copyright {
|
|
||||||
padding-top: 40rpx;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
text {
|
|
||||||
font-size: 26rpx;
|
|
||||||
color: #999;
|
|
||||||
line-height: 1.6;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
@ -1,374 +0,0 @@
|
|||||||
<route lang="json5">
|
|
||||||
{
|
|
||||||
style: {
|
|
||||||
navigationBarTitleText: '我的',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
</route>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<view class="profile-container">
|
|
||||||
{{ JSON.stringify(userInfo) }}
|
|
||||||
<!-- 用户信息区域 -->
|
|
||||||
<view class="user-info-section">
|
|
||||||
<!-- #ifdef MP-WEIXIN -->
|
|
||||||
<button class="avatar-button" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
|
|
||||||
<wd-img :src="userInfo.avatar" width="80px" height="80px" radius="50%"></wd-img>
|
|
||||||
</button>
|
|
||||||
<!-- #endif -->
|
|
||||||
<!-- #ifndef MP-WEIXIN -->
|
|
||||||
<view class="avatar-wrapper" @click="run">
|
|
||||||
<wd-img :src="userInfo.avatar" width="100%" height="100%" radius="50%"></wd-img>
|
|
||||||
</view>
|
|
||||||
<!-- #endif -->
|
|
||||||
<view class="user-details">
|
|
||||||
<!-- #ifdef MP-WEIXIN -->
|
|
||||||
<input
|
|
||||||
type="nickname"
|
|
||||||
class="weui-input"
|
|
||||||
placeholder="请输入昵称"
|
|
||||||
v-model="userInfo.username"
|
|
||||||
/>
|
|
||||||
<!-- #endif -->
|
|
||||||
<!-- #ifndef MP-WEIXIN -->
|
|
||||||
<view class="username">{{ userInfo.username }}</view>
|
|
||||||
<!-- #endif -->
|
|
||||||
<view class="user-id">ID: {{ userInfo.id }}</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 功能区块 -->
|
|
||||||
<view class="function-section">
|
|
||||||
<view class="cell-group">
|
|
||||||
<view class="group-title">账号管理</view>
|
|
||||||
<wd-cell title="个人资料" is-link @click="handleProfileInfo">
|
|
||||||
<template #icon>
|
|
||||||
<wd-icon name="user" size="20px"></wd-icon>
|
|
||||||
</template>
|
|
||||||
</wd-cell>
|
|
||||||
<wd-cell title="账号安全" is-link @click="handlePassword">
|
|
||||||
<template #icon>
|
|
||||||
<wd-icon name="lock-on" size="20px"></wd-icon>
|
|
||||||
</template>
|
|
||||||
</wd-cell>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="cell-group">
|
|
||||||
<view class="group-title">通用设置</view>
|
|
||||||
<wd-cell title="消息通知" is-link @click="handleInform">
|
|
||||||
<template #icon>
|
|
||||||
<wd-icon name="notification" size="20px"></wd-icon>
|
|
||||||
</template>
|
|
||||||
</wd-cell>
|
|
||||||
<wd-cell title="清理缓存" is-link @click="handleClearCache">
|
|
||||||
<template #icon>
|
|
||||||
<wd-icon name="clear" size="20px"></wd-icon>
|
|
||||||
</template>
|
|
||||||
</wd-cell>
|
|
||||||
<wd-cell title="应用更新" is-link @click="handleAppUpdate">
|
|
||||||
<template #icon>
|
|
||||||
<wd-icon name="refresh1" size="20px"></wd-icon>
|
|
||||||
</template>
|
|
||||||
</wd-cell>
|
|
||||||
<wd-cell title="关于我们" is-link @click="handleAbout">
|
|
||||||
<template #icon>
|
|
||||||
<wd-icon name="info-circle" size="20px"></wd-icon>
|
|
||||||
</template>
|
|
||||||
</wd-cell>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="logout-button-wrapper">
|
|
||||||
<wd-button type="error" v-if="hasLogin" block @click="handleLogout">退出登录</wd-button>
|
|
||||||
<wd-button type="primary" v-else block @click="handleLogin">登录</wd-button>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
|
||||||
import { useUserStore } from '@/store'
|
|
||||||
import { useToast } from 'wot-design-uni'
|
|
||||||
import { useUpload } from '@/utils/uploadFile'
|
|
||||||
import { storeToRefs } from 'pinia'
|
|
||||||
import { IUploadSuccessInfo } from '@/api/login.typings'
|
|
||||||
|
|
||||||
const userStore = useUserStore()
|
|
||||||
// 使用storeToRefs解构userInfo
|
|
||||||
const { userInfo } = storeToRefs(userStore)
|
|
||||||
const toast = useToast()
|
|
||||||
const hasLogin = ref(false)
|
|
||||||
|
|
||||||
onShow((options) => {
|
|
||||||
hasLogin.value = !!uni.getStorageSync('token')
|
|
||||||
console.log('个人中心onShow', hasLogin.value, options)
|
|
||||||
|
|
||||||
hasLogin.value && useUserStore().getUserInfo()
|
|
||||||
})
|
|
||||||
// #ifndef MP-WEIXIN
|
|
||||||
// 上传头像
|
|
||||||
const { run } = useUpload<IUploadSuccessInfo>(
|
|
||||||
import.meta.env.VITE_UPLOAD_BASEURL,
|
|
||||||
{},
|
|
||||||
{
|
|
||||||
onSuccess: (res) => {
|
|
||||||
console.log('h5头像上传成功', res)
|
|
||||||
useUserStore().setUserAvatar(res.url)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
// #endif
|
|
||||||
|
|
||||||
// 微信小程序下登录
|
|
||||||
const handleLogin = async () => {
|
|
||||||
// #ifdef MP-WEIXIN
|
|
||||||
|
|
||||||
// 微信登录
|
|
||||||
await userStore.wxLogin()
|
|
||||||
hasLogin.value = true
|
|
||||||
// #endif
|
|
||||||
// #ifndef MP-WEIXIN
|
|
||||||
uni.navigateTo({ url: '/pages/login/index' })
|
|
||||||
// #endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// #ifdef MP-WEIXIN
|
|
||||||
|
|
||||||
// 微信小程序下选择头像事件
|
|
||||||
const onChooseAvatar = (e: any) => {
|
|
||||||
console.log('选择头像', e.detail)
|
|
||||||
const { avatarUrl } = e.detail
|
|
||||||
const { run } = useUpload<IUploadSuccessInfo>(
|
|
||||||
import.meta.env.VITE_UPLOAD_BASEURL,
|
|
||||||
{},
|
|
||||||
{
|
|
||||||
onSuccess: (res) => {
|
|
||||||
console.log('wx头像上传成功', res)
|
|
||||||
useUserStore().setUserAvatar(res.url)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
avatarUrl,
|
|
||||||
)
|
|
||||||
run()
|
|
||||||
}
|
|
||||||
// #endif
|
|
||||||
// #ifdef MP-WEIXIN
|
|
||||||
// 微信小程序下设置用户名
|
|
||||||
const getUserInfo = (e: any) => {
|
|
||||||
console.log(e.detail)
|
|
||||||
}
|
|
||||||
// #endif
|
|
||||||
|
|
||||||
// 个人资料
|
|
||||||
const handleProfileInfo = () => {
|
|
||||||
uni.navigateTo({ url: `/pages/mine/info/index` })
|
|
||||||
}
|
|
||||||
// 账号安全
|
|
||||||
const handlePassword = () => {
|
|
||||||
uni.navigateTo({ url: `/pages/mine/password/index` })
|
|
||||||
}
|
|
||||||
// 消息通知
|
|
||||||
const handleInform = () => {
|
|
||||||
// uni.navigateTo({ url: `/pages/mine/inform/index` })
|
|
||||||
toast.show('功能开发中')
|
|
||||||
}
|
|
||||||
// 应用更新
|
|
||||||
const handleAppUpdate = () => {
|
|
||||||
// #ifdef MP
|
|
||||||
// #ifndef MP-HARMONY
|
|
||||||
const updateManager = uni.getUpdateManager()
|
|
||||||
updateManager.onCheckForUpdate(function (res) {
|
|
||||||
// 请求完新版本信息的回调
|
|
||||||
// console.log(res.hasUpdate)
|
|
||||||
if (res.hasUpdate) {
|
|
||||||
toast.show('检测到新版本,正在下载中...')
|
|
||||||
} else {
|
|
||||||
toast.show('已是最新版本')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
updateManager.onUpdateReady(function (res) {
|
|
||||||
uni.showModal({
|
|
||||||
title: '更新提示',
|
|
||||||
content: '新版本已经准备好,是否重启应用?',
|
|
||||||
success(res) {
|
|
||||||
if (res.confirm) {
|
|
||||||
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
|
||||||
updateManager.applyUpdate()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
})
|
|
||||||
})
|
|
||||||
updateManager.onUpdateFailed(function (res) {
|
|
||||||
// 新的版本下载失败
|
|
||||||
toast.error('新版本下载失败')
|
|
||||||
})
|
|
||||||
// #endif
|
|
||||||
// #endif
|
|
||||||
|
|
||||||
// #ifndef MP
|
|
||||||
toast.show('功能开发中')
|
|
||||||
// #endif
|
|
||||||
}
|
|
||||||
// 关于我们
|
|
||||||
const handleAbout = () => {
|
|
||||||
uni.navigateTo({ url: `/pages/mine/about/index` })
|
|
||||||
}
|
|
||||||
// 清除缓存
|
|
||||||
const handleClearCache = () => {
|
|
||||||
uni.showModal({
|
|
||||||
title: '清除缓存',
|
|
||||||
content: '确定要清除所有缓存吗?\n清除后需要重新登录',
|
|
||||||
success: (res) => {
|
|
||||||
if (res.confirm) {
|
|
||||||
try {
|
|
||||||
// 清除所有缓存
|
|
||||||
uni.clearStorageSync()
|
|
||||||
// 清除用户信息并跳转到登录页
|
|
||||||
useUserStore().logout()
|
|
||||||
toast.show('清除缓存成功')
|
|
||||||
} catch (err) {
|
|
||||||
console.error('清除缓存失败:', err)
|
|
||||||
toast.error('清除缓存失败')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
// 退出登录
|
|
||||||
const handleLogout = () => {
|
|
||||||
uni.showModal({
|
|
||||||
title: '提示',
|
|
||||||
content: '确定要退出登录吗?',
|
|
||||||
success: (res) => {
|
|
||||||
if (res.confirm) {
|
|
||||||
// 清空用户信息
|
|
||||||
useUserStore().logout()
|
|
||||||
hasLogin.value = false
|
|
||||||
// 执行退出登录逻辑
|
|
||||||
toast.show('退出登录成功')
|
|
||||||
// #ifdef MP-WEIXIN
|
|
||||||
// 微信小程序,去首页
|
|
||||||
// uni.reLaunch({ url: '/pages/index/index' })
|
|
||||||
// #endif
|
|
||||||
// #ifndef MP-WEIXIN
|
|
||||||
// 非微信小程序,去登录页
|
|
||||||
// uni.reLaunch({ url: '/pages/login/index' })
|
|
||||||
// #endif
|
|
||||||
}
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
/* 基础样式 */
|
|
||||||
.profile-container {
|
|
||||||
overflow: hidden;
|
|
||||||
font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
|
|
||||||
background-color: #f7f8fa;
|
|
||||||
}
|
|
||||||
/* 用户信息区域 */
|
|
||||||
.user-info-section {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
padding: 40rpx;
|
|
||||||
margin: 30rpx 30rpx 20rpx;
|
|
||||||
background-color: #fff;
|
|
||||||
border-radius: 24rpx;
|
|
||||||
box-shadow: 0 6rpx 20rpx rgba(0, 0, 0, 0.08);
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar-wrapper {
|
|
||||||
width: 160rpx;
|
|
||||||
height: 160rpx;
|
|
||||||
margin-right: 40rpx;
|
|
||||||
overflow: hidden;
|
|
||||||
border: 4rpx solid #f5f5f5;
|
|
||||||
border-radius: 50%;
|
|
||||||
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
|
|
||||||
}
|
|
||||||
.avatar-button {
|
|
||||||
height: 160rpx;
|
|
||||||
padding: 0;
|
|
||||||
margin-right: 40rpx;
|
|
||||||
overflow: hidden;
|
|
||||||
border: 4rpx solid #f5f5f5;
|
|
||||||
border-radius: 50%;
|
|
||||||
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
|
|
||||||
}
|
|
||||||
.user-details {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.username {
|
|
||||||
margin-bottom: 12rpx;
|
|
||||||
font-size: 38rpx;
|
|
||||||
font-weight: 600;
|
|
||||||
color: #333;
|
|
||||||
letter-spacing: 0.5rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.user-id {
|
|
||||||
font-size: 28rpx;
|
|
||||||
color: #666;
|
|
||||||
}
|
|
||||||
|
|
||||||
.user-created {
|
|
||||||
margin-top: 8rpx;
|
|
||||||
font-size: 24rpx;
|
|
||||||
color: #999;
|
|
||||||
}
|
|
||||||
/* 功能区块 */
|
|
||||||
.function-section {
|
|
||||||
padding: 0 20rpx;
|
|
||||||
margin-top: 20rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cell-group {
|
|
||||||
margin-bottom: 20rpx;
|
|
||||||
overflow: hidden;
|
|
||||||
background-color: #fff;
|
|
||||||
border-radius: 16rpx;
|
|
||||||
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
|
|
||||||
}
|
|
||||||
|
|
||||||
.group-title {
|
|
||||||
padding: 24rpx 30rpx 16rpx;
|
|
||||||
font-size: 30rpx;
|
|
||||||
font-weight: 500;
|
|
||||||
color: #999;
|
|
||||||
background-color: #fafafa;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.wd-cell) {
|
|
||||||
border-bottom: 1rpx solid #f5f5f5;
|
|
||||||
|
|
||||||
&:last-child {
|
|
||||||
border-bottom: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wd-cell__title {
|
|
||||||
margin-left: 5px;
|
|
||||||
font-size: 32rpx;
|
|
||||||
color: #333;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cell-icon {
|
|
||||||
margin-right: 20rpx;
|
|
||||||
font-size: 36rpx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* 退出登录按钮 */
|
|
||||||
.logout-button-wrapper {
|
|
||||||
padding: 40rpx 30rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.wd-button--danger) {
|
|
||||||
height: 88rpx;
|
|
||||||
font-size: 32rpx;
|
|
||||||
line-height: 88rpx;
|
|
||||||
color: #fff;
|
|
||||||
background-color: #f53f3f;
|
|
||||||
border-radius: 44rpx;
|
|
||||||
}
|
|
||||||
</style>
|
|
@ -1,190 +0,0 @@
|
|||||||
<route lang="json5">
|
|
||||||
{
|
|
||||||
style: {
|
|
||||||
navigationBarTitleText: '个人资料',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
</route>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<view class="profile-info-container">
|
|
||||||
<view class="profile-card">
|
|
||||||
<view class="form-wrapper">
|
|
||||||
<wd-form ref="formRef" :model="formData" label-width="160rpx" class="profile-form">
|
|
||||||
<wd-cell-group class="form-group">
|
|
||||||
<!-- 昵称 -->
|
|
||||||
<view class="sex-field">
|
|
||||||
<text class="field-label">昵称</text>
|
|
||||||
<wd-input
|
|
||||||
prop="name"
|
|
||||||
clearable
|
|
||||||
v-model="formData.name"
|
|
||||||
placeholder="请输入昵称"
|
|
||||||
:rules="[{ required: true, message: '请填写昵称' }]"
|
|
||||||
class="form-input"
|
|
||||||
/>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 性别 -->
|
|
||||||
<view class="sex-field">
|
|
||||||
<text class="field-label">性别</text>
|
|
||||||
<wd-radio-group
|
|
||||||
v-model="formData.sex"
|
|
||||||
shape="button"
|
|
||||||
:rules="[{ required: true, message: '请选择性别' }]"
|
|
||||||
>
|
|
||||||
<wd-radio :value="'1'">男</wd-radio>
|
|
||||||
<wd-radio :value="'0'">女</wd-radio>
|
|
||||||
</wd-radio-group>
|
|
||||||
</view>
|
|
||||||
</wd-cell-group>
|
|
||||||
</wd-form>
|
|
||||||
|
|
||||||
<!-- 操作按钮 -->
|
|
||||||
<view class="form-actions">
|
|
||||||
<wd-button type="primary" size="large" @click="handleSubmit">保存修改</wd-button>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
|
||||||
import { ref } from 'vue'
|
|
||||||
import { useUserStore } from '@/store'
|
|
||||||
import { storeToRefs } from 'pinia'
|
|
||||||
import { toast } from '@/utils/toast'
|
|
||||||
import { updateInfo } from '@/api/login'
|
|
||||||
|
|
||||||
// 表单引用
|
|
||||||
const formRef = ref()
|
|
||||||
|
|
||||||
// 用户信息
|
|
||||||
const userStore = useUserStore()
|
|
||||||
const { userInfo } = storeToRefs(userStore)
|
|
||||||
|
|
||||||
// 表单数据
|
|
||||||
const formData = ref({
|
|
||||||
id: userInfo.value.id,
|
|
||||||
name: userInfo.value.name,
|
|
||||||
sex: userInfo.value.sex,
|
|
||||||
})
|
|
||||||
|
|
||||||
// 提交表单
|
|
||||||
const handleSubmit = async () => {
|
|
||||||
// 表单验证
|
|
||||||
const valid = await formRef.value.validate()
|
|
||||||
if (!valid) return
|
|
||||||
const { message } = await updateInfo(formData.value)
|
|
||||||
await useUserStore().getUserInfo()
|
|
||||||
toast.success(message)
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.profile-info-container {
|
|
||||||
min-height: 100vh;
|
|
||||||
background-color: #f5f7fa;
|
|
||||||
padding: 30rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.profile-card {
|
|
||||||
background-color: #ffffff;
|
|
||||||
border-radius: 24rpx;
|
|
||||||
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-header {
|
|
||||||
padding: 40rpx 30rpx 20rpx;
|
|
||||||
border-bottom: 2rpx solid #f0f0f0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-title {
|
|
||||||
font-size: 36rpx;
|
|
||||||
font-weight: 600;
|
|
||||||
color: #333;
|
|
||||||
position: relative;
|
|
||||||
display: inline-block;
|
|
||||||
padding-bottom: 16rpx;
|
|
||||||
|
|
||||||
&::after {
|
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
bottom: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 60rpx;
|
|
||||||
height: 6rpx;
|
|
||||||
background: linear-gradient(90deg, #4a7bff, #6a5acd);
|
|
||||||
border-radius: 6rpx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-wrapper {
|
|
||||||
padding: 30rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group {
|
|
||||||
border-radius: 16rpx;
|
|
||||||
overflow: hidden;
|
|
||||||
margin-bottom: 40rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-input {
|
|
||||||
font-size: 30rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sex-field {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
padding: 24rpx 30rpx;
|
|
||||||
background-color: #ffffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.field-label {
|
|
||||||
width: 160rpx;
|
|
||||||
font-size: 30rpx;
|
|
||||||
color: #333;
|
|
||||||
}
|
|
||||||
|
|
||||||
.radio-group {
|
|
||||||
flex: 1;
|
|
||||||
display: flex;
|
|
||||||
gap: 20rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.radio-btn {
|
|
||||||
flex: 1;
|
|
||||||
height: 80rpx;
|
|
||||||
line-height: 80rpx;
|
|
||||||
text-align: center;
|
|
||||||
font-size: 30rpx;
|
|
||||||
border-radius: 12rpx;
|
|
||||||
background-color: #f5f7fa;
|
|
||||||
|
|
||||||
&:active {
|
|
||||||
opacity: 0.8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-actions {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
gap: 20rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.submit-btn {
|
|
||||||
height: 90rpx;
|
|
||||||
border-radius: 45rpx;
|
|
||||||
font-size: 32rpx;
|
|
||||||
font-weight: 500;
|
|
||||||
background: linear-gradient(135deg, #4a7bff, #6a5acd);
|
|
||||||
box-shadow: 0 8rpx 16rpx rgba(74, 123, 255, 0.2);
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
|
|
||||||
&:active {
|
|
||||||
transform: translateY(2rpx);
|
|
||||||
box-shadow: 0 4rpx 8rpx rgba(74, 123, 255, 0.15);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
@ -1,203 +0,0 @@
|
|||||||
<route lang="json5">
|
|
||||||
{
|
|
||||||
style: {
|
|
||||||
navigationBarTitleText: '修改密码',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
</route>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<view class="profile-info-container">
|
|
||||||
<view class="profile-card">
|
|
||||||
<view class="form-wrapper">
|
|
||||||
<wd-form ref="formRef" :model="formData" label-width="160rpx" class="profile-form">
|
|
||||||
<wd-cell-group class="form-group">
|
|
||||||
<!-- 昵称 -->
|
|
||||||
<view class="sex-field">
|
|
||||||
<text class="field-label">旧密码</text>
|
|
||||||
<wd-input
|
|
||||||
prop="oldPassword"
|
|
||||||
clearable
|
|
||||||
v-model="formData.oldPassword"
|
|
||||||
placeholder="请输入旧密码"
|
|
||||||
show-password
|
|
||||||
:rules="[{ required: true, message: '请填写旧密码' }]"
|
|
||||||
class="form-input"
|
|
||||||
/>
|
|
||||||
</view>
|
|
||||||
<view class="sex-field">
|
|
||||||
<text class="field-label">新密码</text>
|
|
||||||
<wd-input
|
|
||||||
prop="newPassword"
|
|
||||||
clearable
|
|
||||||
v-model="formData.newPassword"
|
|
||||||
placeholder="请输入新密码"
|
|
||||||
show-password
|
|
||||||
:rules="[{ required: true, message: '请填写新密码' }]"
|
|
||||||
class="form-input"
|
|
||||||
/>
|
|
||||||
</view>
|
|
||||||
<view class="sex-field">
|
|
||||||
<text class="field-label">确认密码</text>
|
|
||||||
<wd-input
|
|
||||||
prop="confirmPassword"
|
|
||||||
clearable
|
|
||||||
v-model="formData.confirmPassword"
|
|
||||||
placeholder="请输入新密码"
|
|
||||||
show-password
|
|
||||||
:rules="[{ required: true, message: '请填写新密码' }]"
|
|
||||||
class="form-input"
|
|
||||||
/>
|
|
||||||
</view>
|
|
||||||
</wd-cell-group>
|
|
||||||
</wd-form>
|
|
||||||
|
|
||||||
<!-- 操作按钮 -->
|
|
||||||
<view class="form-actions">
|
|
||||||
<wd-button type="primary" size="large" @click="handleSubmit">保存修改</wd-button>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
|
||||||
import { ref } from 'vue'
|
|
||||||
import { useUserStore } from '@/store'
|
|
||||||
import { storeToRefs } from 'pinia'
|
|
||||||
import { toast } from '@/utils/toast'
|
|
||||||
import { updateInfo, updateUserPassword } from '@/api/login'
|
|
||||||
|
|
||||||
// 表单引用
|
|
||||||
const formRef = ref()
|
|
||||||
|
|
||||||
// 用户信息
|
|
||||||
const userStore = useUserStore()
|
|
||||||
const { userInfo } = storeToRefs(userStore)
|
|
||||||
|
|
||||||
// 表单数据
|
|
||||||
const formData = ref({
|
|
||||||
id: userInfo.value.id,
|
|
||||||
oldPassword: '',
|
|
||||||
newPassword: '',
|
|
||||||
confirmPassword: '',
|
|
||||||
})
|
|
||||||
|
|
||||||
// 提交表单
|
|
||||||
const handleSubmit = async () => {
|
|
||||||
// 表单验证
|
|
||||||
const valid = await formRef.value.validate()
|
|
||||||
if (!valid) return
|
|
||||||
const { message } = await updateUserPassword(formData.value)
|
|
||||||
await useUserStore().logout()
|
|
||||||
toast.success('修改成功,请重新登录')
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.profile-info-container {
|
|
||||||
min-height: 100vh;
|
|
||||||
background-color: #f5f7fa;
|
|
||||||
padding: 30rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.profile-card {
|
|
||||||
background-color: #ffffff;
|
|
||||||
border-radius: 24rpx;
|
|
||||||
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-header {
|
|
||||||
padding: 40rpx 30rpx 20rpx;
|
|
||||||
border-bottom: 2rpx solid #f0f0f0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-title {
|
|
||||||
font-size: 36rpx;
|
|
||||||
font-weight: 600;
|
|
||||||
color: #333;
|
|
||||||
position: relative;
|
|
||||||
display: inline-block;
|
|
||||||
padding-bottom: 16rpx;
|
|
||||||
|
|
||||||
&::after {
|
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
bottom: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 60rpx;
|
|
||||||
height: 6rpx;
|
|
||||||
background: linear-gradient(90deg, #4a7bff, #6a5acd);
|
|
||||||
border-radius: 6rpx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-wrapper {
|
|
||||||
padding: 30rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group {
|
|
||||||
border-radius: 16rpx;
|
|
||||||
overflow: hidden;
|
|
||||||
margin-bottom: 40rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-input {
|
|
||||||
font-size: 30rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sex-field {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
padding: 24rpx 30rpx;
|
|
||||||
background-color: #ffffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.field-label {
|
|
||||||
width: 160rpx;
|
|
||||||
font-size: 30rpx;
|
|
||||||
color: #333;
|
|
||||||
}
|
|
||||||
|
|
||||||
.radio-group {
|
|
||||||
flex: 1;
|
|
||||||
display: flex;
|
|
||||||
gap: 20rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.radio-btn {
|
|
||||||
flex: 1;
|
|
||||||
height: 80rpx;
|
|
||||||
line-height: 80rpx;
|
|
||||||
text-align: center;
|
|
||||||
font-size: 30rpx;
|
|
||||||
border-radius: 12rpx;
|
|
||||||
background-color: #f5f7fa;
|
|
||||||
|
|
||||||
&:active {
|
|
||||||
opacity: 0.8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-actions {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
gap: 20rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.submit-btn {
|
|
||||||
height: 90rpx;
|
|
||||||
border-radius: 45rpx;
|
|
||||||
font-size: 32rpx;
|
|
||||||
font-weight: 500;
|
|
||||||
background: linear-gradient(135deg, #4a7bff, #6a5acd);
|
|
||||||
box-shadow: 0 8rpx 16rpx rgba(74, 123, 255, 0.2);
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
|
|
||||||
&:active {
|
|
||||||
transform: translateY(2rpx);
|
|
||||||
box-shadow: 0 4rpx 8rpx rgba(74, 123, 255, 0.15);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
@ -1,27 +1,28 @@
|
|||||||
import { http } from '@/utils/http'
|
import { http } from '@/utils/http'
|
||||||
|
|
||||||
export interface IFooItem {
|
export interface IFooItem {
|
||||||
id: string
|
id: string
|
||||||
name: string
|
name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
/** GET 请求 */
|
/** GET 请求 */
|
||||||
export const getFooAPI = (name: string) => {
|
export function getFooAPI(name: string) {
|
||||||
return http.get<IFooItem>('/foo', { name })
|
return http.get<IFooItem>('/foo', { name })
|
||||||
}
|
}
|
||||||
/** GET 请求;支持 传递 header 的范例 */
|
/** GET 请求;支持 传递 header 的范例 */
|
||||||
export const getFooAPI2 = (name: string) => {
|
export function getFooAPI2(name: string) {
|
||||||
return http.get<IFooItem>('/foo', { name }, { 'Content-Type-100': '100' })
|
return http.get<IFooItem>('/foo', { name }, { 'Content-Type-100': '100' })
|
||||||
}
|
}
|
||||||
|
|
||||||
/** POST 请求 */
|
/** POST 请求 */
|
||||||
export const postFooAPI = (name: string) => {
|
export function postFooAPI(name: string) {
|
||||||
return http.post<IFooItem>('/foo', { name })
|
return http.post<IFooItem>('/foo', { name })
|
||||||
}
|
}
|
||||||
/** POST 请求;需要传递 query 参数的范例;微信小程序经常有同时需要query参数和body参数的场景 */
|
/** POST 请求;需要传递 query 参数的范例;微信小程序经常有同时需要query参数和body参数的场景 */
|
||||||
export const postFooAPI2 = (name: string) => {
|
export function postFooAPI2(name: string) {
|
||||||
return http.post<IFooItem>('/foo', { name })
|
return http.post<IFooItem>('/foo', { name })
|
||||||
}
|
}
|
||||||
/** POST 请求;支持 传递 header 的范例 */
|
/** POST 请求;支持 传递 header 的范例 */
|
||||||
export const postFooAPI3 = (name: string) => {
|
export function postFooAPI3(name: string) {
|
||||||
return http.post<IFooItem>('/foo', { name }, { name }, { 'Content-Type-100': '100' })
|
return http.post<IFooItem>('/foo', { name }, { name }, { 'Content-Type-100': '100' })
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
import {
|
import type { IUserInfoVo } from '@/api/types/login'
|
||||||
login as _login,
|
|
||||||
getUserInfo as _getUserInfo,
|
|
||||||
wxLogin as _wxLogin,
|
|
||||||
logout as _logout,
|
|
||||||
getWxCode,
|
|
||||||
} from '@/api/login'
|
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
import {
|
||||||
|
getUserInfo as _getUserInfo,
|
||||||
|
login as _login,
|
||||||
|
logout as _logout,
|
||||||
|
wxLogin as _wxLogin,
|
||||||
|
getWxCode,
|
||||||
|
} from '@/api/login'
|
||||||
import { toast } from '@/utils/toast'
|
import { toast } from '@/utils/toast'
|
||||||
import { IUserInfoVo } from '@/api/login.typings'
|
|
||||||
|
|
||||||
// 初始化状态
|
// 初始化状态
|
||||||
const userInfoState: IUserInfoVo = {
|
const userInfoState: IUserInfoVo = {
|
||||||
@ -29,7 +29,8 @@ export const useUserStore = defineStore(
|
|||||||
// 若头像为空 则使用默认头像
|
// 若头像为空 则使用默认头像
|
||||||
if (!val.avatar) {
|
if (!val.avatar) {
|
||||||
val.avatar = userInfoState.avatar
|
val.avatar = userInfoState.avatar
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
val.avatar = 'https://oss.laf.run/ukw0y1-site/avatar.jpg?feige'
|
val.avatar = 'https://oss.laf.run/ukw0y1-site/avatar.jpg?feige'
|
||||||
}
|
}
|
||||||
userInfo.value = val
|
userInfo.value = val
|
||||||
@ -45,6 +46,18 @@ export const useUserStore = defineStore(
|
|||||||
uni.removeStorageSync('userInfo')
|
uni.removeStorageSync('userInfo')
|
||||||
uni.removeStorageSync('token')
|
uni.removeStorageSync('token')
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 获取用户信息
|
||||||
|
*/
|
||||||
|
const getUserInfo = async () => {
|
||||||
|
const res = await _getUserInfo()
|
||||||
|
const userInfo = res.data
|
||||||
|
setUserInfo(userInfo)
|
||||||
|
uni.setStorageSync('userInfo', userInfo)
|
||||||
|
uni.setStorageSync('token', userInfo.token)
|
||||||
|
// TODO 这里可以增加获取用户路由的方法 根据用户的角色动态生成路由
|
||||||
|
return res
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 用户登录
|
* 用户登录
|
||||||
* @param credentials 登录参数
|
* @param credentials 登录参数
|
||||||
@ -59,21 +72,10 @@ export const useUserStore = defineStore(
|
|||||||
const res = await _login(credentials)
|
const res = await _login(credentials)
|
||||||
console.log('登录信息', res)
|
console.log('登录信息', res)
|
||||||
toast.success('登录成功')
|
toast.success('登录成功')
|
||||||
getUserInfo()
|
await getUserInfo()
|
||||||
return res
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 获取用户信息
|
|
||||||
*/
|
|
||||||
const getUserInfo = async () => {
|
|
||||||
const res = await _getUserInfo()
|
|
||||||
const userInfo = res.data
|
|
||||||
setUserInfo(userInfo)
|
|
||||||
uni.setStorageSync('userInfo', userInfo)
|
|
||||||
uni.setStorageSync('token', userInfo.token)
|
|
||||||
// TODO 这里可以增加获取用户路由的方法 根据用户的角色动态生成路由
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 退出登录 并 删除用户信息
|
* 退出登录 并 删除用户信息
|
||||||
*/
|
*/
|
||||||
@ -90,7 +92,7 @@ export const useUserStore = defineStore(
|
|||||||
console.log('微信登录code', data)
|
console.log('微信登录code', data)
|
||||||
|
|
||||||
const res = await _wxLogin(data)
|
const res = await _wxLogin(data)
|
||||||
getUserInfo()
|
await getUserInfo()
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// @import './iconfont.css';
|
@import './iconfont.css';
|
||||||
|
|
||||||
.test {
|
.test {
|
||||||
// 可以通过 @apply 多个样式封装整体样式
|
// 可以通过 @apply 多个样式封装整体样式
|
||||||
|
6
src/typings.d.ts
vendored
6
src/typings.d.ts
vendored
@ -1,14 +1,14 @@
|
|||||||
// 全局要用的类型放到这里
|
// 全局要用的类型放到这里
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
type IResData<T> = {
|
interface IResData<T> {
|
||||||
code: number
|
code: number
|
||||||
msg: string
|
msg: string
|
||||||
data: T
|
data: T
|
||||||
}
|
}
|
||||||
|
|
||||||
// uni.uploadFile文件上传参数
|
// uni.uploadFile文件上传参数
|
||||||
type IUniUploadFileOptions = {
|
interface IUniUploadFileOptions {
|
||||||
file?: File
|
file?: File
|
||||||
files?: UniApp.UploadFileOptionFiles[]
|
files?: UniApp.UploadFileOptionFiles[]
|
||||||
filePath?: string
|
filePath?: string
|
||||||
@ -16,7 +16,7 @@ declare global {
|
|||||||
formData?: any
|
formData?: any
|
||||||
}
|
}
|
||||||
|
|
||||||
type IUserInfo = {
|
interface IUserInfo {
|
||||||
nickname?: string
|
nickname?: string
|
||||||
avatar?: string
|
avatar?: string
|
||||||
/** 微信的 openid,非微信没有这个字段 */
|
/** 微信的 openid,非微信没有这个字段 */
|
||||||
|
@ -6,7 +6,7 @@ export enum TestEnum {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// uni.uploadFile文件上传参数
|
// uni.uploadFile文件上传参数
|
||||||
export type IUniUploadFileOptions = {
|
export interface IUniUploadFileOptions {
|
||||||
file?: File
|
file?: File
|
||||||
files?: UniApp.UploadFileOptionFiles[]
|
files?: UniApp.UploadFileOptionFiles[]
|
||||||
filePath?: string
|
filePath?: string
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { CustomRequestOptions } from '@/interceptors/request'
|
import type { CustomRequestOptions } from '@/interceptors/request'
|
||||||
|
|
||||||
export const http = <T>(options: CustomRequestOptions) => {
|
export function http<T>(options: CustomRequestOptions) {
|
||||||
// 1. 返回 Promise 对象
|
// 1. 返回 Promise 对象
|
||||||
return new Promise<IResData<T>>((resolve, reject) => {
|
return new Promise<IResData<T>>((resolve, reject) => {
|
||||||
uni.request({
|
uni.request({
|
||||||
@ -15,15 +15,17 @@ export const http = <T>(options: CustomRequestOptions) => {
|
|||||||
if (res.statusCode >= 200 && res.statusCode < 300) {
|
if (res.statusCode >= 200 && res.statusCode < 300) {
|
||||||
// 2.1 提取核心数据 res.data
|
// 2.1 提取核心数据 res.data
|
||||||
resolve(res.data as IResData<T>)
|
resolve(res.data as IResData<T>)
|
||||||
} else if (res.statusCode === 401) {
|
}
|
||||||
|
else if (res.statusCode === 401) {
|
||||||
// 401错误 -> 清理用户信息,跳转到登录页
|
// 401错误 -> 清理用户信息,跳转到登录页
|
||||||
// userStore.clearUserInfo()
|
// userStore.clearUserInfo()
|
||||||
// uni.navigateTo({ url: '/pages/login/login' })
|
// uni.navigateTo({ url: '/pages/login/login' })
|
||||||
reject(res)
|
reject(res)
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// 其他错误 -> 根据后端错误信息轻提示
|
// 其他错误 -> 根据后端错误信息轻提示
|
||||||
!options.hideErrorToast &&
|
!options.hideErrorToast
|
||||||
uni.showToast({
|
&& uni.showToast({
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
title: (res.data as IResData<T>).msg || '请求错误',
|
title: (res.data as IResData<T>).msg || '请求错误',
|
||||||
})
|
})
|
||||||
@ -49,16 +51,13 @@ export const http = <T>(options: CustomRequestOptions) => {
|
|||||||
* @param header 请求头,默认为json格式
|
* @param header 请求头,默认为json格式
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export const httpGet = <T>(
|
export function httpGet<T>(url: string, query?: Record<string, any>, header?: Record<string, any>, options?: Partial<CustomRequestOptions>) {
|
||||||
url: string,
|
|
||||||
query?: Record<string, any>,
|
|
||||||
header?: Record<string, any>,
|
|
||||||
) => {
|
|
||||||
return http<T>({
|
return http<T>({
|
||||||
url,
|
url,
|
||||||
query,
|
query,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
header,
|
header,
|
||||||
|
...options,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,51 +69,40 @@ export const httpGet = <T>(
|
|||||||
* @param header 请求头,默认为json格式
|
* @param header 请求头,默认为json格式
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export const httpPost = <T>(
|
export function httpPost<T>(url: string, data?: Record<string, any>, query?: Record<string, any>, header?: Record<string, any>, options?: Partial<CustomRequestOptions>) {
|
||||||
url: string,
|
|
||||||
data?: Record<string, any>,
|
|
||||||
query?: Record<string, any>,
|
|
||||||
header?: Record<string, any>,
|
|
||||||
) => {
|
|
||||||
return http<T>({
|
return http<T>({
|
||||||
url,
|
url,
|
||||||
query,
|
query,
|
||||||
data,
|
data,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
header,
|
header,
|
||||||
|
...options,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* PUT 请求
|
* PUT 请求
|
||||||
*/
|
*/
|
||||||
export const httpPut = <T>(
|
export function httpPut<T>(url: string, data?: Record<string, any>, query?: Record<string, any>, header?: Record<string, any>, options?: Partial<CustomRequestOptions>) {
|
||||||
url: string,
|
|
||||||
data?: Record<string, any>,
|
|
||||||
query?: Record<string, any>,
|
|
||||||
header?: Record<string, any>,
|
|
||||||
) => {
|
|
||||||
return http<T>({
|
return http<T>({
|
||||||
url,
|
url,
|
||||||
data,
|
data,
|
||||||
query,
|
query,
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
header,
|
header,
|
||||||
|
...options,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DELETE 请求(无请求体,仅 query)
|
* DELETE 请求(无请求体,仅 query)
|
||||||
*/
|
*/
|
||||||
export const httpDelete = <T>(
|
export function httpDelete<T>(url: string, query?: Record<string, any>, header?: Record<string, any>, options?: Partial<CustomRequestOptions>) {
|
||||||
url: string,
|
|
||||||
query?: Record<string, any>,
|
|
||||||
header?: Record<string, any>,
|
|
||||||
) => {
|
|
||||||
return http<T>({
|
return http<T>({
|
||||||
url,
|
url,
|
||||||
query,
|
query,
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
header,
|
header,
|
||||||
|
...options,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
import pagesConfig from '@/pages.json'
|
import { pages, subPackages } from '@/pages.json'
|
||||||
import { isMpWeixin } from './platform'
|
import { isMpWeixin } from './platform'
|
||||||
|
|
||||||
const { pages, subPackages, tabBar = { list: [] } } = { ...pagesConfig }
|
export function getLastPage() {
|
||||||
|
|
||||||
export const getLastPage = () => {
|
|
||||||
// getCurrentPages() 至少有1个元素,所以不再额外判断
|
// getCurrentPages() 至少有1个元素,所以不再额外判断
|
||||||
// const lastPage = getCurrentPages().at(-1)
|
// const lastPage = getCurrentPages().at(-1)
|
||||||
// 上面那个在低版本安卓中打包会报错,所以改用下面这个【虽然我加了 src/interceptions/prototype.ts,但依然报错】
|
// 上面那个在低版本安卓中打包会报错,所以改用下面这个【虽然我加了 src/interceptions/prototype.ts,但依然报错】
|
||||||
@ -11,46 +9,12 @@ export const getLastPage = () => {
|
|||||||
return pages[pages.length - 1]
|
return pages[pages.length - 1]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const tabBarList = tabBar?.list || []
|
|
||||||
|
|
||||||
/** 判断当前页面是否是 tabbar 页 */
|
|
||||||
export const getIsTabbar = () => {
|
|
||||||
try {
|
|
||||||
const lastPage = getLastPage()
|
|
||||||
const currPath = lastPage?.route
|
|
||||||
|
|
||||||
return Boolean(tabBar?.list?.some((item) => item.pagePath === currPath))
|
|
||||||
} catch {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断指定页面是否是 tabbar 页
|
|
||||||
* @param path 页面路径
|
|
||||||
* @returns true: 是 tabbar 页 false: 不是 tabbar 页
|
|
||||||
*/
|
|
||||||
export const isTableBar = (path: string) => {
|
|
||||||
if (!tabBar) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if (!tabBar.list.length) {
|
|
||||||
// 通常有 tabBar 的话,list 不能有空,且至少有2个元素,这里其实不用处理
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
// 这里需要处理一下 path,因为 tabBar 中的 pagePath 是不带 /pages 前缀的
|
|
||||||
if (path.startsWith('/')) {
|
|
||||||
path = path.substring(1)
|
|
||||||
}
|
|
||||||
return !!tabBar.list.find((e) => e.pagePath === path)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前页面路由的 path 路径和 redirectPath 路径
|
* 获取当前页面路由的 path 路径和 redirectPath 路径
|
||||||
* path 如 '/pages/login/index'
|
* path 如 '/pages/login/index'
|
||||||
* redirectPath 如 '/pages/demo/base/route-interceptor'
|
* redirectPath 如 '/pages/demo/base/route-interceptor'
|
||||||
*/
|
*/
|
||||||
export const currRoute = () => {
|
export function currRoute() {
|
||||||
const lastPage = getLastPage()
|
const lastPage = getLastPage()
|
||||||
const currRoute = (lastPage as any).$page
|
const currRoute = (lastPage as any).$page
|
||||||
// console.log('lastPage.$page:', currRoute)
|
// console.log('lastPage.$page:', currRoute)
|
||||||
@ -65,7 +29,7 @@ export const currRoute = () => {
|
|||||||
return getUrlObj(fullPath)
|
return getUrlObj(fullPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
const ensureDecodeURIComponent = (url: string) => {
|
function ensureDecodeURIComponent(url: string) {
|
||||||
if (url.startsWith('%')) {
|
if (url.startsWith('%')) {
|
||||||
return ensureDecodeURIComponent(decodeURIComponent(url))
|
return ensureDecodeURIComponent(decodeURIComponent(url))
|
||||||
}
|
}
|
||||||
@ -76,7 +40,7 @@ const ensureDecodeURIComponent = (url: string) => {
|
|||||||
* 比如输入url: /pages/login/index?redirect=%2Fpages%2Fdemo%2Fbase%2Froute-interceptor
|
* 比如输入url: /pages/login/index?redirect=%2Fpages%2Fdemo%2Fbase%2Froute-interceptor
|
||||||
* 输出: {path: /pages/login/index, query: {redirect: /pages/demo/base/route-interceptor}}
|
* 输出: {path: /pages/login/index, query: {redirect: /pages/demo/base/route-interceptor}}
|
||||||
*/
|
*/
|
||||||
export const getUrlObj = (url: string) => {
|
export function getUrlObj(url: string) {
|
||||||
const [path, queryStr] = url.split('?')
|
const [path, queryStr] = url.split('?')
|
||||||
// console.log(path, queryStr)
|
// console.log(path, queryStr)
|
||||||
|
|
||||||
@ -99,11 +63,11 @@ export const getUrlObj = (url: string) => {
|
|||||||
* 这里设计得通用一点,可以传递 key 作为判断依据,默认是 needLogin, 与 route-block 配对使用
|
* 这里设计得通用一点,可以传递 key 作为判断依据,默认是 needLogin, 与 route-block 配对使用
|
||||||
* 如果没有传 key,则表示所有的 pages,如果传递了 key, 则表示通过 key 过滤
|
* 如果没有传 key,则表示所有的 pages,如果传递了 key, 则表示通过 key 过滤
|
||||||
*/
|
*/
|
||||||
export const getAllPages = (key = 'needLogin') => {
|
export function getAllPages(key = 'needLogin') {
|
||||||
// 这里处理主包
|
// 这里处理主包
|
||||||
const mainPages = pages
|
const mainPages = pages
|
||||||
.filter((page) => !key || page[key])
|
.filter(page => !key || page[key])
|
||||||
.map((page) => ({
|
.map(page => ({
|
||||||
...page,
|
...page,
|
||||||
path: `/${page.path}`,
|
path: `/${page.path}`,
|
||||||
}))
|
}))
|
||||||
@ -115,7 +79,7 @@ export const getAllPages = (key = 'needLogin') => {
|
|||||||
const { root } = subPageObj
|
const { root } = subPageObj
|
||||||
|
|
||||||
subPageObj.pages
|
subPageObj.pages
|
||||||
.filter((page) => !key || page[key])
|
.filter(page => !key || page[key])
|
||||||
.forEach((page: { path: string } & Record<string, any>) => {
|
.forEach((page: { path: string } & Record<string, any>) => {
|
||||||
subPages.push({
|
subPages.push({
|
||||||
...page,
|
...page,
|
||||||
@ -132,18 +96,18 @@ export const getAllPages = (key = 'needLogin') => {
|
|||||||
* 得到所有的需要登录的 pages,包括主包和分包的
|
* 得到所有的需要登录的 pages,包括主包和分包的
|
||||||
* 只得到 path 数组
|
* 只得到 path 数组
|
||||||
*/
|
*/
|
||||||
export const getNeedLoginPages = (): string[] => getAllPages('needLogin').map((page) => page.path)
|
export const getNeedLoginPages = (): string[] => getAllPages('needLogin').map(page => page.path)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 得到所有的需要登录的 pages,包括主包和分包的
|
* 得到所有的需要登录的 pages,包括主包和分包的
|
||||||
* 只得到 path 数组
|
* 只得到 path 数组
|
||||||
*/
|
*/
|
||||||
export const needLoginPages: string[] = getAllPages('needLogin').map((page) => page.path)
|
export const needLoginPages: string[] = getAllPages('needLogin').map(page => page.path)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据微信小程序当前环境,判断应该获取的 baseUrl
|
* 根据微信小程序当前环境,判断应该获取的 baseUrl
|
||||||
*/
|
*/
|
||||||
export const getEnvBaseUrl = () => {
|
export function getEnvBaseUrl() {
|
||||||
// 请求基准地址
|
// 请求基准地址
|
||||||
let baseUrl = import.meta.env.VITE_SERVER_BASEURL
|
let baseUrl = import.meta.env.VITE_SERVER_BASEURL
|
||||||
|
|
||||||
@ -172,7 +136,7 @@ export const getEnvBaseUrl = () => {
|
|||||||
/**
|
/**
|
||||||
* 根据微信小程序当前环境,判断应该获取的 UPLOAD_BASEURL
|
* 根据微信小程序当前环境,判断应该获取的 UPLOAD_BASEURL
|
||||||
*/
|
*/
|
||||||
export const getEnvBaseUploadUrl = () => {
|
export function getEnvBaseUploadUrl() {
|
||||||
// 请求基准地址
|
// 请求基准地址
|
||||||
let baseUploadUrl = import.meta.env.VITE_UPLOAD_BASEURL
|
let baseUploadUrl = import.meta.env.VITE_UPLOAD_BASEURL
|
||||||
|
|
||||||
|
29
src/utils/queryString.ts
Normal file
29
src/utils/queryString.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/**
|
||||||
|
* 将对象序列化为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('&')
|
||||||
|
}
|
@ -1,11 +1,11 @@
|
|||||||
import { CustomRequestOptions } from '@/interceptors/request'
|
import type { CustomRequestOptions } from '@/interceptors/request'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 请求方法: 主要是对 uni.request 的封装,去适配 openapi-ts-request 的 request 方法
|
* 请求方法: 主要是对 uni.request 的封装,去适配 openapi-ts-request 的 request 方法
|
||||||
* @param options 请求参数
|
* @param options 请求参数
|
||||||
* @returns 返回 Promise 对象
|
* @returns 返回 Promise 对象
|
||||||
*/
|
*/
|
||||||
const http = <T>(options: CustomRequestOptions) => {
|
function http<T>(options: CustomRequestOptions) {
|
||||||
// 1. 返回 Promise 对象
|
// 1. 返回 Promise 对象
|
||||||
return new Promise<T>((resolve, reject) => {
|
return new Promise<T>((resolve, reject) => {
|
||||||
uni.request({
|
uni.request({
|
||||||
@ -20,15 +20,17 @@ const http = <T>(options: CustomRequestOptions) => {
|
|||||||
if (res.statusCode >= 200 && res.statusCode < 300) {
|
if (res.statusCode >= 200 && res.statusCode < 300) {
|
||||||
// 2.1 提取核心数据 res.data
|
// 2.1 提取核心数据 res.data
|
||||||
resolve(res.data as T)
|
resolve(res.data as T)
|
||||||
} else if (res.statusCode === 401) {
|
}
|
||||||
|
else if (res.statusCode === 401) {
|
||||||
// 401错误 -> 清理用户信息,跳转到登录页
|
// 401错误 -> 清理用户信息,跳转到登录页
|
||||||
// userStore.clearUserInfo()
|
// userStore.clearUserInfo()
|
||||||
// uni.navigateTo({ url: '/pages/login/login' })
|
// uni.navigateTo({ url: '/pages/login/login' })
|
||||||
reject(res)
|
reject(res)
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// 其他错误 -> 根据后端错误信息轻提示
|
// 其他错误 -> 根据后端错误信息轻提示
|
||||||
!options.hideErrorToast &&
|
!options.hideErrorToast
|
||||||
uni.showToast({
|
&& uni.showToast({
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
title: (res.data as T & { msg?: string })?.msg || '请求错误',
|
title: (res.data as T & { msg?: string })?.msg || '请求错误',
|
||||||
})
|
})
|
||||||
|
@ -21,8 +21,8 @@ export function showToast(options: ToastOptions | string) {
|
|||||||
position: 'middle',
|
position: 'middle',
|
||||||
message: '',
|
message: '',
|
||||||
}
|
}
|
||||||
const mergedOptions =
|
const mergedOptions
|
||||||
typeof options === 'string'
|
= typeof options === 'string'
|
||||||
? { ...defaultOptions, message: options }
|
? { ...defaultOptions, message: options }
|
||||||
: { ...defaultOptions, ...options }
|
: { ...defaultOptions, ...options }
|
||||||
// 映射position到uniapp支持的格式
|
// 映射position到uniapp支持的格式
|
||||||
|
@ -21,7 +21,7 @@ import { toast } from './toast'
|
|||||||
*/
|
*/
|
||||||
export const uploadFileUrl = {
|
export const uploadFileUrl = {
|
||||||
/** 用户头像上传地址 */
|
/** 用户头像上传地址 */
|
||||||
USER_AVATAR: import.meta.env.VITE_SERVER_BASEURL + '/user/avatar',
|
USER_AVATAR: `${import.meta.env.VITE_SERVER_BASEURL}/user/avatar`,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,12 +31,7 @@ export const uploadFileUrl = {
|
|||||||
* @param formData 额外表单数据
|
* @param formData 额外表单数据
|
||||||
* @param options 上传选项
|
* @param options 上传选项
|
||||||
*/
|
*/
|
||||||
export const useFileUpload = <T = string>(
|
export function useFileUpload<T = string>(url: string, filePath: string, formData: Record<string, any> = {}, options: Omit<UploadOptions, 'sourceType' | 'sizeType' | 'count'> = {}) {
|
||||||
url: string,
|
|
||||||
filePath: string,
|
|
||||||
formData: Record<string, any> = {},
|
|
||||||
options: Omit<UploadOptions, 'sourceType' | 'sizeType' | 'count'> = {},
|
|
||||||
) => {
|
|
||||||
return useUpload<T>(
|
return useUpload<T>(
|
||||||
url,
|
url,
|
||||||
formData,
|
formData,
|
||||||
@ -76,13 +71,9 @@ export interface UploadOptions {
|
|||||||
* @param options 上传选项
|
* @param options 上传选项
|
||||||
* @returns 上传状态和控制对象
|
* @returns 上传状态和控制对象
|
||||||
*/
|
*/
|
||||||
export const useUpload = <T = string>(
|
export function useUpload<T = string>(url: string, formData: Record<string, any> = {}, options: UploadOptions = {},
|
||||||
url: string,
|
|
||||||
formData: Record<string, any> = {},
|
|
||||||
options: UploadOptions = {},
|
|
||||||
/** 直接传入文件路径,跳过选择器 */
|
/** 直接传入文件路径,跳过选择器 */
|
||||||
directFilePath?: string,
|
directFilePath?: string) {
|
||||||
) => {
|
|
||||||
/** 上传中状态 */
|
/** 上传中状态 */
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
/** 上传错误状态 */
|
/** 上传错误状态 */
|
||||||
@ -161,7 +152,8 @@ export const useUpload = <T = string>(
|
|||||||
success: (res) => {
|
success: (res) => {
|
||||||
const file = res.tempFiles[0]
|
const file = res.tempFiles[0]
|
||||||
// 检查文件大小是否符合限制
|
// 检查文件大小是否符合限制
|
||||||
if (!checkFileSize(file.size)) return
|
if (!checkFileSize(file.size))
|
||||||
|
return
|
||||||
|
|
||||||
// 开始上传
|
// 开始上传
|
||||||
loading.value = true
|
loading.value = true
|
||||||
@ -295,7 +287,8 @@ function uploadFile<T>({
|
|||||||
// 上传成功
|
// 上传成功
|
||||||
data.value = _data as T
|
data.value = _data as T
|
||||||
onSuccess?.(_data)
|
onSuccess?.(_data)
|
||||||
} catch (err) {
|
}
|
||||||
|
catch (err) {
|
||||||
// 响应解析错误
|
// 响应解析错误
|
||||||
console.error('解析上传响应失败:', err)
|
console.error('解析上传响应失败:', err)
|
||||||
error.value = true
|
error.value = true
|
||||||
@ -320,7 +313,8 @@ function uploadFile<T>({
|
|||||||
progress.value = res.progress
|
progress.value = res.progress
|
||||||
onProgress?.(res.progress)
|
onProgress?.(res.progress)
|
||||||
})
|
})
|
||||||
} catch (err) {
|
}
|
||||||
|
catch (err) {
|
||||||
// 创建上传任务失败
|
// 创建上传任务失败
|
||||||
console.error('创建上传任务失败:', err)
|
console.error('创建上传任务失败:', err)
|
||||||
error.value = true
|
error.value = true
|
||||||
|
@ -1,21 +1,15 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": true,
|
"composite": true,
|
||||||
"skipLibCheck": true,
|
"lib": ["esnext", "dom"],
|
||||||
|
"baseUrl": ".",
|
||||||
"module": "ESNext",
|
"module": "ESNext",
|
||||||
"moduleResolution": "Node",
|
"moduleResolution": "Node",
|
||||||
"resolveJsonModule": true,
|
|
||||||
"noImplicitThis": true,
|
|
||||||
"allowSyntheticDefaultImports": true,
|
|
||||||
"allowJs": true,
|
|
||||||
"sourceMap": true,
|
|
||||||
"baseUrl": ".",
|
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": ["./src/*"],
|
"@/*": ["./src/*"],
|
||||||
"@img/*": ["./src/static/*"]
|
"@img/*": ["./src/static/*"]
|
||||||
},
|
},
|
||||||
"outDir": "dist",
|
"resolveJsonModule": true,
|
||||||
"lib": ["esnext", "dom"],
|
|
||||||
"types": [
|
"types": [
|
||||||
"@dcloudio/types",
|
"@dcloudio/types",
|
||||||
"@uni-helper/uni-types",
|
"@uni-helper/uni-types",
|
||||||
@ -23,12 +17,17 @@
|
|||||||
"wot-design-uni/global.d.ts",
|
"wot-design-uni/global.d.ts",
|
||||||
"z-paging/types",
|
"z-paging/types",
|
||||||
"./src/typings.d.ts"
|
"./src/typings.d.ts"
|
||||||
]
|
],
|
||||||
|
"allowJs": true,
|
||||||
|
"noImplicitThis": true,
|
||||||
|
"outDir": "dist",
|
||||||
|
"sourceMap": true,
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"skipLibCheck": true
|
||||||
},
|
},
|
||||||
"vueCompilerOptions": {
|
"vueCompilerOptions": {
|
||||||
"plugins": ["@uni-helper/uni-types/volar-plugin"]
|
"plugins": ["@uni-helper/uni-types/volar-plugin"]
|
||||||
},
|
},
|
||||||
"exclude": ["node_modules"],
|
|
||||||
"include": [
|
"include": [
|
||||||
"src/**/*.ts",
|
"src/**/*.ts",
|
||||||
"src/**/*.js",
|
"src/**/*.js",
|
||||||
@ -37,5 +36,6 @@
|
|||||||
"src/**/*.jsx",
|
"src/**/*.jsx",
|
||||||
"src/**/*.vue",
|
"src/**/*.vue",
|
||||||
"src/**/*.json"
|
"src/**/*.json"
|
||||||
]
|
],
|
||||||
|
"exclude": ["node_modules"]
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
import { presetUni } from '@uni-helper/unocss-preset-uni'
|
import { presetUni } from '@uni-helper/unocss-preset-uni'
|
||||||
import {
|
import {
|
||||||
defineConfig,
|
defineConfig,
|
||||||
presetIcons,
|
|
||||||
presetAttributify,
|
presetAttributify,
|
||||||
|
presetIcons,
|
||||||
transformerDirectives,
|
transformerDirectives,
|
||||||
transformerVariantGroup,
|
transformerVariantGroup,
|
||||||
} from 'unocss'
|
} from 'unocss'
|
||||||
@ -20,7 +20,7 @@ export default defineConfig({
|
|||||||
scale: 1.2,
|
scale: 1.2,
|
||||||
warn: true,
|
warn: true,
|
||||||
extraProperties: {
|
extraProperties: {
|
||||||
display: 'inline-block',
|
'display': 'inline-block',
|
||||||
'vertical-align': 'middle',
|
'vertical-align': 'middle',
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
@ -39,6 +39,7 @@ export default defineConfig({
|
|||||||
center: 'flex justify-center items-center',
|
center: 'flex justify-center items-center',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
safelist: [],
|
||||||
rules: [
|
rules: [
|
||||||
[
|
[
|
||||||
'p-safe',
|
'p-safe',
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
|
import path from 'node:path'
|
||||||
|
import process from 'node:process'
|
||||||
import fs from 'fs-extra'
|
import fs from 'fs-extra'
|
||||||
import path from 'path'
|
|
||||||
|
|
||||||
export function copyNativeRes() {
|
export function copyNativeRes() {
|
||||||
const waitPath = path.resolve(__dirname, '../src/nativeResources')
|
const waitPath = path.resolve(__dirname, '../src/nativeResources')
|
||||||
@ -31,7 +32,8 @@ export function copyNativeRes() {
|
|||||||
console.log(
|
console.log(
|
||||||
`[copyNativeRes] 成功将 nativeResources 目录中的资源移动到构建目录:${buildPath}`,
|
`[copyNativeRes] 成功将 nativeResources 目录中的资源移动到构建目录:${buildPath}`,
|
||||||
)
|
)
|
||||||
} catch (error) {
|
}
|
||||||
|
catch (error) {
|
||||||
console.error(`[copyNativeRes] 复制资源失败:`, error)
|
console.error(`[copyNativeRes] 复制资源失败:`, error)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
37
vite-plugins/updatePackageJson.ts
Normal file
37
vite-plugins/updatePackageJson.ts
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// src/plugins/updatePackageJson.ts
|
||||||
|
import type { Plugin } from 'vite'
|
||||||
|
import fs from 'node:fs/promises'
|
||||||
|
import path from 'node:path'
|
||||||
|
import process from 'node:process'
|
||||||
|
|
||||||
|
function updatePackageJson(): Plugin {
|
||||||
|
return {
|
||||||
|
name: 'update-package-json',
|
||||||
|
async buildStart() {
|
||||||
|
// 只在生产环境构建时执行
|
||||||
|
if (process.env.NODE_ENV !== 'production')
|
||||||
|
return
|
||||||
|
|
||||||
|
const packageJsonPath = path.resolve(process.cwd(), 'package.json')
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 读取并解析 package.json
|
||||||
|
const content = await fs.readFile(packageJsonPath, 'utf-8')
|
||||||
|
const packageJson = JSON.parse(content)
|
||||||
|
|
||||||
|
// 更新时间戳(使用 ISO 格式或自定义格式)
|
||||||
|
packageJson['update-time'] = new Date().toISOString().split('T')[0] // YYYY-MM-DD
|
||||||
|
|
||||||
|
// 写回文件(保持 2 空格缩进)
|
||||||
|
await fs.writeFile(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`, 'utf-8')
|
||||||
|
|
||||||
|
console.log(`[update-package-json] 更新时间戳: ${packageJson['update-time']}`)
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.error('[update-package-json] 插件执行失败:', error)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default updatePackageJson
|
@ -1,26 +1,27 @@
|
|||||||
import Uni from '@dcloudio/vite-plugin-uni'
|
|
||||||
import dayjs from 'dayjs'
|
|
||||||
import path from 'node:path'
|
import path from 'node:path'
|
||||||
import { defineConfig, loadEnv } from 'vite'
|
import process from 'node:process'
|
||||||
// @see https://uni-helper.js.org/vite-plugin-uni-pages
|
import Uni from '@dcloudio/vite-plugin-uni'
|
||||||
import UniPages from '@uni-helper/vite-plugin-uni-pages'
|
import Components from '@uni-helper/vite-plugin-uni-components'
|
||||||
// @see https://uni-helper.js.org/vite-plugin-uni-layouts
|
// @see https://uni-helper.js.org/vite-plugin-uni-layouts
|
||||||
import UniLayouts from '@uni-helper/vite-plugin-uni-layouts'
|
import UniLayouts from '@uni-helper/vite-plugin-uni-layouts'
|
||||||
|
// @see https://github.com/uni-helper/vite-plugin-uni-manifest
|
||||||
|
import UniManifest from '@uni-helper/vite-plugin-uni-manifest'
|
||||||
|
// @see https://uni-helper.js.org/vite-plugin-uni-pages
|
||||||
|
import UniPages from '@uni-helper/vite-plugin-uni-pages'
|
||||||
// @see https://github.com/uni-helper/vite-plugin-uni-platform
|
// @see https://github.com/uni-helper/vite-plugin-uni-platform
|
||||||
// 需要与 @uni-helper/vite-plugin-uni-pages 插件一起使用
|
// 需要与 @uni-helper/vite-plugin-uni-pages 插件一起使用
|
||||||
import UniPlatform from '@uni-helper/vite-plugin-uni-platform'
|
import UniPlatform from '@uni-helper/vite-plugin-uni-platform'
|
||||||
// @see https://github.com/uni-helper/vite-plugin-uni-manifest
|
|
||||||
import UniManifest from '@uni-helper/vite-plugin-uni-manifest'
|
|
||||||
/**
|
/**
|
||||||
* 分包优化、模块异步跨包调用、组件异步跨包引用
|
* 分包优化、模块异步跨包调用、组件异步跨包引用
|
||||||
* @see https://github.com/uni-ku/bundle-optimizer
|
* @see https://github.com/uni-ku/bundle-optimizer
|
||||||
*/
|
*/
|
||||||
import Optimization from '@uni-ku/bundle-optimizer'
|
import Optimization from '@uni-ku/bundle-optimizer'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
import { visualizer } from 'rollup-plugin-visualizer'
|
import { visualizer } from 'rollup-plugin-visualizer'
|
||||||
import AutoImport from 'unplugin-auto-import/vite'
|
import AutoImport from 'unplugin-auto-import/vite'
|
||||||
|
import { defineConfig, loadEnv } from 'vite'
|
||||||
import ViteRestart from 'vite-plugin-restart'
|
import ViteRestart from 'vite-plugin-restart'
|
||||||
import { copyNativeRes } from './vite-plugins/copyNativeRes'
|
import updatePackageJson from './vite-plugins/updatePackageJson'
|
||||||
import Components from '@uni-helper/vite-plugin-uni-components'
|
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default async ({ command, mode }) => {
|
export default async ({ command, mode }) => {
|
||||||
@ -74,7 +75,7 @@ export default async ({ command, mode }) => {
|
|||||||
// 自定义插件禁用 vite:vue 插件的 devToolsEnabled,强制编译 vue 模板时 inline 为 true
|
// 自定义插件禁用 vite:vue 插件的 devToolsEnabled,强制编译 vue 模板时 inline 为 true
|
||||||
name: 'fix-vite-plugin-vue',
|
name: 'fix-vite-plugin-vue',
|
||||||
configResolved(config) {
|
configResolved(config) {
|
||||||
const plugin = config.plugins.find((p) => p.name === 'vite:vue')
|
const plugin = config.plugins.find(p => p.name === 'vite:vue')
|
||||||
if (plugin && plugin.api && plugin.api.options) {
|
if (plugin && plugin.api && plugin.api.options) {
|
||||||
plugin.api.options.devToolsEnabled = false
|
plugin.api.options.devToolsEnabled = false
|
||||||
}
|
}
|
||||||
@ -90,7 +91,7 @@ export default async ({ command, mode }) => {
|
|||||||
// Optimization 插件需要 page.json 文件,故应在 UniPages 插件之后执行
|
// Optimization 插件需要 page.json 文件,故应在 UniPages 插件之后执行
|
||||||
Optimization({
|
Optimization({
|
||||||
enable: {
|
enable: {
|
||||||
optimization: true,
|
'optimization': true,
|
||||||
'async-import': true,
|
'async-import': true,
|
||||||
'async-component': true,
|
'async-component': true,
|
||||||
},
|
},
|
||||||
@ -112,9 +113,9 @@ export default async ({ command, mode }) => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
// 打包分析插件,h5 + 生产环境才弹出
|
// 打包分析插件,h5 + 生产环境才弹出
|
||||||
UNI_PLATFORM === 'h5' &&
|
UNI_PLATFORM === 'h5'
|
||||||
mode === 'production' &&
|
&& mode === 'production'
|
||||||
visualizer({
|
&& visualizer({
|
||||||
filename: './node_modules/.cache/visualizer/stats.html',
|
filename: './node_modules/.cache/visualizer/stats.html',
|
||||||
open: true,
|
open: true,
|
||||||
gzipSize: true,
|
gzipSize: true,
|
||||||
@ -129,6 +130,7 @@ export default async ({ command, mode }) => {
|
|||||||
dts: 'src/types/components.d.ts', // 自动生成的组件类型声明文件路径(用于 TypeScript 支持)
|
dts: 'src/types/components.d.ts', // 自动生成的组件类型声明文件路径(用于 TypeScript 支持)
|
||||||
}),
|
}),
|
||||||
Uni(),
|
Uni(),
|
||||||
|
updatePackageJson(),
|
||||||
],
|
],
|
||||||
define: {
|
define: {
|
||||||
__UNI_PLATFORM__: JSON.stringify(UNI_PLATFORM),
|
__UNI_PLATFORM__: JSON.stringify(UNI_PLATFORM),
|
||||||
@ -161,7 +163,7 @@ export default async ({ command, mode }) => {
|
|||||||
[VITE_APP_PROXY_PREFIX]: {
|
[VITE_APP_PROXY_PREFIX]: {
|
||||||
target: VITE_SERVER_BASEURL,
|
target: VITE_SERVER_BASEURL,
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: (path) => path.replace(new RegExp(`^${VITE_APP_PROXY_PREFIX}`), ''),
|
rewrite: path => path.replace(new RegExp(`^${VITE_APP_PROXY_PREFIX}`), ''),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user