Skip to content

Commit e0b5fa8

Browse files
committed
initial commit
0 parents  commit e0b5fa8

38 files changed

+2951
-0
lines changed

.editorconfig

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false

.eslintrc.js

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
browser: true,
5+
node: true,
6+
},
7+
parserOptions: {
8+
parser: 'babel-eslint',
9+
},
10+
extends: [
11+
'@nuxtjs',
12+
'plugin:nuxt/recommended',
13+
],
14+
rules: {
15+
'array-bracket-spacing': [ 'error', 'always' ],
16+
'arrow-parens': 'off',
17+
'comma-dangle': [ 'error', 'always-multiline' ],
18+
'comma-spacing': 'error',
19+
'curly': 'off',
20+
'indent': [ 'error', 2 ],
21+
'key-spacing': 'error',
22+
'keyword-spacing': 'error',
23+
'linebreak-style': [ 'error', 'unix' ],
24+
'no-console': 'off',
25+
'no-extra-semi': 'off',
26+
'no-multi-spaces': 'error',
27+
'no-trailing-spaces': 'error',
28+
'no-return-assign': 'off',
29+
'no-undef': 'warn',
30+
'no-unused-vars': 'warn',
31+
'nuxt/no-cjs-in-config': 'off',
32+
'object-curly-spacing': [ 'error', 'always' ],
33+
'quotes': [ 'error', 'single' ],
34+
'semi': [ 'error', 'never', { beforeStatementContinuationChars: 'always' } ],
35+
'space-before-blocks': [ 'error', 'always' ],
36+
'space-before-function-paren': [ 'error', 'always' ],
37+
'space-in-parens': 'error',
38+
'space-infix-ops': 'error',
39+
'space-unary-ops': 'error',
40+
'spaced-comment': [ 'error', 'always', { exceptions: [ '*' ] } ],
41+
'vue/singleline-html-element-content-newline': 'off',
42+
}
43+
}

.gitignore

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### Node template
3+
# Logs
4+
/logs
5+
*.log
6+
npm-debug.log*
7+
yarn-debug.log*
8+
yarn-error.log*
9+
10+
.vscode
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
18+
# Directory for instrumented libs generated by jscoverage/JSCover
19+
lib-cov
20+
21+
# Coverage directory used by tools like istanbul
22+
coverage
23+
24+
# nyc test coverage
25+
.nyc_output
26+
27+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
28+
.grunt
29+
30+
# Bower dependency directory (https://bower.io/)
31+
bower_components
32+
33+
# node-waf configuration
34+
.lock-wscript
35+
36+
# Compiled binary addons (https://nodejs.org/api/addons.html)
37+
build/Release
38+
39+
# Dependency directories
40+
node_modules/
41+
jspm_packages/
42+
43+
# TypeScript v1 declaration files
44+
typings/
45+
46+
# Optional npm cache directory
47+
.npm
48+
49+
# Optional eslint cache
50+
.eslintcache
51+
52+
# Optional REPL history
53+
.node_repl_history
54+
55+
# Output of 'npm pack'
56+
*.tgz
57+
58+
# Yarn Integrity file
59+
.yarn-integrity
60+
61+
# dotenv environment variables file
62+
.env
63+
64+
# parcel-bundler cache (https://parceljs.org/)
65+
.cache
66+
67+
# next.js build output
68+
.next
69+
70+
# nuxt.js build output
71+
.nuxt
72+
73+
# Nuxt generate
74+
dist
75+
76+
# vuepress build output
77+
.vuepress/dist
78+
79+
# Serverless directories
80+
.serverless
81+
82+
# IDE / Editor
83+
.idea
84+
85+
# Service worker
86+
sw.*
87+
88+
# macOS
89+
.DS_Store
90+
91+
# Vim swap files
92+
*.swp

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

