|
@@ -7,10 +7,10 @@ class CustomView(jp.JustpyBaseComponent):
|
|
|
|
|
|
vue_dependencies = []
|
|
|
|
|
|
- def __init__(self, vue_type, filename, dependencies=[], **options):
|
|
|
+ def __init__(self, vue_type, filepath, dependencies=[], **options):
|
|
|
|
|
|
self.vue_type = vue_type
|
|
|
- self.vue_filepath = os.path.realpath(filename).replace('.py', '.js')
|
|
|
+ self.vue_filepath = os.path.realpath(filepath).replace('.py', '.js')
|
|
|
self.vue_dependencies = dependencies
|
|
|
|
|
|
self.pages = {}
|
|
@@ -27,7 +27,12 @@ class CustomView(jp.JustpyBaseComponent):
|
|
|
if marker not in wp.head_html:
|
|
|
wp.head_html += marker
|
|
|
for dependency in self.vue_dependencies:
|
|
|
- wp.head_html += f'<script src="{dependency}"></script>\n'
|
|
|
+ if dependency.startswith('http://') or dependency.startswith('https://'):
|
|
|
+ wp.head_html += f'<script src="{dependency}"></script>\n'
|
|
|
+ else:
|
|
|
+ wp.head_html += f'<script src="lib/{dependency}"></script>\n'
|
|
|
+ filepath = f'{os.path.dirname(self.vue_filepath)}/lib/{dependency}'
|
|
|
+ jp.app.routes.insert(0, Route(f'/lib/{dependency}', lambda _: FileResponse(filepath)))
|
|
|
|
|
|
if self.vue_filepath not in jp.component_file_list:
|
|
|
filename = os.path.basename(self.vue_filepath)
|