添加类型标注
This commit is contained in:
parent
a6372ba559
commit
370a426291
@ -1,10 +1,10 @@
|
||||
const TokenKey = 'App-Token'
|
||||
|
||||
export function getToken() {
|
||||
export function getToken():string {
|
||||
return uni.getStorageSync(TokenKey)
|
||||
}
|
||||
|
||||
export function setToken(token) {
|
||||
export function setToken(token:string) {
|
||||
return uni.setStorageSync(TokenKey, token)
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* 显示消息提示框
|
||||
* @param content 提示的标题
|
||||
*/
|
||||
export function toast(content) {
|
||||
export function toast(content:string) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: content
|
||||
@ -13,7 +13,7 @@ export function toast(content) {
|
||||
* 显示模态弹窗
|
||||
* @param content 提示的标题
|
||||
*/
|
||||
export function showConfirm(content) {
|
||||
export function showConfirm(content:string):Promise<any> {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
@ -31,7 +31,7 @@ export function showConfirm(content) {
|
||||
* 参数处理
|
||||
* @param params 参数
|
||||
*/
|
||||
export function tansParams(params) {
|
||||
export function tansParams(params:any) {
|
||||
let result = ''
|
||||
for (const propName of Object.keys(params)) {
|
||||
const value = params[propName]
|
||||
@ -5,9 +5,9 @@ import store from '@/store'
|
||||
* @param {Array} value 校验值
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
export function checkPermi(value) {
|
||||
export function checkPermi(value:Array<string>) {
|
||||
if (value && value instanceof Array && value.length > 0) {
|
||||
const permissions = store.getters && store.getters.permissions
|
||||
const permissions:Array<string> = store.getters && store.getters.permissions
|
||||
const permissionDatas = value
|
||||
const all_permission = "*:*:*"
|
||||
|
||||
@ -30,9 +30,9 @@ export function checkPermi(value) {
|
||||
* @param {Array} value 校验值
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
export function checkRole(value) {
|
||||
export function checkRole(value:Array<string>) {
|
||||
if (value && value instanceof Array && value.length > 0) {
|
||||
const roles = store.getters && store.getters.roles
|
||||
const roles:Array<string> = store.getters && store.getters.roles
|
||||
const permissionRoles = value
|
||||
const super_admin = "admin"
|
||||
|
||||
@ -10,7 +10,7 @@ let storageNodeKeys = [constant.avatar, constant.name, constant.roles, constant.
|
||||
let storageData = uni.getStorageSync(storageKey) || {}
|
||||
|
||||
const storage = {
|
||||
set: function(key, value) {
|
||||
set: function(key:string, value:any) {
|
||||
if (storageNodeKeys.indexOf(key) != -1) {
|
||||
let tmp = uni.getStorageSync(storageKey)
|
||||
tmp = tmp ? tmp : {}
|
||||
@ -18,10 +18,10 @@ const storage = {
|
||||
uni.setStorageSync(storageKey, tmp)
|
||||
}
|
||||
},
|
||||
get: function(key) {
|
||||
get: function(key:string) {
|
||||
return storageData[key] || ""
|
||||
},
|
||||
remove: function(key) {
|
||||
remove: function(key:string) {
|
||||
delete storageData[key]
|
||||
uni.setStorageSync(storageKey, storageData)
|
||||
},
|
||||
@ -53,8 +53,7 @@ const upload = <T>(config:RequestUploadConfig):Promise<ResponseData<T>> => {
|
||||
reject(code)
|
||||
}
|
||||
},
|
||||
fail: (error) => {
|
||||
// @ts-ignore
|
||||
fail: (error: any) => {
|
||||
let { message } = error
|
||||
if (message == 'Network Error') {
|
||||
message = '后端接口连接异常'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user