1、添加自定义icon组件、空数据组件;2、添加数据持久化,方便web调试

unocss
chris 8 months ago
parent 7db8a995b2
commit 601e687c48

@ -10,6 +10,13 @@
"app-plus" : { "app-plus" : {
"launchtype" : "local" "launchtype" : "local"
}, },
"default" : {
"launchtype" : "local"
},
"h5" : {
"launchtype" : "local"
},
"provider" : "aliyun",
"type" : "uniCloud" "type" : "uniCloud"
}, },
{ {

@ -1,12 +1,15 @@
<script setup> <script setup>
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app' import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
import { onBeforeUnmount } from 'vue' import { onBeforeMount } from 'vue'
// #ifdef APP // #ifdef APP
import { useSystemStore } from '@/store/system.js'; import { useSystemStore } from '@/store/system.js';
const systemStore = useSystemStore() const systemStore = useSystemStore()
// #endif // #endif
import { useUserStore } from '@/store/user.js';
const userStore = useUserStore();
onLaunch(() => { onLaunch(() => {
console.log('App Launch') console.log('App Launch')
// #ifdef APP // #ifdef APP
@ -23,34 +26,12 @@
console.log('App Hide') console.log('App Hide')
}) })
onBeforeUnmount(() => { onBeforeMount(() => {
uni.removeStorage({ key: 'uId' }) const userInfo = uni.getStorageSync('uInfo')
if (userInfo) {
userStore.setUserInfo(JSON.parse(userInfo))
}
}) })
// export default {
// onLaunch: function() {
// console.log('App Launch')
// },
// onShow: function() {
// console.log('App Show')
// // #ifdef APP
// checkUpdate().then(res => {
// console.log('', res)
// }).catch(error => {
// console.log("", error)
// })
// // #endif
// const appInfo = uni.getAppBaseInfo()
// console.log(appInfo)
// systemStore.setAppInfo(appInfo)
// },
// onHide: function() {
// console.log('App Hide')
// },
// beforeUnmount () {
// uni.removeStorage({ key: 'uId' })
// }
// }
</script> </script>
<style> <style>

@ -0,0 +1,85 @@
@font-face {
font-family: "iconfont"; /* Project id */
src: url('./iconfont.ttf?t=1711616861841') format('truetype');
}
.iconfont {
font-family: "iconfont" !important;
font-size: 16px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-tigan:before {
content: "\e62f";
}
.icon-zuoye:before {
content: "\e625";
}
.icon-erweima:before {
content: "\e624";
}
.icon-daan:before {
content: "\e632";
}
.icon-xiezuoye:before {
content: "\e626";
}
.icon-empty:before {
content: "\e65f";
}
.icon-shiti:before {
content: "\e665";
}
.icon-shengban-shengji:before {
content: "\e643";
}
.icon-zhishidian:before {
content: "\e723";
}
.icon-xuesheng:before {
content: "\e67c";
}
.icon-banji:before {
content: "\e61a";
}
.icon-jiexi:before {
content: "\e769";
}
.icon-xuehao:before {
content: "\e666";
}
.icon-denglu:before {
content: "\e6bd";
}
.icon-lianxi2hebing_dayin:before {
content: "\e630";
}
.icon-dayinyulan:before {
content: "\e601";
}
.icon-a-kaoshi4:before {
content: "\eb09";
}
.icon-yulan:before {
content: "\e678";
}

Binary file not shown.

@ -1,2 +1,3 @@
@import './common.scss'; @import './common.scss';
@import './content.scss'; @import './content.scss';
@import './fonts/iconfont.css';

@ -0,0 +1,3 @@
.ch-empty {
padding: 60rpx 60rpx;
}

@ -0,0 +1,12 @@
<template>
<ch-flex class="ch-empty" justify="center" items="center">
<ch-icon name="empty" :size="100" color="#bbb"></ch-icon>
</ch-flex>
</template>
<script setup name="ch-empty">
</script>
<style lang="scss" scoped>
@import './ch-empty.scss';
</style>

@ -0,0 +1,35 @@
<template>
<text class="ch-icon iconfont" :class="iconCls" :style="style">
</text>
</template>
<script setup name="ch-icon">
import { computed, defineProps } from 'vue';
const props = defineProps({
size: {
type: Number,
default: 28
},
name: {
type: String,
default: ''
},
color: {
type: String,
default: '#666'
}
})
const iconCls = computed(() => {
return props.name ? `icon-${props.name}` : ''
})
const style = computed(() => {
return `font-size: ${props.size}px; color: ${props.color}`
})
</script>
<style lang="scss">
</style>

@ -1,7 +1,10 @@
import ChNavBar from '@/components/ch-nav-bar/ch-nav-bar.vue' import ChNavBar from '@/components/ch-nav-bar/ch-nav-bar.vue'
import ChNavBtn from '@/components/ch-nav-btn/ch-nav-btn.vue' import ChNavBtn from '@/components/ch-nav-btn/ch-nav-btn.vue'
import ChIcon from '@/components/ch-icon/ch-icon.vue';
import ChEmpty from '@/components/ch-empty/ch-empty.vue';
export default function registerComponents (app) { export default function registerComponents (app) {
app.component(ChNavBar.name, ChNavBar); app.component(ChNavBar.name, ChNavBar);
app.component(ChNavBtn.name, ChNavBtn); app.component(ChNavBtn.name, ChNavBtn);
app.component(ChIcon.name, ChIcon)
} }

@ -15,6 +15,7 @@
</uni-list-item> </uni-list-item>
</template> </template>
</uni-list> </uni-list>
<ch-empty v-if="!examList.length"></ch-empty>
</view> </view>
</template> </template>

@ -29,7 +29,8 @@
</ch-flex> </ch-flex>
</checkbox-group> </checkbox-group>
</view> </view>
<uni-load-more :status="scrollStatus"></uni-load-more> <ch-empty v-if="!questionList.length"></ch-empty>
<uni-load-more :status="scrollStatus" v-if="questionList.length > queryParams.pagesize"></uni-load-more>
</scroll-view> </scroll-view>
</view> </view>
</template> </template>

@ -15,6 +15,7 @@
</uni-list-item> </uni-list-item>
</template> </template>
</uni-list> </uni-list>
<ch-empty v-if="!taskList.length"></ch-empty>
</view> </view>
</template> </template>

@ -52,7 +52,7 @@ const status = computed(() => {
}) })
const uploadUrl = computed(() => { const uploadUrl = computed(() => {
return `${config.baseUrl}/api/user.ashx?act=studenthomeworkinfo&studentid=${userId}&homeworkid=${taskId.value}` return `${config.baseUrl}/api/user.ashx?act=subhomeworkinfo&studentid=${userId}&homeworkid=${taskId.value}`
}) })
onLoad((option) => { onLoad((option) => {

@ -11,9 +11,9 @@ uniCrazyRouter.beforeEach(async (to, from ,next)=>{
console.log('beforEach router') console.log('beforEach router')
const path = to.url; const path = to.url;
const uId = uni.getStorageSync('uId') || null; const uInfo = uni.getStorageSync('uInfo') || null;
if (whiteList.includes(path) || uId) { if (whiteList.includes(path) || uInfo) {
next() next()
return; return;
} }

@ -15,8 +15,7 @@ export const useSystemStore = defineStore('system', () => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
login(params,).then(res => { login(params,).then(res => {
userStore.setUserInfo(res); userStore.setUserInfo(res);
userStore.setUserId(res.studentid); uni.setStorageSync('uInfo', JSON.stringify(res));
uni.setStorageSync('uId', res.studentid);
resolve(res) resolve(res)
}).catch(error => { }).catch(error => {
console.log('登录失败:', error) console.log('登录失败:', error)

@ -7,11 +7,8 @@ export const useUserStore = defineStore('user', () => {
function setUserInfo(info) { function setUserInfo(info) {
userInfo.value = info; userInfo.value = info;
userId.value = info.studentid
} }
function setUserId(id) { return { userInfo, userId, setUserInfo };
userId.value = id;
}
return { userInfo, userId, setUserInfo, setUserId };
}) })

Loading…
Cancel
Save