README.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# node-kas
2+
3+
> A drop-in replacement for KAS.
4+
5+
## Build Setup
6+
7+
```bash
8+
# install dependencies
9+
$ npm install
10+
11+
# serve with hot reload at localhost:3000
12+
$ npm run dev
13+
14+
# build for production and launch server
15+
$ npm run build
16+
$ npm run start
17+
18+
# generate static project
19+
$ npm run generate
20+
```
21+
22+
For detailed explanation on how things work, check out [Nuxt.js docs](https://nuxtjs.org).

components/container.vue

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<template>
2+
<content :class="classes">
3+
<div :class="{ profile }">
4+
<slot />
5+
</div>
6+
</content>
7+
</template>
8+
9+
<script>
10+
export default {
11+
props: {
12+
dark: Boolean,
13+
header: Boolean,
14+
alignCenter: Boolean,
15+
profile: Boolean,
16+
},
17+
computed: {
18+
classes () {
19+
const { dark, header } = this
20+
return { dark, header, light: !dark, 'align-center': this.alignCenter }
21+
},
22+
},
23+
}
24+
</script>
25+
26+
<style scoped>
27+
content { display: flex; }
28+
29+
content > * {
30+
width: 100%;
31+
max-width: 750px;
32+
padding: 16px;
33+
}
34+
35+
content::before, content::after {
36+
content: ' ';
37+
flex: auto;
38+
height: 100%;
39+
}
40+
content.header { height: 200px; }
41+
content.header > * {
42+
display: flex;
43+
flex-direction: column;
44+
}
45+
content.header > *::before, content.header > *::after {
46+
content: ' ';
47+
flex: auto;
48+
}
49+
50+
content.light {
51+
color: #002d4d;
52+
background-color: #fff;
53+
}
54+
content.dark {
55+
color: #f5fafd;
56+
background-color: #002d4d;
57+
}
58+
59+
.align-center {
60+
text-align: center;
61+
}
62+
63+
.profile {
64+
margin: 15px 0;
65+
max-width: 300px;
66+
}
67+
</style>

components/headline.vue

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<template>
2+
<container dark header align-center>
3+
<h1 class="display-3">{{ title }}</h1>
4+
<h2 class="subtitle-1">{{ subtitle }}</h2>
5+
</container>
6+
</template>
7+
<script>
8+
import Container from '~/components/container'
9+
export default {
10+
components: { Container },
11+
props: { title: String, subtitle: String }, // eslint-disable-line vue/require-default-prop
12+
}
13+
</script>
14+
<style scoped>
15+
.v-application h1.display-3 {
16+
font-weight: 200;
17+
margin: 40px 0 16px;
18+
}
19+
</style>

components/set-property.vue

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<template>
2+
<div>
3+
<v-btn icon color="#f5fafd" class="back" @click="back"><v-icon>mdi-arrow-left</v-icon></v-btn>
4+
<headline :title="title" :subtitle="subtitle" />
5+
<container profile>
6+
<slot />
7+
<v-btn
8+
v-if="!noSubmit"
9+
:disabled="!valid || submitting"
10+
depressed
11+
color="primary"
12+
class="confirm"
13+
@click="submit"
14+
>
15+
确认
16+
</v-btn>
17+
</container>
18+
</div>
19+
</template>
20+
21+
<script>
22+
/* eslint-disable vue/require-default-prop */
23+
import Headline from '~/components/headline'
24+
import Container from '~/components/container'
25+
export default {
26+
components: { Headline, Container },
27+
props: {
28+
noSubmit: Boolean,
29+
title: String,
30+
subtitle: String,
31+
putPath: String,
32+
getData: Function,
33+
validate: {
34+
type: Function,
35+
required: false,
36+
},
37+
},
38+
data () {
39+
return { submitting: false }
40+
},
41+
inject: [ 'snackbar' ],
42+
computed: {
43+
valid () {
44+
return this.validate ? this.validate() : true
45+
},
46+
},
47+
mounted () {
48+
const idFrameEl = document.createElement('span')
49+
window.idFrameEl = idFrameEl
50+
idFrameEl.style.cssText = 'top: 12px; right: 12px; position: fixed; --mdc-theme-primary: #f5fafd;'
51+
const scriptEl = document.createElement('script')
52+
scriptEl.src = 'https://idframe.keeer.net/js/appbar.js'
53+
document.head.appendChild(scriptEl)
54+
document.body.appendChild(idFrameEl)
55+
const intervalId = setInterval(function () {
56+
if ('idFrame' in window) {
57+
clearInterval(intervalId)
58+
// eslint-disable-next-line no-new, no-undef
59+
new idFrame.AppBarFrame({ container: idFrameEl, base: location.origin })
60+
}
61+
}, 100)
62+
},
63+
beforeDestroy () {
64+
document.body.removeChild(window.idFrameEl)
65+
delete window.idFrameEl
66+
},
67+
methods: {
68+
back () { this.$router.back() },
69+
async submit () {
70+
if (!this.valid) return
71+
try {
72+
this.submitting = true
73+
const res = await fetch(this.putPath, {
74+
method: 'put',
75+
body: JSON.stringify(this.getData()),
76+
headers: { 'Content-Type': 'application/json' },
77+
}).then(res => res.json())
78+
if (res.status !== 0) {
79+
this.snackbar(res.message || '未知错误')
80+
} else {
81+
this.snackbar(res.message || '成功设置')
82+
this.$router.back()
83+
}
84+
} catch (e) {
85+
this.snackbar('网络错误')
86+
console.error('set property', e)
87+
}
88+
this.submitting = false
89+
},
90+
},
91+
}
92+
</script>
93+
94+
<style scoped>
95+
.confirm {
96+
margin-top: 12px;
97+
float: right;
98+
}
99+
.back {
100+
position: absolute;
101+
top: 12px;
102+
left: 12px;
103+
}
104+
</style>
105+
<style>
106+
.v-text-field.v-input {
107+
margin: 8px;
108+
width: 100%;
109+
}
110+
</style>

0 commit comments

Comments
 (0)