Commit 2d77c605 authored by 张超's avatar 张超 🎱

zice

parent 710252f2
...@@ -6,7 +6,7 @@ export let API_HOST; ...@@ -6,7 +6,7 @@ export let API_HOST;
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
//API_HOST = '//10.10.95.74:7777'; //API_HOST = '//10.10.95.74:7777';
//API_HOST = '//192.168.1.16:7777'; //API_HOST = '//192.168.1.16:7777';
API_HOST = '//10.10.94.107:3000'; API_HOST = '//10.10.95.89:3000';
//API_HOST = '//192.168.0.105:7777'; //API_HOST = '//192.168.0.105:7777';
//API_HOST = '//localhost:3002'; //API_HOST = '//localhost:3002';
//API_HOST = window.__data.apiHost; //API_HOST = window.__data.apiHost;
......
...@@ -227,6 +227,9 @@ ...@@ -227,6 +227,9 @@
"Operate": "操作", "Operate": "操作",
"Computed": "计算属性", "Computed": "计算属性",
"Are you sure to close?": "确定关闭吗?", "Are you sure to close?": "确定关闭吗?",
"Failed to update operator": "更新权限列表失败",
"Error delete self": "连自己都删? 不可以!",
"No permission": "没有权限喔!",
"eventGroup": { "eventGroup": {
"in": "接收", "in": "接收",
"out": "派发" "out": "派发"
......
...@@ -126,10 +126,12 @@ export const projectStore = { ...@@ -126,10 +126,12 @@ export const projectStore = {
}, },
updateProject(state, project) { updateProject(state, project) {
const {id, name, creator, data} = project; const {id, name, creator, data, operators, operator} = project;
state.id = id; state.id = id;
state.name = name; state.name = name;
state.creator = creator; state.creator = creator;
state.operators = operators;
state.operator = operator;
const localData = state.data; const localData = state.data;
if (data) { if (data) {
...@@ -184,6 +186,9 @@ export const projectStore = { ...@@ -184,6 +186,9 @@ export const projectStore = {
modifyDependencies(state, value) { modifyDependencies(state, value) {
state.data.dependencies = value; state.data.dependencies = value;
}, },
modifyOperators(state, value) {
state.operators = value;
},
/** /**
* 激活组件 * 激活组件
* @param {*} state * @param {*} state
......
...@@ -86,6 +86,8 @@ ...@@ -86,6 +86,8 @@
codeSyncServeConfig(state) { codeSyncServeConfig(state) {
return state.editor.codeSyncServeConfig; return state.editor.codeSyncServeConfig;
}, },
operators: (state) => state.project.operators,
currentOperator: (state) => state.editor.operator,
}), }),
}, },
async mounted() { async mounted() {
...@@ -212,12 +214,23 @@ ...@@ -212,12 +214,23 @@
} }
return cancel; return cancel;
},
checkAuth() {
let checkStatus = this.operators.includes(this.currentOperator);
if(!checkStatus) {
this.$message({
message: this.$t('No permission'),
type: 'error',
duration: 1000,
});
}
return checkStatus;
}, },
async clickMenu(menuItem) { async clickMenu(menuItem) {
switch (menuItem) { switch (menuItem) {
case 'save': case 'save':
try { try {
this.saveProject(); this.checkAuth() && this.saveProject();
} catch (e) { } catch (e) {
} }
break; break;
...@@ -232,13 +245,13 @@ ...@@ -232,13 +245,13 @@
this.preview(); this.preview();
break; break;
case 'pack': case 'pack':
await this.pack(); this.checkAuth() && await this.pack();
break; break;
case 'pack-debug-mode': case 'pack-debug-mode':
await this.pack(true); this.checkAuth() && await this.pack(true);
break; break;
case 'pack-manager': case 'pack-manager':
this.$refs.packManagerDialog.show(); this.checkAuth() && this.$refs.packManagerDialog.show();
break; break;
case 'search': case 'search':
await this.$refs.processSearchDialog.show(); await this.$refs.processSearchDialog.show();
...@@ -253,7 +266,7 @@ ...@@ -253,7 +266,7 @@
this.$store.commit('undoRedo', -1); this.$store.commit('undoRedo', -1);
break; break;
case 'px-skin-editor': case 'px-skin-editor':
this.$refs.pxSkinEditorDialog.show(); this.checkAuth() && this.$refs.pxSkinEditorDialog.show();
break; break;
case 'exit': case 'exit':
const {projectID} = this.$route.params; const {projectID} = this.$route.params;
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<projectx-config ref="projectxConfig"/> <projectx-config ref="projectxConfig"/>
</el-tab-pane> </el-tab-pane>
<el-tab-pane :label="$t('Auth manager')" name="authManagerEditor"> <el-tab-pane :label="$t('Auth manager')" name="authManagerEditor">
<auth-manager-editor></auth-manager-editor> <auth-manager-editor ref="authManagerEditor"/>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
......
<template> <template>
<div class="project-auth-manager"> <div class="project-auth-manager">
<el-card shadow="hover"> <el-card shadow="hover">
<h3 class="title">当前权限用户列表</h3> <h3 class="title">当前权限用户列表{{operatorsData.length}}</h3>
<div class="user-list" v-if="operators.length > 0"> <div class="user-list" v-if="operatorsData.length > 0">
<el-tag <el-tag
:key="tag" :key="tag"
v-for="tag in operators" v-for="tag in operatorsData"
closable closable
:disable-transitions="false" :disable-transitions="false"
@close="deleteAuth(tag)" @close="deleteAuth(tag)"
...@@ -15,80 +15,97 @@ ...@@ -15,80 +15,97 @@
</div> </div>
<p v-else></p> <p v-else></p>
<el-divider></el-divider> <el-divider></el-divider>
<el-button type="primary" size="small" @click="addDivShow = true">增加权限</el-button> <el-button type="primary" size="small" @click="addDivShow = true"
>增加权限</el-button
>
</el-card> </el-card>
<br />
<el-card shadow="hover" v-show="addDivShow"> <el-card shadow="hover" v-show="addDivShow">
<p>请先勾选后,点击添加按钮</p> <p>请先勾选后,点击添加按钮</p>
<el-checkbox-group v-model="checkList"> <el-checkbox-group v-model="checkList">
<el-checkbox <el-checkbox
v-for="item in devPersons" v-for="item in devPersons"
:key="'dev-' + item" :key="'dev-' + item.id"
:label="item" :label="item.name"
:disabled="operators.includes(item)" :disabled="operatorsData.includes(item.name)"
></el-checkbox> ></el-checkbox>
</el-checkbox-group> </el-checkbox-group>
<br />
<el-button type="primary" size="small" @click="onAdd">添加</el-button> <el-button type="primary" size="small" @click="onAdd">添加</el-button>
</el-card> </el-card>
</div> </div>
</template> </template>
<script> <script>
import { mapState, mapGetters, mapMutations } from "vuex"; import { mapState, mapGetters, mapMutations } from "vuex";
import {playWaiting} from "../../../../utils"; import { playWaiting } from "../../../../utils";
import { getDevPersons } from "../../../../api/editor";
import { updateOperators } from "../../../../api/project";
// updateOperators
export default { export default {
name: "AuthManagerEditor", name: "AuthManagerEditor",
data() { data() {
return { return {
authList: ["张超", "姜西西", "王竹君"], checkList: [],
checkList: ["张超"],
devPersons: [], devPersons: [],
addDivShow: false addDivShow: false,
}; };
}, },
computed: { computed: {
...mapState({ ...mapState({
operators: (state) => operatorsData: (state) => state.project.operators && state.project.operators.split(","),
state.project.operators && state.project.operators.split(","), projectId: (state) => state.project.id,
currentOperator: (state) => state.editor.operator,
}), }),
}, },
mounted() {
// getDevPersons
this._getDevPersons()
},
methods: { methods: {
async _getDevPersons() { ...mapMutations(["modifyOperators"]),
this.devPersons = await this.getDevPersons(); async edit() {
}, this.devPersons = await getDevPersons();
// edit() {
// this.operators = clonePureObj(this.operators).split(",");
// },
save() {
// this.modifyEnv(this.editData);
}, },
onAdd() { onAdd() {
if(!this.operatorsData.includes(this.currentOperator)) {
this.$message({ message: this.$t('No permission'), type: "error" });
return false;
}
let mergeData = [...this.operatorsData, ...this.checkList].join(",");
this.onUpdate(mergeData);
},
async onUpdate(mergeData) {
updateOperators(this.projectId, mergeData)
.then(() => {
this.$message({
message: this.$t("Operate success"),
type: "success",
});
this.modifyOperators(mergeData);
this.checkList = []; this.checkList = [];
this.addDivShow = false; this.addDivShow = false;
// this.editData.push({ })
// name: "", .catch((e) => {
// value: "", this.$message({ message: e.message, type: "error" });
// }); });
}, },
deleteAuth(tag) { deleteAuth(tag) {
this.$confirm( if(this.currentOperator === tag) {
this.$t("Are you sure to delete this user auth") + tag, this.$message({ message: this.$t('Error delete self'), type: "error" });
// this.$t("Alert"), return false;
{ }
if(!this.operatorsData.includes(this.currentOperator)) {
this.$message({ message: this.$t('No permission'), type: "error" });
return false;
}
this.$confirm(this.$t("Are you sure to delete this user auth") + tag, {
confirmButtonText: this.$t("Confirm"), confirmButtonText: this.$t("Confirm"),
cancelButtonText: this.$t("Cancel"), cancelButtonText: this.$t("Cancel"),
type: "warning", type: "warning",
} })
)
.then(() => { .then(() => {
this.authList = this.authList.filter((item) => item !== tag); let mergeData = this.operatorsData
.filter((item) => item !== tag)
.join(",");
this.onUpdate(mergeData);
}) })
.catch((e) => {}); .catch((e) => {});
console.log(tag);
}, },
}, },
}; };
......
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