Commit 2fafa841 by 庄欣

完成

parent fb7dbea6
......@@ -135,3 +135,33 @@ input[type=radio] {
justify-content: center;
align-content: center;
}
#___container .mask {
position: absolute;
width: 100%;
height: 100%;
z-index: 999;
top: 0;
background-color: rgba(0,0,0,0.2);
display:flex;
justify-content: center;
align-items: center;
align-content: center;
justify-items: center;
color: #ffffff;
}
.xuanzhuan {
animation: xz 1s linear infinite;
}
@keyframes xz {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
\ No newline at end of file
......@@ -27,6 +27,7 @@ fetch(UI).then(function(res){
app = new Vue({
el: '#__extend_dom',
data: {
loadingimg: chrome.extension.getURL("loading.png"),
closeX: chrome.extension.getURL("close.png"),
fade: false,
canOpen: false,
......@@ -56,16 +57,14 @@ fetch(UI).then(function(res){
userPermission: "-1",
userToken: "",
err: "",
loading: true,
loading: false,
API: {
addZone: "https://api.mepai.me/manage/youmi/add-zone",
getZone: "https://api.mepai.me/manage/youmi/get-zone",
removeZone: "https://api.mepai.me/manage/youmi/remove-zone",
setRemark: "https://api.mepai.me/manage/youmi/set-remark",
getRemark: "https://api.mepai.me/manage/youmi/get-remark",
getUserInfo: "https://api.mepai.me/v5/user/info",
getReadingInfo: "https://api.mepai.me/v5/reading/info",
getWorksInfo: "https://api.mepai.me/v5/works/info",
getUserInfo: "https://api.mepai.me/manage/youmi/user",
getIsYoumi: "https://api.mepai.me/manage/youmi/is-youmi",
auth: "https://api.mepai.me/manage/youmi/is-auth"
}
......@@ -73,12 +72,17 @@ fetch(UI).then(function(res){
methods: {
showUi: function() {
this.showUiProp = !this.showUiProp;
if (this.showUiProp) {
this.openUi();
}
},
openUi: function() {
let $this = this;
let canOpen = this.assertIn();
this.canOpen = canOpen;
if (canOpen) {
if ($this.type !== null && $this.type !== undefined) {
$this.getData($this.API.getRemark, {
object_id: $this.objectId,
type: $this.type
......@@ -91,6 +95,7 @@ fetch(UI).then(function(res){
}
}
});
}
//获取基本信息并显示在编辑框
if ($this.isUserInfo) {
this.getData($this.API.getUserInfo, {
......@@ -110,7 +115,7 @@ fetch(UI).then(function(res){
}, res => {
if (res.code.toString() === "100001") {
if (res.data.toString() !== "{}") {
$this.useRemark = res.data.remark;
$this.userRemark = res.data.remark;
$this.userPermission = res.data.permission.toString();
$this.userToken = res.data.lock_token
}
......@@ -118,12 +123,6 @@ fetch(UI).then(function(res){
})
}
if ($this.isWorks ) {
/* $this.getData($this.API.getWorksInfo, {
works_id: $this.objectId
}, data => {
let works = data.data;
$this.isYoumi = works.is_youmi;
});*/
$this.getData($this.API.getIsYoumi, {
object_id: $this.objectId,
type : $this.type
......@@ -132,13 +131,6 @@ fetch(UI).then(function(res){
});
}
if ($this.isReading) {
/*$this.getData(this.API.getReadingInfo, {
reading_id: $this.objectId
}, data => {
let reading = data.data;
$this.isYoumi = reading.is_youmi;
});*/
$this.getData($this.API.getIsYoumi, {
object_id: $this.objectId,
type : $this.type
......@@ -202,7 +194,6 @@ fetch(UI).then(function(res){
}
if (res.code.toString() === "100002") {
$this.isAuth = false;
$this.err = "权限不足";
}
});
},
......@@ -223,8 +214,8 @@ fetch(UI).then(function(res){
}).then(final => {
if (final.code.toString() === "100002") {
$this.err = "请您先在网站登录,或者请确定您的操作权限";
} else {
$this.err = final.message;
} else if (final.code.toString() === "100001") {
$this.err = "";
}
return callback(final);
}).catch(e => {
......@@ -232,6 +223,8 @@ fetch(UI).then(function(res){
});
},
sendData: function(api, data, callback) {
let $this = app;
$this.loading = true;
var header = {
method: "POST",
headers: {
......@@ -241,6 +234,7 @@ fetch(UI).then(function(res){
body: JSON.stringify(data)
};
fetch(api, header).then(res => {
$this.loading = false;
return res.json()
}).then(final => {
return callback(final);
......@@ -299,13 +293,14 @@ fetch(UI).then(function(res){
if (res.code === "100001") {
$this.remark = res.data.remark;
$this.permission = res.data.permission.toString();
$this.token = res.data.lock_token
}
$this.token = res.data.lock_token;
$this.showToast("操作成功");
} else {
if (res.code.toString() === "100002") {
$this.err = "请您先在网站登录,或者请确定您的操作权限";
alert($this.err);
} else {
$this.err = res.message;
$this.showToast(res.message);
}
}
});
},
......@@ -322,13 +317,14 @@ fetch(UI).then(function(res){
if (res.code === "100001") {
$this.userRemark = res.data.remark;
$this.userPermission = res.data.permission.toString();
$this.userToken = res.data.lock_token
}
$this.userToken = res.data.lock_token;
$this.showToast("操作成功");
} else {
if (res.code.toString() === "100002") {
$this.err = "请您先在网站登录,或者请确定您的操作权限";
alert($this.err);
} else {
$this.err = res.message;
$this.showToast(res.message);
}
}
});
},
......@@ -340,13 +336,15 @@ fetch(UI).then(function(res){
}, res => {
if (res.code.toString() === "100001") {
$this.inZone = false;
}
$this.showToast("操作成功");
} else {
if (res.code.toString() === "100002") {
$this.err = "请您先在网站登录,或者请确定您的操作权限";
alert($this.err);
} else {
$this.err = res.message;
$this.showToast(res.message);
}
}
});
},
addZone() {
......@@ -357,15 +355,23 @@ fetch(UI).then(function(res){
}, res => {
if (res.code.toString() === "100001") {
$this.inZone = true;
}
$this.showToast("操作成功");
} else {
if (res.code.toString() === "100002") {
$this.err = "请您先在网站登录,或者请确定您的操作权限";
alert($this.err);
} else {
$this.err = res.message;
$this.showToast(res.message);
}
}
});
},
showToast(msg) {
let $this = this;
$this.err = msg;
setTimeout(function () {
$this.err = "";
}, 3000);
},
base64Decode(data) {
var rv = window.atob(data);
rv = escape(rv);
......
......@@ -21,7 +21,7 @@
}
],
"web_accessible_resources": [
"ui.html", "icon.png","close.png"
"ui.html", "icon.png","close.png","loading.png"
],
"browser_action": {
"default_icon": "icon.png",
......
<div v-if="showUiProp" id="___container">
<div class="mask" v-if="loading">
<img class="xuanzhuan" :src="loadingimg" style="width:10%;"></img>
</div>
<div class="x" v-on:click="showUi"><img :src="closeX"></div>
<div class="danger" v-if="err != ''">{{err}}</div>
<!------------------- 用户开始 -------->
......@@ -49,7 +52,7 @@
</div>
</div>
<div style="display: flex;justify-content: center;justify-items: center">
<button class="btn btn-primary primary large" v-on:click="submitUserRemark">提交用户备注</button>
<button class="btn btn-primary primary large" v-on:click="submitUserRemark">提交用户设置</button>
</div>
</div>
</div>
......@@ -92,7 +95,7 @@
</div>
</div>
<div class="form-group" style="display: flex;justify-items: center;justify-content: center">
<button class="btn btn-primary primary large" v-on:click="submitRemark">提交作品备注</button>
<button class="btn btn-primary primary large" v-on:click="submitRemark">提交作品设置</button>
</div>
</div>
</div>
......@@ -135,7 +138,7 @@
</div>
</div>
<div class="form-group" style="display: flex;justify-items: center;justify-content: center">
<button class="btn btn-primary primary large" v-on:click="submitRemark">提交文章备注</button>
<button class="btn btn-primary primary large" v-on:click="submitRemark">提交文章设置</button>
</div>
</div>
</div>
......
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