Commit 46513798 authored by zhangtong5@yidian-inc.com's avatar zhangtong5@yidian-inc.com

update:合并

parents e4707a7e c58cec36
...@@ -90,8 +90,8 @@ exports.get_ks3_config = async (ctx, next) => { ...@@ -90,8 +90,8 @@ exports.get_ks3_config = async (ctx, next) => {
console.log('stringToSign:::', stringToSign) console.log('stringToSign:::', stringToSign)
// const signature = Ks3Util.b64_hmac_sha1(KS3_CONFIG.AccessKeySecret, stringToSign) const signature = Ks3Util.b64_hmac_sha1(KS3_CONFIG.SK, stringToSign)
const signature = crypto.createHmac('sha1', KS3_CONFIG.SK).update(stringToSign).digest().toString('base64'); // const signature = crypto.createHmac('sha1', KS3_CONFIG.SK).update(stringToSign).digest().toString('base64');
console.log("signature::::::", signature) console.log("signature::::::", signature)
ctx.body = { ctx.body = {
......
...@@ -12,6 +12,7 @@ Ks3.b64_hmac_sha1 = function (key, data) { ...@@ -12,6 +12,7 @@ Ks3.b64_hmac_sha1 = function (key, data) {
* Convert an array of big-endian words to a base-64 string * Convert an array of big-endian words to a base-64 string
*/ */
Ks3.binb2b64 = function (binarray) { Ks3.binb2b64 = function (binarray) {
console.log("binb2b64::::::", binarray)
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var str = ""; var str = "";
for (var i = 0; i < binarray.length * 4; i += 3) { for (var i = 0; i < binarray.length * 4; i += 3) {
...@@ -23,6 +24,8 @@ Ks3.binb2b64 = function (binarray) { ...@@ -23,6 +24,8 @@ Ks3.binb2b64 = function (binarray) {
else str += tab.charAt((triplet >> 6 * (3 - j)) & 0x3F); else str += tab.charAt((triplet >> 6 * (3 - j)) & 0x3F);
} }
} }
console.log("binb2b6422222::::::", str)
return str; return str;
} }
......
...@@ -4,10 +4,20 @@ exports.httpReq = (ctx, opts) => { ...@@ -4,10 +4,20 @@ exports.httpReq = (ctx, opts) => {
opts.timeout = opts.timeout || 1000 opts.timeout = opts.timeout || 1000
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
var time_start = +new Date() var time_start = +new Date()
opts.qs = {...ctx.request.query, ...opts.qs};
const defaultQs = {
appid: 'merchant-op',
cv: '1.0.0',
version: '999999',
distribution: 'op',
net: 'wifi',
platform: '2',
}
opts.qs = { ...defaultQs, ...ctx.request.query, ...opts.qs};
request(opts, (err, res, body) => { request(opts, (err, res, body) => {
console.info(`[Api] httpReq (${opts.url},${opts.headers && opts.headers.cookie}, user:[${opts.qs.op_cur_user}]) spent: ${+new Date() - time_start}ms`) console.info(`[Api] httpReq (${ctx.request.url}, user:[${opts.qs.op_cur_user}]) spent: ${+new Date() - time_start}ms`)
if (!err) { if (!err) {
resolve(body) resolve(body)
......
...@@ -47,7 +47,6 @@ export default { ...@@ -47,7 +47,6 @@ export default {
}, },
activeMenu: function () { activeMenu: function () {
console.log(988888, this.$route.path)
return this.$route.path; return this.$route.path;
}, },
}, },
......
ks3-js-sdk @ ea6ab311
Subproject commit ea6ab311ebfa69725e824a5cc28bd53d93681d34
...@@ -8,30 +8,32 @@ import "element-plus/lib/theme-chalk/index.css"; ...@@ -8,30 +8,32 @@ import "element-plus/lib/theme-chalk/index.css";
import "dayjs/locale/zh-cn"; import "dayjs/locale/zh-cn";
import locale from "element-plus/lib/locale/lang/zh-cn"; import locale from "element-plus/lib/locale/lang/zh-cn";
/* import { fetchCurrentUser } from "./service/user"; import { fetchCurrentUser } from "./service/user";
import { checkPathAuth } from "./utils/authUtil"; import { checkPathAuth } from "./utils/authUtil";
import { redirectToLogin } from "./utils/util"; */ import { redirectToLogin } from "./utils/util";
// 处理路由权限 // 处理路由权限
/* router.beforeResolve(async (to, from, next) => { router.beforeResolve(async (to, from, next) => {
if (to.meta.requireAuth && !store.state.permissions) {
if (!to.meta.requireAuth) next();
if (!store.state.permissions) {
const { status, user } = await fetchCurrentUser(); const { status, user } = await fetchCurrentUser();
if (status === 'success') { if (status === 'success') {
store.commit('updateUserInfo', user); store.commit('updateUserInfo', user);
store.dispatch('updateUserPermission', { email: user.email }).then(() => { await store.dispatch('updateUserPermission', { email: user.email })
if (!checkPathAuth(to.path)) {
router.push('/403')
}
})
next()
} else { } else {
redirectToLogin(); redirectToLogin();
return false;
} }
return false; }
if (!checkPathAuth(to.path)) {
router.push('/403')
} else { } else {
next() next()
} }
}) */ })
createApp(App) createApp(App)
.use(router) .use(router)
......
<template> <template>
<div> <div>
<layout> Forbidden! </layout> <layout> 没有权限! </layout>
</div> </div>
</template> </template>
......
<template> <template>
<div> <div>
<layout> <layout>
not found 页面不存在!
</layout> </layout>
</div> </div>
</template> </template>
......
...@@ -31,7 +31,9 @@ ...@@ -31,7 +31,9 @@
<el-form-item class="func-btn"> <el-form-item class="func-btn">
<el-button type="primary" @click="getUserList">查询</el-button> <el-button type="primary" @click="getUserList">查询</el-button>
<el-button @click="onReset">重置</el-button> <el-button @click="onReset">重置</el-button>
<el-button @click="createUser">新建用户</el-button> <el-button @click="createUser" :disabled="!permission.get('create')"
>新建用户</el-button
>
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-table :data="renderUserList" border style="width: 100%"> <el-table :data="renderUserList" border style="width: 100%">
...@@ -50,7 +52,11 @@ ...@@ -50,7 +52,11 @@
<el-button type="text" size="small" @click="checkUser(scope.row)" <el-button type="text" size="small" @click="checkUser(scope.row)"
>查看</el-button >查看</el-button
> >
<el-button @click="editUser(scope.row)" type="text" size="small" <el-button
@click="editUser(scope.row)"
type="text"
size="small"
:disabled="!permission.get('edit')"
>修改</el-button >修改</el-button
> >
<el-button <el-button
...@@ -58,6 +64,7 @@ ...@@ -58,6 +64,7 @@
type="text" type="text"
size="small" size="small"
@click="disableUser(scope.row)" @click="disableUser(scope.row)"
:disabled="!permission.get('enable')"
>禁用</el-button >禁用</el-button
> >
<el-button <el-button
...@@ -65,6 +72,7 @@ ...@@ -65,6 +72,7 @@
type="text" type="text"
size="small" size="small"
@click="enableUser(scope.row)" @click="enableUser(scope.row)"
:disabled="!permission.get('disable')"
>启用</el-button >启用</el-button
> >
</template> </template>
...@@ -118,7 +126,7 @@ export default { ...@@ -118,7 +126,7 @@ export default {
UserInfoEditModal, UserInfoEditModal,
UserInfoNewModal, UserInfoNewModal,
}, },
data () { data() {
return { return {
pageParams: { pageParams: {
page: 1, page: 1,
...@@ -140,7 +148,14 @@ export default { ...@@ -140,7 +148,14 @@ export default {
}; };
}, },
computed: { computed: {
renderUserList () { permission() {
const modulePermissions =
this.$store.getters.moduleSubPermissions("user") || [];
console.log("Current page func-permissions:", modulePermissions);
return new Map(modulePermissions.map((ele) => [ele.name, true]));
},
renderUserList() {
const statusMap = new Map([ const statusMap = new Map([
[1, "启用"], [1, "启用"],
[2, "禁用"], [2, "禁用"],
...@@ -152,11 +167,11 @@ export default { ...@@ -152,11 +167,11 @@ export default {
}); });
}, },
}, },
beforeMount () { beforeMount() {
this.getUserList(); this.getUserList();
}, },
methods: { methods: {
async getUserList () { async getUserList() {
const { code, result } = await reqGetUserList(this.pageParams); const { code, result } = await reqGetUserList(this.pageParams);
if (code !== 0) { if (code !== 0) {
...@@ -168,7 +183,7 @@ export default { ...@@ -168,7 +183,7 @@ export default {
this.userList = data; this.userList = data;
}, },
async setCurUserInfo (user_id) { async setCurUserInfo(user_id) {
const { code, result } = await reqGetUserDetail({ user_id }); const { code, result } = await reqGetUserDetail({ user_id });
if (code === 0) { if (code === 0) {
this.curUserInfo = { this.curUserInfo = {
...@@ -180,13 +195,13 @@ export default { ...@@ -180,13 +195,13 @@ export default {
} }
}, },
async checkUser (row) { async checkUser(row) {
const { user_id } = row; const { user_id } = row;
await this.setCurUserInfo(user_id); await this.setCurUserInfo(user_id);
this.openModal("info"); this.openModal("info");
}, },
async editUser (row) { async editUser(row) {
const { user_id } = row; const { user_id } = row;
await this.setCurUserInfo(user_id); await this.setCurUserInfo(user_id);
// this.openModal('edit'); // this.openModal('edit');
...@@ -194,13 +209,13 @@ export default { ...@@ -194,13 +209,13 @@ export default {
this.curOperateMode = "edit"; this.curOperateMode = "edit";
}, },
openModal (key) { openModal(key) {
Object.keys(this.modalVisable).forEach((ele) => { Object.keys(this.modalVisable).forEach((ele) => {
this.modalVisable[ele] = key === ele; this.modalVisable[ele] = key === ele;
}); });
}, },
async confirmEditModal (userInfo) { async confirmEditModal(userInfo) {
const { const {
user_id, user_id,
user_name, user_name,
...@@ -247,17 +262,17 @@ export default { ...@@ -247,17 +262,17 @@ export default {
} }
}, },
cancelModal (name) { cancelModal(name) {
this.modalVisable[name] = false; this.modalVisable[name] = false;
}, },
createUser () { createUser() {
this.curOperateMode = "new"; this.curOperateMode = "new";
this.openModal("new"); this.openModal("new");
}, },
//重置 //重置
onReset () { onReset() {
this.pageParams = { this.pageParams = {
page: 1, page: 1,
pageSize: 20, pageSize: 20,
...@@ -266,15 +281,16 @@ export default { ...@@ -266,15 +281,16 @@ export default {
user_mobile: "", user_mobile: "",
user_status: "", user_status: "",
}; };
this.getUserList();
}, },
updatePage ({ page, pageSize }) { updatePage({ page, pageSize }) {
page && (this.pageParams.page = page); page && (this.pageParams.page = page);
pageSize && (this.pageParams.pageSize = pageSize); pageSize && (this.pageParams.pageSize = pageSize);
this.getUserList(); this.getUserList();
}, },
async enableUser (row) { async enableUser(row) {
const { user_id } = row; const { user_id } = row;
const { code, reason } = await reqEditUser({ user_status: 1, user_id }); const { code, reason } = await reqEditUser({ user_status: 1, user_id });
...@@ -286,7 +302,7 @@ export default { ...@@ -286,7 +302,7 @@ export default {
} }
}, },
async disableUser (row) { async disableUser(row) {
const { user_id, reason } = row; const { user_id, reason } = row;
const { code } = await reqEditUser({ user_status: 2, user_id }); const { code } = await reqEditUser({ user_status: 2, user_id });
if (code === 0) { if (code === 0) {
......
...@@ -13,13 +13,13 @@ import axios from '../utils/request'; ...@@ -13,13 +13,13 @@ import axios from '../utils/request';
export async function ksOssUpload(file) { export async function ksOssUpload(file) {
const {bucket, objectId, policy, signature} = await getKs3Config(); const { bucket, objectId, policy, signature } = await getKs3Config();
const protocal = window.location.protocol === 'https:' ? 'https' : 'http'; const protocal = window.location.protocol === 'https:' ? 'https' : 'http';
const uploadURL = `${protocal}://${KS3_CONST.DOMAIN}/${bucket}`; const uploadURL = `${protocal}://${KS3_CONST.DOMAIN}/${bucket}`;
// return new Promise((resolve, reject) => { // return new Promise((resolve, reject) => {
// CommonServer.getKsOssSign().then(res => { // CommonServer.getKsOssSign().then(res => {
// const { accessid, policy, signature } = res // const { accessid, policy, signature } = res
const formData = new FormData() const formData = new FormData()
formData.append('acl', 'public-read') formData.append('acl', 'public-read')
formData.append('key', objectId) formData.append('key', objectId)
...@@ -27,23 +27,9 @@ export async function ksOssUpload(file) { ...@@ -27,23 +27,9 @@ export async function ksOssUpload(file) {
formData.append('KSSAccessKeyId', KS3_CONST.AccessKeyID) formData.append('KSSAccessKeyId', KS3_CONST.AccessKeyID)
formData.append('policy', policy) formData.append('policy', policy)
formData.append('file', file) formData.append('file', file)
const res = await axios.post(uploadURL, formData).then(res => { console.log('ksOssUpload url::', uploadURL)
console.log(66666 ,res) const res = await axios({ url: uploadURL, method: 'post', data: formData, withCredentials: false }).then(res => {
// const { status } = res console.log('ksOssUpload res::', res)
// if (status === 200) {
// const data = {
// url: `${OSS_URL}/${key}`,
// type: fileType(file.name)
// }
// resolve(data)
// } else {
// reject(res)
// }
}) })
// .catch(err => {
// reject(err)
// })
return res; return res;
// }).catch(err => {})
// })
} }
\ No newline at end of file
/**
* axios封装
*/
import axios from "axios"; import axios from "axios";
import store from "@/store" import store from "@/store"
import { v1 as uuidv1 } from 'uuid';
// import { ElMessage } from "element-plus"; // import { ElMessage } from "element-plus";
// import { APP_URI } from "../config/app.config"; // import { APP_URI } from "../config/app.config";
/** /**
...@@ -32,7 +31,9 @@ export const defaultConfig = { ...@@ -32,7 +31,9 @@ export const defaultConfig = {
*/ */
const getDefaultParams = () => { const getDefaultParams = () => {
return { return {
'op_cur_user': store.state.userInfo && store.state.userInfo.email 'op_cur_user': store.state.userInfo && store.state.userInfo.email,
'reqid': uuidv1().replace(/-/g, '')
} }
}; };
const getDefaultHeaders = () => {}; const getDefaultHeaders = () => {};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment